Completed
Push — master ( c1c82d...7206f2 )
by Jared
18:17
created
lib/timber-theme.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		$ss = $data->get_stylesheet();
77 77
 		$this->slug = $ss;
78 78
 
79
-		if ( ! function_exists( 'get_home_path' ) ) {
79
+		if ( !function_exists('get_home_path') ) {
80 80
 			require_once(ABSPATH . 'wp-admin/includes/file.php');
81 81
 		}
82 82
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @return  string the relative path to the theme (ex: `/wp-content/themes/my-timber-theme`)
104 104
 	 */
105 105
 	public function path() {
106
-		return TimberURLHelper::get_rel_url( $this->link() );
106
+		return TimberURLHelper::get_rel_url($this->link());
107 107
 	}
108 108
 
109 109
 	/**
Please login to merge, or discard this patch.
lib/timber-twig.php 1 patch
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	function __construct() {
15
-		add_action( 'timber/twig/filters', array( $this, 'add_timber_filters_deprecated' ) );
16
-		add_action( 'timber/twig/filters', array( $this, 'add_timber_filters' ) );
15
+		add_action('timber/twig/filters', array($this, 'add_timber_filters_deprecated'));
16
+		add_action('timber/twig/filters', array($this, 'add_timber_filters'));
17 17
 	}
18 18
 
19 19
 	/**
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	 * @deprecated since 0.20.7
24 24
 	 * @return Twig_Environment
25 25
 	 */
26
-	function add_timber_filters_deprecated( $twig ) {
27
-		$twig->addFilter( new Twig_SimpleFilter( 'get_src_from_attachment_id', 'twig_get_src_from_attachment_id' ) );
28
-		$twig->addFilter( new Twig_SimpleFilter( 'wp_body_class', array( $this, 'body_class' ) ) );
29
-		$twig->addFilter( new Twig_SimpleFilter( 'twitterify', array( 'TimberHelper', 'twitterify' ) ) );
30
-		$twig->addFilter( new Twig_SimpleFilter( 'twitterfy', array( 'TimberHelper', 'twitterify' ) ) );
31
-		$twig->addFilter( new Twig_SimpleFilter( 'string', function($arr, $glue = ' '){
26
+	function add_timber_filters_deprecated($twig) {
27
+		$twig->addFilter(new Twig_SimpleFilter('get_src_from_attachment_id', 'twig_get_src_from_attachment_id'));
28
+		$twig->addFilter(new Twig_SimpleFilter('wp_body_class', array($this, 'body_class')));
29
+		$twig->addFilter(new Twig_SimpleFilter('twitterify', array('TimberHelper', 'twitterify')));
30
+		$twig->addFilter(new Twig_SimpleFilter('twitterfy', array('TimberHelper', 'twitterify')));
31
+		$twig->addFilter(new Twig_SimpleFilter('string', function($arr, $glue = ' ') {
32 32
 			return twig_join_filter($arr, $glue);
33
-		} ) );
33
+		} ));
34 34
 		return $twig;
35 35
 	}
36 36
 
@@ -40,150 +40,150 @@  discard block
 block discarded – undo
40 40
 	 * @param Twig_Environment $twig
41 41
 	 * @return Twig_Environment
42 42
 	 */
43
-	function add_timber_filters( $twig ) {
43
+	function add_timber_filters($twig) {
44 44
 		/* image filters */
45
-		$twig->addFilter( new Twig_SimpleFilter( 'resize', array( 'TimberImageHelper', 'resize' ) ) );
46
-		$twig->addFilter( new Twig_SimpleFilter( 'retina', array( 'TimberImageHelper', 'retina_resize' ) ) );
47
-		$twig->addFilter( new Twig_SimpleFilter( 'letterbox', array( 'TimberImageHelper', 'letterbox' ) ) );
48
-		$twig->addFilter( new Twig_SimpleFilter( 'tojpg', array( 'TimberImageHelper', 'img_to_jpg' ) ) );
45
+		$twig->addFilter(new Twig_SimpleFilter('resize', array('TimberImageHelper', 'resize')));
46
+		$twig->addFilter(new Twig_SimpleFilter('retina', array('TimberImageHelper', 'retina_resize')));
47
+		$twig->addFilter(new Twig_SimpleFilter('letterbox', array('TimberImageHelper', 'letterbox')));
48
+		$twig->addFilter(new Twig_SimpleFilter('tojpg', array('TimberImageHelper', 'img_to_jpg')));
49 49
 
50 50
 		/* debugging filters */
51
-		$twig->addFilter( new Twig_SimpleFilter( 'docs', 'twig_object_docs' ) );
52
-		$twig->addFilter( new Twig_SimpleFilter( 'get_class',  'get_class' ) );
53
-		$twig->addFilter( new Twig_SimpleFilter( 'get_type', 'get_type' ) );
54
-		$twig->addFilter( new Twig_SimpleFilter( 'print_r', function( $arr ) {
55
-					return print_r( $arr, true );
56
-				} ) );
57
-		$twig->addFilter( new Twig_SimpleFilter( 'print_a', function( $arr ) {
58
-					return '<pre>' . self::object_docs( $arr, true ) . '</pre>';
59
-				} ) );
51
+		$twig->addFilter(new Twig_SimpleFilter('docs', 'twig_object_docs'));
52
+		$twig->addFilter(new Twig_SimpleFilter('get_class', 'get_class'));
53
+		$twig->addFilter(new Twig_SimpleFilter('get_type', 'get_type'));
54
+		$twig->addFilter(new Twig_SimpleFilter('print_r', function($arr) {
55
+					return print_r($arr, true);
56
+				} ));
57
+		$twig->addFilter(new Twig_SimpleFilter('print_a', function($arr) {
58
+					return '<pre>' . self::object_docs($arr, true) . '</pre>';
59
+				} ));
60 60
 
61 61
 		/* other filters */
62
-		$twig->addFilter( new Twig_SimpleFilter( 'stripshortcodes', 'strip_shortcodes' ) );
63
-		$twig->addFilter( new Twig_SimpleFilter( 'array', array( $this, 'to_array' ) ) );
64
-		$twig->addFilter( new Twig_SimpleFilter( 'excerpt', 'wp_trim_words' ) );
65
-		$twig->addFilter( new Twig_SimpleFilter( 'function', array( $this, 'exec_function' ) ) );
66
-		$twig->addFilter( new Twig_SimpleFilter( 'pretags', array( $this, 'twig_pretags' ) ) );
67
-		$twig->addFilter( new Twig_SimpleFilter( 'sanitize', 'sanitize_title' ) );
68
-		$twig->addFilter( new Twig_SimpleFilter( 'shortcodes', 'do_shortcode' ) );
69
-		$twig->addFilter( new Twig_SimpleFilter( 'time_ago', array( $this, 'time_ago' ) ) );
70
-		$twig->addFilter( new Twig_SimpleFilter( 'wpautop', 'wpautop' ) );
62
+		$twig->addFilter(new Twig_SimpleFilter('stripshortcodes', 'strip_shortcodes'));
63
+		$twig->addFilter(new Twig_SimpleFilter('array', array($this, 'to_array')));
64
+		$twig->addFilter(new Twig_SimpleFilter('excerpt', 'wp_trim_words'));
65
+		$twig->addFilter(new Twig_SimpleFilter('function', array($this, 'exec_function')));
66
+		$twig->addFilter(new Twig_SimpleFilter('pretags', array($this, 'twig_pretags')));
67
+		$twig->addFilter(new Twig_SimpleFilter('sanitize', 'sanitize_title'));
68
+		$twig->addFilter(new Twig_SimpleFilter('shortcodes', 'do_shortcode'));
69
+		$twig->addFilter(new Twig_SimpleFilter('time_ago', array($this, 'time_ago')));
70
+		$twig->addFilter(new Twig_SimpleFilter('wpautop', 'wpautop'));
71 71
 
72
-		$twig->addFilter( new Twig_SimpleFilter( 'relative', function ( $link ) {
73
-					return TimberURLHelper::get_rel_url( $link, true );
74
-				} ) );
72
+		$twig->addFilter(new Twig_SimpleFilter('relative', function($link) {
73
+					return TimberURLHelper::get_rel_url($link, true);
74
+				} ));
75 75
 
76
-		$twig->addFilter( new Twig_SimpleFilter( 'date', array( $this, 'intl_date' ) ) );
76
+		$twig->addFilter(new Twig_SimpleFilter('date', array($this, 'intl_date')));
77 77
 
78
-		$twig->addFilter( new Twig_SimpleFilter( 'truncate', function ( $text, $len ) {
79
-					return TimberHelper::trim_words( $text, $len );
80
-				} ) );
78
+		$twig->addFilter(new Twig_SimpleFilter('truncate', function($text, $len) {
79
+					return TimberHelper::trim_words($text, $len);
80
+				} ));
81 81
 
82 82
 		/* actions and filters */
83
-		$twig->addFunction( new Twig_SimpleFunction( 'action', function ( $context ) {
83
+		$twig->addFunction(new Twig_SimpleFunction('action', function($context) {
84 84
 					$args = func_get_args();
85
-					array_shift( $args );
85
+					array_shift($args);
86 86
 					$args[] = $context;
87
-					call_user_func_array( 'do_action', $args );
88
-				}, array( 'needs_context' => true ) ) );
87
+					call_user_func_array('do_action', $args);
88
+				}, array('needs_context' => true)));
89 89
 
90
-		$twig->addFilter( new Twig_SimpleFilter( 'apply_filters', function () {
90
+		$twig->addFilter(new Twig_SimpleFilter('apply_filters', function() {
91 91
 					$args = func_get_args();
92
-					$tag = current( array_splice( $args, 1, 1 ) );
92
+					$tag = current(array_splice($args, 1, 1));
93 93
 
94
-					return apply_filters_ref_array( $tag, $args );
95
-				} ) );
96
-		$twig->addFunction( new Twig_SimpleFunction( 'function', array( &$this, 'exec_function' ) ) );
97
-		$twig->addFunction( new Twig_SimpleFunction( 'fn', array( &$this, 'exec_function' ) ) );
94
+					return apply_filters_ref_array($tag, $args);
95
+				} ));
96
+		$twig->addFunction(new Twig_SimpleFunction('function', array(&$this, 'exec_function')));
97
+		$twig->addFunction(new Twig_SimpleFunction('fn', array(&$this, 'exec_function')));
98 98
 
99
-		$twig->addFunction( new Twig_SimpleFunction( 'shortcode', 'do_shortcode' ) );
99
+		$twig->addFunction(new Twig_SimpleFunction('shortcode', 'do_shortcode'));
100 100
 
101 101
 		/* TimberObjects */
102
-		$twig->addFunction( new Twig_SimpleFunction( 'TimberPost', function ( $pid, $PostClass = 'TimberPost' ) {
103
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
104
-						foreach ( $pid as &$p ) {
105
-							$p = new $PostClass( $p );
102
+		$twig->addFunction(new Twig_SimpleFunction('TimberPost', function($pid, $PostClass = 'TimberPost') {
103
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
104
+						foreach ($pid as &$p) {
105
+							$p = new $PostClass($p);
106 106
 						}
107 107
 						return $pid;
108 108
 					}
109
-					return new $PostClass( $pid );
110
-				} ) );
111
-		$twig->addFunction( new Twig_SimpleFunction( 'TimberImage', function ( $pid, $ImageClass = 'TimberImage' ) {
112
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
113
-						foreach ( $pid as &$p ) {
114
-							$p = new $ImageClass( $p );
109
+					return new $PostClass($pid);
110
+				} ));
111
+		$twig->addFunction(new Twig_SimpleFunction('TimberImage', function($pid, $ImageClass = 'TimberImage') {
112
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
113
+						foreach ($pid as &$p) {
114
+							$p = new $ImageClass($p);
115 115
 						}
116 116
 						return $pid;
117 117
 					}
118
-					return new $ImageClass( $pid );
119
-				} ) );
120
-		$twig->addFunction( new Twig_SimpleFunction( 'TimberTerm', function ( $pid, $TermClass = 'TimberTerm' ) {
121
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
122
-						foreach ( $pid as &$p ) {
123
-							$p = new $TermClass( $p );
118
+					return new $ImageClass($pid);
119
+				} ));
120
+		$twig->addFunction(new Twig_SimpleFunction('TimberTerm', function($pid, $TermClass = 'TimberTerm') {
121
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
122
+						foreach ($pid as &$p) {
123
+							$p = new $TermClass($p);
124 124
 						}
125 125
 						return $pid;
126 126
 					}
127
-					return new $TermClass( $pid );
128
-				} ) );
129
-		$twig->addFunction( new Twig_SimpleFunction( 'TimberUser', function ( $pid, $UserClass = 'TimberUser' ) {
130
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
131
-						foreach ( $pid as &$p ) {
132
-							$p = new $UserClass( $p );
127
+					return new $TermClass($pid);
128
+				} ));
129
+		$twig->addFunction(new Twig_SimpleFunction('TimberUser', function($pid, $UserClass = 'TimberUser') {
130
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
131
+						foreach ($pid as &$p) {
132
+							$p = new $UserClass($p);
133 133
 						}
134 134
 						return $pid;
135 135
 					}
136
-					return new $UserClass( $pid );
137
-				} ) );
136
+					return new $UserClass($pid);
137
+				} ));
138 138
 
139 139
 		/* TimberObjects Alias */
140
-		$twig->addFunction( new Twig_SimpleFunction( 'Post', function ( $pid, $PostClass = 'TimberPost' ) {
141
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
142
-						foreach ( $pid as &$p ) {
143
-							$p = new $PostClass( $p );
140
+		$twig->addFunction(new Twig_SimpleFunction('Post', function($pid, $PostClass = 'TimberPost') {
141
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
142
+						foreach ($pid as &$p) {
143
+							$p = new $PostClass($p);
144 144
 						}
145 145
 						return $pid;
146 146
 					}
147
-					return new $PostClass( $pid );
148
-				} ) );
149
-		$twig->addFunction( new Twig_SimpleFunction( 'Image', function ( $pid, $ImageClass = 'TimberImage' ) {
150
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
151
-						foreach ( $pid as &$p ) {
152
-							$p = new $ImageClass( $p );
147
+					return new $PostClass($pid);
148
+				} ));
149
+		$twig->addFunction(new Twig_SimpleFunction('Image', function($pid, $ImageClass = 'TimberImage') {
150
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
151
+						foreach ($pid as &$p) {
152
+							$p = new $ImageClass($p);
153 153
 						}
154 154
 						return $pid;
155 155
 					}
156
-					return new $ImageClass( $pid );
157
-				} ) );
158
-		$twig->addFunction( new Twig_SimpleFunction( 'Term', function ( $pid, $TermClass = 'TimberTerm' ) {
159
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
160
-						foreach ( $pid as &$p ) {
161
-							$p = new $TermClass( $p );
156
+					return new $ImageClass($pid);
157
+				} ));
158
+		$twig->addFunction(new Twig_SimpleFunction('Term', function($pid, $TermClass = 'TimberTerm') {
159
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
160
+						foreach ($pid as &$p) {
161
+							$p = new $TermClass($p);
162 162
 						}
163 163
 						return $pid;
164 164
 					}
165
-					return new $TermClass( $pid );
166
-				} ) );
167
-		$twig->addFunction( new Twig_SimpleFunction( 'User', function ( $pid, $UserClass = 'TimberUser' ) {
168
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
169
-						foreach ( $pid as &$p ) {
170
-							$p = new $UserClass( $p );
165
+					return new $TermClass($pid);
166
+				} ));
167
+		$twig->addFunction(new Twig_SimpleFunction('User', function($pid, $UserClass = 'TimberUser') {
168
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
169
+						foreach ($pid as &$p) {
170
+							$p = new $UserClass($p);
171 171
 						}
172 172
 						return $pid;
173 173
 					}
174
-					return new $UserClass( $pid );
175
-				} ) );
174
+					return new $UserClass($pid);
175
+				} ));
176 176
 
177 177
 		/* bloginfo and translate */
178
-		$twig->addFunction( 'bloginfo', new Twig_SimpleFunction( 'bloginfo', function ( $show = '', $filter = 'raw' ) {
179
-					return get_bloginfo( $show, $filter );
180
-				} ) );
181
-		$twig->addFunction( '__', new Twig_SimpleFunction( '__', function ( $text, $domain = 'default' ) {
182
-					return __( $text, $domain );
183
-				} ) );
178
+		$twig->addFunction('bloginfo', new Twig_SimpleFunction('bloginfo', function($show = '', $filter = 'raw') {
179
+					return get_bloginfo($show, $filter);
180
+				} ));
181
+		$twig->addFunction('__', new Twig_SimpleFunction('__', function($text, $domain = 'default') {
182
+					return __($text, $domain);
183
+				} ));
184 184
 		/* get_twig is deprecated, use timber/twig */
185
-		$twig = apply_filters( 'get_twig', $twig );
186
-		$twig = apply_filters( 'timber/twig', $twig );
185
+		$twig = apply_filters('get_twig', $twig);
186
+		$twig = apply_filters('timber/twig', $twig);
187 187
 		return $twig;
188 188
 	}
189 189
 
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
 	 * @param mixed   $arr
194 194
 	 * @return array
195 195
 	 */
196
-	function to_array( $arr ) {
197
-		if ( is_array( $arr ) ) {
196
+	function to_array($arr) {
197
+		if ( is_array($arr) ) {
198 198
 			return $arr;
199 199
 		}
200
-		$arr = array( $arr );
200
+		$arr = array($arr);
201 201
 		return $arr;
202 202
 	}
203 203
 
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
 	 * @param string  $function_name
208 208
 	 * @return mixed
209 209
 	 */
210
-	function exec_function( $function_name ) {
210
+	function exec_function($function_name) {
211 211
 		$args = func_get_args();
212
-		array_shift( $args );
212
+		array_shift($args);
213 213
 		if ( is_string($function_name) ) {
214
-			$function_name = trim( $function_name );
214
+			$function_name = trim($function_name);
215 215
 		}
216
-		return call_user_func_array( $function_name, ( $args ) );
216
+		return call_user_func_array($function_name, ($args));
217 217
 	}
218 218
 
219 219
 	/**
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 * @param string  $content
223 223
 	 * @return string
224 224
 	 */
225
-	function twig_pretags( $content ) {
226
-		return preg_replace_callback( '|<pre.*>(.*)</pre|isU', array( &$this, 'convert_pre_entities' ), $content );
225
+	function twig_pretags($content) {
226
+		return preg_replace_callback('|<pre.*>(.*)</pre|isU', array(&$this, 'convert_pre_entities'), $content);
227 227
 	}
228 228
 
229 229
 	/**
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
 	 * @param array   $matches
233 233
 	 * @return string
234 234
 	 */
235
-	function convert_pre_entities( $matches ) {
236
-		return str_replace( $matches[1], htmlentities( $matches[1] ), $matches[0] );
235
+	function convert_pre_entities($matches) {
236
+		return str_replace($matches[1], htmlentities($matches[1]), $matches[0]);
237 237
 	}
238 238
 
239 239
 	/**
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 	 * @deprecated 0.20.7
242 242
 	 * @return string
243 243
 	 */
244
-	function body_class( $body_classes ) {
244
+	function body_class($body_classes) {
245 245
 		ob_start();
246
-		if ( is_array( $body_classes ) ) {
247
-			$body_classes = explode( ' ', $body_classes );
246
+		if ( is_array($body_classes) ) {
247
+			$body_classes = explode(' ', $body_classes);
248 248
 		}
249
-		body_class( $body_classes );
249
+		body_class($body_classes);
250 250
 		$return = ob_get_contents();
251 251
 		ob_end_clean();
252 252
 		return $return;
@@ -259,20 +259,20 @@  discard block
 block discarded – undo
259 259
 	 * @param string  $format (optional)
260 260
 	 * @return string
261 261
 	 */
262
-	function intl_date( $date, $format = null ) {
262
+	function intl_date($date, $format = null) {
263 263
 		if ( $format === null ) {
264
-			$format = get_option( 'date_format' );
264
+			$format = get_option('date_format');
265 265
 		}
266 266
 
267 267
 		if ( $date instanceof DateTime ) {
268 268
 			$timestamp = $date->getTimestamp();
269
-		} else if (is_numeric( $date ) && strtotime( $date ) === false ) {
270
-			$timestamp = intval( $date );
269
+		} else if ( is_numeric($date) && strtotime($date) === false ) {
270
+			$timestamp = intval($date);
271 271
 		} else {
272
-			$timestamp = strtotime( $date );
272
+			$timestamp = strtotime($date);
273 273
 		}
274 274
 
275
-		return date_i18n( $format, $timestamp );
275
+		return date_i18n($format, $timestamp);
276 276
 	}
277 277
 
278 278
 	//debug
@@ -284,17 +284,17 @@  discard block
 block discarded – undo
284 284
 	 * @param bool    $methods
285 285
 	 * @return string
286 286
 	 */
287
-	function object_docs( $obj, $methods = true ) {
288
-		$class = get_class( $obj );
289
-		$properties = (array)$obj;
287
+	function object_docs($obj, $methods = true) {
288
+		$class = get_class($obj);
289
+		$properties = (array) $obj;
290 290
 		if ( $methods ) {
291 291
 			/** @var array $methods */
292 292
 			$methods = $obj->get_method_values();
293 293
 		}
294
-		$rets = array_merge( $properties, $methods );
295
-		ksort( $rets );
296
-		$str = print_r( $rets, true );
297
-		$str = str_replace( 'Array', $class . ' Object', $str );
294
+		$rets = array_merge($properties, $methods);
295
+		ksort($rets);
296
+		$str = print_r($rets, true);
297
+		$str = str_replace('Array', $class . ' Object', $str);
298 298
 		return $str;
299 299
 	}
300 300
 
@@ -305,15 +305,15 @@  discard block
 block discarded – undo
305 305
 	 * @param string $format_future
306 306
 	 * @return string
307 307
 	 */
308
-	function time_ago( $from, $to = null, $format_past = '%s ago', $format_future = '%s from now' ) {
308
+	function time_ago($from, $to = null, $format_past = '%s ago', $format_future = '%s from now') {
309 309
 		$to = $to === null ? time() : $to;
310
-		$to = is_int( $to ) ? $to : strtotime( $to );
311
-		$from = is_int( $from ) ? $from : strtotime( $from );
310
+		$to = is_int($to) ? $to : strtotime($to);
311
+		$from = is_int($from) ? $from : strtotime($from);
312 312
 
313 313
 		if ( $from < $to ) {
314
-			return sprintf( $format_past, human_time_diff( $from, $to ) );
314
+			return sprintf($format_past, human_time_diff($from, $to));
315 315
 		} else {
316
-			return sprintf( $format_future, human_time_diff( $to, $from ) );
316
+			return sprintf($format_future, human_time_diff($to, $from));
317 317
 		}
318 318
 	}
319 319
 
Please login to merge, or discard this patch.
lib/timber-url-helper.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 	 */
10 10
 	public static function get_current_url() {
11 11
 		$pageURL = "http://";
12
-		if ( isset( $_SERVER['HTTPS'] ) && $_SERVER["HTTPS"] == "on" ) {
13
-			$pageURL = "https://";;
12
+		if ( isset($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on" ) {
13
+			$pageURL = "https://"; ;
14 14
 		}
15 15
 		if ( isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] && $_SERVER["SERVER_PORT"] != "80" ) {
16 16
 			$pageURL .= self::get_host() . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	 * @param string  $url
27 27
 	 * @return bool
28 28
 	 */
29
-	public static function is_url( $url ) {
30
-		if ( !is_string( $url ) ) {
29
+	public static function is_url($url) {
30
+		if ( !is_string($url) ) {
31 31
 			return false;
32 32
 		}
33
-		$url = strtolower( $url );
34
-		if ( strstr( $url, '://' ) ) {
33
+		$url = strtolower($url);
34
+		if ( strstr($url, '://') ) {
35 35
 			return true;
36 36
 		}
37 37
 		return false;
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 	 * @return string
44 44
 	 */
45 45
 	public static function get_path_base() {
46
-		$struc = get_option( 'permalink_structure' );
47
-		$struc = explode( '/', $struc );
46
+		$struc = get_option('permalink_structure');
47
+		$struc = explode('/', $struc);
48 48
 		$p = '/';
49
-		foreach ( $struc as $s ) {
50
-			if ( !strstr( $s, '%' ) && strlen( $s ) ) {
49
+		foreach ($struc as $s) {
50
+			if ( !strstr($s, '%') && strlen($s) ) {
51 51
 				$p .= $s . '/';
52 52
 			}
53 53
 		}
@@ -61,22 +61,22 @@  discard block
 block discarded – undo
61 61
 	 * @param bool    $force
62 62
 	 * @return string
63 63
 	 */
64
-	public static function get_rel_url( $url, $force = false ) {
65
-		$url_info = parse_url( $url );
66
-		if ( isset( $url_info['host'] ) && $url_info['host'] != self::get_host() && !$force ) {
64
+	public static function get_rel_url($url, $force = false) {
65
+		$url_info = parse_url($url);
66
+		if ( isset($url_info['host']) && $url_info['host'] != self::get_host() && !$force ) {
67 67
 			return $url;
68 68
 		}
69 69
 		$link = '';
70
-		if ( isset( $url_info['path'] ) ) {
70
+		if ( isset($url_info['path']) ) {
71 71
 			$link = $url_info['path'];
72 72
 		}
73
-		if ( isset( $url_info['query'] ) && strlen( $url_info['query'] ) ) {
73
+		if ( isset($url_info['query']) && strlen($url_info['query']) ) {
74 74
 			$link .= '?' . $url_info['query'];
75 75
 		}
76
-		if ( isset( $url_info['fragment'] ) && strlen( $url_info['fragment'] ) ) {
76
+		if ( isset($url_info['fragment']) && strlen($url_info['fragment']) ) {
77 77
 			$link .= '#' . $url_info['fragment'];
78 78
 		}
79
-		$link = TimberURLHelper::remove_double_slashes( $link );
79
+		$link = TimberURLHelper::remove_double_slashes($link);
80 80
 		return $link;
81 81
 	}
82 82
 
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 * @return string the HTTP_HOST or SERVER_NAME
87 87
 	 */
88 88
 	public static function get_host() {
89
-		if (isset($_SERVER['HTTP_HOST'])) {
89
+		if ( isset($_SERVER['HTTP_HOST']) ) {
90 90
 			return $_SERVER['HTTP_HOST'];
91 91
 		}
92
-		if (isset($_SERVER['SERVER_NAME'])) {
92
+		if ( isset($_SERVER['SERVER_NAME']) ) {
93 93
 			return $_SERVER['SERVER_NAME'];
94 94
 		}
95 95
 		return '';
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 * @param string  $url
102 102
 	 * @return bool
103 103
 	 */
104
-	public static function is_local( $url ) {
105
-		if ( strstr( $url, self::get_host() ) ) {
104
+	public static function is_local($url) {
105
+		if ( strstr($url, self::get_host()) ) {
106 106
 			return true;
107 107
 		}
108 108
 		return false;
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 	 * @param string  $src
115 115
 	 * @return string
116 116
 	 */
117
-	public static function get_full_path( $src ) {
117
+	public static function get_full_path($src) {
118 118
 		$root = ABSPATH;
119 119
 		$old_root_path = $root . $src;
120
-		$old_root_path = str_replace( '//', '/', $old_root_path );
120
+		$old_root_path = str_replace('//', '/', $old_root_path);
121 121
 		return $old_root_path;
122 122
 	}
123 123
 
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
 	 * @param string  $url
130 130
 	 * @return string
131 131
 	 */
132
-	public static function url_to_file_system( $url ) {
133
-		$url_parts = parse_url( $url );
132
+	public static function url_to_file_system($url) {
133
+		$url_parts = parse_url($url);
134 134
 		$path = ABSPATH . $url_parts['path'];
135
-		$path = str_replace( '//', '/', $path );
135
+		$path = str_replace('//', '/', $path);
136 136
 		return $path;
137 137
 	}
138 138
 
139
-	public static function file_system_to_url( $fs ) {
140
-		$relative_path = self::get_rel_path( $fs );
141
-		$home = home_url( '/'.$relative_path );
139
+	public static function file_system_to_url($fs) {
140
+		$relative_path = self::get_rel_path($fs);
141
+		$home = home_url('/' . $relative_path);
142 142
 		return $home;
143 143
 	}
144 144
 
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 	 * @param string  $src
149 149
 	 * @return string
150 150
 	 */
151
-	public static function get_rel_path( $src ) {
152
-		if ( strstr( $src, ABSPATH ) ) {
153
-			return str_replace( ABSPATH, '', $src );
151
+	public static function get_rel_path($src) {
152
+		if ( strstr($src, ABSPATH) ) {
153
+			return str_replace(ABSPATH, '', $src);
154 154
 		}
155 155
 		//its outside the wordpress directory, alternate setups:
156
-		$src = str_replace( WP_CONTENT_DIR, '', $src );
156
+		$src = str_replace(WP_CONTENT_DIR, '', $src);
157 157
 		return WP_CONTENT_SUBDIR . $src;
158 158
 	}
159 159
 
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 	 * @param string  $url
164 164
 	 * @return string
165 165
 	 */
166
-	public static function remove_double_slashes( $url ) {
167
-		$url = str_replace( '//', '/', $url );
168
-		if ( strstr( $url, 'http:' ) && !strstr( $url, 'http://' ) ) {
169
-			$url = str_replace( 'http:/', 'http://', $url );
166
+	public static function remove_double_slashes($url) {
167
+		$url = str_replace('//', '/', $url);
168
+		if ( strstr($url, 'http:') && !strstr($url, 'http://') ) {
169
+			$url = str_replace('http:/', 'http://', $url);
170 170
 		}
171 171
 		return $url;
172 172
 	}
@@ -178,20 +178,20 @@  discard block
 block discarded – undo
178 178
 	 * @param string  $path
179 179
 	 * @return string
180 180
 	 */
181
-	public static function prepend_to_url( $url, $path ) {
182
-		if ( strstr( strtolower( $url ), 'http' ) ) {
183
-			$url_parts = parse_url( $url );
181
+	public static function prepend_to_url($url, $path) {
182
+		if ( strstr(strtolower($url), 'http') ) {
183
+			$url_parts = parse_url($url);
184 184
 			$url = $url_parts['scheme'] . '://' . $url_parts['host'] . $path . $url_parts['path'];
185
-			if ( isset( $url_parts['query'] ) ) {
185
+			if ( isset($url_parts['query']) ) {
186 186
 				$url .= $url_parts['query'];
187 187
 			}
188
-			if ( isset( $url_parts['fragment'] ) ) {
188
+			if ( isset($url_parts['fragment']) ) {
189 189
 				$url .= $url_parts['fragment'];
190 190
 			}
191 191
 		} else {
192 192
 			$url = $url . $path;
193 193
 		}
194
-		return self::remove_double_slashes( $url );
194
+		return self::remove_double_slashes($url);
195 195
 	}
196 196
 
197 197
 	/**
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	 * @param string  $path
201 201
 	 * @return string
202 202
 	 */
203
-	public static function preslashit( $path ) {
204
-		if ( strpos( $path, '/' ) != 0 ) {
203
+	public static function preslashit($path) {
204
+		if ( strpos($path, '/') != 0 ) {
205 205
 			$path = '/' . $path;
206 206
 		}
207 207
 		return $path;
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return boolean true if $path is an absolute url, false if relative.
214 214
 	 */
215
-	public static function is_absolute( $path ) {
216
-		return (boolean) ( strstr( $path, 'http' ) );
215
+	public static function is_absolute($path) {
216
+		return (boolean) (strstr($path, 'http'));
217 217
 	}
218 218
 
219 219
 	/**
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 	 * @param string  $url a URL to evaluate against
225 225
 	 * @return boolean if $url points to an external location returns true
226 226
 	 */
227
-	public static function is_external_content( $url ) {
228
-		$is_external = TimberURLHelper::is_absolute( $url ) && ! TimberURLHelper::is_internal_content( $url );
227
+	public static function is_external_content($url) {
228
+		$is_external = TimberURLHelper::is_absolute($url) && !TimberURLHelper::is_internal_content($url);
229 229
 
230 230
 		return $is_external;
231 231
 	}
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 		// otherwise you run into errors with sites that:
236 236
 		// 1. use WPML plugin
237 237
 		// 2. or redefine content directory
238
-		$is_content_url = strstr( $url, content_url() );
238
+		$is_content_url = strstr($url, content_url());
239 239
 
240 240
 		// this case covers when the upload directory has been redefined
241 241
 		$upload_dir = wp_upload_dir();
242
-		$is_upload_url = strstr( $url, $upload_dir['baseurl'] );
242
+		$is_upload_url = strstr($url, $upload_dir['baseurl']);
243 243
 
244 244
 		return $is_content_url || $is_upload_url;
245 245
 	}
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	 * @return bool     true if $path is an external url, false if relative or local.
252 252
 	 *                  true if it's a subdomain (http://cdn.example.org = true)
253 253
 	 */
254
-	public static function is_external( $url ) {
255
-		$has_http = strstr( strtolower( $url ), 'http' );
256
-		$on_domain = strstr( $url, self::get_host() );
254
+	public static function is_external($url) {
255
+		$has_http = strstr(strtolower($url), 'http');
256
+		$on_domain = strstr($url, self::get_host());
257 257
 		if ( $has_http && !$on_domain ) {
258 258
 			return true;
259 259
 		}
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 	 * @param string  $link
267 267
 	 * @return string
268 268
 	 */
269
-	public static function remove_trailing_slash( $link ) {
269
+	public static function remove_trailing_slash($link) {
270 270
 		if ( $link != "/" )
271
-			$link = untrailingslashit( $link );
271
+			$link = untrailingslashit($link);
272 272
 		return $link;
273 273
 	}
274 274
 
@@ -280,25 +280,25 @@  discard block
 block discarded – undo
280 280
 	 * @return string|WP_Error the location of the temporay file name or an error
281 281
 	 * @deprecated since 0.20.0
282 282
 	 */
283
-	static function download_url( $url, $timeout = 300 ) {
283
+	static function download_url($url, $timeout = 300) {
284 284
 		if ( !$url ) {
285
-			return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) );
285
+			return new WP_Error('http_no_url', __('Invalid URL Provided.'));
286 286
 		}
287 287
 
288
-		$tmpfname = wp_tempnam( $url );
288
+		$tmpfname = wp_tempnam($url);
289 289
 		if ( !$tmpfname ) {
290
-			return new WP_Error( 'http_no_file', __( 'Could not create Temporary file.' ) );
290
+			return new WP_Error('http_no_file', __('Could not create Temporary file.'));
291 291
 		}
292 292
 
293
-		$response = wp_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
293
+		$response = wp_remote_get($url, array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname));
294 294
 
295
-		if ( is_wp_error( $response ) ) {
296
-			unlink( $tmpfname );
295
+		if ( is_wp_error($response) ) {
296
+			unlink($tmpfname);
297 297
 			return $response;
298 298
 		}
299
-		if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
300
-			unlink( $tmpfname );
301
-			return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
299
+		if ( 200 != wp_remote_retrieve_response_code($response) ) {
300
+			unlink($tmpfname);
301
+			return new WP_Error('http_404', trim(wp_remote_retrieve_response_message($response)));
302 302
 		}
303 303
 		return $tmpfname;
304 304
 	}
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
 	 * @param int $i the position of the parameter to grab.
312 312
 	 * @return array|string
313 313
 	 */
314
-	public static function get_params( $i = false ) {
315
-		$args = explode( '/', trim( strtolower( $_SERVER['REQUEST_URI'] ) ) );
314
+	public static function get_params($i = false) {
315
+		$args = explode('/', trim(strtolower($_SERVER['REQUEST_URI'])));
316 316
 		$newargs = array();
317
-		foreach ( $args as $arg ) {
318
-			if ( strlen( $arg ) ) {
317
+		foreach ($args as $arg) {
318
+			if ( strlen($arg) ) {
319 319
 				$newargs[] = $arg;
320 320
 			}
321 321
 		}
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 		}
325 325
 		if ( $i < 0 ) {
326 326
 			//count from end
327
-			$i = count( $newargs ) + $i;
327
+			$i = count($newargs) + $i;
328 328
 		}
329
-		if ( isset( $newargs[$i] ) ) {
329
+		if ( isset($newargs[$i]) ) {
330 330
 			return $newargs[$i];
331 331
 		}
332 332
 	}
Please login to merge, or discard this patch.
timber.php 1 patch
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 // we look for Composer files first in the plugins dir.
15 15
 // then in the wp-content dir (site install).
16 16
 // and finally in the current themes directories.
17
-if (   file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' ) /* check in self */
18
-	|| file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */
19
-	|| file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */
20
-	|| file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */
21
-	|| file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */
17
+if ( file_exists($composer_autoload = __DIR__ . '/vendor/autoload.php') /* check in self */
18
+	|| file_exists($composer_autoload = WP_CONTENT_DIR . '/vendor/autoload.php') /* check in wp-content */
19
+	|| file_exists($composer_autoload = plugin_dir_path(__FILE__) . 'vendor/autoload.php') /* check in plugin directory */
20
+	|| file_exists($composer_autoload = get_stylesheet_directory() . '/vendor/autoload.php') /* check in child theme */
21
+	|| file_exists($composer_autoload = get_template_directory() . '/vendor/autoload.php') /* check in parent theme */
22 22
 	) {
23 23
 	require_once $composer_autoload;
24 24
 }
@@ -63,21 +63,21 @@  discard block
 block discarded – undo
63 63
 		if ( is_admin() || $_SERVER['PHP_SELF'] == '/wp-login.php' ) {
64 64
 			return;
65 65
 		}
66
-		if ( version_compare( phpversion(), '5.3.0', '<' ) && !is_admin() ) {
67
-			trigger_error( 'Timber requires PHP 5.3.0 or greater. You have '.phpversion(), E_USER_ERROR );
66
+		if ( version_compare(phpversion(), '5.3.0', '<') && !is_admin() ) {
67
+			trigger_error('Timber requires PHP 5.3.0 or greater. You have ' . phpversion(), E_USER_ERROR);
68 68
 		}
69
-		if ( !class_exists( 'Twig_Autoloader' ) ) {
70
-			trigger_error( 'You have not run "composer install" to download required dependencies for Timber, you can read more on https://github.com/jarednova/timber#installation', E_USER_ERROR );
69
+		if ( !class_exists('Twig_Autoloader') ) {
70
+			trigger_error('You have not run "composer install" to download required dependencies for Timber, you can read more on https://github.com/jarednova/timber#installation', E_USER_ERROR);
71 71
 		}
72 72
 	}
73 73
 
74 74
 	function init_constants() {
75
-		defined( "TIMBER_LOC" ) or define( "TIMBER_LOC", realpath( __DIR__ ) );
75
+		defined("TIMBER_LOC") or define("TIMBER_LOC", realpath(__DIR__));
76 76
 	}
77 77
 
78 78
 	protected function init() {
79 79
 		TimberTwig::init();
80
-		TimberRoutes::init( $this );
80
+		TimberRoutes::init($this);
81 81
 		TimberImageHelper::init();
82 82
 		TimberAdmin::init();
83 83
 		TimberIntegrations::init();
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 	 * @param string  $PostClass
94 94
 	 * @return array|bool|null
95 95
 	 */
96
-	public static function get_post( $query = false, $PostClass = 'TimberPost' ) {
97
-		return TimberPostGetter::get_post( $query, $PostClass );
96
+	public static function get_post($query = false, $PostClass = 'TimberPost') {
97
+		return TimberPostGetter::get_post($query, $PostClass);
98 98
 	}
99 99
 
100 100
 	/**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param string  $PostClass
105 105
 	 * @return array|bool|null
106 106
 	 */
107
-	public static function get_posts( $query = false, $PostClass = 'TimberPost', $return_collection = false ) {
108
-		return TimberPostGetter::get_posts( $query, $PostClass, $return_collection );
107
+	public static function get_posts($query = false, $PostClass = 'TimberPost', $return_collection = false) {
108
+		return TimberPostGetter::get_posts($query, $PostClass, $return_collection);
109 109
 	}
110 110
 
111 111
 	/**
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * @param string  $PostClass
116 116
 	 * @return array|bool|null
117 117
 	 */
118
-	public static function query_post( $query = false, $PostClass = 'TimberPost' ) {
119
-		return TimberPostGetter::query_post( $query, $PostClass );
118
+	public static function query_post($query = false, $PostClass = 'TimberPost') {
119
+		return TimberPostGetter::query_post($query, $PostClass);
120 120
 	}
121 121
 
122 122
 	/**
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 * @param string  $PostClass
127 127
 	 * @return array|bool|null
128 128
 	 */
129
-	public static function query_posts( $query = false, $PostClass = 'TimberPost' ) {
130
-		return TimberPostGetter::query_posts( $query, $PostClass );
129
+	public static function query_posts($query = false, $PostClass = 'TimberPost') {
130
+		return TimberPostGetter::query_posts($query, $PostClass);
131 131
 	}
132 132
 
133 133
 	/**
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	 * @return array
138 138
 	 * @deprecated since 0.20.0
139 139
 	 */
140
-	static function get_pids( $query = null ) {
141
-		return TimberPostGetter::get_pids( $query );
140
+	static function get_pids($query = null) {
141
+		return TimberPostGetter::get_pids($query);
142 142
 	}
143 143
 
144 144
 	/**
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	 * @return array
149 149
 	 * @deprecated since 0.20.0
150 150
 	 */
151
-	static function get_posts_from_loop( $PostClass ) {
152
-		return TimberPostGetter::get_posts( $PostClass );
151
+	static function get_posts_from_loop($PostClass) {
152
+		return TimberPostGetter::get_posts($PostClass);
153 153
 	}
154 154
 
155 155
 	/**
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 * @return array
161 161
 	 * @deprecated since 0.20.0
162 162
 	 */
163
-	static function get_posts_from_slug( $slug, $PostClass = 'TimberPost' ) {
164
-		return TimberPostGetter::get_posts( $slug, $PostClass );
163
+	static function get_posts_from_slug($slug, $PostClass = 'TimberPost') {
164
+		return TimberPostGetter::get_posts($slug, $PostClass);
165 165
 	}
166 166
 
167 167
 	/**
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	 * @return array
173 173
 	 * @deprecated since 0.20.0
174 174
 	 */
175
-	static function get_posts_from_wp_query( $query = array(), $PostClass = 'TimberPost' ) {
176
-		return TimberPostGetter::query_posts( $query, $PostClass );
175
+	static function get_posts_from_wp_query($query = array(), $PostClass = 'TimberPost') {
176
+		return TimberPostGetter::query_posts($query, $PostClass);
177 177
 	}
178 178
 
179 179
 	/**
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @return array|null
185 185
 	 * @deprecated since 0.20.0
186 186
 	 */
187
-	static function get_posts_from_array_of_ids( $query = array(), $PostClass = 'TimberPost' ) {
188
-		return TimberPostGetter::get_posts( $query, $PostClass );
187
+	static function get_posts_from_array_of_ids($query = array(), $PostClass = 'TimberPost') {
188
+		return TimberPostGetter::get_posts($query, $PostClass);
189 189
 	}
190 190
 
191 191
 	/**
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 	 * @return int
196 196
 	 * @deprecated since 0.20.0
197 197
 	 */
198
-	static function get_pid( $query ) {
199
-		$pids = TimberPostGetter::get_pids( $query );
200
-		if ( is_array( $pids ) && count( $pids ) ) {
198
+	static function get_pid($query) {
199
+		$pids = TimberPostGetter::get_pids($query);
200
+		if ( is_array($pids) && count($pids) ) {
201 201
 			return $pids[0];
202 202
 		}
203 203
 	}
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 * @param string  $TermClass
224 224
 	 * @return mixed
225 225
 	 */
226
-	public static function get_terms( $args = null, $maybe_args = array(), $TermClass = 'TimberTerm' ) {
227
-		return TimberTermGetter::get_terms( $args, $maybe_args, $TermClass );
226
+	public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm') {
227
+		return TimberTermGetter::get_terms($args, $maybe_args, $TermClass);
228 228
 	}
229 229
 
230 230
 	/* Site Retrieval
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
 	 * @param array|bool $blog_ids
237 237
 	 * @return array
238 238
 	 */
239
-	public static function get_sites( $blog_ids = false ) {
240
-		if ( !is_array( $blog_ids ) ) {
239
+	public static function get_sites($blog_ids = false) {
240
+		if ( !is_array($blog_ids) ) {
241 241
 			global $wpdb;
242
-			$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC" );
242
+			$blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC");
243 243
 		}
244 244
 		$return = array();
245
-		foreach ( $blog_ids as $blog_id ) {
246
-			$return[] = new TimberSite( $blog_id );
245
+		foreach ($blog_ids as $blog_id) {
246
+			$return[] = new TimberSite($blog_id);
247 247
 		}
248 248
 		return $return;
249 249
 	}
@@ -261,29 +261,29 @@  discard block
 block discarded – undo
261 261
 		$data = array();
262 262
 		$data['http_host'] = 'http://' . TimberURLHelper::get_host();
263 263
 		$data['wp_title'] = TimberHelper::get_wp_title();
264
-		$data['wp_head'] = TimberHelper::function_wrapper( 'wp_head' );
265
-		$data['wp_footer'] = TimberHelper::function_wrapper( 'wp_footer' );
266
-		$data['body_class'] = implode( ' ', get_body_class() );
264
+		$data['wp_head'] = TimberHelper::function_wrapper('wp_head');
265
+		$data['wp_footer'] = TimberHelper::function_wrapper('wp_footer');
266
+		$data['body_class'] = implode(' ', get_body_class());
267 267
 
268 268
 		$data['site'] = new TimberSite();
269 269
 		$data['theme'] = $data['site']->theme;
270 270
 		//deprecated, these should be fetched via TimberSite or TimberTheme
271
-		$data['theme_dir'] = WP_CONTENT_SUBDIR.str_replace( WP_CONTENT_DIR, '', get_stylesheet_directory() );
272
-		$data['language_attributes'] = TimberHelper::function_wrapper( 'language_attributes' );
271
+		$data['theme_dir'] = WP_CONTENT_SUBDIR . str_replace(WP_CONTENT_DIR, '', get_stylesheet_directory());
272
+		$data['language_attributes'] = TimberHelper::function_wrapper('language_attributes');
273 273
 		$data['stylesheet_uri'] = get_stylesheet_uri();
274 274
 		$data['template_uri'] = get_template_directory_uri();
275 275
 
276 276
 		$data['posts'] = Timber::query_posts();
277 277
 
278 278
 		//deprecated, this should be fetched via TimberMenu
279
-		if ( function_exists( 'wp_nav_menu' ) ) {
279
+		if ( function_exists('wp_nav_menu') ) {
280 280
 			$locations = get_nav_menu_locations();
281
-			if ( count( $locations ) ) {
282
-				$data['wp_nav_menu'] = wp_nav_menu( array( 'container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu' ) );
281
+			if ( count($locations) ) {
282
+				$data['wp_nav_menu'] = wp_nav_menu(array('container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu'));
283 283
 			}
284 284
 		}
285
-		$data = apply_filters( 'timber_context', $data );
286
-		$data = apply_filters( 'timber/context', $data );
285
+		$data = apply_filters('timber_context', $data);
286
+		$data = apply_filters('timber/context', $data);
287 287
 		return $data;
288 288
 	}
289 289
 
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
 	 * @param bool    $via_render
298 298
 	 * @return bool|string
299 299
 	 */
300
-	public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false ) {
300
+	public static function compile($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false) {
301 301
 		$caller = self::get_calling_script_dir();
302 302
 		$caller_file = self::get_calling_script_file();
303
-		$caller_file = apply_filters( 'timber_calling_php_file', $caller_file );
304
-		$loader = new TimberLoader( $caller );
305
-		$file = $loader->choose_template( $filenames );
303
+		$caller_file = apply_filters('timber_calling_php_file', $caller_file);
304
+		$loader = new TimberLoader($caller);
305
+		$file = $loader->choose_template($filenames);
306 306
 		$output = '';
307
-		if ( is_null( $data ) ) {
307
+		if ( is_null($data) ) {
308 308
 			$data = array();
309 309
 		}
310
-		if ( strlen( $file ) ) {
310
+		if ( strlen($file) ) {
311 311
 			if ( $via_render ) {
312
-				$file = apply_filters( 'timber_render_file', $file );
313
-				$data = apply_filters( 'timber_render_data', $data );
312
+				$file = apply_filters('timber_render_file', $file);
313
+				$data = apply_filters('timber_render_data', $data);
314 314
 			} else {
315
-				$file = apply_filters( 'timber_compile_file', $file );
316
-				$data = apply_filters( 'timber_compile_data', $data );
315
+				$file = apply_filters('timber_compile_file', $file);
316
+				$data = apply_filters('timber_compile_data', $data);
317 317
 			}
318
-			$output = $loader->render( $file, $data, $expires, $cache_mode );
318
+			$output = $loader->render($file, $data, $expires, $cache_mode);
319 319
 		}
320
-		do_action( 'timber_compile_done' );
320
+		do_action('timber_compile_done');
321 321
 		return $output;
322 322
 	}
323 323
 
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 	 * @param array   $data   an array with data in it.
329 329
 	 * @return  bool|string
330 330
 	 */
331
-	public static function compile_string( $string, $data = array() ) {
331
+	public static function compile_string($string, $data = array()) {
332 332
 		$dummy_loader = new TimberLoader();
333 333
 		$dummy_loader->get_twig();
334 334
 		$loader = new Twig_Loader_String();
335
-		$twig = new Twig_Environment( $loader );
336
-		$twig = apply_filters( 'timber/twig/filters', $twig );
337
-		$twig = apply_filters( 'twig_apply_filters', $twig );
338
-		return $twig->render( $string, $data );
335
+		$twig = new Twig_Environment($loader);
336
+		$twig = apply_filters('timber/twig/filters', $twig);
337
+		$twig = apply_filters('twig_apply_filters', $twig);
338
+		return $twig->render($string, $data);
339 339
 	}
340 340
 
341 341
 	/**
@@ -347,15 +347,15 @@  discard block
 block discarded – undo
347 347
 	 * @param string  $cache_mode
348 348
 	 * @return bool|string
349 349
 	 */
350
-	public static function fetch( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) {
350
+	public static function fetch($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT) {
351 351
 		if ( $expires === true ) {
352 352
 			//if this is reading as true; the user probably is using the old $echo param
353 353
 			//so we should move all vars up by a spot
354 354
 			$expires = $cache_mode;
355 355
 			$cache_mode = TimberLoader::CACHE_USE_DEFAULT;
356 356
 		}
357
-		$output = self::compile( $filenames, $data, $expires, $cache_mode, true );
358
-		$output = apply_filters( 'timber_compile_result', $output );
357
+		$output = self::compile($filenames, $data, $expires, $cache_mode, true);
358
+		$output = apply_filters('timber_compile_result', $output);
359 359
 		return $output;
360 360
 	}
361 361
 
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
 	 * @param string  $cache_mode
369 369
 	 * @return bool|string
370 370
 	 */
371
-	public static function render( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) {
372
-		$output = static::fetch( $filenames, $data, $expires, $cache_mode );
371
+	public static function render($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT) {
372
+		$output = static::fetch($filenames, $data, $expires, $cache_mode);
373 373
 		echo $output;
374 374
 		return $output;
375 375
 	}
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 	 * @param array   $data   an array with data in it.
382 382
 	 * @return  bool|string
383 383
 	 */
384
-	public static function render_string( $string, $data = array() ) {
385
-		$compiled = self::compile_string( $string, $data );
384
+	public static function render_string($string, $data = array()) {
385
+		$compiled = self::compile_string($string, $data);
386 386
 		echo $compiled;
387 387
 		return $compiled;
388 388
 	}
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
 	 * @param array   $data
399 399
 	 * @return bool|string
400 400
 	 */
401
-	public static function get_sidebar( $sidebar = '', $data = array() ) {
401
+	public static function get_sidebar($sidebar = '', $data = array()) {
402 402
 		if ( $sidebar == '' ) {
403 403
 			$sidebar = 'sidebar.php';
404 404
 		}
405
-		if ( strstr( strtolower( $sidebar ), '.php' ) ) {
406
-			return self::get_sidebar_from_php( $sidebar, $data );
405
+		if ( strstr(strtolower($sidebar), '.php') ) {
406
+			return self::get_sidebar_from_php($sidebar, $data);
407 407
 		}
408
-		return self::compile( $sidebar, $data );
408
+		return self::compile($sidebar, $data);
409 409
 	}
410 410
 
411 411
 	/**
@@ -415,21 +415,21 @@  discard block
 block discarded – undo
415 415
 	 * @param array   $data
416 416
 	 * @return string
417 417
 	 */
418
-	public static function get_sidebar_from_php( $sidebar = '', $data ) {
418
+	public static function get_sidebar_from_php($sidebar = '', $data) {
419 419
 		$caller = self::get_calling_script_dir();
420 420
 		$loader = new TimberLoader();
421
-		$uris = $loader->get_locations( $caller );
421
+		$uris = $loader->get_locations($caller);
422 422
 		ob_start();
423 423
 		$found = false;
424
-		foreach ( $uris as $uri ) {
425
-			if ( file_exists( trailingslashit( $uri ) . $sidebar ) ) {
426
-				include trailingslashit( $uri ) . $sidebar;
424
+		foreach ($uris as $uri) {
425
+			if ( file_exists(trailingslashit($uri) . $sidebar) ) {
426
+				include trailingslashit($uri) . $sidebar;
427 427
 				$found = true;
428 428
 				break;
429 429
 			}
430 430
 		}
431 431
 		if ( !$found ) {
432
-			TimberHelper::error_log( 'error loading your sidebar, check to make sure the file exists' );
432
+			TimberHelper::error_log('error loading your sidebar, check to make sure the file exists');
433 433
 		}
434 434
 		$ret = ob_get_contents();
435 435
 		ob_end_clean();
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	 * @param int     $widget_id
446 446
 	 * @return TimberFunctionWrapper
447 447
 	 */
448
-	public static function get_widgets( $widget_id ) {
449
-		return TimberHelper::function_wrapper( 'dynamic_sidebar', array( $widget_id ), true );
448
+	public static function get_widgets($widget_id) {
449
+		return TimberHelper::function_wrapper('dynamic_sidebar', array($widget_id), true);
450 450
 	}
451 451
 
452 452
 
@@ -461,12 +461,12 @@  discard block
 block discarded – undo
461 461
 	 * @param array   $args
462 462
 	 * @deprecated since 0.20.0
463 463
 	 */
464
-	public static function add_route( $route, $callback, $args = array() ) {
465
-		Routes::map( $route, $callback, $args );
464
+	public static function add_route($route, $callback, $args = array()) {
465
+		Routes::map($route, $callback, $args);
466 466
 	}
467 467
 
468 468
 	public function cancel_query() {
469
-		add_action( 'posts_request', array( $this, 'cancel_query_posts_request' ) );
469
+		add_action('posts_request', array($this, 'cancel_query_posts_request'));
470 470
 	}
471 471
 
472 472
 	function cancel_query_posts_request() {
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 	 *
481 481
 	 * @deprecated since 0.20.0
482 482
 	 */
483
-	public static function load_template( $template, $query = false, $status_code = 200, $tparams = false ) {
484
-		return Routes::load( $template, $tparams, $query, $status_code );
483
+	public static function load_template($template, $query = false, $status_code = 200, $tparams = false) {
484
+		return Routes::load($template, $tparams, $query, $status_code);
485 485
 	}
486 486
 
487 487
 	/**
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
 	 *
490 490
 	 * @deprecated since 0.20.2
491 491
 	 */
492
-	public static function load_view( $template, $query = false, $status_code = 200, $tparams = false ) {
493
-		return Routes::load( $template, $tparams, $query, $status_code );
492
+	public static function load_view($template, $query = false, $status_code = 200, $tparams = false) {
493
+		return Routes::load($template, $tparams, $query, $status_code);
494 494
 	}
495 495
 
496 496
 
@@ -503,44 +503,44 @@  discard block
 block discarded – undo
503 503
 	 * @param array   $prefs
504 504
 	 * @return array mixed
505 505
 	 */
506
-	public static function get_pagination( $prefs = array() ) {
506
+	public static function get_pagination($prefs = array()) {
507 507
 		global $wp_query;
508 508
 		global $paged;
509 509
 		global $wp_rewrite;
510 510
 		$args = array();
511
-		$args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] );
511
+		$args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']);
512 512
 		if ( $wp_rewrite->using_permalinks() ) {
513
-			$url = explode( '?', get_pagenum_link( 0 ) );
514
-			if ( isset( $url[1] ) ) {
515
-				parse_str( $url[1], $query );
513
+			$url = explode('?', get_pagenum_link(0));
514
+			if ( isset($url[1]) ) {
515
+				parse_str($url[1], $query);
516 516
 				$args['add_args'] = $query;
517 517
 			}
518 518
 			$args['format'] = 'page/%#%';
519
-			$args['base'] = trailingslashit( $url[0] ).'%_%';
519
+			$args['base'] = trailingslashit($url[0]) . '%_%';
520 520
 		} else {
521 521
 			$big = 999999999;
522
-			$args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) );
522
+			$args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big)));
523 523
 		}
524 524
 		$args['type'] = 'array';
525
-		$args['current'] = max( 1, get_query_var( 'paged' ) );
526
-		$args['mid_size'] = max( 9 - $args['current'], 3 );
525
+		$args['current'] = max(1, get_query_var('paged'));
526
+		$args['mid_size'] = max(9 - $args['current'], 3);
527 527
 		$args['prev_next'] = false;
528
-		if ( is_int( $prefs ) ) {
528
+		if ( is_int($prefs) ) {
529 529
 			$args['mid_size'] = $prefs - 2;
530 530
 		} else {
531
-			$args = array_merge( $args, $prefs );
531
+			$args = array_merge($args, $prefs);
532 532
 		}
533 533
 		$data = array();
534 534
 		$data['current'] = $args['current'];
535 535
 		$data['total'] = $args['total'];
536
-		$data['pages'] = TimberHelper::paginate_links( $args );
537
-		$next = get_next_posts_page_link( $args['total'] );
536
+		$data['pages'] = TimberHelper::paginate_links($args);
537
+		$next = get_next_posts_page_link($args['total']);
538 538
 		if ( $next ) {
539
-			$data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' );
539
+			$data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next');
540 540
 		}
541
-		$prev = previous_posts( false );
541
+		$prev = previous_posts(false);
542 542
 		if ( $prev ) {
543
-			$data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' );
543
+			$data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev');
544 544
 		}
545 545
 		if ( $paged < 2 ) {
546 546
 			$data['prev'] = '';
@@ -558,9 +558,9 @@  discard block
 block discarded – undo
558 558
 	 * @return string
559 559
 	 * @deprecated since 0.20.0
560 560
 	 */
561
-	public static function get_calling_script_path( $offset = 0 ) {
562
-		$dir = self::get_calling_script_dir( $offset );
563
-		return str_replace( ABSPATH, '', realpath( $dir ) );
561
+	public static function get_calling_script_path($offset = 0) {
562
+		$dir = self::get_calling_script_dir($offset);
563
+		return str_replace(ABSPATH, '', realpath($dir));
564 564
 	}
565 565
 
566 566
 	/**
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
 	 *
569 569
 	 * @return boolean|string
570 570
 	 */
571
-	public static function get_calling_script_dir( $offset = 0 ) {
572
-		$caller = self::get_calling_script_file( $offset );
573
-		if ( !is_null( $caller ) ) {
574
-			$pathinfo = pathinfo( $caller );
571
+	public static function get_calling_script_dir($offset = 0) {
572
+		$caller = self::get_calling_script_file($offset);
573
+		if ( !is_null($caller) ) {
574
+			$pathinfo = pathinfo($caller);
575 575
 			$dir = $pathinfo['dirname'];
576 576
 			return $dir;
577 577
 		}
@@ -585,11 +585,11 @@  discard block
 block discarded – undo
585 585
 	 * @return string|null
586 586
 	 * @deprecated since 0.20.0
587 587
 	 */
588
-	public static function get_calling_script_file( $offset = 0 ) {
588
+	public static function get_calling_script_file($offset = 0) {
589 589
 		$caller = null;
590 590
 		$backtrace = debug_backtrace();
591 591
 		$i = 0;
592
-		foreach ( $backtrace as $trace ) {
592
+		foreach ($backtrace as $trace) {
593 593
 			if ( $trace['file'] != __FILE__ ) {
594 594
 				$caller = $trace['file'];
595 595
 				break;
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 	 * @return bool
610 610
 	 * @deprecated since 0.20.0
611 611
 	 */
612
-	public static function is_post_class_or_class_map( $args ) {
613
-		return TimberPostGetter::is_post_class_or_class_map( $args );
612
+	public static function is_post_class_or_class_map($args) {
613
+		return TimberPostGetter::is_post_class_or_class_map($args);
614 614
 	}
615 615
 
616 616
 }
Please login to merge, or discard this patch.