Completed
Pull Request — master (#861)
by
unknown
04:29
created
lib/timber-image-helper.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	 * ```
44 44
 	 * @return string (ex: )
45 45
 	 */
46
-	public static function resize( $src, $w, $h = 0, $crop = 'default', $force = false ) {
47
-		if (!is_numeric($w) && is_string($w)) {
48
-			if ($sizes = self::find_wp_dimensions($w)) {
46
+	public static function resize($src, $w, $h = 0, $crop = 'default', $force = false) {
47
+		if ( !is_numeric($w) && is_string($w) ) {
48
+			if ( $sizes = self::find_wp_dimensions($w) ) {
49 49
 				$w = $sizes['w'];
50 50
 				$h = $sizes['h'];
51 51
 			} else {
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
 	 *     @type int h
67 67
 	 * }
68 68
 	 */
69
-	private static function find_wp_dimensions( $size ) {
69
+	private static function find_wp_dimensions($size) {
70 70
 		global $_wp_additional_image_sizes;
71
-		if (isset($_wp_additional_image_sizes[$size])) {
71
+		if ( isset($_wp_additional_image_sizes[$size]) ) {
72 72
 			$w = $_wp_additional_image_sizes[$size]['width'];
73 73
 			$h = $_wp_additional_image_sizes[$size]['height'];
74
-		} else if (in_array($size, array('thumbnail', 'medium', 'large'))) {
75
-			$w = get_option($size.'_size_w');
76
-			$h = get_option($size.'_size_h');
74
+		} else if ( in_array($size, array('thumbnail', 'medium', 'large')) ) {
75
+			$w = get_option($size . '_size_w');
76
+			$h = get_option($size . '_size_h');
77 77
 		}
78
-		if (isset($w) && isset($h) && ($w || $h)) {
78
+		if ( isset($w) && isset($h) && ($w || $h) ) {
79 79
 			return array('w' => $w, 'h' => $h);
80 80
 		}
81 81
 		return false;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return string url to the new image
92 92
 	 */
93
-	public static function retina_resize( $src, $multiplier = 2, $force = false ) {
93
+	public static function retina_resize($src, $multiplier = 2, $force = false) {
94 94
 		$op = new TimberImageOperationRetina($multiplier);
95 95
 		return self::_operate($src, $op, $force);
96 96
 	}
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	 * @param  string  $file local filepath to a file, not a URL
101 101
 	 * @return boolean true if it's an animated gif, false if not
102 102
 	 */
103
-	public static function is_animated_gif( $file ) {
103
+	public static function is_animated_gif($file) {
104 104
 		if ( strpos(strtolower($file), '.gif') == -1 ) {
105 105
 			//doesn't have .gif, bail
106 106
 			return false;
107 107
 		}
108 108
 		//its a gif so test
109
-		if( !($fh = @fopen($file, 'rb')) ) {
109
+		if ( !($fh = @fopen($file, 'rb')) ) {
110 110
 		  	return false;
111 111
 	    }
112 112
 	    $count = 0;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 	    // We read through the file til we reach the end of the file, or we've found
120 120
 	    // at least 2 frame headers
121
-	    while(!feof($fh) && $count < 2) {
121
+	    while (!feof($fh) && $count < 2) {
122 122
 	        $chunk = fread($fh, 1024 * 100); //read 100kb at a time
123 123
 	        $count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00[\x2C\x21]#s', $chunk, $matches);
124 124
 	    }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @param bool    $force
139 139
 	 * @return mixed|null|string
140 140
 	 */
141
-	public static function letterbox( $src, $w, $h, $color = '#000000', $force = false ) {
141
+	public static function letterbox($src, $w, $h, $color = '#000000', $force = false) {
142 142
 		$op = new TimberImageOperationLetterbox($w, $h, $color);
143 143
 		return self::_operate($src, $op, $force);
144 144
 	}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param string  $bghex
151 151
 	 * @return string
152 152
 	 */
153
-	public static function img_to_jpg( $src, $bghex = '#FFFFFF', $force = false ) {
153
+	public static function img_to_jpg($src, $bghex = '#FFFFFF', $force = false) {
154 154
 		$op = new TimberImageOperationToJpg($bghex);
155 155
 		return self::_operate($src, $op, $force);
156 156
 	}
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
 	 * Deletes all resized versions of an image when the source is deleted
160 160
 	 */
161 161
 	protected static function add_actions() {
162
-		add_action( 'delete_attachment', function ( $post_id ) {
163
-			$post = get_post( $post_id );
164
-			$image_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/jpg' );
165
-			if ( in_array( $post->post_mime_type, $image_types ) ) {
166
-				$attachment = new TimberImage( $post_id );
162
+		add_action('delete_attachment', function($post_id) {
163
+			$post = get_post($post_id);
164
+			$image_types = array('image/jpeg', 'image/png', 'image/gif', 'image/jpg');
165
+			if ( in_array($post->post_mime_type, $image_types) ) {
166
+				$attachment = new TimberImage($post_id);
167 167
 				if ( $attachment->file_loc ) {
168
-					TimberImageHelper::delete_generated_files( $attachment->file_loc );
168
+					TimberImageHelper::delete_generated_files($attachment->file_loc);
169 169
 				}
170 170
 			}
171 171
 		} );
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 * for example /wp-content or /content
177 177
 	 */
178 178
 	protected static function add_constants() {
179
-		if ( !defined( 'WP_CONTENT_SUBDIR' ) ) {
180
-			$wp_content_path = str_replace( home_url(), '', WP_CONTENT_URL );
181
-			define( 'WP_CONTENT_SUBDIR', $wp_content_path );
179
+		if ( !defined('WP_CONTENT_SUBDIR') ) {
180
+			$wp_content_path = str_replace(home_url(), '', WP_CONTENT_URL);
181
+			define('WP_CONTENT_SUBDIR', $wp_content_path);
182 182
 		}
183 183
 	}
184 184
 
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @return void
189 189
 	 */
190 190
 	static function add_filters() {
191
-		add_filter( 'upload_dir', function ( $arr ) {
192
-			$arr['relative'] = str_replace( home_url(), '', $arr['baseurl'] );
191
+		add_filter('upload_dir', function($arr) {
192
+			$arr['relative'] = str_replace(home_url(), '', $arr['baseurl']);
193 193
 			return $arr;
194 194
 		} );
195 195
 	}
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
 	 * @param string  $local_file   ex: /var/www/wp-content/uploads/2015/my-pic.jpg
201 201
 	 *                              or: http://example.org/wp-content/uploads/2015/my-pic.jpg
202 202
 	 */
203
-	static function delete_generated_files( $local_file ) {
204
-		if (TimberURLHelper::is_absolute( $local_file ) ) {
205
-			$local_file = TimberURLHelper::url_to_file_system( $local_file );
203
+	static function delete_generated_files($local_file) {
204
+		if ( TimberURLHelper::is_absolute($local_file) ) {
205
+			$local_file = TimberURLHelper::url_to_file_system($local_file);
206 206
 		}
207
-		$info = pathinfo( $local_file );
207
+		$info = pathinfo($local_file);
208 208
 		$dir = $info['dirname'];
209 209
 		$ext = $info['extension'];
210 210
 		$filename = $info['filename'];
211
-		self::process_delete_generated_files( $filename, $ext, $dir, '-[0-9999999]*', '-[0-9]*x[0-9]*-c-[a-z]*.' );
212
-		self::process_delete_generated_files( $filename, $ext, $dir, '-lbox-[0-9999999]*', '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.' );
211
+		self::process_delete_generated_files($filename, $ext, $dir, '-[0-9999999]*', '-[0-9]*x[0-9]*-c-[a-z]*.');
212
+		self::process_delete_generated_files($filename, $ext, $dir, '-lbox-[0-9999999]*', '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.');
213 213
 	}
214 214
 
215 215
 	/**
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
 	 * @param string 	$search_pattern pattern of files to pluck from
227 227
 	 * @param string 	$match_pattern pattern of files to go forth and delete
228 228
 	 */
229
-	protected static function process_delete_generated_files( $filename, $ext, $dir, $search_pattern, $match_pattern ) {
229
+	protected static function process_delete_generated_files($filename, $ext, $dir, $search_pattern, $match_pattern) {
230 230
 		$searcher = '/' . $filename . $search_pattern;
231
-		foreach ( glob( $dir . $searcher ) as $found_file ) {
232
-			$regexdir = str_replace( '/', '\/', $dir );
233
-			$pattern = '/' . ( $regexdir ) . '\/' . $filename . $match_pattern . $ext . '/';
234
-			$match = preg_match( $pattern, $found_file );
231
+		foreach (glob($dir . $searcher) as $found_file) {
232
+			$regexdir = str_replace('/', '\/', $dir);
233
+			$pattern = '/' . ($regexdir) . '\/' . $filename . $match_pattern . $ext . '/';
234
+			$match = preg_match($pattern, $found_file);
235 235
 			if ( $match ) {
236
-				unlink( $found_file );
236
+				unlink($found_file);
237 237
 			}
238 238
 		}
239 239
 	}
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
 	 * @param string  $url
246 246
 	 * @return string
247 247
 	 */
248
-	public static function get_server_location( $url ) {
248
+	public static function get_server_location($url) {
249 249
 		// if we're already an absolute dir, just return
250
-		if ( 0 === strpos( $url, ABSPATH ) ) {
250
+		if ( 0 === strpos($url, ABSPATH) ) {
251 251
 			return $url;
252 252
 		}
253 253
 		// otherwise, analyze URL then build mapping path
@@ -262,15 +262,15 @@  discard block
 block discarded – undo
262 262
 	 * @param string  $file
263 263
 	 * @return string
264 264
 	 */
265
-	public static function get_sideloaded_file_loc( $file ) {
265
+	public static function get_sideloaded_file_loc($file) {
266 266
 		$upload = wp_upload_dir();
267 267
 		$dir = $upload['path'];
268 268
 		$filename = $file;
269
-		$file = parse_url( $file );
270
-		$path_parts = pathinfo( $file['path'] );
271
-		$basename = md5( $filename );
269
+		$file = parse_url($file);
270
+		$path_parts = pathinfo($file['path']);
271
+		$basename = md5($filename);
272 272
 		$ext = 'jpg';
273
-		if ( isset( $path_parts['extension'] ) ) {
273
+		if ( isset($path_parts['extension']) ) {
274 274
 			$ext = $path_parts['extension'];
275 275
 		}
276 276
 		return $dir . '/' . $basename . '.' . $ext;
@@ -282,28 +282,28 @@  discard block
 block discarded – undo
282 282
 	 * @param string  $file the URL to the original file
283 283
 	 * @return string the URL to the downloaded file
284 284
 	 */
285
-	public static function sideload_image( $file ) {
286
-		$loc = self::get_sideloaded_file_loc( $file );
287
-		if ( file_exists( $loc ) ) {
288
-			return TimberURLHelper::preslashit( TimberURLHelper::get_rel_path( $loc ) );
285
+	public static function sideload_image($file) {
286
+		$loc = self::get_sideloaded_file_loc($file);
287
+		if ( file_exists($loc) ) {
288
+			return TimberURLHelper::preslashit(TimberURLHelper::get_rel_path($loc));
289 289
 		}
290 290
 		// Download file to temp location
291
-		if ( !function_exists( 'download_url' ) ) {
291
+		if ( !function_exists('download_url') ) {
292 292
 			require_once ABSPATH . '/wp-admin/includes/file.php';
293 293
 		}
294
-		$tmp = download_url( $file );
295
-		preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
294
+		$tmp = download_url($file);
295
+		preg_match('/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches);
296 296
 		$file_array = array();
297
-		$file_array['name'] = basename( $matches[0] );
297
+		$file_array['name'] = basename($matches[0]);
298 298
 		$file_array['tmp_name'] = $tmp;
299 299
 		// If error storing temporarily, unlink
300
-		if ( is_wp_error( $tmp ) ) {
301
-			@unlink( $file_array['tmp_name'] );
300
+		if ( is_wp_error($tmp) ) {
301
+			@unlink($file_array['tmp_name']);
302 302
 			$file_array['tmp_name'] = '';
303 303
 		}
304 304
 		// do the validation and storage stuff
305
-		$locinfo = pathinfo( $loc );
306
-		$file = wp_upload_bits( $locinfo['basename'], null, file_get_contents( $file_array['tmp_name'] ) );
305
+		$locinfo = pathinfo($loc);
306
+		$file = wp_upload_bits($locinfo['basename'], null, file_get_contents($file_array['tmp_name']));
307 307
 		return $file['url'];
308 308
 	}
309 309
 
@@ -330,23 +330,23 @@  discard block
 block discarded – undo
330 330
 		if ( 0 === strpos($tmp, ABSPATH) ) { // we've been given a dir, not an url
331 331
 			$result['absolute'] = true;
332 332
 			if ( 0 === strpos($tmp, $upload_dir['basedir']) ) {
333
-				$result['base']= self::BASE_UPLOADS; // upload based
333
+				$result['base'] = self::BASE_UPLOADS; // upload based
334 334
 				$tmp = str_replace($upload_dir['basedir'], '', $tmp);
335 335
 			}
336 336
 			if ( 0 === strpos($tmp, WP_CONTENT_DIR) ) {
337
-				$result['base']= self::BASE_CONTENT; // content based
337
+				$result['base'] = self::BASE_CONTENT; // content based
338 338
 				$tmp = str_replace(WP_CONTENT_DIR, '', $tmp);
339 339
 			}
340 340
 		} else {
341
-			if (!$result['absolute']) {
342
-				$tmp = home_url().$tmp;
341
+			if ( !$result['absolute'] ) {
342
+				$tmp = home_url() . $tmp;
343 343
 			}
344
-			if (0 === strpos($tmp, $upload_dir['baseurl'])) {
345
-				$result['base']= self::BASE_UPLOADS; // upload based
344
+			if ( 0 === strpos($tmp, $upload_dir['baseurl']) ) {
345
+				$result['base'] = self::BASE_UPLOADS; // upload based
346 346
 				$tmp = str_replace($upload_dir['baseurl'], '', $tmp);
347 347
 			}
348
-			if (0 === strpos($tmp, content_url())) {
349
-				$result['base']= self::BASE_CONTENT; // content-based
348
+			if ( 0 === strpos($tmp, content_url()) ) {
349
+				$result['base'] = self::BASE_CONTENT; // content-based
350 350
 				$tmp = str_replace(content_url(), '', $tmp);
351 351
 			}
352 352
 		}
@@ -370,18 +370,18 @@  discard block
 block discarded – undo
370 370
 	 */
371 371
 	private static function _get_file_url($base, $subdir, $filename, $absolute) {
372 372
 		$url = '';
373
-		if( self::BASE_UPLOADS == $base ) {
373
+		if ( self::BASE_UPLOADS == $base ) {
374 374
 			$upload_dir = wp_upload_dir();
375 375
 			$url = $upload_dir['baseurl'];
376 376
 		}
377
-		if( self::BASE_CONTENT == $base ) {
377
+		if ( self::BASE_CONTENT == $base ) {
378 378
 			$url = content_url();
379 379
 		}
380
-		if(!empty($subdir)) {
380
+		if ( !empty($subdir) ) {
381 381
 			$url .= $subdir;
382 382
 		}
383
-		$url .= '/'.$filename;
384
-		if(!$absolute) {
383
+		$url .= '/' . $filename;
384
+		if ( !$absolute ) {
385 385
 			$url = str_replace(home_url(), '', $url);
386 386
 		}
387 387
 		// $url = TimberURLHelper::remove_double_slashes( $url);
@@ -398,17 +398,17 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	private static function _get_file_path($base, $subdir, $filename) {
400 400
 		$path = '';
401
-		if(self::BASE_UPLOADS == $base) {
401
+		if ( self::BASE_UPLOADS == $base ) {
402 402
 			$upload_dir = wp_upload_dir();
403 403
 			$path = $upload_dir['basedir'];
404 404
 		}
405
-		if(self::BASE_CONTENT == $base) {
405
+		if ( self::BASE_CONTENT == $base ) {
406 406
 			$path = WP_CONTENT_DIR;
407 407
 		}
408
-		if(!empty($subdir)) {
408
+		if ( !empty($subdir) ) {
409 409
 			$path .= $subdir;
410 410
 		}
411
-		$path .= '/'.$filename;
411
+		$path .= '/' . $filename;
412 412
 		return $path;
413 413
 	}
414 414
 
@@ -426,13 +426,13 @@  discard block
 block discarded – undo
426 426
 	 * @return string         URL to the new image - or the source one if error
427 427
 	 *
428 428
 	 */
429
-	private static function _operate( $src, $op, $force = false ) {
430
-		if ( empty( $src ) ) {
429
+	private static function _operate($src, $op, $force = false) {
430
+		if ( empty($src) ) {
431 431
 			return '';
432 432
 		}
433 433
 		// if external image, load it first
434
-		if ( TimberURLHelper::is_external_content( $src ) ) {
435
-			$src = self::sideload_image( $src );
434
+		if ( TimberURLHelper::is_external_content($src) ) {
435
+			$src = self::sideload_image($src);
436 436
 		}
437 437
 		// break down URL into components
438 438
 		$au = self::analyze_url($src);
@@ -454,17 +454,17 @@  discard block
 block discarded – undo
454 454
 			$au['basename']
455 455
 		);
456 456
 		// if already exists...
457
-		if ( file_exists( $new_server_path ) ) {
457
+		if ( file_exists($new_server_path) ) {
458 458
 			if ( $force ) {
459 459
 				// Force operation - warning: will regenerate the image on every pageload, use for testing purposes only!
460
-				unlink( $new_server_path );
460
+				unlink($new_server_path);
461 461
 			} else {
462 462
 				// return existing file (caching)
463 463
 				return $new_url;
464 464
 			}
465 465
 		}
466 466
 		// otherwise generate result file
467
-		if($op->run($old_server_path, $new_server_path)) {
467
+		if ( $op->run($old_server_path, $new_server_path) ) {
468 468
 			return $new_url;
469 469
 		} else {
470 470
 			// in case of error, we return source file itself
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 		);
487 487
 		return $new_url;
488 488
 	}
489
-	public static function get_letterbox_file_path($url, $w, $h, $color ) {
489
+	public static function get_letterbox_file_path($url, $w, $h, $color) {
490 490
 		$au = self::analyze_url($url);
491 491
 		$op = new TimberImageOperationLetterbox($w, $h, $color);
492 492
 		$new_path = self::_get_file_path(
Please login to merge, or discard this patch.
lib/image/timber-image-operation-retina.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,30 +44,30 @@
 block discarded – undo
44 44
      *                               (ex: /src/var/www/wp-content/uploads/[email protected])
45 45
      * @return bool                  true if everything went fine, false otherwise
46 46
      */
47
-    function run($load_filename, $save_filename){
48
-        $image = wp_get_image_editor( $load_filename );
49
-        if ( !is_wp_error( $image ) ) {
47
+    function run($load_filename, $save_filename) {
48
+        $image = wp_get_image_editor($load_filename);
49
+        if ( !is_wp_error($image) ) {
50 50
             $current_size = $image->get_size();
51 51
             $src_w = $current_size['width'];
52 52
             $src_h = $current_size['height'];
53 53
             // Get ratios
54 54
             $w = $src_w * $this->factor;
55 55
             $h = $src_h * $this->factor;
56
-            $image->crop( 0, 0, $src_w, $src_h, $w, $h );
57
-            $result = $image->save( $save_filename );
58
-            if ( is_wp_error( $result ) ) {
56
+            $image->crop(0, 0, $src_w, $src_h, $w, $h);
57
+            $result = $image->save($save_filename);
58
+            if ( is_wp_error($result) ) {
59 59
             	// @codeCoverageIgnoreStart
60
-				TimberHelper::error_log( 'Error resizing image' );
61
-				TimberHelper::error_log( $result );
60
+				TimberHelper::error_log('Error resizing image');
61
+				TimberHelper::error_log($result);
62 62
 				return false;
63 63
 				// @codeCoverageIgnoreEnd
64 64
             } else {
65 65
                 return true;
66 66
             }
67
-        } else if ( isset( $image->error_data['error_loading_image'] ) ) {
68
-            TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
67
+        } else if ( isset($image->error_data['error_loading_image']) ) {
68
+            TimberHelper::error_log('Error loading ' . $image->error_data['error_loading_image']);
69 69
         } else {
70
-            TimberHelper::error_log( $image );
70
+            TimberHelper::error_log($image);
71 71
         }
72 72
         return false;
73 73
     }
Please login to merge, or discard this patch.
lib/timber-comment.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 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';
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
 	 * @return bool|mixed|string
115 115
 	 */
116 116
 	public function avatar($size = 92, $default = '') {
117
-		if (!get_option('show_avatars')) {
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;
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 	 * ```
180 180
 	 * @return string
181 181
 	 */
182
-	public function date( $date_format = '' ) {
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
 
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 	 * ```
205 205
 	 * @return string
206 206
 	 */
207
-	public function time( $time_format = '' ) {
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
 
@@ -232,14 +232,14 @@  discard block
 block discarded – undo
232 232
 	 * @return mixed
233 233
 	 */
234 234
 	protected function get_meta_fields($comment_id = null) {
235
-		if ($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 241
 		foreach ($comment_metas as &$cm) {
242
-			if (is_array($cm) && count($cm) == 1) {
242
+			if ( is_array($cm) && count($cm) == 1 ) {
243 243
 				$cm = $cm[0];
244 244
 			}
245 245
 		}
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 */
255 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);
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
 	 * @api
268 268
 	 * @return string
269 269
 	 */
270
-	public function reply_link( $reply_text = 'Reply' ) {
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;
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
 	 * @return string
312 312
 	 */
313 313
 	protected function avatar_host($email_hash) {
314
-		if (is_ssl()) {
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';
@@ -333,28 +333,28 @@  discard block
 block discarded – undo
333 333
 	 * @return string
334 334
 	 */
335 335
 	protected function avatar_default($default, $email, $size, $host) {
336
-		if (substr($default, 0, 1) == '/') {
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;
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 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.
lib/image/timber-image-operation-tojpg.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 	 * @return bool                  true if everything went fine, false otherwise
37 37
 	 */
38 38
 	function run($load_filename, $save_filename) {
39
-		$input = self::image_create( $load_filename );
40
-		list( $width, $height ) = getimagesize( $load_filename );
41
-		$output = imagecreatetruecolor( $width, $height );
42
-		$c = self::hexrgb( $this->color );
43
-		$color = imagecolorallocate( $output, $c['red'], $c['green'], $c['blue'] );
44
-		imagefilledrectangle( $output, 0, 0, $width, $height, $color );
45
-		imagecopy( $output, $input, 0, 0, 0, 0, $width, $height );
46
-		imagejpeg( $output, $save_filename );
39
+		$input = self::image_create($load_filename);
40
+		list($width, $height) = getimagesize($load_filename);
41
+		$output = imagecreatetruecolor($width, $height);
42
+		$c = self::hexrgb($this->color);
43
+		$color = imagecolorallocate($output, $c['red'], $c['green'], $c['blue']);
44
+		imagefilledrectangle($output, 0, 0, $width, $height, $color);
45
+		imagecopy($output, $input, 0, 0, 0, 0, $width, $height);
46
+		imagejpeg($output, $save_filename);
47 47
 		return true;
48 48
 	}
49 49
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	 * @return resource an image identifier representing the image obtained from the given filename
53 53
 	 *                  will return the same data type regardless of whether the source is gif or png
54 54
 	 */
55
-	function image_create( $filename, $ext = 'auto' ) {
55
+	function image_create($filename, $ext = 'auto') {
56 56
 		if ( $ext == 'auto' ) {
57 57
 			$ext = wp_check_filetype($filename);
58
-			if (isset($ext['ext'])) {
58
+			if ( isset($ext['ext']) ) {
59 59
 				$ext = $ext['ext'];
60 60
 			}
61 61
 		}
@@ -69,6 +69,6 @@  discard block
 block discarded – undo
69 69
 		if ( $ext == 'jpg' || $ext == 'jpeg' ) {
70 70
 			return imagecreatefromjpeg($filename);
71 71
 		}
72
-		throw new InvalidArgumentException( 'image_create only accepts PNG, GIF and JPGs. File extension was: '.$ext );
72
+		throw new InvalidArgumentException('image_create only accepts PNG, GIF and JPGs. File extension was: ' . $ext);
73 73
 	}
74 74
 }
Please login to merge, or discard this patch.
lib/timber-archives.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * }
55 55
 	 * @param string $base any additional paths that need to be prepended to the URLs that are generated, for example: "tags"
56 56
 	 */
57
-	function __construct( $args = null, $base = '' ) {
57
+	function __construct($args = null, $base = '') {
58 58
 		$this->init($args, $base);
59 59
 	}
60 60
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param array|string $args
64 64
 	 * @param string $base
65 65
 	 */
66
-	function init( $args = null, $base = '' ) {
66
+	function init($args = null, $base = '') {
67 67
 		$this->base = $base;
68 68
 		$this->items = $this->get_items($args);
69 69
 	}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @param string $text
75 75
 	 * @return mixed
76 76
 	 */
77
-	protected function get_archives_link( $url, $text ) {
77
+	protected function get_archives_link($url, $text) {
78 78
 		$ret = array();
79 79
 		$ret['text'] = $ret['title'] = $ret['name'] = wptexturize($text);
80 80
 		$ret['url'] = $ret['link'] = esc_url(TimberURLHelper::prepend_to_url($url, $this->base));
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
 	 * @param string $limit
92 92
 	 * @return array
93 93
 	 */
94
-	protected function get_items_yearly( $args, $last_changed, $join, $where, $order, $limit ) {
94
+	protected function get_items_yearly($args, $last_changed, $join, $where, $order, $limit) {
95 95
 		global $wpdb;
96 96
 		$output = array();
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
 			}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * @param bool $nested
123 123
 	 * @return array
124 124
 	 */
125
-	protected function get_items_monthly( $args, $last_changed, $join, $where, $order, $limit = 1000, $nested = true ) {
125
+	protected function get_items_monthly($args, $last_changed, $join, $where, $order, $limit = 1000, $nested = true) {
126 126
 		global $wpdb, $wp_locale;
127 127
 		$output = array();
128 128
 		$defaults = array(
@@ -137,26 +137,26 @@  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 161
 			foreach ($output as $year => $months) {
162 162
 				$out2[] = array('name' => $year, 'children' => $months);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * @param array|string $args
172 172
 	 * @return array|string
173 173
 	 */
174
-	function get_items( $args = null ) {
174
+	function get_items($args = null) {
175 175
 		global $wpdb;
176 176
 
177 177
 		$defaults = array(
@@ -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/image/timber-image-operation-letterbox.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *                    (ex: my-awesome-pic-lbox-300x200-FF3366.jpg)
31 31
 	 */
32 32
 	public function filename($src_filename, $src_extension) {
33
-		$color = str_replace( '#', '', $this->color );
33
+		$color = str_replace('#', '', $this->color);
34 34
 		$newbase = $src_filename . '-lbox-' . $this->w . 'x' . $this->h . '-' . $color;
35 35
 		$new_name = $newbase . '.' . $src_extension;
36 36
 		return $new_name;
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 		$w = $this->w;
51 51
 		$h = $this->h;
52 52
 
53
-		$bg = imagecreatetruecolor( $w, $h );
54
-		$c = self::hexrgb( $this->color );
55
-		$bgColor = imagecolorallocate( $bg, $c['red'], $c['green'], $c['blue'] );
56
-		imagefill( $bg, 0, 0, $bgColor );
57
-		$image = wp_get_image_editor( $load_filename );
58
-		if ( !is_wp_error( $image ) ) {
53
+		$bg = imagecreatetruecolor($w, $h);
54
+		$c = self::hexrgb($this->color);
55
+		$bgColor = imagecolorallocate($bg, $c['red'], $c['green'], $c['blue']);
56
+		imagefill($bg, 0, 0, $bgColor);
57
+		$image = wp_get_image_editor($load_filename);
58
+		if ( !is_wp_error($image) ) {
59 59
 			$current_size = $image->get_size();
60 60
 			$quality = $image->get_quality();
61 61
 			$ow = $current_size['width'];
@@ -69,38 +69,38 @@  discard block
 block discarded – undo
69 69
 				$y = 0;
70 70
 				$x = $w / 2 - $owt / 2;
71 71
 				$oht = $h;
72
-				$image->crop( 0, 0, $ow, $oh, $owt, $oht );
72
+				$image->crop(0, 0, $ow, $oh, $owt, $oht);
73 73
 			} else {
74 74
 				$w_scale = $w / $ow;
75 75
 				$oht = $oh * $w_scale;
76 76
 				$x = 0;
77 77
 				$y = $h / 2 - $oht / 2;
78 78
 				$owt = $w;
79
-				$image->crop( 0, 0, $ow, $oh, $owt, $oht );
79
+				$image->crop(0, 0, $ow, $oh, $owt, $oht);
80 80
 			}
81
-			$result = $image->save( $save_filename );
81
+			$result = $image->save($save_filename);
82 82
 			$func = 'imagecreatefromjpeg';
83 83
 			$save_func = 'imagejpeg';
84
-			$ext = pathinfo( $save_filename, PATHINFO_EXTENSION );
84
+			$ext = pathinfo($save_filename, PATHINFO_EXTENSION);
85 85
 			if ( $ext == 'gif' ) {
86 86
 				$func = 'imagecreatefromgif';
87 87
 				$save_func = 'imagegif';
88 88
 			} else if ( $ext == 'png' ) {
89 89
 				$func = 'imagecreatefrompng';
90 90
 				$save_func = 'imagepng';
91
-				if ($quality > 9) {
92
-					$quality = $quality/10;
91
+				if ( $quality > 9 ) {
92
+					$quality = $quality / 10;
93 93
 					$quality = round(10 - $quality);
94 94
 				}
95 95
 			}
96
-			$image = $func( $save_filename );
97
-			imagecopy( $bg, $image, $x, $y, 0, 0, $owt, $oht );
98
-			if ($save_func === 'imagegif') {
99
-				return $save_func( $bg, $save_filename );
96
+			$image = $func($save_filename);
97
+			imagecopy($bg, $image, $x, $y, 0, 0, $owt, $oht);
98
+			if ( $save_func === 'imagegif' ) {
99
+				return $save_func($bg, $save_filename);
100 100
 			}
101
-			return $save_func( $bg, $save_filename, $quality );
101
+			return $save_func($bg, $save_filename, $quality);
102 102
 		} else {
103
-			TimberHelper::error_log( $image );
103
+			TimberHelper::error_log($image);
104 104
 		}
105 105
 		return false;
106 106
 	}
Please login to merge, or discard this patch.
timber.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@
 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
 }
Please login to merge, or discard this patch.
lib/timber-post-getter.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@  discard block
 block discarded – undo
8 8
 	 * @return array|bool|null
9 9
 	 */
10 10
 	static function get_post($query = false, $PostClass = 'TimberPost') {
11
-		$posts = self::get_posts( $query, $PostClass );
12
-		if ( $post = reset($posts ) ) {
11
+		$posts = self::get_posts($query, $PostClass);
12
+		if ( $post = reset($posts) ) {
13 13
 			return $post;
14 14
 		}
15 15
 	}
16 16
 
17
-	static function get_posts( $query = false, $PostClass = 'TimberPost', $return_collection = false ) {
18
-		$posts = self::query_posts( $query, $PostClass );
19
-		return apply_filters('timber_post_getter_get_posts', $posts->get_posts( $return_collection ));
17
+	static function get_posts($query = false, $PostClass = 'TimberPost', $return_collection = false) {
18
+		$posts = self::query_posts($query, $PostClass);
19
+		return apply_filters('timber_post_getter_get_posts', $posts->get_posts($return_collection));
20 20
 	}
21 21
 
22
-	static function query_post( $query = false, $PostClass = 'TimberPost' ) {
23
-		$posts = self::query_posts( $query, $PostClass );
22
+	static function query_post($query = false, $PostClass = 'TimberPost') {
23
+		$posts = self::query_posts($query, $PostClass);
24 24
 		if ( method_exists($posts, 'current') && $post = $posts->current() ) {
25 25
 			return $post;
26 26
 		}
@@ -31,32 +31,32 @@  discard block
 block discarded – undo
31 31
 	 * @param string $PostClass
32 32
 	 * @return array|bool|null
33 33
 	 */
34
-	static function query_posts($query = false, $PostClass = 'TimberPost' ) {
35
-		if (self::is_post_class_or_class_map($query)) {
34
+	static function query_posts($query = false, $PostClass = 'TimberPost') {
35
+		if ( self::is_post_class_or_class_map($query) ) {
36 36
 			$PostClass = $query;
37 37
 			$query = false;
38 38
 		}
39 39
 
40
-		if (is_object($query) && !is_a($query, 'WP_Query') ){
40
+		if ( is_object($query) && !is_a($query, 'WP_Query') ) {
41 41
 			// The only object other than a query is a type of post object
42
-			$query = array( $query );
42
+			$query = array($query);
43 43
 		}
44 44
 
45
-		if ( is_array( $query ) && count( $query ) && isset( $query[0] ) && is_object( $query[0] ) ) {
45
+		if ( is_array($query) && count($query) && isset($query[0]) && is_object($query[0]) ) {
46 46
 			// We have an array of post objects that already have data
47
-			return new TimberPostsCollection( $query, $PostClass );
47
+			return new TimberPostsCollection($query, $PostClass);
48 48
 		} else {
49 49
 			// We have a query (of sorts) to work with
50
-			$tqi = new TimberQueryIterator( $query, $PostClass );
50
+			$tqi = new TimberQueryIterator($query, $PostClass);
51 51
 			return $tqi;
52 52
 		}
53 53
 	}
54 54
 
55
-	static function get_pids($query){
55
+	static function get_pids($query) {
56 56
 		$posts = self::get_posts($query);
57 57
 		$pids = array();
58
-		foreach($posts as $post){
59
-			if (isset($post->ID)){
58
+		foreach ($posts as $post) {
59
+			if ( isset($post->ID) ) {
60 60
 				$pids[] = $post->ID;
61 61
 			}
62 62
 		}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	}
65 65
 
66 66
 	static function loop_to_id() {
67
-		if (!self::wp_query_has_posts()) { return false; }
67
+		if ( !self::wp_query_has_posts() ) { return false; }
68 68
 
69 69
 		global $wp_query;
70 70
 		$post_num = property_exists($wp_query, 'current_post')
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 				  : 0
73 73
 				  ;
74 74
 
75
-		if (!isset($wp_query->posts[$post_num])) { return false; }
75
+		if ( !isset($wp_query->posts[$post_num]) ) { return false; }
76 76
 
77 77
 		return $wp_query->posts[$post_num]->ID;
78 78
 	}
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	 * @param string|array $arg
90 90
 	 * @return bool
91 91
 	 */
92
-	static function is_post_class_or_class_map($arg){
93
-		if (is_string($arg) && class_exists($arg)) {
92
+	static function is_post_class_or_class_map($arg) {
93
+		if ( is_string($arg) && class_exists($arg) ) {
94 94
 			return true;
95 95
 		}
96
-		if (is_array($arg)) {
96
+		if ( is_array($arg) ) {
97 97
 			foreach ($arg as $item) {
98
-				if (is_string($item) && (class_exists($item) && is_subclass_of($item, 'TimberPost'))) {
98
+				if ( is_string($item) && (class_exists($item) && is_subclass_of($item, 'TimberPost')) ) {
99 99
 					return true;
100 100
 				}
101 101
 			}
Please login to merge, or discard this patch.
lib/timber-post.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * @param mixed $pid
163 163
 	 */
164 164
 	public function __construct($pid = null) {
165
-		$pid = $this->determine_id( $pid );
165
+		$pid = $this->determine_id($pid);
166 166
 		$this->init($pid);
167 167
 	}
168 168
 
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 			&& get_class($wp_query->queried_object) == 'WP_Post'
183 183
 			) {
184 184
 			$pid = $wp_query->queried_object_id;
185
-		} else if ( $pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id )  {
185
+		} else if ( $pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id ) {
186 186
 			//hack for static page as home page
187 187
 			$pid = $wp_query->queried_object_id;
188 188
 		} else if ( $pid === null ) {
189 189
 			$gtid = false;
190 190
 			$maybe_post = get_post();
191
-			if ( isset($maybe_post->ID) ){
191
+			if ( isset($maybe_post->ID) ) {
192 192
 				$gtid = true;
193 193
 			}
194 194
 			if ( $gtid ) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * @param string $field
253 253
 	 * @param mixed $value
254 254
 	 */
255
-	public function update( $field, $value ) {
255
+	public function update($field, $value) {
256 256
 		if ( isset($this->ID) ) {
257 257
 			update_post_meta($this->ID, $field, $value);
258 258
 			$this->$field = $value;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @param mixed $pid
268 268
 	 * @return WP_Post on success
269 269
 	 */
270
-	protected function prepare_post_info( $pid = 0 ) {
270
+	protected function prepare_post_info($pid = 0) {
271 271
 		if ( is_string($pid) || is_numeric($pid) || (is_object($pid) && !isset($pid->post_title)) || $pid === 0 ) {
272 272
 			$pid = self::check_post_id($pid);
273 273
 			$post = get_post($pid);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * @internal
287 287
 	 * @return integer ID number of a post
288 288
 	 */
289
-	protected function check_post_id( $pid ) {
289
+	protected function check_post_id($pid) {
290 290
 		if ( is_numeric($pid) && $pid === 0 ) {
291 291
 			$pid = get_the_ID();
292 292
 			return $pid;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 		global $wpdb;
313 313
 		$query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $post_name);
314 314
 		$result = $wpdb->get_row($query);
315
-		if (!$result) {
315
+		if ( !$result ) {
316 316
 			return null;
317 317
 		}
318 318
 		return $result->ID;
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 				$text = TimberHelper::trim_words($text, $len, false);
352 352
 				$trimmed = true;
353 353
 			}
354
-			$text = do_shortcode( $text );
354
+			$text = do_shortcode($text);
355 355
 		}
356 356
 		if ( !strlen($text) ) {
357 357
 			$text = TimberHelper::trim_words($this->get_content(), $len, false);
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
 			}
381 381
 			$read_more_class = apply_filters('timber/post/get_preview/read_more_class', "read-more");
382 382
 			if ( $readmore && isset($readmore_matches) && !empty($readmore_matches[1]) ) {
383
-				$text .= ' <a href="' . $this->get_permalink() . '" class="'.$read_more_class .'">' . trim($readmore_matches[1]) . '</a>';
383
+				$text .= ' <a href="' . $this->get_permalink() . '" class="' . $read_more_class . '">' . trim($readmore_matches[1]) . '</a>';
384 384
 			} elseif ( $readmore ) {
385
-				$text .= ' <a href="' . $this->get_permalink() . '" class="'.$read_more_class .'">' . trim($readmore) . '</a>';
385
+				$text .= ' <a href="' . $this->get_permalink() . '" class="' . $read_more_class . '">' . trim($readmore) . '</a>';
386 386
 			}
387
-			if ( !$strip && $last_p_tag && ( strpos($text, '<p>') || strpos($text, '<p ') ) ) {
387
+			if ( !$strip && $last_p_tag && (strpos($text, '<p>') || strpos($text, '<p ')) ) {
388 388
 				$text .= '</p>';
389 389
 			}
390 390
 		}
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	 * @internal
397 397
 	 * @param bool|int $pid a post ID number
398 398
 	 */
399
-	function import_custom( $pid = false ) {
399
+	function import_custom($pid = false) {
400 400
 		if ( !$pid ) {
401 401
 			$pid = $this->ID;
402 402
 		}
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 	 * @param int $pid
412 412
 	 * @return array
413 413
 	 */
414
-	protected function get_post_custom( $pid ) {
414
+	protected function get_post_custom($pid) {
415 415
 		apply_filters('timber_post_get_meta_pre', array(), $pid, $this);
416 416
 		$customs = get_post_custom($pid);
417 417
 		if ( !is_array($customs) || empty($customs) ) {
418 418
 			return array();
419 419
 		}
420
-		foreach ( $customs as $key => $value ) {
420
+		foreach ($customs as $key => $value) {
421 421
 			if ( is_array($value) && count($value) == 1 && isset($value[0]) ) {
422 422
 				$value = $value[0];
423 423
 			}
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 * @param bool $taxonomy
472 472
 	 * @return TimberPost|boolean
473 473
 	 */
474
-	function get_next( $taxonomy = false ) {
474
+	function get_next($taxonomy = false) {
475 475
 		if ( !isset($this->_next) || !isset($this->_next[$taxonomy]) ) {
476 476
 			global $post;
477 477
 			$this->_next = array();
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 		$post = $this;
503 503
 		$ret = array();
504 504
 		if ( $multipage ) {
505
-			for ( $i = 1; $i <= $numpages; $i++ ) {
505
+			for ($i = 1; $i <= $numpages; $i++) {
506 506
 				$link = self::get_wp_link_page($i);
507 507
 				$data = array('name' => $i, 'title' => $i, 'text' => $i, 'link' => $link);
508 508
 				if ( $i == $page ) {
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 	 * @param bool $taxonomy
555 555
 	 * @return TimberPost|boolean
556 556
 	 */
557
-	function get_prev( $taxonomy = false ) {
557
+	function get_prev($taxonomy = false) {
558 558
 		if ( isset($this->_prev) && isset($this->_prev[$taxonomy]) ) {
559 559
 			return $this->_prev[$taxonomy];
560 560
 		}
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 		$post->slug = $post->post_name;
622 622
 		$customs = $this->get_post_custom($post->ID);
623 623
 		$post->custom = $customs;
624
-		$post = (object) array_merge((array)$customs, (array)$post);
624
+		$post = (object) array_merge((array) $customs, (array) $post);
625 625
 		return $post;
626 626
 	}
627 627
 
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 	 * @param  string $date_format
632 632
 	 * @return string
633 633
 	 */
634
-	function get_date( $date_format = '' ) {
634
+	function get_date($date_format = '') {
635 635
 		$df = $date_format ? $date_format : get_option('date_format');
636
-		$the_date = (string)mysql2date($df, $this->post_date);
636
+		$the_date = (string) mysql2date($df, $this->post_date);
637 637
 		return apply_filters('get_the_date', $the_date, $df);
638 638
 	}
639 639
 
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 	 * @param  string $date_format
643 643
 	 * @return string
644 644
 	 */
645
-	function get_modified_date( $date_format = '' ) {
645
+	function get_modified_date($date_format = '') {
646 646
 		$df = $date_format ? $date_format : get_option('date_format');
647 647
 		$the_time = $this->get_modified_time($df);
648 648
 		return apply_filters('get_the_modified_date', $the_time, $date_format);
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 * @param  string $time_format
654 654
 	 * @return string
655 655
 	 */
656
-	function get_modified_time( $time_format = '' ) {
656
+	function get_modified_time($time_format = '') {
657 657
 		$tf = $time_format ? $time_format : get_option('time_format');
658 658
 		$the_time = get_post_modified_time($tf, false, $this->ID, true);
659 659
 		return apply_filters('get_the_modified_time', $the_time, $time_format);
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	 * @param bool|string 	$childPostClass
667 667
 	 * @return array
668 668
 	 */
669
-	function get_children( $post_type = 'any', $childPostClass = false ) {
669
+	function get_children($post_type = 'any', $childPostClass = false) {
670 670
 		if ( $childPostClass === false ) {
671 671
 			$childPostClass = $this->PostClass;
672 672
 		}
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 			$post_type = $this->post_type;
675 675
 		}
676 676
 		$children = get_children('post_parent=' . $this->ID . '&post_type=' . $post_type . '&numberposts=-1&orderby=menu_order title&order=ASC');
677
-		foreach ( $children as &$child ) {
677
+		foreach ($children as &$child) {
678 678
 			$child = new $childPostClass($child->ID);
679 679
 		}
680 680
 		$children = array_values($children);
@@ -711,42 +711,42 @@  discard block
 block discarded – undo
711 711
 		}
712 712
 
713 713
 		if ( $user_ID ) {
714
-			$args['include_unapproved'] = array( $user_ID );
715
-		} elseif ( ! empty( $comment_author_email ) ) {
716
-			$args['include_unapproved'] = array( $comment_author_email );
714
+			$args['include_unapproved'] = array($user_ID);
715
+		} elseif ( !empty($comment_author_email) ) {
716
+			$args['include_unapproved'] = array($comment_author_email);
717 717
 		}
718 718
 
719 719
 		$comments = get_comments($args);
720 720
 		$timber_comments = array();
721 721
 
722 722
 		if ( '' == get_query_var('cpage') && get_option('page_comments') ) {
723
-			set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 );
723
+			set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1);
724 724
 			$overridden_cpage = true;
725 725
 		}
726 726
 
727
-		foreach($comments as $key => &$comment) {
727
+		foreach ($comments as $key => &$comment) {
728 728
 			$timber_comment = new $CommentClass($comment);
729 729
 			$timber_comments[$timber_comment->id] = $timber_comment;
730 730
 		}
731 731
 
732 732
 		// Build a flattened (depth=1) comment tree
733 733
 		$comments_tree = array();
734
-		foreach( $timber_comments as $key => $comment ) {
735
-			if ( ! $comment->is_child() ) {
734
+		foreach ($timber_comments as $key => $comment) {
735
+			if ( !$comment->is_child() ) {
736 736
 				continue;
737 737
 			}
738 738
 
739 739
 			$tree_element = $comment;
740 740
 			do {
741 741
 				$tree_element = $timber_comments[$tree_element->comment_parent];
742
-			} while( $tree_element->is_child() );
742
+			} while ($tree_element->is_child());
743 743
 
744 744
 			$comments_tree[$tree_element->id][] = $comment->id;
745 745
 		}
746 746
 
747 747
 		// Add child comments to the relative "super parents"
748
-		foreach($comments_tree as $comment_parent => $comment_children) {
749
-			foreach($comment_children as $comment_child) {
748
+		foreach ($comments_tree as $comment_parent => $comment_children) {
749
+			foreach ($comment_children as $comment_child) {
750 750
 				$timber_comments[$comment_parent]->children[] = $timber_comments[$comment_child];
751 751
 				unset($timber_comments[$comment_child]);
752 752
 			}
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 	 * @param string $TermClass
787 787
 	 * @return array
788 788
 	 */
789
-	function get_terms( $tax = '', $merge = true, $TermClass = '' ) {
789
+	function get_terms($tax = '', $merge = true, $TermClass = '') {
790 790
 
791 791
 		$TermClass = $TermClass ?: $this->TermClass;
792 792
 
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 			$taxonomies = $tax;
798 798
 		}
799 799
 		if ( is_string($tax) ) {
800
-			if ( in_array($tax, array('all','any','')) ) {
800
+			if ( in_array($tax, array('all', 'any', '')) ) {
801 801
 				$taxonomies = get_object_taxonomies($this->post_type);
802 802
 			} else {
803 803
 				$taxonomies = array($tax);
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
 
807 807
 		$term_class_objects = array();
808 808
 
809
-		foreach ( $taxonomies as $taxonomy ) {
810
-			if ( in_array($taxonomy, array('tag','tags')) ) {
809
+		foreach ($taxonomies as $taxonomy) {
810
+			if ( in_array($taxonomy, array('tag', 'tags')) ) {
811 811
 				$taxonomy = 'post_tag';
812 812
 			}
813 813
 			if ( $taxonomy == 'categories' ) {
@@ -844,11 +844,11 @@  discard block
 block discarded – undo
844 844
 	 * @param string $taxonomy
845 845
 	 * @return bool
846 846
 	 */
847
-	function has_term( $term_name_or_id, $taxonomy = 'all' ) {
847
+	function has_term($term_name_or_id, $taxonomy = 'all') {
848 848
 		if ( $taxonomy == 'all' || $taxonomy == 'any' ) {
849 849
 			$taxes = get_object_taxonomies($this->post_type, 'names');
850 850
 			$ret = false;
851
-			foreach ( $taxes as $tax ) {
851
+			foreach ($taxes as $tax) {
852 852
 				if ( has_term($term_name_or_id, $tax, $this->ID) ) {
853 853
 					$ret = true;
854 854
 					break;
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 	 * @param string $field
864 864
 	 * @return TimberImage
865 865
 	 */
866
-	function get_image( $field ) {
866
+	function get_image($field) {
867 867
 		return new $this->ImageClass($this->$field);
868 868
 	}
869 869
 
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 	 * @param int $page
914 914
 	 * @return string
915 915
 	 */
916
-	function get_content( $len = 0, $page = 0 ) {
916
+	function get_content($len = 0, $page = 0) {
917 917
 		if ( $len == 0 && $page == 0 && $this->_content ) {
918 918
 			return $this->_content;
919 919
 		}
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 	 * @param string $field_name
971 971
 	 * @return mixed
972 972
 	 */
973
-	public function get_field( $field_name ) {
973
+	public function get_field($field_name) {
974 974
 		$value = apply_filters('timber_post_get_meta_field_pre', null, $this->ID, $field_name, $this);
975 975
 		if ( $value === null ) {
976 976
 			$value = get_post_meta($this->ID, $field_name);
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 	/**
989 989
 	 * @param string $field_name
990 990
 	 */
991
-	function import_field( $field_name ) {
991
+	function import_field($field_name) {
992 992
 		$this->$field_name = $this->get_field($field_name);
993 993
 	}
994 994
 
@@ -1019,13 +1019,13 @@  discard block
 block discarded – undo
1019 1019
 	 * ```
1020 1020
 	 * @return string a space-seperated list of classes
1021 1021
 	 */
1022
-	public function post_class( $class='' ) {
1022
+	public function post_class($class = '') {
1023 1023
 		global $post;
1024 1024
 		$old_global_post = $post;
1025 1025
 		$post = $this;
1026 1026
 		$class_array = get_post_class($class, $this->ID);
1027 1027
 		$post = $old_global_post;
1028
-		if ( is_array($class_array) ){
1028
+		if ( is_array($class_array) ) {
1029 1029
 			return implode(' ', $class_array);
1030 1030
 		}
1031 1031
 		return $class_array;
@@ -1127,8 +1127,8 @@  discard block
 block discarded – undo
1127 1127
 	 * @param string|bool $childPostClass _optional_ a custom post class (ex: 'MyTimberPost') to return the objects as. By default (false) it will use TimberPost::$post_class value.
1128 1128
 	 * @return array
1129 1129
 	 */
1130
-	public function children( $post_type = 'any', $childPostClass = false ) {
1131
-		return $this->get_children( $post_type, $childPostClass );
1130
+	public function children($post_type = 'any', $childPostClass = false) {
1131
+		return $this->get_children($post_type, $childPostClass);
1132 1132
 	}
1133 1133
 
1134 1134
 	/**
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 	 * ```
1153 1153
 	 * @return bool|array
1154 1154
 	 */
1155
-	public function comments( $count = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment' ) {
1155
+	public function comments($count = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment') {
1156 1156
 		return $this->get_comments($count, $order, $type, $status, $CommentClass);
1157 1157
 	}
1158 1158
 
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 	 * @param int $page
1170 1170
 	 * @return string
1171 1171
 	 */
1172
-	public function content( $page = 0 ) {
1172
+	public function content($page = 0) {
1173 1173
 		return $this->get_content(0, $page);
1174 1174
 	}
1175 1175
 
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
 	 * @param string $date_format
1199 1199
 	 * @return string
1200 1200
 	 */
1201
-	public function date( $date_format = '' ) {
1201
+	public function date($date_format = '') {
1202 1202
 		return $this->get_date($date_format);
1203 1203
 	}
1204 1204
 
@@ -1220,9 +1220,9 @@  discard block
 block discarded – undo
1220 1220
 	 * @param string $time_format
1221 1221
 	 * @return string
1222 1222
 	 */
1223
-	public function time( $time_format = '' ) {
1223
+	public function time($time_format = '') {
1224 1224
 		$tf = $time_format ? $time_format : get_option('time_format');
1225
-	 	$the_time = (string)mysql2date($tf, $this->post_date);
1225
+	 	$the_time = (string) mysql2date($tf, $this->post_date);
1226 1226
 	 	return apply_filters('get_the_time', $the_time, $tf);
1227 1227
 	}
1228 1228
 
@@ -1258,7 +1258,7 @@  discard block
 block discarded – undo
1258 1258
 	 * @param string $field_name
1259 1259
 	 * @return mixed
1260 1260
 	 */
1261
-	public function meta( $field_name = null ) {
1261
+	public function meta($field_name = null) {
1262 1262
 		if ( $field_name === null ) {
1263 1263
 			//on the off-chance the field is actually named meta
1264 1264
 			$field_name = 'meta';
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
 	/**
1270 1270
 	 * @return string
1271 1271
 	 */
1272
-	public function name(){
1272
+	public function name() {
1273 1273
 		return $this->title();
1274 1274
 	}
1275 1275
 
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 	 * @param string $date_format
1278 1278
 	 * @return string
1279 1279
 	 */
1280
-	public function modified_date( $date_format = '' ) {
1280
+	public function modified_date($date_format = '') {
1281 1281
 		return $this->get_modified_date($date_format);
1282 1282
 	}
1283 1283
 
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 	 * @param string $time_format
1286 1286
 	 * @return string
1287 1287
 	 */
1288
-	public function modified_time( $time_format = '' ) {
1288
+	public function modified_time($time_format = '') {
1289 1289
 		return $this->get_modified_time($time_format);
1290 1290
 	}
1291 1291
 
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 	 * @param bool $in_same_cat
1295 1295
 	 * @return mixed
1296 1296
 	 */
1297
-	public function next( $in_same_cat = false ) {
1297
+	public function next($in_same_cat = false) {
1298 1298
 		return $this->get_next($in_same_cat);
1299 1299
 	}
1300 1300
 
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
 	 * @param bool $in_same_cat
1353 1353
 	 * @return mixed
1354 1354
 	 */
1355
-	public function prev( $in_same_cat = false ) {
1355
+	public function prev($in_same_cat = false) {
1356 1356
 		return $this->get_prev($in_same_cat);
1357 1357
 	}
1358 1358
 
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
 	 * @param bool $merge Should the resulting array be one big one (true)? Or should it be an array of sub-arrays for each taxonomy (false)?
1365 1365
 	 * @return array
1366 1366
 	 */
1367
-	public function terms( $tax = '', $merge = true ) {
1367
+	public function terms($tax = '', $merge = true) {
1368 1368
 		return $this->get_terms($tax, $merge);
1369 1369
 	}
1370 1370
 
Please login to merge, or discard this patch.