Completed
Push — master ( 7eb7d5...b49144 )
by Jared
02:46
created
lib/timber-twig.php 1 patch
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 	 * @codeCoverageIgnore
16 16
 	 */
17 17
 	function __construct() {
18
-		add_action( 'timber/twig/filters', array( $this, 'add_timber_filters_deprecated' ) );
19
-		add_action( 'timber/twig/filters', array( $this, 'add_timber_filters' ) );
18
+		add_action('timber/twig/filters', array($this, 'add_timber_filters_deprecated'));
19
+		add_action('timber/twig/filters', array($this, 'add_timber_filters'));
20 20
 	}
21 21
 
22 22
 	/**
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 	 * @return Twig_Environment
28 28
 	 */
29 29
 	function add_timber_filters_deprecated( $twig ) {
30
-		$twig->addFilter( new Twig_SimpleFilter( 'get_src_from_attachment_id', 'twig_get_src_from_attachment_id' ) );
31
-		$twig->addFilter( new Twig_SimpleFilter( 'wp_body_class', array( $this, 'body_class' ) ) );
32
-		$twig->addFilter( new Twig_SimpleFilter( 'twitterify', array( 'TimberHelper', 'twitterify' ) ) );
33
-		$twig->addFilter( new Twig_SimpleFilter( 'twitterfy', array( 'TimberHelper', 'twitterify' ) ) );
34
-		$twig->addFilter( new Twig_SimpleFilter( 'string', function($arr, $glue = ' '){
30
+		$twig->addFilter(new Twig_SimpleFilter('get_src_from_attachment_id', 'twig_get_src_from_attachment_id'));
31
+		$twig->addFilter(new Twig_SimpleFilter('wp_body_class', array($this, 'body_class')));
32
+		$twig->addFilter(new Twig_SimpleFilter('twitterify', array('TimberHelper', 'twitterify')));
33
+		$twig->addFilter(new Twig_SimpleFilter('twitterfy', array('TimberHelper', 'twitterify')));
34
+		$twig->addFilter(new Twig_SimpleFilter('string', function( $arr, $glue = ' ' ) {
35 35
 			return twig_join_filter($arr, $glue);
36
-		} ) );
36
+		} ));
37 37
 		return $twig;
38 38
 	}
39 39
 
