@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function approve() |
| 23 | 23 | { |
| 24 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 24 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 25 | + return; |
|
| 26 | + } |
|
| 25 | 27 | check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
| 26 | 28 | wp_update_post([ |
| 27 | 29 | 'ID' => $postId, |
@@ -59,7 +61,9 @@ discard block |
||
| 59 | 61 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
| 60 | 62 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 61 | 63 | foreach( $postTypeColumns as $key => &$value ) { |
| 62 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
| 64 | + if( !array_key_exists( $key, $columns ) || !empty( $value )) { |
|
| 65 | + continue; |
|
| 66 | + } |
|
| 63 | 67 | $value = $columns[$key]; |
| 64 | 68 | } |
| 65 | 69 | if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
@@ -100,7 +104,8 @@ discard block |
||
| 100 | 104 | * @return array |
| 101 | 105 | * @filter display_post_states |
| 102 | 106 | */ |
| 103 | - public function filterPostStates( $postStates, WP_Post $post ) { |
|
| 107 | + public function filterPostStates( $postStates, WP_Post $post ) |
|
| 108 | + { |
|
| 104 | 109 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
| 105 | 110 | if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
| 106 | 111 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
@@ -148,7 +153,9 @@ discard block |
||
| 148 | 153 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 149 | 154 | unset( $postTypeColumns['cb'] ); |
| 150 | 155 | foreach( $postTypeColumns as $key => $value ) { |
| 151 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 156 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
| 157 | + continue; |
|
| 158 | + } |
|
| 152 | 159 | $columns[$key] = $key; |
| 153 | 160 | } |
| 154 | 161 | return $columns; |
@@ -172,7 +179,9 @@ discard block |
||
| 172 | 179 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 173 | 180 | ]; |
| 174 | 181 | foreach( $strings as $search => $replace ) { |
| 175 | - if( strpos( $single, $search ) === false )continue; |
|
| 182 | + if( strpos( $single, $search ) === false ) { |
|
| 183 | + continue; |
|
| 184 | + } |
|
| 176 | 185 | $translation = $this->getTranslation([ |
| 177 | 186 | 'number' => $number, |
| 178 | 187 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -224,7 +233,9 @@ discard block |
||
| 224 | 233 | */ |
| 225 | 234 | public function saveBulkEditFields( $postId ) |
| 226 | 235 | { |
| 227 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 236 | + if( !current_user_can( 'edit_posts' )) { |
|
| 237 | + return; |
|
| 238 | + } |
|
| 228 | 239 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 229 | 240 | if( $assignedTo && get_post( $assignedTo )) { |
| 230 | 241 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -237,7 +248,9 @@ discard block |
||
| 237 | 248 | */ |
| 238 | 249 | public function setQueryForColumn( WP_Query $query ) |
| 239 | 250 | { |
| 240 | - if( !$this->hasPermission( $query ))return; |
|
| 251 | + if( !$this->hasPermission( $query )) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 241 | 254 | $this->setMetaQuery( $query, [ |
| 242 | 255 | 'rating', 'review_type', |
| 243 | 256 | ]); |
@@ -250,7 +263,9 @@ discard block |
||
| 250 | 263 | */ |
| 251 | 264 | public function unapprove() |
| 252 | 265 | { |
| 253 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 266 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 267 | + return; |
|
| 268 | + } |
|
| 254 | 269 | check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
| 255 | 270 | wp_update_post([ |
| 256 | 271 | 'ID' => $postId, |
@@ -310,7 +325,9 @@ discard block |
||
| 310 | 325 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 311 | 326 | { |
| 312 | 327 | foreach( $metaKeys as $key ) { |
| 313 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 328 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
| 329 | + continue; |
|
| 330 | + } |
|
| 314 | 331 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 315 | 332 | $metaQuery[] = [ |
| 316 | 333 | 'key' => $key, |
@@ -97,7 +97,9 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
| 99 | 99 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
| 100 | - if( get_post_meta( $post->ID, 'review_type', true ) != 'local' )return; |
|
| 100 | + if( get_post_meta( $post->ID, 'review_type', true ) != 'local' ) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 101 | 103 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
| 102 | 104 | } |
| 103 | 105 | |
@@ -133,7 +135,9 @@ discard block |
||
| 133 | 135 | */ |
| 134 | 136 | public function renderAssignedToMetabox( WP_Post $post ) |
| 135 | 137 | { |
| 136 | - if( !$this->isReviewPostType( $post ))return; |
|
| 138 | + if( !$this->isReviewPostType( $post )) { |
|
| 139 | + return; |
|
| 140 | + } |
|
| 137 | 141 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 138 | 142 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 139 | 143 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -148,7 +152,9 @@ discard block |
||
| 148 | 152 | */ |
| 149 | 153 | public function renderDetailsMetaBox( WP_Post $post ) |
| 150 | 154 | { |
| 151 | - if( !$this->isReviewPostType( $post ))return; |
|
| 155 | + if( !$this->isReviewPostType( $post )) { |
|
| 156 | + return; |
|
| 157 | + } |
|
| 152 | 158 | $review = glsr( ReviewManager::class )->single( $post ); |
| 153 | 159 | glsr()->render( 'partials/editor/metabox-details', [ |
| 154 | 160 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -162,7 +168,9 @@ discard block |
||
| 162 | 168 | */ |
| 163 | 169 | public function renderPinnedInPublishMetaBox() |
| 164 | 170 | { |
| 165 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 171 | + if( !$this->isReviewPostType( get_post() )) { |
|
| 172 | + return; |
|
| 173 | + } |
|
| 166 | 174 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
| 167 | 175 | 'context' => [ |
| 168 | 176 | 'no' => __( 'No', 'site-reviews' ), |
@@ -178,7 +186,9 @@ discard block |
||
| 178 | 186 | */ |
| 179 | 187 | public function renderResponseMetaBox( WP_Post $post ) |
| 180 | 188 | { |
| 181 | - if( !$this->isReviewPostType( $post ))return; |
|
| 189 | + if( !$this->isReviewPostType( $post )) { |
|
| 190 | + return; |
|
| 191 | + } |
|
| 182 | 192 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 183 | 193 | glsr()->render( 'partials/editor/metabox-response', [ |
| 184 | 194 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -191,7 +201,9 @@ discard block |
||
| 191 | 201 | */ |
| 192 | 202 | public function renderReviewEditor( WP_Post $post ) |
| 193 | 203 | { |
| 194 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 204 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 205 | + return; |
|
| 206 | + } |
|
| 195 | 207 | glsr()->render( 'partials/editor/review', [ |
| 196 | 208 | 'post' => $post, |
| 197 | 209 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -205,7 +217,9 @@ discard block |
||
| 205 | 217 | public function renderReviewFields() |
| 206 | 218 | { |
| 207 | 219 | $screen = glsr_current_screen(); |
| 208 | - if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
|
| 220 | + if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE ) { |
|
| 221 | + return; |
|
| 222 | + } |
|
| 209 | 223 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
| 210 | 224 | add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
| 211 | 225 | } |
@@ -216,7 +230,9 @@ discard block |
||
| 216 | 230 | */ |
| 217 | 231 | public function renderReviewNotice( WP_Post $post ) |
| 218 | 232 | { |
| 219 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 233 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 234 | + return; |
|
| 235 | + } |
|
| 220 | 236 | glsr( Notice::class )->addWarning( sprintf( |
| 221 | 237 | __( '%s reviews are read-only.', 'site-reviews' ), |
| 222 | 238 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
@@ -235,7 +251,9 @@ discard block |
||
| 235 | 251 | */ |
| 236 | 252 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 237 | 253 | { |
| 238 | - if( !$this->isReviewPostType( $post ))return; |
|
| 254 | + if( !$this->isReviewPostType( $post )) { |
|
| 255 | + return; |
|
| 256 | + } |
|
| 239 | 257 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 240 | 258 | 'post' => $post, |
| 241 | 259 | 'tax_name' => Application::TAXONOMY, |
@@ -250,7 +268,9 @@ discard block |
||
| 250 | 268 | */ |
| 251 | 269 | public function revertReview() |
| 252 | 270 | { |
| 253 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 271 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 272 | + return; |
|
| 273 | + } |
|
| 254 | 274 | check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
| 255 | 275 | glsr( ReviewManager::class )->revert( $postId ); |
| 256 | 276 | $this->redirect( $postId, 52 ); |
@@ -274,7 +294,9 @@ discard block |
||
| 274 | 294 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 275 | 295 | { |
| 276 | 296 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 277 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 297 | + if( !( $assignedPost instanceof WP_Post )) { |
|
| 298 | + return; |
|
| 299 | + } |
|
| 278 | 300 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
| 279 | 301 | 'context' => [ |
| 280 | 302 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -320,7 +342,9 @@ discard block |
||
| 320 | 342 | */ |
| 321 | 343 | protected function getReviewType( $review ) |
| 322 | 344 | { |
| 323 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 345 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 346 | + return; |
|
| 347 | + } |
|
| 324 | 348 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 325 | 349 | ? glsr()->reviewTypes[$review->review_type] |
| 326 | 350 | : __( 'Unknown', 'site-reviews' ); |