@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | 'post_type' => Application::POST_TYPE, |
37 | 37 | ]; |
38 | 38 | $postId = wp_insert_post( $postValues, true ); |
39 | - if( is_wp_error( $postId )) { |
|
39 | + if( is_wp_error( $postId ) ) { |
|
40 | 40 | glsr_log()->error( $postId->get_error_message() )->debug( $postValues ); |
41 | 41 | return false; |
42 | 42 | } |
43 | 43 | $this->setTerms( $postId, $command->category ); |
44 | - $review = $this->single( get_post( $postId )); |
|
44 | + $review = $this->single( get_post( $postId ) ); |
|
45 | 45 | do_action( 'site-reviews/review/created', $review, $command ); |
46 | 46 | return $review; |
47 | 47 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function delete( $metaReviewId ) |
54 | 54 | { |
55 | - if( $postId = $this->getPostId( $metaReviewId )) { |
|
55 | + if( $postId = $this->getPostId( $metaReviewId ) ) { |
|
56 | 56 | wp_delete_post( $postId, true ); |
57 | 57 | } |
58 | 58 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $paged = glsr( QueryBuilder::class )->getPaged( |
75 | 75 | wp_validate_boolean( $args['pagination'] ) |
76 | 76 | ); |
77 | - $query = new WP_Query([ |
|
77 | + $query = new WP_Query( [ |
|
78 | 78 | 'meta_key' => 'pinned', |
79 | 79 | 'meta_query' => $metaQuery, |
80 | 80 | 'offset' => $args['offset'], |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | 'post_type' => Application::POST_TYPE, |
88 | 88 | 'posts_per_page' => $args['count'], |
89 | 89 | 'tax_query' => $taxQuery, |
90 | - ]); |
|
90 | + ] ); |
|
91 | 91 | $results = array_map( [$this, 'single'], $query->posts ); |
92 | 92 | $reviews = new Reviews( $results, $query->max_num_pages, $args ); |
93 | 93 | return apply_filters( 'site-reviews/get/reviews', $reviews, $query ); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | public function normalizeTermIds( $commaSeparatedTermIds ) |
110 | 110 | { |
111 | 111 | $termIds = glsr_array_column( $this->normalizeTerms( $commaSeparatedTermIds ), 'term_id' ); |
112 | - return array_unique( array_map( 'intval', $termIds )); |
|
112 | + return array_unique( array_map( 'intval', $termIds ) ); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | $terms = []; |
122 | 122 | $termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds ); |
123 | 123 | foreach( $termIds as $termId ) { |
124 | - if( is_numeric( $termId )) { |
|
124 | + if( is_numeric( $termId ) ) { |
|
125 | 125 | $termId = intval( $termId ); |
126 | 126 | } |
127 | 127 | $term = term_exists( $termId, Application::TAXONOMY ); |
128 | - if( !isset( $term['term_id'] ))continue; |
|
128 | + if( !isset($term['term_id']) )continue; |
|
129 | 129 | $terms[] = $term; |
130 | 130 | } |
131 | 131 | return $terms; |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | { |
140 | 140 | if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
141 | 141 | delete_post_meta( $postId, '_edit_last' ); |
142 | - $result = wp_update_post([ |
|
142 | + $result = wp_update_post( [ |
|
143 | 143 | 'ID' => $postId, |
144 | 144 | 'post_content' => get_post_meta( $postId, 'content', true ), |
145 | 145 | 'post_date' => get_post_meta( $postId, 'date', true ), |
146 | 146 | 'post_title' => get_post_meta( $postId, 'title', true ), |
147 | - ]); |
|
148 | - if( is_wp_error( $result )) { |
|
147 | + ] ); |
|
148 | + if( is_wp_error( $result ) ) { |
|
149 | 149 | glsr_log()->error( $result->get_error_message() ); |
150 | 150 | } |
151 | 151 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | protected function getNewPostStatus( array $review, $isBlacklisted ) |
170 | 170 | { |
171 | 171 | $requireApprovalOption = glsr( OptionManager::class )->get( 'settings.general.require.approval' ); |
172 | - return $review['review_type'] == 'local' && ( $requireApprovalOption == 'yes' || $isBlacklisted ) |
|
172 | + return $review['review_type'] == 'local' && ($requireApprovalOption == 'yes' || $isBlacklisted) |
|
173 | 173 | ? 'pending' |
174 | 174 | : 'publish'; |
175 | 175 | } |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | protected function setTerms( $postId, $termIds ) |
183 | 183 | { |
184 | 184 | $termIds = $this->normalizeTermIds( $termIds ); |
185 | - if( empty( $termIds ))return; |
|
185 | + if( empty($termIds) )return; |
|
186 | 186 | $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY ); |
187 | - if( is_wp_error( $termTaxonomyIds )) { |
|
187 | + if( is_wp_error( $termTaxonomyIds ) ) { |
|
188 | 188 | glsr_log()->error( $termTaxonomyIds->get_error_message() ); |
189 | 189 | } |
190 | 190 | } |
@@ -125,7 +125,9 @@ discard block |
||
125 | 125 | $termId = intval( $termId ); |
126 | 126 | } |
127 | 127 | $term = term_exists( $termId, Application::TAXONOMY ); |
128 | - if( !isset( $term['term_id'] ))continue; |
|
128 | + if( !isset( $term['term_id'] )) { |
|
129 | + continue; |
|
130 | + } |
|
129 | 131 | $terms[] = $term; |
130 | 132 | } |
131 | 133 | return $terms; |
@@ -137,7 +139,9 @@ discard block |
||
137 | 139 | */ |
138 | 140 | public function revert( $postId ) |
139 | 141 | { |
140 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
142 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
143 | + return; |
|
144 | + } |
|
141 | 145 | delete_post_meta( $postId, '_edit_last' ); |
142 | 146 | $result = wp_update_post([ |
143 | 147 | 'ID' => $postId, |
@@ -182,7 +186,9 @@ discard block |
||
182 | 186 | protected function setTerms( $postId, $termIds ) |
183 | 187 | { |
184 | 188 | $termIds = $this->normalizeTermIds( $termIds ); |
185 | - if( empty( $termIds ))return; |
|
189 | + if( empty( $termIds )) { |
|
190 | + return; |
|
191 | + } |
|
186 | 192 | $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY ); |
187 | 193 | if( is_wp_error( $termTaxonomyIds )) { |
188 | 194 | glsr_log()->error( $termTaxonomyIds->get_error_message() ); |