@@ -45,149 +45,149 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	function add_timber_filters( $twig ) {
47 47
 		/* image filters */
48
-		$twig->addFilter( new Twig_SimpleFilter( 'resize', array( 'TimberImageHelper', 'resize' ) ) );
49
-		$twig->addFilter( new Twig_SimpleFilter( 'retina', array( 'TimberImageHelper', 'retina_resize' ) ) );
50
-		$twig->addFilter( new Twig_SimpleFilter( 'letterbox', array( 'TimberImageHelper', 'letterbox' ) ) );
51
-		$twig->addFilter( new Twig_SimpleFilter( 'tojpg', array( 'TimberImageHelper', 'img_to_jpg' ) ) );
48
+		$twig->addFilter(new Twig_SimpleFilter('resize', array('TimberImageHelper', 'resize')));
49
+		$twig->addFilter(new Twig_SimpleFilter('retina', array('TimberImageHelper', 'retina_resize')));
50
+		$twig->addFilter(new Twig_SimpleFilter('letterbox', array('TimberImageHelper', 'letterbox')));
51
+		$twig->addFilter(new Twig_SimpleFilter('tojpg', array('TimberImageHelper', 'img_to_jpg')));
52 52
 
53 53
 		/* debugging filters */
54
-		$twig->addFilter( new Twig_SimpleFilter( 'docs', 'twig_object_docs' ) );
55
-		$twig->addFilter( new Twig_SimpleFilter( 'get_class',  'get_class' ) );
56
-		$twig->addFilter( new Twig_SimpleFilter( 'get_type', 'get_type' ) );
57
-		$twig->addFilter( new Twig_SimpleFilter( 'print_r', function( $arr ) {
58
-					return print_r( $arr, true );
59
-				} ) );
60
-		$twig->addFilter( new Twig_SimpleFilter( 'print_a', function( $arr ) {
61
-					return '<pre>' . self::object_docs( $arr, true ) . '</pre>';
62
-				} ) );
54
+		$twig->addFilter(new Twig_SimpleFilter('docs', 'twig_object_docs'));
55
+		$twig->addFilter(new Twig_SimpleFilter('get_class', 'get_class'));
56
+		$twig->addFilter(new Twig_SimpleFilter('get_type', 'get_type'));
57
+		$twig->addFilter(new Twig_SimpleFilter('print_r', function( $arr ) {
58
+					return print_r($arr, true);
59
+				} ));
60
+		$twig->addFilter(new Twig_SimpleFilter('print_a', function( $arr ) {
61
+					return '<pre>' . self::object_docs($arr, true) . '</pre>';
62
+				} ));
63 63
 
64 64
 		/* other filters */
65
-		$twig->addFilter( new Twig_SimpleFilter( 'stripshortcodes', 'strip_shortcodes' ) );
66
-		$twig->addFilter( new Twig_SimpleFilter( 'array', array( $this, 'to_array' ) ) );
67
-		$twig->addFilter( new Twig_SimpleFilter( 'excerpt', 'wp_trim_words' ) );
68
-		$twig->addFilter( new Twig_SimpleFilter( 'function', array( $this, 'exec_function' ) ) );
69
-		$twig->addFilter( new Twig_SimpleFilter( 'pretags', array( $this, 'twig_pretags' ) ) );
70
-		$twig->addFilter( new Twig_SimpleFilter( 'sanitize', 'sanitize_title' ) );
71
-		$twig->addFilter( new Twig_SimpleFilter( 'shortcodes', 'do_shortcode' ) );
72
-		$twig->addFilter( new Twig_SimpleFilter( 'time_ago', array( $this, 'time_ago' ) ) );
73
-		$twig->addFilter( new Twig_SimpleFilter( 'wpautop', 'wpautop' ) );
74
-		$twig->addFilter( new Twig_SimpleFilter( 'list', array( $this, 'add_list_separators' ) ) );
75
-
76
-		$twig->addFilter( new Twig_SimpleFilter( 'relative', function ( $link ) {
77
-					return TimberURLHelper::get_rel_url( $link, true );
78
-				} ) );
79
-
80
-		$twig->addFilter( new Twig_SimpleFilter( 'date', array( $this, 'intl_date' ) ) );
81
-
82
-		$twig->addFilter( new Twig_SimpleFilter( 'truncate', function ( $text, $len ) {
83
-					return TimberHelper::trim_words( $text, $len );
84
-				} ) );
65
+		$twig->addFilter(new Twig_SimpleFilter('stripshortcodes', 'strip_shortcodes'));
66
+		$twig->addFilter(new Twig_SimpleFilter('array', array($this, 'to_array')));
67
+		$twig->addFilter(new Twig_SimpleFilter('excerpt', 'wp_trim_words'));
68
+		$twig->addFilter(new Twig_SimpleFilter('function', array($this, 'exec_function')));
69
+		$twig->addFilter(new Twig_SimpleFilter('pretags', array($this, 'twig_pretags')));
70
+		$twig->addFilter(new Twig_SimpleFilter('sanitize', 'sanitize_title'));
71
+		$twig->addFilter(new Twig_SimpleFilter('shortcodes', 'do_shortcode'));
72
+		$twig->addFilter(new Twig_SimpleFilter('time_ago', array($this, 'time_ago')));
73
+		$twig->addFilter(new Twig_SimpleFilter('wpautop', 'wpautop'));
74
+		$twig->addFilter(new Twig_SimpleFilter('list', array($this, 'add_list_separators')));
75
+
76
+		$twig->addFilter(new Twig_SimpleFilter('relative', function( $link ) {
77
+					return TimberURLHelper::get_rel_url($link, true);
78
+				} ));
79
+
80
+		$twig->addFilter(new Twig_SimpleFilter('date', array($this, 'intl_date')));
81
+
82
+		$twig->addFilter(new Twig_SimpleFilter('truncate', function( $text, $len ) {
83
+					return TimberHelper::trim_words($text, $len);
84
+				} ));
85 85
 
86 86
 		/* actions and filters */
87
-		$twig->addFunction( new Twig_SimpleFunction( 'action', function ( $context ) {
87
+		$twig->addFunction(new Twig_SimpleFunction('action', function( $context ) {
88 88
 					$args = func_get_args();
89
-					array_shift( $args );
89
+					array_shift($args);
90 90
 					$args[] = $context;
91
-					call_user_func_array( 'do_action', $args );
92
-				}, array( 'needs_context' => true ) ) );
91
+					call_user_func_array('do_action', $args);
92
+				}, array('needs_context' => true)));
93 93
 
94
-		$twig->addFilter( new Twig_SimpleFilter( 'apply_filters', function () {
94
+		$twig->addFilter(new Twig_SimpleFilter('apply_filters', function() {
95 95
 					$args = func_get_args();
96
-					$tag = current( array_splice( $args, 1, 1 ) );
96
+					$tag = current(array_splice($args, 1, 1));
97 97
 
98
-					return apply_filters_ref_array( $tag, $args );
99
-				} ) );
100
-		$twig->addFunction( new Twig_SimpleFunction( 'function', array( &$this, 'exec_function' ) ) );
101
-		$twig->addFunction( new Twig_SimpleFunction( 'fn', array( &$this, 'exec_function' ) ) );
98
+					return apply_filters_ref_array($tag, $args);
99
+				} ));
100
+		$twig->addFunction(new Twig_SimpleFunction('function', array(&$this, 'exec_function')));
101
+		$twig->addFunction(new Twig_SimpleFunction('fn', array(&$this, 'exec_function')));
102 102
 
103
-		$twig->addFunction( new Twig_SimpleFunction( 'shortcode', 'do_shortcode' ) );
103
+		$twig->addFunction(new Twig_SimpleFunction('shortcode', 'do_shortcode'));
104 104
 
105 105
 		/* TimberObjects */
106
-		$twig->addFunction( new Twig_SimpleFunction( 'TimberPost', function ( $pid, $PostClass = 'TimberPost' ) {
107
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
106
+		$twig->addFunction(new Twig_SimpleFunction('TimberPost', function( $pid, $PostClass = 'TimberPost' ) {
107
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
108 108
 						foreach ( $pid as &$p ) {
109
-							$p = new $PostClass( $p );
109
+							$p = new $PostClass($p);
110 110
 						}
111 111
 						return $pid;
112 112
 					}
113
-					return new $PostClass( $pid );
114
-				} ) );
115
-		$twig->addFunction( new Twig_SimpleFunction( 'TimberImage', function ( $pid, $ImageClass = 'TimberImage' ) {
116
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
113
+					return new $PostClass($pid);
114
+				} ));
115
+		$twig->addFunction(new Twig_SimpleFunction('TimberImage', function( $pid, $ImageClass = 'TimberImage' ) {
116
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
117 117
 						foreach ( $pid as &$p ) {
118
-							$p = new $ImageClass( $p );
118
+							$p = new $ImageClass($p);
119 119
 						}
120 120
 						return $pid;
121 121
 					}
122
-					return new $ImageClass( $pid );
123
-				} ) );
124
-		$twig->addFunction( new Twig_SimpleFunction( 'TimberTerm', function ( $pid, $TermClass = 'TimberTerm' ) {
125
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
122
+					return new $ImageClass($pid);
123
+				} ));
124
+		$twig->addFunction(new Twig_SimpleFunction('TimberTerm', function( $pid, $TermClass = 'TimberTerm' ) {
125
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
126 126
 						foreach ( $pid as &$p ) {
127
-							$p = new $TermClass( $p );
127
+							$p = new $TermClass($p);
128 128
 						}
129 129
 						return $pid;
130 130
 					}
131
-					return new $TermClass( $pid );
132
-				} ) );
133
-		$twig->addFunction( new Twig_SimpleFunction( 'TimberUser', function ( $pid, $UserClass = 'TimberUser' ) {
134
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
131
+					return new $TermClass($pid);
132
+				} ));
133
+		$twig->addFunction(new Twig_SimpleFunction('TimberUser', function( $pid, $UserClass = 'TimberUser' ) {
134
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
135 135
 						foreach ( $pid as &$p ) {
136
-							$p = new $UserClass( $p );
136
+							$p = new $UserClass($p);
137 137
 						}
138 138
 						return $pid;
139 139
 					}
140
-					return new $UserClass( $pid );
141
-				} ) );
140
+					return new $UserClass($pid);
141
+				} ));
142 142
 
143 143
 		/* TimberObjects Alias */
