@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | public function approve() |
| 23 | 23 | { |
| 24 | 24 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
| 25 | - check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
|
| 26 | - wp_update_post([ |
|
| 25 | + check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) ); |
|
| 26 | + wp_update_post( [ |
|
| 27 | 27 | 'ID' => $postId, |
| 28 | 28 | 'post_status' => 'publish', |
| 29 | - ]); |
|
| 29 | + ] ); |
|
| 30 | 30 | wp_safe_redirect( wp_get_referer() ); |
| 31 | 31 | exit; |
| 32 | 32 | } |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
| 60 | 60 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 61 | 61 | foreach( $postTypeColumns as $key => &$value ) { |
| 62 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
| 62 | + if( !array_key_exists( $key, $columns ) || !empty($value) )continue; |
|
| 63 | 63 | $value = $columns[$key]; |
| 64 | 64 | } |
| 65 | - if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
|
| 66 | - unset( $postTypeColumns['review_type'] ); |
|
| 65 | + if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) { |
|
| 66 | + unset($postTypeColumns['review_type']); |
|
| 67 | 67 | } |
| 68 | 68 | return array_filter( $postTypeColumns, 'strlen' ); |
| 69 | 69 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function filterPostStates( $postStates, WP_Post $post ) { |
| 104 | 104 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
| 105 | - if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
|
| 105 | + if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates ) ) { |
|
| 106 | 106 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
| 107 | 107 | } |
| 108 | 108 | return $postStates; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | if( $post->post_type != Application::POST_TYPE || $post->post_status == 'trash' ) { |
| 119 | 119 | return $actions; |
| 120 | 120 | } |
| 121 | - unset( $actions['inline hide-if-no-js'] ); //Remove Quick-edit |
|
| 121 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
| 122 | 122 | $rowActions = [ |
| 123 | 123 | 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
| 124 | 124 | 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ), |
| 133 | 133 | $key.'-review_'.$post->ID |
| 134 | 134 | ), |
| 135 | - ]); |
|
| 135 | + ] ); |
|
| 136 | 136 | } |
| 137 | 137 | return $newActions + glsr( Helper::class )->consolidateArray( $actions ); |
| 138 | 138 | } |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
| 148 | 148 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 149 | - unset( $postTypeColumns['cb'] ); |
|
| 149 | + unset($postTypeColumns['cb']); |
|
| 150 | 150 | foreach( $postTypeColumns as $key => $value ) { |
| 151 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 151 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) )continue; |
|
| 152 | 152 | $columns[$key] = $key; |
| 153 | 153 | } |
| 154 | 154 | return $columns; |
@@ -166,18 +166,18 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function filterStatusText( $translation, $single, $plural, $number, $domain ) |
| 168 | 168 | { |
| 169 | - if( $this->canModifyTranslation( $domain )) { |
|
| 169 | + if( $this->canModifyTranslation( $domain ) ) { |
|
| 170 | 170 | $strings = [ |
| 171 | 171 | 'Published' => __( 'Approved', 'site-reviews' ), |
| 172 | 172 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 173 | 173 | ]; |
| 174 | 174 | foreach( $strings as $search => $replace ) { |
| 175 | 175 | if( strpos( $single, $search ) === false )continue; |
| 176 | - $translation = $this->getTranslation([ |
|
| 176 | + $translation = $this->getTranslation( [ |
|
| 177 | 177 | 'number' => $number, |
| 178 | 178 | 'plural' => str_replace( $search, $replace, $plural ), |
| 179 | 179 | 'single' => str_replace( $search, $replace, $single ), |
| 180 | - ]); |
|
| 180 | + ] ); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | return $translation; |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | public function saveBulkEditFields( $postId ) |
| 226 | 226 | { |
| 227 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 227 | + if( !current_user_can( 'edit_posts' ) )return; |
|
| 228 | 228 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 229 | - if( $assignedTo && get_post( $assignedTo )) { |
|
| 229 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
| 230 | 230 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
| 231 | 231 | } |
| 232 | 232 | } |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function setQueryForColumn( WP_Query $query ) |
| 239 | 239 | { |
| 240 | - if( !$this->hasPermission( $query ))return; |
|
| 240 | + if( !$this->hasPermission( $query ) )return; |
|
| 241 | 241 | $this->setMetaQuery( $query, [ |
| 242 | 242 | 'rating', 'review_type', |
| 243 | - ]); |
|
| 243 | + ] ); |
|
| 244 | 244 | $this->setOrderby( $query ); |
| 245 | 245 | } |
| 246 | 246 | |
@@ -251,11 +251,11 @@ discard block |
||
| 251 | 251 | public function unapprove() |
| 252 | 252 | { |
| 253 | 253 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
| 254 | - check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
|
| 255 | - wp_update_post([ |
|
| 254 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
| 255 | + wp_update_post( [ |
|
| 256 | 256 | 'ID' => $postId, |
| 257 | 257 | 'post_status' => 'pending', |
| 258 | - ]); |
|
| 258 | + ] ); |
|
| 259 | 259 | wp_safe_redirect( wp_get_referer() ); |
| 260 | 260 | exit; |
| 261 | 261 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | 'single' => '', |
| 286 | 286 | 'text' => '', |
| 287 | 287 | ]; |
| 288 | - $args = (object) wp_parse_args( $args, $defaults ); |
|
| 288 | + $args = (object)wp_parse_args( $args, $defaults ); |
|
| 289 | 289 | $translations = get_translations_for_domain( Application::ID ); |
| 290 | 290 | return $args->text |
| 291 | 291 | ? $translations->translate( $args->text ) |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 311 | 311 | { |
| 312 | 312 | foreach( $metaKeys as $key ) { |
| 313 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 313 | + if( !($value = filter_input( INPUT_GET, $key )) )continue; |
|
| 314 | 314 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 315 | 315 | $metaQuery[] = [ |
| 316 | 316 | 'key' => $key, |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | { |
| 328 | 328 | $orderby = $query->get( 'orderby' ); |
| 329 | 329 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 330 | - unset( $columns['cb'], $columns['title'], $columns['date'] ); |
|
| 331 | - if( in_array( $orderby, array_keys( $columns ))) { |
|
| 330 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
| 331 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
| 332 | 332 | $query->set( 'meta_key', $orderby ); |
| 333 | 333 | $query->set( 'orderby', 'meta_value' ); |
| 334 | 334 | } |
@@ -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, |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function renderAssignedToMetabox( WP_Post $post ) |
| 135 | 135 | { |
| 136 | - if( !$this->isReviewPostType( $post ))return; |
|
| 136 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 137 | 137 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 138 | 138 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 139 | 139 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
| 140 | 140 | 'id' => $assignedTo, |
| 141 | 141 | 'template' => $this->buildAssignedToTemplate( $assignedTo, $post ), |
| 142 | - ]); |
|
| 142 | + ] ); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -148,12 +148,12 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function renderDetailsMetaBox( WP_Post $post ) |
| 150 | 150 | { |
| 151 | - if( !$this->isReviewPostType( $post ))return; |
|
| 151 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 152 | 152 | $review = glsr( ReviewManager::class )->single( $post ); |
| 153 | 153 | glsr()->render( 'partials/editor/metabox-details', [ |
| 154 | 154 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
| 155 | 155 | 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
| 156 | - ]); |
|
| 156 | + ] ); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | public function renderPinnedInPublishMetaBox() |
| 164 | 164 | { |
| 165 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 165 | + if( !$this->isReviewPostType( get_post() ) )return; |
|
| 166 | 166 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
| 167 | 167 | 'context' => [ |
| 168 | 168 | 'no' => __( 'No', 'site-reviews' ), |
| 169 | 169 | 'yes' => __( 'Yes', 'site-reviews' ), |
| 170 | 170 | ], |
| 171 | - 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true )), |
|
| 172 | - ]); |
|
| 171 | + 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true ) ), |
|
| 172 | + ] ); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function renderResponseMetaBox( WP_Post $post ) |
| 180 | 180 | { |
| 181 | - if( !$this->isReviewPostType( $post ))return; |
|
| 181 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 182 | 182 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 183 | 183 | glsr()->render( 'partials/editor/metabox-response', [ |
| 184 | 184 | 'response' => get_post_meta( $post->ID, 'response', true ), |
| 185 | - ]); |
|
| 185 | + ] ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public function renderReviewEditor( WP_Post $post ) |
| 193 | 193 | { |
| 194 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 194 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 195 | 195 | glsr()->render( 'partials/editor/review', [ |
| 196 | 196 | 'post' => $post, |
| 197 | 197 | 'response' => get_post_meta( $post->ID, 'response', true ), |
| 198 | - ]); |
|
| 198 | + ] ); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $screen = glsr_current_screen(); |
| 208 | 208 | if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
| 209 | 209 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
| 210 | - add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
| 210 | + add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -216,16 +216,16 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function renderReviewNotice( WP_Post $post ) |
| 218 | 218 | { |
| 219 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 219 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 220 | 220 | glsr( Notice::class )->addWarning( sprintf( |
| 221 | 221 | __( '%s reviews are read-only.', 'site-reviews' ), |
| 222 | 222 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
| 223 | - )); |
|
| 223 | + ) ); |
|
| 224 | 224 | glsr( Template::class )->render( 'partials/editor/notice', [ |
| 225 | 225 | 'context' => [ |
| 226 | 226 | 'notices' => glsr( Notice::class )->get(), |
| 227 | 227 | ], |
| 228 | - ]); |
|
| 228 | + ] ); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -235,12 +235,12 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 237 | 237 | { |
| 238 | - if( !$this->isReviewPostType( $post ))return; |
|
| 238 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 239 | 239 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 240 | 240 | 'post' => $post, |
| 241 | 241 | 'tax_name' => Application::TAXONOMY, |
| 242 | 242 | 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
| 243 | - ]); |
|
| 243 | + ] ); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | public function revertReview() |
| 252 | 252 | { |
| 253 | 253 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
| 254 | - check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
|
| 254 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
| 255 | 255 | glsr( ReviewManager::class )->revert( $postId ); |
| 256 | 256 | $this->redirect( $postId, 52 ); |
| 257 | 257 | } |
@@ -274,13 +274,13 @@ discard block |
||
| 274 | 274 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 275 | 275 | { |
| 276 | 276 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 277 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 277 | + if( !($assignedPost instanceof WP_Post) )return; |
|
| 278 | 278 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
| 279 | 279 | 'context' => [ |
| 280 | 280 | 'data.url' => (string)get_permalink( $assignedPost ), |
| 281 | 281 | 'data.title' => get_the_title( $assignedPost ), |
| 282 | 282 | ], |
| 283 | - ]); |
|
| 283 | + ] ); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -305,13 +305,13 @@ discard block |
||
| 305 | 305 | 'class' => 'button button-large', |
| 306 | 306 | 'href' => $revertUrl, |
| 307 | 307 | 'id' => 'revert', |
| 308 | - ]); |
|
| 308 | + ] ); |
|
| 309 | 309 | } |
| 310 | 310 | return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
| 311 | 311 | 'class' => 'button button-large', |
| 312 | 312 | 'disabled' => true, |
| 313 | 313 | 'id' => 'revert', |
| 314 | - ]); |
|
| 314 | + ] ); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -324,11 +324,11 @@ discard block |
||
| 324 | 324 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 325 | 325 | ? glsr()->reviewTypes[$review->review_type] |
| 326 | 326 | : __( 'Unknown', 'site-reviews' ); |
| 327 | - if( !empty( $review->url )) { |
|
| 327 | + if( !empty($review->url) ) { |
|
| 328 | 328 | $reviewType = glsr( Builder::class )->a( $reviewType, [ |
| 329 | 329 | 'href' => $review->url, |
| 330 | 330 | 'target' => '_blank', |
| 331 | - ]); |
|
| 331 | + ] ); |
|
| 332 | 332 | } |
| 333 | 333 | return $reviewType; |
| 334 | 334 | } |
@@ -357,16 +357,16 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | protected function normalizeDetailsMetaBox( Review $review ) |
| 359 | 359 | { |
| 360 | - $user = empty( $review->user_id ) |
|
| 360 | + $user = empty($review->user_id) |
|
| 361 | 361 | ? __( 'Unregistered user', 'site-reviews' ) |
| 362 | 362 | : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
| 363 | 363 | 'href' => get_author_posts_url( $review->user_id ), |
| 364 | - ]); |
|
| 365 | - $email = empty( $review->email ) |
|
| 364 | + ] ); |
|
| 365 | + $email = empty($review->email) |
|
| 366 | 366 | ? '—' |
| 367 | 367 | : glsr( Builder::class )->a( $review->email, [ |
| 368 | 368 | 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
| 369 | - ]); |
|
| 369 | + ] ); |
|
| 370 | 370 | $metabox = [ |
| 371 | 371 | __( 'Rating', 'site-reviews' ) => glsr( Partial::class )->build( 'star-rating', ['rating' => $review->rating] ), |
| 372 | 372 | __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | __( 'IP Address', 'site-reviews' ) => $review->ip_address, |
| 378 | 378 | __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ), |
| 379 | 379 | ]; |
| 380 | - return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review )); |
|
| 380 | + return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) ); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | $redirectUri = $hasReferer |
| 395 | 395 | ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
| 396 | 396 | : get_edit_post_link( $postId ); |
| 397 | - wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri )); |
|
| 397 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
| 398 | 398 | exit; |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -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' ); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'setting' => 'Plugin Settings', |
| 41 | 41 | 'reviews' => 'Review Counts', |
| 42 | 42 | ]; |
| 43 | - $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) { |
|
| 43 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) { |
|
| 44 | 44 | $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' ); |
| 45 | 45 | if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
| 46 | 46 | return $carry.$this->implode( |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $plugins = get_plugins(); |
| 62 | 62 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 63 | - $inactive = array_diff_key( $plugins, array_flip( $activePlugins )); |
|
| 64 | - return $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 63 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
| 64 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public function getInactivePluginDetails() |
| 96 | 96 | { |
| 97 | 97 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 98 | - return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
| 98 | + return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $plugins = array_merge( |
| 107 | 107 | get_mu_plugins(), |
| 108 | - get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
|
| 108 | + get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) ) |
|
| 109 | 109 | ); |
| 110 | - if( empty( $plugins ))return; |
|
| 110 | + if( empty($plugins) )return; |
|
| 111 | 111 | return $this->normalizePluginList( $plugins ); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function getMultisitePluginDetails() |
| 118 | 118 | { |
| 119 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
| 119 | + if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return; |
|
| 120 | 120 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | 'Memory Limit' => ini_get( 'memory_limit' ), |
| 145 | 145 | 'Post Max Size' => ini_get( 'post_max_size' ), |
| 146 | 146 | 'Sendmail Path' => ini_get( 'sendmail_path' ), |
| 147 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
| 148 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
| 149 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
| 150 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ), |
|
| 151 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
| 147 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
| 148 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
| 149 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
| 150 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
| 151 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
| 152 | 152 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
| 153 | 153 | ]; |
| 154 | 154 | } |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | $counts = glsr( CountsManager::class )->getCounts(); |
| 162 | 162 | $counts = glsr( Helper::class )->flattenArray( $counts ); |
| 163 | - array_walk( $counts, function( &$ratings ) use( $counts ) { |
|
| 164 | - if( !is_array( $ratings )) { |
|
| 163 | + array_walk( $counts, function( &$ratings ) use($counts) { |
|
| 164 | + if( !is_array( $ratings ) ) { |
|
| 165 | 165 | glsr_log() |
| 166 | 166 | ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' ) |
| 167 | 167 | ->debug( $ratings ) |
@@ -200,8 +200,8 @@ discard block |
||
| 200 | 200 | ksort( $settings ); |
| 201 | 201 | $details = []; |
| 202 | 202 | foreach( $settings as $key => $value ) { |
| 203 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
| 204 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
| 203 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
| 204 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
| 205 | 205 | $details[$key] = $value; |
| 206 | 206 | } |
| 207 | 207 | return $details; |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | { |
| 215 | 215 | return [ |
| 216 | 216 | 'Console size' => glsr( Console::class )->humanSize( '0' ), |
| 217 | - 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' )), |
|
| 217 | + 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ), |
|
| 218 | 218 | 'Version (current)' => glsr()->version, |
| 219 | 219 | 'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ), |
| 220 | 220 | ]; |
@@ -274,10 +274,10 @@ discard block |
||
| 274 | 274 | 'WPE_APIKEY' => 'WP Engine', |
| 275 | 275 | ]; |
| 276 | 276 | foreach( $checks as $key => $value ) { |
| 277 | - if( !$this->isWebhostCheckValid( $key ))continue; |
|
| 277 | + if( !$this->isWebhostCheckValid( $key ) )continue; |
|
| 278 | 278 | return $value; |
| 279 | 279 | } |
| 280 | - return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] )); |
|
| 280 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -298,8 +298,8 @@ discard block |
||
| 298 | 298 | { |
| 299 | 299 | $plugins = get_plugins(); |
| 300 | 300 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 301 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
| 302 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 301 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
| 302 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 303 | 303 | return $active + $inactive; |
| 304 | 304 | } |
| 305 | 305 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | protected function implode( $title, array $details ) |
| 311 | 311 | { |
| 312 | 312 | $strings = ['['.$title.']']; |
| 313 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
| 313 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
| 314 | 314 | $padding = max( [$padding, static::PAD] ); |
| 315 | 315 | foreach( $details as $key => $value ) { |
| 316 | 316 | $strings[] = is_string( $key ) |
@@ -353,9 +353,9 @@ discard block |
||
| 353 | 353 | $keys = [ |
| 354 | 354 | 'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret', |
| 355 | 355 | ]; |
| 356 | - array_walk( $settings, function( &$value, $setting ) use( $keys ) { |
|
| 356 | + array_walk( $settings, function( &$value, $setting ) use($keys) { |
|
| 357 | 357 | foreach( $keys as $key ) { |
| 358 | - if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue; |
|
| 358 | + if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue; |
|
| 359 | 359 | $value = str_repeat( '•', 13 ); |
| 360 | 360 | return; |
| 361 | 361 | } |