Completed
Pull Request — master (#891)
by
unknown
03:05
created
lib/timber-post-getter.php 2 patches
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
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 42
 			$query = array( $query );
43 43
 		}
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
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
 		}
@@ -89,7 +89,7 @@  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){
92
+	static function is_post_class_or_class_map($arg) {
93 93
 		$type = false;
94 94
 
95 95
 		if(is_string($arg)) {
@@ -98,7 +98,9 @@  discard block
 block discarded – undo
98 98
 			$type = $arg['post_type'];
99 99
 		}
100 100
 
101
-		if(!$type) return false;
101
+		if(!$type) {
102
+			return false;
103
+		}
102 104
 
103 105
 		if (class_exists($type) && is_subclass_of($type, 'TimberPost')) {
104 106
 			return $type;
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
 	 * @param string $PostClass
8 8
 	 * @return array|bool|null
9 9
 	 */
10
-	static function get_post($query = false, $PostClass = 'TimberPost') {
11
-		$posts = self::get_posts( $query, $PostClass );
12
-		if ( $post = reset($posts ) ) {
10
+	static function get_post( $query = false, $PostClass = 'TimberPost' ) {
11
+		$posts = self::get_posts($query, $PostClass);
12
+		if ( $post = reset($posts) ) {
13 13
 			return $post;
14 14
 		}
15 15
 	}
16 16
 
17 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 ));
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 22
 	static function query_post( $query = false, $PostClass = 'TimberPost' ) {
23
-		$posts = self::query_posts( $query, $PostClass );
23
+		$posts = self::query_posts($query, $PostClass);
24 24
 		if ( method_exists($posts, 'current') && $post = $posts->current() ) {
25 25
 			return $post;
26 26
 		}
@@ -31,7 +31,7 @@  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' ) {
34
+	static function query_posts( $query = false, $PostClass = 'TimberPost' ) {
35 35
 		if ( $type = self::get_class_for_use_as_timber_post($query) ) {
36 36
 			$PostClass = $type;
37 37
 			if ( self::is_post_class_or_class_map($query) ) {
@@ -39,26 +39,26 @@  discard block
 block discarded – undo
39 39
 			}
40 40
 		}
41 41
 
42
-		if (is_object($query) && !is_a($query, 'WP_Query') ){
42
+		if ( is_object($query) && !is_a($query, 'WP_Query') ) {
43 43
 			// The only object other than a query is a type of post object
44
-			$query = array( $query );
44
+			$query = array($query);
45 45
 		}
46 46
 
47
-		if ( is_array( $query ) && count( $query ) && isset( $query[0] ) && is_object( $query[0] ) ) {
47
+		if ( is_array($query) && count($query) && isset($query[0]) && is_object($query[0]) ) {
48 48
 			// We have an array of post objects that already have data
49
-			return new TimberPostsCollection( $query, $PostClass );
49
+			return new TimberPostsCollection($query, $PostClass);
50 50
 		} else {
51 51
 			// We have a query (of sorts) to work with
52
-			$tqi = new TimberQueryIterator( $query, $PostClass );
52
+			$tqi = new TimberQueryIterator($query, $PostClass);
53 53
 			return $tqi;
54 54
 		}
55 55
 	}
56 56
 
57
-	static function get_pids($query){
57
+	static function get_pids( $query ) {
58 58
 		$posts = self::get_posts($query);
59 59
 		$pids = array();
60
-		foreach($posts as $post){
61
-			if (isset($post->ID)){
60
+		foreach ( $posts as $post ) {
61
+			if ( isset($post->ID) ) {
62 62
 				$pids[] = $post->ID;
63 63
 			}
64 64
 		}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	}
67 67
 
68 68
 	static function loop_to_id() {
69
-		if (!self::wp_query_has_posts()) { return false; }
69
+		if ( !self::wp_query_has_posts() ) { return false; }
70 70
 
71 71
 		global $wp_query;
72 72
 		$post_num = property_exists($wp_query, 'current_post')
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 				  : 0
75 75
 				  ;
76 76
 
77
-		if (!isset($wp_query->posts[$post_num])) { return false; }
77
+		if ( !isset($wp_query->posts[$post_num]) ) { return false; }
78 78
 
79 79
 		return $wp_query->posts[$post_num]->ID;
80 80
 	}
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	 * @param string|array $arg
92 92
 	 * @return bool
93 93
 	 */
94
-	static function is_post_class_or_class_map($arg){
95
-		$maybe_type = self::get_class_for_use_as_timber_post( $arg );
96
-		if ( is_array($arg) && isset($arg['post_type'])) {
94
+	static function is_post_class_or_class_map( $arg ) {
95
+		$maybe_type = self::get_class_for_use_as_timber_post($arg);
96
+		if ( is_array($arg) && isset($arg['post_type']) ) {
97 97
 			//the user has passed a true WP_Query-style query array that needs to be used later, so the $arg is not a class map or post class
98 98
 			return false;
99 99
 		}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param string|array $arg
107 107
 	 * @return string|bool if a $type is found; false if not
108 108
 	 */
109
-	static function get_class_for_use_as_timber_post($arg) {
109
+	static function get_class_for_use_as_timber_post( $arg ) {
110 110
 		$type = false;
111 111
 
112 112
 		if ( is_string($arg) ) {
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 			$type = $arg['post_type'];
116 116
 		}
117 117
 
118
-		if(!$type) return false;
118
+		if ( !$type ) return false;
119 119
 
120
-		if (class_exists($type) && is_subclass_of($type, 'TimberPost')) {
120
+		if ( class_exists($type) && is_subclass_of($type, 'TimberPost') ) {
121 121
 			return $type;
122 122
 		}
123 123
 	}
Please login to merge, or discard this patch.