@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function deleteAllSessions( $sessionCookiePrefix ) |
24 | 24 | { |
25 | - return $this->db->query(" |
|
25 | + return $this->db->query( " |
|
26 | 26 | DELETE |
27 | 27 | FROM {$this->db->options} |
28 | 28 | WHERE option_name LIKE '{$sessionCookiePrefix}_%' |
29 | - "); |
|
29 | + " ); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function deleteExpiredSessions( $expiredSessions ) |
37 | 37 | { |
38 | - return $this->db->query(" |
|
38 | + return $this->db->query( " |
|
39 | 39 | DELETE |
40 | 40 | FROM {$this->db->options} |
41 | 41 | WHERE option_name IN ('{$expiredSessions}') |
42 | - "); |
|
42 | + " ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function getExpiredSessions( $sessionCookiePrefix, $limit ) |
51 | 51 | { |
52 | - return (array) $this->db->get_results(" |
|
52 | + return (array)$this->db->get_results( " |
|
53 | 53 | SELECT option_name AS name, option_value AS expiration |
54 | 54 | FROM {$this->db->options} |
55 | 55 | WHERE option_name LIKE '{$sessionCookiePrefix}_expires_%' |
56 | 56 | ORDER BY option_value ASC |
57 | 57 | LIMIT 0, {$limit} |
58 | - "); |
|
58 | + " ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function getPostIdFromReviewId( $metaReviewId ) |
66 | 66 | { |
67 | - $postId = $this->db->get_var(" |
|
67 | + $postId = $this->db->get_var( " |
|
68 | 68 | SELECT p.ID |
69 | 69 | FROM {$this->db->posts} AS p |
70 | 70 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
71 | 71 | WHERE p.post_type = '{$this->postType}' |
72 | 72 | AND m.meta_key = 'review_id' |
73 | 73 | AND m.meta_value = '{$metaReviewId}' |
74 | - "); |
|
74 | + " ); |
|
75 | 75 | return intval( $postId ); |
76 | 76 | } |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getReviewCounts( array $args, $lastPostId = 0, $limit = 500 ) |
84 | 84 | { |
85 | - return (array) $this->db->get_results(" |
|
85 | + return (array)$this->db->get_results( " |
|
86 | 86 | SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type |
87 | 87 | FROM {$this->db->posts} AS p |
88 | 88 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | {$this->getAndForCounts( $args )} |
97 | 97 | ORDER By p.ID ASC |
98 | 98 | LIMIT {$limit} |
99 | - "); |
|
99 | + " ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function getReviewCountsFor( $metaKey ) |
108 | 108 | { |
109 | - return (array) $this->db->get_results(" |
|
109 | + return (array)$this->db->get_results( " |
|
110 | 110 | SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts |
111 | 111 | FROM {$this->db->posts} AS p |
112 | 112 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
113 | 113 | WHERE p.post_type = '{$this->postType}' |
114 | 114 | AND m.meta_key = '{$metaKey}' |
115 | 115 | GROUP BY name |
116 | - "); |
|
116 | + " ); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function getReviewIdsByType( $reviewType ) |
125 | 125 | { |
126 | - $results = $this->db->get_col(" |
|
126 | + $results = $this->db->get_col( " |
|
127 | 127 | SELECT DISTINCT m1.meta_value AS review_id |
128 | 128 | FROM {$this->db->posts} AS p |
129 | 129 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | AND m1.meta_key = 'review_id' |
133 | 133 | AND m2.meta_key = 'review_type' |
134 | 134 | AND m2.meta_value = '{$reviewType}' |
135 | - "); |
|
136 | - return array_keys( array_flip( $results )); |
|
135 | + " ); |
|
136 | + return array_keys( array_flip( $results ) ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 ) |
145 | 145 | { |
146 | 146 | sort( $postIds ); |
147 | - $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds )), $limit ); |
|
147 | + $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit ); |
|
148 | 148 | $postIds = implode( ',', $postIds ); |
149 | - return (array) $this->db->get_results(" |
|
149 | + return (array)$this->db->get_results( " |
|
150 | 150 | SELECT p.ID, m.meta_value AS rating |
151 | 151 | FROM {$this->db->posts} AS p |
152 | 152 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | GROUP BY p.ID |
159 | 159 | ORDER By p.ID ASC |
160 | 160 | LIMIT {$limit} |
161 | - "); |
|
161 | + " ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function getReviewsMeta( $key, $status = 'publish' ) |
170 | 170 | { |
171 | - $values = $this->db->get_col(" |
|
171 | + $values = $this->db->get_col( " |
|
172 | 172 | SELECT DISTINCT m.meta_value |
173 | 173 | FROM {$this->db->postmeta} m |
174 | 174 | LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | AND p.post_status = '{$status}' |
179 | 179 | GROUP BY p.ID -- remove duplicate meta_value entries |
180 | 180 | ORDER BY m.meta_id ASC -- sort by oldest meta_value |
181 | - "); |
|
181 | + " ); |
|
182 | 182 | sort( $values ); |
183 | 183 | return $values; |
184 | 184 | } |
@@ -189,16 +189,16 @@ discard block |
||
189 | 189 | */ |
190 | 190 | protected function getAndForCounts( array $args, $and = '' ) |
191 | 191 | { |
192 | - $postIds = implode( ',', array_filter( glsr_get( $args, 'post_ids'))); |
|
193 | - $termIds = implode( ',', array_filter( glsr_get( $args, 'term_ids'))); |
|
194 | - if( !empty( $args['type'] )) { |
|
195 | - $and.= "AND m2.meta_value = '{$args['type']}' "; |
|
192 | + $postIds = implode( ',', array_filter( glsr_get( $args, 'post_ids' ) ) ); |
|
193 | + $termIds = implode( ',', array_filter( glsr_get( $args, 'term_ids' ) ) ); |
|
194 | + if( !empty($args['type']) ) { |
|
195 | + $and .= "AND m2.meta_value = '{$args['type']}' "; |
|
196 | 196 | } |
197 | 197 | if( $postIds ) { |
198 | - $and.= "AND m3.meta_key = 'assigned_to' AND m3.meta_value IN ({$postIds}) "; |
|
198 | + $and .= "AND m3.meta_key = 'assigned_to' AND m3.meta_value IN ({$postIds}) "; |
|
199 | 199 | } |
200 | 200 | if( $termIds ) { |
201 | - $and.= "AND tr.term_taxonomy_id IN ({$termIds}) "; |
|
201 | + $and .= "AND tr.term_taxonomy_id IN ({$termIds}) "; |
|
202 | 202 | } |
203 | 203 | return apply_filters( 'site-reviews/query/and-for-counts', $and ); |
204 | 204 | } |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function getInnerJoinForCounts( array $args, $innerJoin = '' ) |
211 | 211 | { |
212 | - if( !empty( glsr_get( $args, 'post_ids'))) { |
|
213 | - $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id "; |
|
212 | + if( !empty(glsr_get( $args, 'post_ids' )) ) { |
|
213 | + $innerJoin .= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id "; |
|
214 | 214 | } |
215 | - if( !empty( glsr_get( $args, 'term_ids'))) { |
|
216 | - $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id "; |
|
215 | + if( !empty(glsr_get( $args, 'term_ids' )) ) { |
|
216 | + $innerJoin .= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id "; |
|
217 | 217 | } |
218 | 218 | return apply_filters( 'site-reviews/query/inner-join-for-counts', $innerJoin ); |
219 | 219 | } |