144
-		$twig->addFunction( new Twig_SimpleFunction( 'Post', function ( $pid, $PostClass = 'TimberPost' ) {
145
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
144
+		$twig->addFunction(new Twig_SimpleFunction('Post', function( $pid, $PostClass = 'TimberPost' ) {
145
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
146 146
 						foreach ( $pid as &$p ) {
147
-							$p = new $PostClass( $p );
147
+							$p = new $PostClass($p);
148 148
 						}
149 149
 						return $pid;
150 150
 					}
151
-					return new $PostClass( $pid );
152
-				} ) );
153
-		$twig->addFunction( new Twig_SimpleFunction( 'Image', function ( $pid, $ImageClass = 'TimberImage' ) {
154
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
151
+					return new $PostClass($pid);
152
+				} ));
153
+		$twig->addFunction(new Twig_SimpleFunction('Image', function( $pid, $ImageClass = 'TimberImage' ) {
154
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
155 155
 						foreach ( $pid as &$p ) {
156
-							$p = new $ImageClass( $p );
156
+							$p = new $ImageClass($p);
157 157
 						}
158 158
 						return $pid;
159 159
 					}
160
-					return new $ImageClass( $pid );
161
-				} ) );
162
-		$twig->addFunction( new Twig_SimpleFunction( 'Term', function ( $pid, $TermClass = 'TimberTerm' ) {
163
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
160
+					return new $ImageClass($pid);
161
+				} ));
162
+		$twig->addFunction(new Twig_SimpleFunction('Term', function( $pid, $TermClass = 'TimberTerm' ) {
163
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
164 164
 						foreach ( $pid as &$p ) {
165
-							$p = new $TermClass( $p );
165
+							$p = new $TermClass($p);
166 166
 						}
167 167
 						return $pid;
168 168
 					}
169
-					return new $TermClass( $pid );
170
-				} ) );
171
-		$twig->addFunction( new Twig_SimpleFunction( 'User', function ( $pid, $UserClass = 'TimberUser' ) {
172
-					if ( is_array( $pid ) && !TimberHelper::is_array_assoc( $pid ) ) {
169
+					return new $TermClass($pid);
170
+				} ));
171
+		$twig->addFunction(new Twig_SimpleFunction('User', function( $pid, $UserClass = 'TimberUser' ) {
172
+					if ( is_array($pid) && !TimberHelper::is_array_assoc($pid) ) {
173 173
 						foreach ( $pid as &$p ) {
174
-							$p = new $UserClass( $p );
174
+							$p = new $UserClass($p);
175 175
 						}
176 176
 						return $pid;
177 177
 					}
178
-					return new $UserClass( $pid );
179
-				} ) );
178
+					return new $UserClass($pid);
179
+				} ));
180 180
 
181 181
 		/* bloginfo and translate */
182
-		$twig->addFunction( 'bloginfo', new Twig_SimpleFunction( 'bloginfo', function ( $show = '', $filter = 'raw' ) {
183
-					return get_bloginfo( $show, $filter );
184
-				} ) );
185
-		$twig->addFunction( '__', new Twig_SimpleFunction( '__', function ( $text, $domain = 'default' ) {
186
-					return __( $text, $domain );
187
-				} ) );
182
+		$twig->addFunction('bloginfo', new Twig_SimpleFunction('bloginfo', function( $show = '', $filter = 'raw' ) {
183
+					return get_bloginfo($show, $filter);
184
+				} ));
185
+		$twig->addFunction('__', new Twig_SimpleFunction('__', function( $text, $domain = 'default' ) {
186
+					return __($text, $domain);
187
+				} ));
188 188
 		/* get_twig is deprecated, use timber/twig */
189
-		$twig = apply_filters( 'get_twig', $twig );
190
-		$twig = apply_filters( 'timber/twig', $twig );
189
+		$twig = apply_filters('get_twig', $twig);
190
+		$twig = apply_filters('timber/twig', $twig);
191 191
 		return $twig;
192 192
 	}
193 193
 
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 * @return array
199 199
 	 */
