@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | { |
23 | 23 | global $menu, $typenow; |
24 | 24 | foreach( $menu as $key => $value ) { |
25 | - if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
25 | + if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE ) { |
|
26 | + continue; |
|
27 | + } |
|
26 | 28 | $postCount = wp_count_posts( Application::POST_TYPE ); |
27 | 29 | $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
28 | 30 | 'class' => 'pending-count', |
@@ -53,7 +55,9 @@ discard block |
||
53 | 55 | foreach( $pages as $slug => $title ) { |
54 | 56 | $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' ); |
55 | 57 | $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
56 | - if( !is_callable( $callback ))continue; |
|
58 | + if( !is_callable( $callback )) { |
|
59 | + continue; |
|
60 | + } |
|
57 | 61 | add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->constant( 'CAPABILITY' ), $slug, $callback ); |
58 | 62 | } |
59 | 63 | } |
@@ -33,7 +33,8 @@ |
||
33 | 33 | protected $settings; |
34 | 34 | protected $taxonomy; |
35 | 35 | |
36 | - public function __construct( Application $app ) { |
|
36 | + public function __construct( Application $app ) |
|
37 | + { |
|
37 | 38 | $this->app = $app; |
38 | 39 | $this->admin = $app->make( AdminController::class ); |
39 | 40 | $this->blocks = $app->make( BlocksController::class ); |
@@ -19,7 +19,9 @@ |
||
19 | 19 | */ |
20 | 20 | public function register( $block ) |
21 | 21 | { |
22 | - if( !function_exists( 'register_block_type' ))return; |
|
22 | + if( !function_exists( 'register_block_type' )) { |
|
23 | + return; |
|
24 | + } |
|
23 | 25 | register_block_type( Application::ID.'/'.$block, [ |
24 | 26 | 'attributes' => $this->attributes(), |
25 | 27 | 'editor_script' => Application::ID.'/blocks', |
@@ -90,10 +90,14 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function registerMetaBoxes( $postType, $post ) |
92 | 92 | { |
93 | - if( $postType != Application::POST_TYPE )return; |
|
93 | + if( $postType != Application::POST_TYPE ) { |
|
94 | + return; |
|
95 | + } |
|
94 | 96 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
95 | 97 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
96 | - if( get_post_meta( $post->ID, 'review_type', true ) != 'local' )return; |
|
98 | + if( get_post_meta( $post->ID, 'review_type', true ) != 'local' ) { |
|
99 | + return; |
|
100 | + } |
|
97 | 101 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
98 | 102 | } |
99 | 103 | |
@@ -129,7 +133,9 @@ discard block |
||
129 | 133 | */ |
130 | 134 | public function renderAssignedToMetabox( WP_Post $post ) |
131 | 135 | { |
132 | - if( !$this->isReviewPostType( $post ))return; |
|
136 | + if( !$this->isReviewPostType( $post )) { |
|
137 | + return; |
|
138 | + } |
|
133 | 139 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
134 | 140 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
135 | 141 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -144,7 +150,9 @@ discard block |
||
144 | 150 | */ |
145 | 151 | public function renderDetailsMetaBox( WP_Post $post ) |
146 | 152 | { |
147 | - if( !$this->isReviewPostType( $post ))return; |
|
153 | + if( !$this->isReviewPostType( $post )) { |
|
154 | + return; |
|
155 | + } |
|
148 | 156 | $review = glsr( ReviewManager::class )->single( $post ); |
149 | 157 | glsr()->render( 'partials/editor/metabox-details', [ |
150 | 158 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -158,7 +166,9 @@ discard block |
||
158 | 166 | */ |
159 | 167 | public function renderPinnedInPublishMetaBox() |
160 | 168 | { |
161 | - if( !$this->isReviewPostType( get_post() ))return; |
|
169 | + if( !$this->isReviewPostType( get_post() )) { |
|
170 | + return; |
|
171 | + } |
|
162 | 172 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
163 | 173 | 'context' => [ |
164 | 174 | 'no' => __( 'No', 'site-reviews' ), |
@@ -174,7 +184,9 @@ discard block |
||
174 | 184 | */ |
175 | 185 | public function renderResponseMetaBox( WP_Post $post ) |
176 | 186 | { |
177 | - if( !$this->isReviewPostType( $post ))return; |
|
187 | + if( !$this->isReviewPostType( $post )) { |
|
188 | + return; |
|
189 | + } |
|
178 | 190 | wp_nonce_field( 'response', '_nonce-response', false ); |
179 | 191 | glsr()->render( 'partials/editor/metabox-response', [ |
180 | 192 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -187,7 +199,9 @@ discard block |
||
187 | 199 | */ |
188 | 200 | public function renderReviewEditor( WP_Post $post ) |
189 | 201 | { |
190 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
202 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
203 | + return; |
|
204 | + } |
|
191 | 205 | glsr()->render( 'partials/editor/review', [ |
192 | 206 | 'post' => $post, |
193 | 207 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -201,7 +215,9 @@ discard block |
||
201 | 215 | public function renderReviewFields() |
202 | 216 | { |
203 | 217 | $screen = glsr_current_screen(); |
204 | - if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
|
218 | + if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE ) { |
|
219 | + return; |
|
220 | + } |
|
205 | 221 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
206 | 222 | add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
207 | 223 | } |
@@ -212,7 +228,9 @@ discard block |
||
212 | 228 | */ |
213 | 229 | public function renderReviewNotice( WP_Post $post ) |
214 | 230 | { |
215 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
231 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
232 | + return; |
|
233 | + } |
|
216 | 234 | glsr( Notice::class )->addWarning( sprintf( |
217 | 235 | __( '%s reviews are read-only.', 'site-reviews' ), |
218 | 236 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
@@ -231,7 +249,9 @@ discard block |
||
231 | 249 | */ |
232 | 250 | public function renderTaxonomyMetabox( WP_Post $post ) |
233 | 251 | { |
234 | - if( !$this->isReviewPostType( $post ))return; |
|
252 | + if( !$this->isReviewPostType( $post )) { |
|
253 | + return; |
|
254 | + } |
|
235 | 255 | glsr()->render( 'partials/editor/metabox-categories', [ |
236 | 256 | 'post' => $post, |
237 | 257 | 'tax_name' => Application::TAXONOMY, |
@@ -269,7 +289,9 @@ discard block |
||
269 | 289 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
270 | 290 | { |
271 | 291 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
272 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
292 | + if( !( $assignedPost instanceof WP_Post )) { |
|
293 | + return; |
|
294 | + } |
|
273 | 295 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
274 | 296 | 'context' => [ |
275 | 297 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -314,7 +336,9 @@ discard block |
||
314 | 336 | */ |
315 | 337 | protected function getReviewType( $review ) |
316 | 338 | { |
317 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
339 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
340 | + return; |
|
341 | + } |
|
318 | 342 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
319 | 343 | ? glsr()->reviewTypes[$review->review_type] |
320 | 344 | : __( 'Unknown', 'site-reviews' ); |
@@ -35,7 +35,9 @@ |
||
35 | 35 | */ |
36 | 36 | public function renderTaxonomyFilter() |
37 | 37 | { |
38 | - if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ))return; |
|
38 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY )) { |
|
39 | + return; |
|
40 | + } |
|
39 | 41 | echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
40 | 42 | 'class' => 'screen-reader-text', |
41 | 43 | 'for' => Application::TAXONOMY, |
@@ -115,7 +115,9 @@ discard block |
||
115 | 115 | $termId = intval( $termId ); |
116 | 116 | } |
117 | 117 | $term = term_exists( $termId, Application::TAXONOMY ); |
118 | - if( !isset( $term['term_id'] ))continue; |
|
118 | + if( !isset( $term['term_id'] )) { |
|
119 | + continue; |
|
120 | + } |
|
119 | 121 | $terms[] = intval( $term['term_id'] ); |
120 | 122 | } |
121 | 123 | return $terms; |
@@ -127,7 +129,9 @@ discard block |
||
127 | 129 | */ |
128 | 130 | public function revert( $postId ) |
129 | 131 | { |
130 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
132 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
133 | + return; |
|
134 | + } |
|
131 | 135 | delete_post_meta( $postId, '_edit_last' ); |
132 | 136 | $result = wp_update_post([ |
133 | 137 | 'ID' => $postId, |
@@ -145,7 +149,9 @@ discard block |
||
145 | 149 | */ |
146 | 150 | public function single( WP_Post $post ) |
147 | 151 | { |
148 | - if( $post->post_type != Application::POST_TYPE )return; |
|
152 | + if( $post->post_type != Application::POST_TYPE ) { |
|
153 | + return; |
|
154 | + } |
|
149 | 155 | $review = new Review( $post ); |
150 | 156 | return apply_filters( 'site-reviews/get/review', $review, $post ); |
151 | 157 | } |
@@ -170,7 +176,9 @@ discard block |
||
170 | 176 | protected function setTerms( $postId, $termIds ) |
171 | 177 | { |
172 | 178 | $terms = $this->normalizeTerms( $termIds ); |
173 | - if( empty( $terms ))return; |
|
179 | + if( empty( $terms )) { |
|
180 | + return; |
|
181 | + } |
|
174 | 182 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
175 | 183 | if( is_wp_error( $result )) { |
176 | 184 | glsr_log()->error( $result->get_error_message() ); |
@@ -74,7 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function decreasePostCounts( Review $review ) |
76 | 76 | { |
77 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
77 | + if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) { |
|
78 | + return; |
|
79 | + } |
|
78 | 80 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
79 | 81 | $this->setPostCounts( $review->assigned_to, $counts ); |
80 | 82 | } |
@@ -85,7 +87,9 @@ discard block |
||
85 | 87 | public function decreaseTermCounts( Review $review ) |
86 | 88 | { |
87 | 89 | foreach( $review->term_ids as $termId ) { |
88 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
90 | + if( empty( $counts = $this->getTermCounts( $termId ))) { |
|
91 | + continue; |
|
92 | + } |
|
89 | 93 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
90 | 94 | $this->setTermCounts( $termId, $counts ); |
91 | 95 | } |
@@ -107,7 +111,9 @@ discard block |
||
107 | 111 | 'min' => Rating::MIN_RATING, |
108 | 112 | ]); |
109 | 113 | foreach( $counts as $index => &$num ) { |
110 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
114 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
115 | + continue; |
|
116 | + } |
|
111 | 117 | $num = 0; |
112 | 118 | } |
113 | 119 | return $counts; |
@@ -199,7 +205,9 @@ discard block |
||
199 | 205 | */ |
200 | 206 | public function increasePostCounts( Review $review ) |
201 | 207 | { |
202 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
208 | + if( !( get_post( $review->assigned_to ) instanceof WP_Post )) { |
|
209 | + return; |
|
210 | + } |
|
203 | 211 | $counts = $this->getPostCounts( $review->assigned_to ); |
204 | 212 | $counts = empty( $counts ) |
205 | 213 | ? $this->buildPostCounts( $review->assigned_to ) |
@@ -248,7 +256,9 @@ discard block |
||
248 | 256 | */ |
249 | 257 | public function setTermCounts( $termId, array $reviewCounts ) |
250 | 258 | { |
251 | - if( !term_exists( $termId ))return; |
|
259 | + if( !term_exists( $termId )) { |
|
260 | + return; |
|
261 | + } |
|
252 | 262 | $ratingCounts = $this->flatten( $reviewCounts ); |
253 | 263 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
254 | 264 | update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
@@ -268,7 +278,9 @@ discard block |
||
268 | 278 | $types = array_unique( array_merge( ['local'], $types )); |
269 | 279 | foreach( $types as $type ) { |
270 | 280 | $type = $this->normalizeType( $type ); |
271 | - if( isset( $counts[$type] ))continue; |
|
281 | + if( isset( $counts[$type] )) { |
|
282 | + continue; |
|
283 | + } |
|
272 | 284 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
273 | 285 | } |
274 | 286 | foreach( $reviews as $review ) { |
@@ -321,7 +333,9 @@ discard block |
||
321 | 333 | } |
322 | 334 | foreach( $reviewCounts as &$counts ) { |
323 | 335 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
324 | - if( isset( $counts[$index] ))continue; |
|
336 | + if( isset( $counts[$index] )) { |
|
337 | + continue; |
|
338 | + } |
|
325 | 339 | $counts[$index] = 0; |
326 | 340 | } |
327 | 341 | ksort( $counts ); |
@@ -108,12 +108,16 @@ |
||
108 | 108 | public function renderTinymceButton( $editorId ) |
109 | 109 | { |
110 | 110 | $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'] ); |
111 | - if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return; |
|
111 | + if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors )) { |
|
112 | + return; |
|
113 | + } |
|
112 | 114 | $shortcodes = []; |
113 | 115 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
114 | 116 | $shortcodes[$shortcode] = $values; |
115 | 117 | } |
116 | - if( empty( $shortcodes ))return; |
|
118 | + if( empty( $shortcodes )) { |
|
119 | + return; |
|
120 | + } |
|
117 | 121 | glsr()->render( 'partials/editor/tinymce', [ |
118 | 122 | 'shortcodes' => $shortcodes, |
119 | 123 | ]); |