200 200
 	function to_array( $arr ) {
201
-		if ( is_array( $arr ) ) {
201
+		if ( is_array($arr) ) {
202 202
 			return $arr;
203 203
 		}
204
-		$arr = array( $arr );
204
+		$arr = array($arr);
205 205
 		return $arr;
206 206
 	}
207 207
 
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	 */
214 214
 	function exec_function( $function_name ) {
215 215
 		$args = func_get_args();
216
-		array_shift( $args );
216
+		array_shift($args);
217 217
 		if ( is_string($function_name) ) {
218
-			$function_name = trim( $function_name );
218
+			$function_name = trim($function_name);
219 219
 		}
220
-		return call_user_func_array( $function_name, ( $args ) );
220
+		return call_user_func_array($function_name, ($args));
221 221
 	}
222 222
 
223 223
 	/**
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * @return string
228 228
 	 */
229 229
 	function twig_pretags( $content ) {
230
-		return preg_replace_callback( '|<pre.*>(.*)</pre|isU', array( &$this, 'convert_pre_entities' ), $content );
230
+		return preg_replace_callback('|<pre.*>(.*)</pre|isU', array(&$this, 'convert_pre_entities'), $content);
231 231
 	}
232 232
 
233 233
 	/**
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 * @return string
238 238
 	 */
239 239
 	function convert_pre_entities( $matches ) {
240
-		return str_replace( $matches[1], htmlentities( $matches[1] ), $matches[0] );
240
+		return str_replace($matches[1], htmlentities($matches[1]), $matches[0]);
241 241
 	}
242 242
 
243 243
 	/**
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	function body_class( $body_classes ) {
249 249
 		ob_start();
250
-		if ( is_array( $body_classes ) ) {
251
-			$body_classes = explode( ' ', $body_classes );
250
+		if ( is_array($body_classes) ) {
251
+			$body_classes = explode(' ', $body_classes);
252 252
 		}
253
-		body_class( $body_classes );
253
+		body_class($body_classes);
254 254
 		$return = ob_get_contents();
255 255
 		ob_end_clean();
256 256
 		return $return;
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
 	 */
266 266
 	function intl_date( $date, $format = null ) {
267 267
 		if ( $format === null ) {
268
-			$format = get_option( 'date_format' );
268
+			$format = get_option('date_format');
269 269
 		}
270 270
 
271 271
 		if ( $date instanceof DateTime ) {
272 272
 			$timestamp = $date->getTimestamp() + $date->getOffset();
273
-		} else if (is_numeric( $date ) && strtotime( $date ) === false ) {
274
-			$timestamp = intval( $date );
273
+		} else if ( is_numeric($date) && strtotime($date) === false ) {
274
+			$timestamp = intval($date);
275 275
 		} else {
276
-			$timestamp = strtotime( $date );
276
+			$timestamp = strtotime($date);
277 277
 		}
278 278
 
279
-		return date_i18n( $format, $timestamp );
279
+		return date_i18n($format, $timestamp);
280 280
 	}
281 281
 
282 282
 	//debug
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
 	 * @return string
291 291
 	 */
292 292
 	function object_docs( $obj, $methods = true ) {
293
-		$class = get_class( $obj );
294
-		$properties = (array)$obj;
293
+		$class = get_class($obj);
294
+		$properties = (array) $obj;
295 295
 		if ( $methods ) {
296 296
 			/** @var array $methods */
297 297
 			$methods = $obj->get_method_values();
298 298
 		}
299
-		$rets = array_merge( $properties, $methods );
300
-		ksort( $rets );
301
-		$str = print_r( $rets, true );
302
-		$str = str_replace( 'Array', $class . ' Object', $str );
299
+		$rets = array_merge($properties, $methods);
300
+		ksort($rets);
301
+		$str = print_r($rets, true);
302
+		$str = str_replace('Array', $class . ' Object', $str);
303 303
 		return $str;
304 304
 	}
305 305
 
@@ -312,13 +312,13 @@  discard block
 block discarded – undo
312 312
 	 */
313 313
 	function time_ago( $from, $to = null, $format_past = '%s ago', $format_future = '%s from now' ) {
314 314
 		$to = $to === null ? time() : $to;
315
-		$to = is_int( $to ) ? $to : strtotime( $to );
316
-		$from = is_int( $from ) ? $from : strtotime( $from );
315
+		$to = is_int($to) ? $to : strtotime($to);
316
+		$from = is_int($from) ? $from : strtotime($from);
317 317
 
318 318
 		if ( $from < $to ) {
319
-			return sprintf( $format_past, human_time_diff( $from, $to ) );
319
+			return sprintf($format_past, human_time_diff($from, $to));
320 320
 		} else {
321
-			return sprintf( $format_future, human_time_diff( $to, $from ) );
321
+			return sprintf($format_future, human_time_diff($to, $from));
322 322
 		}
323 323
 	}
324 324
 
@@ -329,17 +329,17 @@  discard block
 block discarded – undo
329 329
 	 * @return string
330 330
 	 */
331 331
 	function add_list_separators( $arr, $first_delimiter = ',', $second_delimiter = 'and' ) {
332
-		$length = count( $arr );
332
+		$length = count($arr);
333 333
 		$list = '';
334
-		foreach( $arr as $index => $item ) {
334
+		foreach ( $arr as $index => $item ) {
335 335
 			if ( $index < $length - 2 ) {
336
-				$delimiter = $first_delimiter.' ';
336
+				$delimiter = $first_delimiter . ' ';
337 337
 			} elseif ( $index == $length - 2 ) {
338
-				$delimiter = ' '.$second_delimiter.' ';
338
+				$delimiter = ' ' . $second_delimiter . ' ';
339 339
 			} else {
340 340
 				$delimiter = '';
341 341
 			}
342
-			$list = $list.$item.$delimiter;
342
+			$list = $list . $item . $delimiter;
343 343
 		}
344 344
 		return $list;
345 345
 	}
Please login to merge, or discard this patch.
lib/timber-admin.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class TimberAdmin {
4 4
 
5 5
     public static function init() {
6
-        return add_filter( 'plugin_row_meta', array( __CLASS__, 'meta_links' ), 10, 2 );
6
+        return add_filter('plugin_row_meta', array(__CLASS__, 'meta_links'), 10, 2);
7 7
     }
8 8
 
9 9
 	/**
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 * @return array
13 13
 	 */
14 14
 	public static function meta_links( $links, $file ) {
15
-		if ( strstr( $file, '/timber.php' ) ) {
15
+		if ( strstr($file, '/timber.php') ) {
16 16
 			unset($links[2]);
17 17
 			$links[] = '<a href="/wp-admin/plugin-install.php?tab=plugin-information&amp;plugin=timber-library&amp;TB_iframe=true&amp;width=600&amp;height=550" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>';
18 18
 			$links[] = '<a href="http://upstatement.com/timber" target="_blank">Homepage</a>';
Please login to merge, or discard this patch.
lib/timber-image.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * ```
89 89
 	 * @param int|string $iid
90 90
 	 */
91
-	public function __construct($iid) {
91
+	public function __construct( $iid ) {
92 92
 		$this->init($iid);
93 93
 	}
94 94
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @param string $dim
116 116
 	 * @return array|int
117 117
 	 */
118
-	protected function get_dimensions($dim = null) {
118
+	protected function get_dimensions( $dim = null ) {
119 119
 		if ( isset($this->_dimensions) ) {
120 120
 			return $this->get_dimensions_loaded($dim);
121 121
 		}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @param string|null $dim
134 134
 	 * @return array|int
135 135
 	 */
136
-	protected function get_dimensions_loaded($dim) {
136
+	protected function get_dimensions_loaded( $dim ) {
137 137
 		if ( $dim === null ) {
138 138
 			return $this->_dimensions;
139 139
 		}
@@ -152,25 +152,25 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	protected function get_image_info( $iid ) {
154 154
 		$image_info = $iid;
155
-		if (is_numeric($iid)) {
155
+		if ( is_numeric($iid) ) {
156 156
 			$image_info = wp_get_attachment_metadata($iid);
157
-			if (!is_array($image_info)) {
157
+			if ( !is_array($image_info) ) {
158 158
 				$image_info = array();
159 159
 			}
160 160
 			$image_custom = get_post_custom($iid);
161 161
 			$basic = get_post($iid);
162
-			if ($basic) {
163
-				if (isset($basic->post_excerpt)) {
162
+			if ( $basic ) {
163
+				if ( isset($basic->post_excerpt) ) {
164 164
 					$this->caption = $basic->post_excerpt;
165 165
 				}
166 166
 				$image_custom = array_merge($image_custom, get_object_vars($basic));
167 167
 			}
168 168
 			return array_merge($image_info, $image_custom);
169 169
 		}
170
-		if (is_array($image_info) && isset($image_info['image'])) {
170
+		if ( is_array($image_info) && isset($image_info['image']) ) {
171 171
 			return $image_info['image'];
172 172
 		}
173
-		if (is_object($image_info)) {
173
+		if ( is_object($image_info) ) {
174 174
 		   return get_object_vars($image_info);
175 175
 		}
176 176
 		return $iid;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @param  string $url for evaluation
182 182
 	 * @return string with http/https corrected depending on what's appropriate for server
183 183
 	 */
184
-	protected static function _maybe_secure_url($url) {
184
+	protected static function _maybe_secure_url( $url ) {
185 185
 		if ( is_ssl() && strpos($url, 'https') !== 0 && strpos($url, 'http') === 0 ) {
186 186
 			$url = 'https' . substr($url, strlen('http'));
187 187
 		}
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 	 * @param int $iid
204 204
 	 */
205 205
 	function init( $iid = false ) {
206
-		if ( !is_numeric( $iid ) && is_string( $iid ) ) {
207
-			if (strstr($iid, '://')) {
206
+		if ( !is_numeric($iid) && is_string($iid) ) {
207
+			if ( strstr($iid, '://') ) {
208 208
 				$this->init_with_url($iid);
209 209
 				return;
210 210
 			}
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
 
216 216
 			$relative = false;
217 217
 			$iid_lower = strtolower($iid);
218
-			foreach( $this->file_types as $type ) { if( strstr( $iid_lower, $type ) ) { $relative = true; break; } };
218
+			foreach ( $this->file_types as $type ) { if ( strstr($iid_lower, $type) ) { $relative = true; break; } };
219 219
 			if ( $relative ) {
220
-				$this->init_with_relative_path( $iid );
220
+				$this->init_with_relative_path($iid);
221 221
 				return;
222 222
 			}
223 223
 		} else if ( $iid instanceof WP_Post ) {
224 224
 			$ref = new ReflectionClass($this);
225 225
 			$post = $ref->getParentClass()->newInstance($iid->ID);
226
-			if (isset($post->_thumbnail_id) && $post->_thumbnail_id) {
226
+			if ( isset($post->_thumbnail_id) && $post->_thumbnail_id ) {
227 227
 				return $this->init((int) $post->_thumbnail_id);
228 228
 			}
229 229
 			return $this->init($iid->ID);
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 		}
255 255
 		if ( isset($this->ID) ) {
256 256
 			$custom = get_post_custom($this->ID);
257
-			foreach ($custom as $key => $value) {
257
+			foreach ( $custom as $key => $value ) {
258 258
 				$this->$key = $value[0];
259 259
 			}
260 260
 			$this->id = $this->ID;
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 	 * @param string $relative_path
274 274
 	 */
275 275
 	protected function init_with_relative_path( $relative_path ) {
276
-		$this->abs_url = home_url( $relative_path );
277
-		$file_path = TimberURLHelper::get_full_path( $relative_path );
276
+		$this->abs_url = home_url($relative_path);
277
+		$file_path = TimberURLHelper::get_full_path($relative_path);
278 278
 		$this->file_loc = $file_path;
279 279
 		$this->file = $file_path;
280 280
 	}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @param string $file_path
285 285
 	 */
286 286
 	protected function init_with_file_path( $file_path ) {
287
-		$url = TimberURLHelper::file_system_to_url( $file_path );
287
+		$url = TimberURLHelper::file_system_to_url($file_path);
288 288
 		$this->abs_url = $url;
289 289
 		$this->file_loc = $file_path;
290 290
 		$this->file = $file_path;
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 * @internal
295 295
 	 * @param string $url
296 296
 	 */
297
-	protected function init_with_url($url) {
297
+	protected function init_with_url( $url ) {
298 298
 		$this->abs_url = $url;
299 299
 		if ( TimberURLHelper::is_local($url) ) {
300 300
 			$this->file = ABSPATH . TimberURLHelper::get_rel_url($url);
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 	 * ```
410 410
 	 * @return bool|string
411 411
 	 */
412
-	public function src($size = '') {
412
+	public function src( $size = '' ) {
413 413
 		if ( isset($this->abs_url) ) {
414 414
 			return $this->_maybe_secure_url($this->abs_url);
415 415
 		}
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	 * @return bool|string
485 485
 	 */
486 486
 	function get_src( $size = '' ) {
487
-		return $this->src( $size );
487
+		return $this->src($size);
488 488
 	}
489 489
 
490 490
 	/**
Please login to merge, or discard this patch.
lib/timber-archives.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 		$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM {$wpdb->posts} $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
98 98
 		$key = md5($query);
99 99
 		$key = "wp_get_archives:$key:$last_changed";
100
-		if (!$results = wp_cache_get($key, 'posts')) {
100
+		if ( !$results = wp_cache_get($key, 'posts') ) {
101 101
 			$results = $wpdb->get_results($query);
102 102
 			wp_cache_set($key, $results, 'posts');
103 103
 		}
104
-		if ($results) {
105
-			foreach ( (array)$results as $result ) {
106
-				$url = get_year_link( $result->year );
104
+		if ( $results ) {
105
+			foreach ( (array) $results as $result ) {
106
+				$url = get_year_link($result->year);
107 107
 				$text = sprintf('%d', $result->year);
108 108
 				$output[] = $this->get_archives_link($url, $text);
109 109
 			}
@@ -137,28 +137,28 @@  discard block
 block discarded – undo
137 137
 			. "ORDER BY post_date $order $limit";
138 138
 		$key = md5($query);
139 139
 		$key = "wp_get_archives:$key:$last_changed";
140
-		if (!$results = wp_cache_get($key, 'posts')) {
140
+		if ( !$results = wp_cache_get($key, 'posts') ) {
141 141
 			$results = $wpdb->get_results($query);
142 142
 			wp_cache_set($key, $results, 'posts');
143 143
 		}
144
-		if ($results) {
145
-			foreach ((array)$results as $result) {
144
+		if ( $results ) {
145
+			foreach ( (array) $results as $result ) {
146 146
 				$url = get_month_link($result->year, $result->month);
147
-				if ($show_year && !$nested) {
147
+				if ( $show_year && !$nested ) {
148 148
 					$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year);
149 149
 				} else {
150 150
 					$text = sprintf(__('%1$s'), $wp_locale->get_month($result->month));
151 151
 				}
152
-				if ($nested) {
152
+				if ( $nested ) {
153 153
 					$output[$result->year][] = $this->get_archives_link($url, $text);
154 154
 				} else {
155 155
 					$output[] = $this->get_archives_link($url, $text);
156 156
 				}
157 157
 			}
158 158
 		}
159
-		if ($nested) {
159
+		if ( $nested ) {
160 160
 			$out2 = array();
161
-			foreach ($output as $year => $months) {
161
+			foreach ( $output as $year => $months ) {
162 162
 				$out2[] = array('name' => $year, 'children' => $months);
163 163
 			}
164 164
 			return $out2;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		$archive_week_start_date_format = 'Y/m/d';
221 221
 		$archive_week_end_date_format = 'Y/m/d';
222 222
 
223
-		if (!$archive_date_format_over_ride) {
223
+		if ( !$archive_date_format_over_ride ) {
224 224
 			$archive_day_date_format = get_option('date_format');
225 225
 			$archive_week_start_date_format = get_option('date_format');
226 226
 			$archive_week_end_date_format = get_option('date_format');
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
 		$output = array();
234 234
 		$last_changed = wp_cache_get('last_changed', 'posts');
235
-		if (!$last_changed) {
235
+		if ( !$last_changed ) {
236 236
 			$last_changed = microtime();
237 237
 			wp_cache_set('last_changed', $last_changed, 'posts');
238 238
 		}
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
 			$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
247 247
 			$key = md5($query);
248 248
 			$key = "wp_get_archives:$key:$last_changed";
249
-			if (!$results = wp_cache_get($key, 'posts')) {
249
+			if ( !$results = wp_cache_get($key, 'posts') ) {
250 250
 				$results = $wpdb->get_results($query);
251 251
 				$cache = array();
252 252
 				$cache[$key] = $results;
253 253
 				wp_cache_set($key, $results, 'posts');
254 254
 			}
255 255
 			if ( $results ) {
256
-				foreach ( (array)$results as $result ) {
256
+				foreach ( (array) $results as $result ) {
257 257
 					$url = get_day_link($result->year, $result->month, $result->dayofmonth);
258 258
 					$date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth);
259 259
 					$text = mysql2date($archive_day_date_format, $date);
@@ -266,13 +266,13 @@  discard block
 block discarded – undo
266 266
 				. "count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
267 267
 			$key = md5($query);
268 268
 			$key = "wp_get_archives:$key:$last_changed";
269
-			if (!$results = wp_cache_get($key, 'posts')) {
269
+			if ( !$results = wp_cache_get($key, 'posts') ) {
270 270
 				$results = $wpdb->get_results($query);
271 271
 				wp_cache_set($key, $results, 'posts');
272 272
 			}
273 273
 			$arc_w_last = '';
274 274
 			if ( $results ) {
275
-				foreach ( (array)$results as $result ) {
275
+				foreach ( (array) $results as $result ) {
276 276
 					if ( $result->week != $arc_w_last ) {
277 277
 						$arc_year = $result->yr;
278 278
 						$arc_w_last = $result->week;
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
 				wp_cache_set($key, $results, 'posts');
296 296
 			}
297 297
 			if ( $results ) {
298
-				foreach ( (array)$results as $result ) {
299
-					if ($result->post_date != '0000-00-00 00:00:00') {
298
+				foreach ( (array) $results as $result ) {
299
+					if ( $result->post_date != '0000-00-00 00:00:00' ) {
300 300
 						$url = get_permalink($result);
301
-						if ($result->post_title) {
301
+						if ( $result->post_title ) {
302 302
 							/** This filter is documented in wp-includes/post-template.php */
303 303
 							$text = strip_tags(apply_filters('the_title', $result->post_title, $result->ID));
304 304
 						} else {
Please login to merge, or discard this patch.
lib/integrations/acf-timber.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
 class ACFTimber {
4 4
 
5 5
     function __construct() {
6
-        add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 );
7
-        add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 );
8
-        add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 );
9
-        add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 );
10
-        add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 );
11
-        add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 );
6
+        add_filter('timber_post_get_meta', array($this, 'post_get_meta'), 10, 2);
7
+        add_filter('timber_post_get_meta_field', array($this, 'post_get_meta_field'), 10, 3);
8
+        add_filter('timber_term_get_meta', array($this, 'term_get_meta'), 10, 3);
9
+        add_filter('timber_term_get_meta_field', array($this, 'term_get_meta_field'), 10, 4);
10
+        add_filter('timber_user_get_meta_field_pre', array($this, 'user_get_meta_field'), 10, 3);
11
+        add_filter('timber_term_set_meta', array($this, 'term_set_meta'), 10, 4);
12 12
     }
13 13
 
14 14
     function post_get_meta( $customs, $post_id ) {
@@ -16,32 +16,32 @@  discard block
 block discarded – undo
16 16
     }
17 17
 
18 18
     function post_get_meta_field( $value, $post_id, $field_name ) {
19
-        return get_field( $field_name, $post_id );
19
+        return get_field($field_name, $post_id);
20 20
     }
21 21
 
22 22
     function term_get_meta_field( $value, $term_id, $field_name, $term ) {
23 23
         $searcher = $term->taxonomy . "_" . $term->ID;
24
-        return get_field( $field_name, $searcher );
24
+        return get_field($field_name, $searcher);
25 25
     }
26 26
 
27 27
     function term_set_meta( $value, $field, $term_id, $term ) {
28 28
         $searcher = $term->taxonomy . "_" . $term->ID;
29
-        update_field( $field, $value, $searcher );
29
+        update_field($field, $value, $searcher);
30 30
         return $value;
31 31
     }
32 32
 
33 33
     function term_get_meta( $fields, $term_id, $term ) {
34 34
         $searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category
35
-        $fds = get_fields( $searcher );
36
-        if ( is_array( $fds ) ) {
35
+        $fds = get_fields($searcher);
36
+        if ( is_array($fds) ) {
37 37
             foreach ( $fds as $key => $value ) {
38
-                $key = preg_replace( '/_/', '', $key, 1 );
39
-                $key = str_replace( $searcher, '', $key );
40
-                $key = preg_replace( '/_/', '', $key, 1 );
41
-                $field = get_field( $key, $searcher );
38
+                $key = preg_replace('/_/', '', $key, 1);
39
+                $key = str_replace($searcher, '', $key);
40
+                $key = preg_replace('/_/', '', $key, 1);
41
+                $field = get_field($key, $searcher);
42 42
                 $fields[$key] = $field;
43 43
             }
44
-            $fields = array_merge( $fields, $fds );
44
+            $fields = array_merge($fields, $fds);
45 45
         }
46 46
         return $fields;
47 47
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     function user_get_meta_field( $value, $uid, $field ) {
54
-        return get_field( $field, 'user_' . $uid );
54
+        return get_field($field, 'user_' . $uid);
55 55
     }
56 56
 }
57 57
 
Please login to merge, or discard this patch.
lib/integrations/wpcli-timber.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!class_exists('WP_CLI_Command')) {
2
+if ( !class_exists('WP_CLI_Command') ) {
3 3
 	return;
4 4
 }
5 5
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      *    wp timber clear_cache
14 14
      *
15 15
      */
16
-    public function clear_cache($mode = 'all') {
16
+    public function clear_cache( $mode = 'all' ) {
17 17
         TimberCommand::clear_cache($mode);
18 18
     }
19 19
 
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
      *    wp timber clear_cache_twig
26 26
      *
27 27
      */
28
-    function clear_cache_twig(){
28
+    function clear_cache_twig() {
29 29
         $clear = TimberCommand::clear_cache_twig();
30
-        if ($clear){
30
+        if ( $clear ) {
31 31
             WP_CLI::success('Cleared contents of twig cache');
32 32
         } else {
33 33
             WP_CLI::warning('Failed to clear twig cache');
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     function clear_cache_timber() {
46 46
         $clear = TimberCommand::clear_cache_timber();
47 47
         $message = 'Failed to clear timber cache';
48
-        if ($clear){
48
+        if ( $clear ) {
49 49
             $message = "Cleared contents of Timber's Cache";
50 50
             WP_CLI::success($message);
51 51
         } else {
Please login to merge, or discard this patch.
lib/integrations/timber-command.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
  */
7 7
 class TimberCommand {
8 8
 
9
-    public static function clear_cache($mode = 'all'){
10
-        if (is_array($mode)){
9
+    public static function clear_cache( $mode = 'all' ) {
10
+        if ( is_array($mode) ) {
11 11
             $mode = reset($mode);
12 12
         }
13
-        if ($mode == 'all') {
13
+        if ( $mode == 'all' ) {
14 14
             $twig_cache = self::clear_cache_twig();
15 15
             $timber_cache = self::clear_cache_timber();
16
-            if ($twig_cache && $timber_cache){
16
+            if ( $twig_cache && $timber_cache ) {
17 17
                 return true;
18 18
             }
19
-        } else if ($mode == 'twig') {
19
+        } else if ( $mode == 'twig' ) {
20 20
             return self::clear_cache_twig();
21
-        } else if ($mode == 'timber') {
21
+        } else if ( $mode == 'timber' ) {
22 22
             return self::clear_cache_timber();
23 23
         }
24 24
     }
25 25
 
26
-    static function clear_cache_timber(){
26
+    static function clear_cache_timber() {
27 27
         $loader = new TimberLoader();
28 28
         return $loader->clear_cache_timber();
29 29
     }
30 30
 
31
-    static function clear_cache_twig(){
31
+    static function clear_cache_twig() {
32 32
         $loader = new TimberLoader();
33 33
         return $loader->clear_cache_twig();
34 34
     }
Please login to merge, or discard this patch.
lib/timber-routes.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 * @param callable $callback
16 16
 	 * @deprecated since 0.21.1 use Upstatement/routes instead
17 17
 	 */
18
-	public static function add_route($route, $callback, $args = array()) {
18
+	public static function add_route( $route, $callback, $args = array() ) {
19 19
 		Routes::map($route, $callback, $args);
20 20
 	}
21 21
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @return bool
28 28
 	 * @deprecated since 0.21.1 use Upstatement/routes instead
29 29
 	 */
30
-	public static function load_view($template, $query = false, $status_code = 200, $tparams = false) {
30
+	public static function load_view( $template, $query = false, $status_code = 200, $tparams = false ) {
31 31
 		Routes::load($template, $tparams, $query, $status_code);
32 32
 	}
33 33
 }
Please login to merge, or discard this patch.
lib/timber-comment.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 * @param int $cid
42 42
 	 */
43
-	function __construct($cid) {
43
+	function __construct( $cid ) {
44 44
 		$this->init($cid);
45 45
 	}
46 46
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	 * @internal
53 53
 	 * @param integer $cid
54 54
 	 */
55
-	function init($cid) {
55
+	function init( $cid ) {
56 56
 		$comment_data = $cid;
57
-		if (is_integer($cid)) {
57
+		if ( is_integer($cid) ) {
58 58
 			$comment_data = get_comment($cid);
59 59
 		}
60 60
 		$this->import($comment_data);
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	 * @return TimberUser
87 87
 	 */
88 88
 	public function author() {
89
-		if ($this->user_id) {
89
+		if ( $this->user_id ) {
90 90
 			return new TimberUser($this->user_id);
91 91
 		} else {
92 92
 			$author = new TimberUser(0);
93
-			if (isset($this->comment_author) && $this->comment_author) {
93
+			if ( isset($this->comment_author) && $this->comment_author ) {
94 94
 				$author->name = $this->comment_author;
95 95
 			} else {
96 96
 				$author->name = 'Anonymous';
@@ -113,22 +113,22 @@  discard block
 block discarded – undo
113 113
 	 * @param string $default
114 114
 	 * @return bool|mixed|string
115 115
 	 */
116
-	public function avatar($size = 92, $default = '') {
117
-		if (!get_option('show_avatars')) {
116
+	public function avatar( $size = 92, $default = '' ) {
117
+		if ( !get_option('show_avatars') ) {
118 118
 			return false;
119 119
 		}
120
-		if (!is_numeric($size)) {
120
+		if ( !is_numeric($size) ) {
121 121
 			$size = '92';
122 122
 		}
123 123
 
124 124
 		$email = $this->avatar_email();
125 125
 		$email_hash = '';
126
-		if (!empty($email)) {
126
+		if ( !empty($email) ) {
127 127
 			$email_hash = md5(strtolower(trim($email)));
128 128
 		}
129 129
 		$host = $this->avatar_host($email_hash);
130 130
 		$default = $this->avatar_default($default, $email, $size, $host);
131
-		if (!empty($email)) {
131
+		if ( !empty($email) ) {
132 132
 			$avatar = $this->avatar_out($default, $host, $email_hash, $size);
133 133
 		} else {
134 134
 			$avatar = $default;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function date( $date_format = '' ) {
183 183
 		$df = $date_format ? $date_format : get_option('date_format');
184
-		$the_date = (string)mysql2date($df, $this->comment_date);
184
+		$the_date = (string) mysql2date($df, $this->comment_date);
185 185
 		return apply_filters('get_comment_date ', $the_date, $df);
186 186
 	}
187 187
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function time( $time_format = '' ) {
208 208
 		$tf = $time_format ? $time_format : get_option('time_format');
209
-		$the_time = (string)mysql2date($tf, $this->comment_date);
209
+		$the_time = (string) mysql2date($tf, $this->comment_date);
210 210
 		return apply_filters('get_comment_time', $the_time, $tf);
211 211
 	}
212 212
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @param string $field_name
215 215
 	 * @return mixed
216 216
 	 */
217
-	public function meta($field_name) {
217
+	public function meta( $field_name ) {
218 218
 		return $this->get_meta_field($field_name);
219 219
 	}
220 220
 
@@ -231,15 +231,15 @@  discard block
 block discarded – undo
231 231
 	 * @param int $comment_id
232 232
 	 * @return mixed
233 233
 	 */
234
-	protected function get_meta_fields($comment_id = null) {
235
-		if ($comment_id === null) {
234
+	protected function get_meta_fields( $comment_id = null ) {
235
+		if ( $comment_id === null ) {
236 236
 			$comment_id = $this->ID;
237 237
 		}
238 238
 		//Could not find a WP function to fetch all comment meta data, so I made one.
239 239
 		apply_filters('timber_comment_get_meta_pre', array(), $comment_id);
240 240
 		$comment_metas = get_comment_meta($comment_id);
241
-		foreach ($comment_metas as &$cm) {
242
-			if (is_array($cm) && count($cm) == 1) {
241
+		foreach ( $comment_metas as &$cm ) {
242
+			if ( is_array($cm) && count($cm) == 1 ) {
243 243
 				$cm = $cm[0];
244 244
 			}
245 245
 		}
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 	 * @param string $field_name
253 253
 	 * @return mixed
254 254
 	 */
255
-	protected function get_meta_field($field_name) {
255
+	protected function get_meta_field( $field_name ) {
256 256
 		$value = apply_filters('timber_comment_get_meta_field_pre', null, $this->ID, $field_name, $this);
257
-		if ($value === null) {
257
+		if ( $value === null ) {
258 258
 			$value = get_comment_meta($this->ID, $field_name, true);
259 259
 		}
260 260
 		$value = apply_filters('timber_comment_get_meta_field', $value, $this->ID, $field_name, $this);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 */
270 270
 	public function reply_link( $reply_text = 'Reply' ) {
271 271
 		if ( is_singular() && comments_open() && get_option('thread_comments') ) {
272
-			wp_enqueue_script( 'comment-reply' );
272
+			wp_enqueue_script('comment-reply');
273 273
 		}
274 274
 
275 275
 		// Get the comments depth option from the admin panel
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 			'max_depth' => $max_depth,
285 285
 		);
286 286
 
287
-		return get_comment_reply_link( $args, $this->ID, $this->post_id );
287
+		return get_comment_reply_link($args, $this->ID, $this->post_id);
288 288
 	}
289 289
 
290 290
 	/* AVATAR Stuff
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 	 * @return string
296 296
 	 */
297 297
 	protected function avatar_email() {
298
-		$id = (int)$this->user_id;
298
+		$id = (int) $this->user_id;
299 299
 		$user = get_userdata($id);
300
-		if ($user) {
300
+		if ( $user ) {
301 301
 			$email = $user->user_email;
302 302
 		} else {
303 303
 			$email = $this->comment_author_email;
@@ -310,11 +310,11 @@  discard block
 block discarded – undo
310 310
 	 * @param string $email_hash
311 311
 	 * @return string
312 312
 	 */
313
-	protected function avatar_host($email_hash) {
314
-		if (is_ssl()) {
313
+	protected function avatar_host( $email_hash ) {
314
+		if ( is_ssl() ) {
315 315
 			$host = 'https://secure.gravatar.com';
316 316
 		} else {
317
-			if (!empty($email_hash)) {
317
+			if ( !empty($email_hash) ) {
318 318
 				$host = sprintf("http://%d.gravatar.com", (hexdec($email_hash[0]) % 2));
319 319
 			} else {
320 320
 				$host = 'http://0.gravatar.com';
@@ -332,29 +332,29 @@  discard block
 block discarded – undo
332 332
 	 * @param string $host
333 333
 	 * @return string
334 334
 	 */
335
-	protected function avatar_default($default, $email, $size, $host) {
336
-		if (substr($default, 0, 1) == '/') {
335
+	protected function avatar_default( $default, $email, $size, $host ) {
336
+		if ( substr($default, 0, 1) == '/' ) {
337 337
 			$default = home_url() . $default;
338 338
 		}
339 339
 
340
-		if (empty($default)) {
340
+		if ( empty($default) ) {
341 341
 			$avatar_default = get_option('avatar_default');
342
-			if (empty($avatar_default)) {
342
+			if ( empty($avatar_default) ) {
343 343
 				$default = 'mystery';
344 344
 			} else {
345 345
 				$default = $avatar_default;
346 346
 			}
347 347
 		}
348
-		if ('mystery' == $default) {
348
+		if ( 'mystery' == $default ) {
349 349
 			$default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size;
350 350
 			// ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]')
351
-		} else if ('blank' == $default) {
351
+		} else if ( 'blank' == $default ) {
352 352
 			$default = $email ? 'blank' : includes_url('images/blank.gif');
353
-		} else if (!empty($email) && 'gravatar_default' == $default) {
353
+		} else if ( !empty($email) && 'gravatar_default' == $default ) {
354 354
 			$default = '';
355
-		} else if ('gravatar_default' == $default) {
355
+		} else if ( 'gravatar_default' == $default ) {
356 356
 			$default = $host . '/avatar/?s=' . $size;
357
-		} else if (empty($email) && !strstr($default, 'http://')) {
357
+		} else if ( empty($email) && !strstr($default, 'http://') ) {
358 358
 			$default = $host . '/avatar/?d=' . $default . '&amp;s=' . $size;
359 359
 		}
360 360
 		return $default;
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 	 * @param string $size
369 369
 	 * @return mixed
370 370
 	 */
371
-	protected function avatar_out($default, $host, $email_hash, $size) {
371
+	protected function avatar_out( $default, $host, $email_hash, $size ) {
372 372
 		$out = $host . '/avatar/' . $email_hash . '?s=' . $size . '&amp;d=' . urlencode($default);
373 373
 		$rating = get_option('avatar_rating');
374
-		if (!empty($rating)) {
374
+		if ( !empty($rating) ) {
375 375
 			$out .= '&amp;r=' . $rating;
376 376
 		}
377 377
 		return str_replace('&#038;', '&amp;', esc_url($out));
Please login to merge, or discard this patch.