@@ -17,6 +17,8 @@ |
||
| 17 | 17 | * @return void |
| 18 | 18 | */ |
| 19 | 19 | add_action( 'site-reviews/customize/divi', function( $instance ) { |
| 20 | - if( $instance->tag != 'label' || $instance->args['type'] != 'checkbox' )return; |
|
| 20 | + if( $instance->tag != 'label' || $instance->args['type'] != 'checkbox' ) { |
|
| 21 | + return; |
|
| 22 | + } |
|
| 21 | 23 | $instance->args['text'] = '<i></i>'.$instance->args['text']; |
| 22 | 24 | }); |
@@ -68,7 +68,9 @@ discard block |
||
| 68 | 68 | $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
| 69 | 69 | $this->modified = $this->isModified( $properties ); |
| 70 | 70 | array_walk( $properties, function( $value, $key ) { |
| 71 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
| 71 | + if( !property_exists( $this, $key ) || isset( $this->$key )) { |
|
| 72 | + return; |
|
| 73 | + } |
|
| 72 | 74 | $this->$key = $value; |
| 73 | 75 | }); |
| 74 | 76 | } |
@@ -79,7 +81,9 @@ discard block |
||
| 79 | 81 | protected function setTermIds( WP_Post $post ) |
| 80 | 82 | { |
| 81 | 83 | $this->term_ids = []; |
| 82 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
| 84 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ))) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 83 | 87 | foreach( $terms as $term ) { |
| 84 | 88 | $this->term_ids[] = $term->term_id; |
| 85 | 89 | } |
@@ -88,7 +88,9 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function registerMetaBoxes( $postType ) |
| 90 | 90 | { |
| 91 | - if( $postType != Application::POST_TYPE )return; |
|
| 91 | + if( $postType != Application::POST_TYPE ) { |
|
| 92 | + return; |
|
| 93 | + } |
|
| 92 | 94 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
| 93 | 95 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
| 94 | 96 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
@@ -118,7 +120,9 @@ discard block |
||
| 118 | 120 | */ |
| 119 | 121 | public function renderAssignedToMetabox( WP_Post $post ) |
| 120 | 122 | { |
| 121 | - if( !$this->isReviewPostType( $post ))return; |
|
| 123 | + if( !$this->isReviewPostType( $post )) { |
|
| 124 | + return; |
|
| 125 | + } |
|
| 122 | 126 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 123 | 127 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 124 | 128 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -133,7 +137,9 @@ discard block |
||
| 133 | 137 | */ |
| 134 | 138 | public function renderDetailsMetaBox( WP_Post $post ) |
| 135 | 139 | { |
| 136 | - if( !$this->isReviewPostType( $post ))return; |
|
| 140 | + if( !$this->isReviewPostType( $post )) { |
|
| 141 | + return; |
|
| 142 | + } |
|
| 137 | 143 | $review = glsr( ReviewManager::class )->single( $post ); |
| 138 | 144 | glsr()->render( 'partials/editor/metabox-details', [ |
| 139 | 145 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -147,7 +153,9 @@ discard block |
||
| 147 | 153 | */ |
| 148 | 154 | public function renderPinnedInPublishMetaBox() |
| 149 | 155 | { |
| 150 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 156 | + if( !$this->isReviewPostType( get_post() )) { |
|
| 157 | + return; |
|
| 158 | + } |
|
| 151 | 159 | glsr( Html::class )->renderTemplate( 'partials/editor/pinned', [ |
| 152 | 160 | 'context' => [ |
| 153 | 161 | 'no' => __( 'No', 'site-reviews' ), |
@@ -163,7 +171,9 @@ discard block |
||
| 163 | 171 | */ |
| 164 | 172 | public function renderResponseMetaBox( WP_Post $post ) |
| 165 | 173 | { |
| 166 | - if( !$this->isReviewPostType( $post ))return; |
|
| 174 | + if( !$this->isReviewPostType( $post )) { |
|
| 175 | + return; |
|
| 176 | + } |
|
| 167 | 177 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 168 | 178 | glsr()->render( 'partials/editor/metabox-response', [ |
| 169 | 179 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -177,7 +187,9 @@ discard block |
||
| 177 | 187 | */ |
| 178 | 188 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 179 | 189 | { |
| 180 | - if( !$this->isReviewPostType( $post ))return; |
|
| 190 | + if( !$this->isReviewPostType( $post )) { |
|
| 191 | + return; |
|
| 192 | + } |
|
| 181 | 193 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 182 | 194 | 'post' => $post, |
| 183 | 195 | 'tax_name' => Application::TAXONOMY, |
@@ -215,7 +227,9 @@ discard block |
||
| 215 | 227 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 216 | 228 | { |
| 217 | 229 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 218 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 230 | + if( !( $assignedPost instanceof WP_Post )) { |
|
| 231 | + return; |
|
| 232 | + } |
|
| 219 | 233 | return glsr( Html::class )->buildTemplate( 'partials/editor/assigned-post', [ |
| 220 | 234 | 'context' => [ |
| 221 | 235 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -256,7 +270,9 @@ discard block |
||
| 256 | 270 | */ |
| 257 | 271 | protected function getReviewType( $review ) |
| 258 | 272 | { |
| 259 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 273 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 274 | + return; |
|
| 275 | + } |
|
| 260 | 276 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 261 | 277 | ? glsr()->reviewTypes[$review->review_type] |
| 262 | 278 | : __( 'Unknown', 'site-reviews' ); |
@@ -17,7 +17,9 @@ |
||
| 17 | 17 | natsort( $routines ); |
| 18 | 18 | array_walk( $routines, function( $routine ) { |
| 19 | 19 | $parts = explode( '__', $routine ); |
| 20 | - if( version_compare( glsr()->version, end( $parts ), '<' ))return; |
|
| 20 | + if( version_compare( glsr()->version, end( $parts ), '<' )) { |
|
| 21 | + return; |
|
| 22 | + } |
|
| 21 | 23 | call_user_func( [$this, $routine] ); |
| 22 | 24 | }); |
| 23 | 25 | $this->updateVersion(); |
@@ -13,7 +13,9 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public function saveAssignedToMetabox( $postId ) |
| 15 | 15 | { |
| 16 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 16 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) { |
|
| 17 | + return; |
|
| 18 | + } |
|
| 17 | 19 | $assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' )); |
| 18 | 20 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
| 19 | 21 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
@@ -28,7 +30,9 @@ discard block |
||
| 28 | 30 | */ |
| 29 | 31 | public function saveResponseMetabox( $postId ) |
| 30 | 32 | { |
| 31 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
| 33 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 32 | 36 | $response = strval( glsr( Helper::class )->filterInput( 'response' )); |
| 33 | 37 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
| 34 | 38 | 'a' => ['href' => [], 'title' => []], |
@@ -73,7 +73,9 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function decreasePostCounts( Review $review ) |
| 75 | 75 | { |
| 76 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
| 76 | + if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 77 | 79 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
| 78 | 80 | $this->setPostCounts( $review->assigned_to, $counts ); |
| 79 | 81 | } |
@@ -84,7 +86,9 @@ discard block |
||
| 84 | 86 | public function decreaseTermCounts( Review $review ) |
| 85 | 87 | { |
| 86 | 88 | foreach( $review->term_ids as $termId ) { |
| 87 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
| 89 | + if( empty( $counts = $this->getTermCounts( $termId ))) { |
|
| 90 | + continue; |
|
| 91 | + } |
|
| 88 | 92 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
| 89 | 93 | $this->setTermCounts( $termId, $counts ); |
| 90 | 94 | } |
@@ -106,7 +110,9 @@ discard block |
||
| 106 | 110 | 'min' => Rating::MIN_RATING, |
| 107 | 111 | ]); |
| 108 | 112 | foreach( $counts as $index => &$num ) { |
| 109 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
| 113 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
| 114 | + continue; |
|
| 115 | + } |
|
| 110 | 116 | $num = 0; |
| 111 | 117 | } |
| 112 | 118 | return $counts; |
@@ -191,7 +197,9 @@ discard block |
||
| 191 | 197 | */ |
| 192 | 198 | public function increasePostCounts( Review $review ) |
| 193 | 199 | { |
| 194 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
| 200 | + if( !( get_post( $review->assigned_to ) instanceof WP_Post )) { |
|
| 201 | + return; |
|
| 202 | + } |
|
| 195 | 203 | $counts = $this->getPostCounts( $review->assigned_to ); |
| 196 | 204 | $counts = empty( $counts ) |
| 197 | 205 | ? $this->buildPostCounts( $review->assigned_to ) |
@@ -240,7 +248,9 @@ discard block |
||
| 240 | 248 | */ |
| 241 | 249 | public function setTermCounts( $termId, array $reviewCounts ) |
| 242 | 250 | { |
| 243 | - if( !term_exists( $termId ))return; |
|
| 251 | + if( !term_exists( $termId )) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 244 | 254 | $ratingCounts = glsr( CountsManager::class )->flatten( $reviewCounts ); |
| 245 | 255 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
| 246 | 256 | update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
@@ -258,7 +268,9 @@ discard block |
||
| 258 | 268 | while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) { |
| 259 | 269 | $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
| 260 | 270 | foreach( $types as $type ) { |
| 261 | - if( isset( $counts[$type] ))continue; |
|
| 271 | + if( isset( $counts[$type] )) { |
|
| 272 | + continue; |
|
| 273 | + } |
|
| 262 | 274 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
| 263 | 275 | } |
| 264 | 276 | foreach( $reviews as $review ) { |
@@ -307,7 +319,9 @@ discard block |
||
| 307 | 319 | { |
| 308 | 320 | foreach( $reviewCounts as &$counts ) { |
| 309 | 321 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
| 310 | - if( isset( $counts[$index] ))continue; |
|
| 322 | + if( isset( $counts[$index] )) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 311 | 325 | $counts[$index] = 0; |
| 312 | 326 | } |
| 313 | 327 | ksort( $counts ); |
@@ -111,7 +111,9 @@ discard block |
||
| 111 | 111 | $termIds = array_filter( array_map( 'trim', explode( ',', $commaSeparatedTermIds ))); |
| 112 | 112 | foreach( $termIds as $termId ) { |
| 113 | 113 | $term = get_term( $termId, Application::TAXONOMY ); |
| 114 | - if( !isset( $term->term_id ))continue; |
|
| 114 | + if( !isset( $term->term_id )) { |
|
| 115 | + continue; |
|
| 116 | + } |
|
| 115 | 117 | $terms[] = $term->term_id; |
| 116 | 118 | } |
| 117 | 119 | return $terms; |
@@ -123,7 +125,9 @@ discard block |
||
| 123 | 125 | */ |
| 124 | 126 | public function revert( $postId ) |
| 125 | 127 | { |
| 126 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
| 128 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
| 129 | + return; |
|
| 130 | + } |
|
| 127 | 131 | delete_post_meta( $postId, '_edit_last' ); |
| 128 | 132 | $result = wp_update_post([ |
| 129 | 133 | 'ID' => $postId, |
@@ -141,7 +145,9 @@ discard block |
||
| 141 | 145 | */ |
| 142 | 146 | public function single( WP_Post $post ) |
| 143 | 147 | { |
| 144 | - if( $post->post_type != Application::POST_TYPE )return; |
|
| 148 | + if( $post->post_type != Application::POST_TYPE ) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 145 | 151 | $review = new Review( $post ); |
| 146 | 152 | return apply_filters( 'site-reviews/get/review', $review, $post ); |
| 147 | 153 | } |
@@ -166,7 +172,9 @@ discard block |
||
| 166 | 172 | protected function setTerms( $postId, $termIds ) |
| 167 | 173 | { |
| 168 | 174 | $terms = $this->normalizeTerms( $termIds ); |
| 169 | - if( empty( $terms ))return; |
|
| 175 | + if( empty( $terms )) { |
|
| 176 | + return; |
|
| 177 | + } |
|
| 170 | 178 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
| 171 | 179 | if( is_wp_error( $result )) { |
| 172 | 180 | glsr_log()->error( $result->get_error_message() ); |
@@ -25,7 +25,9 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | sort( $termIds ); |
| 27 | 27 | sort( $oldTermIds ); |
| 28 | - if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ))return; |
|
| 28 | + if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId )) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 29 | 31 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 30 | 32 | $ignoredTerms = array_intersect( $oldTermIds, $termIds ); |
| 31 | 33 | if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms )) { |
@@ -45,7 +47,9 @@ discard block |
||
| 45 | 47 | */ |
| 46 | 48 | public function onAfterCreate( $postData, $meta, $postId ) |
| 47 | 49 | { |
| 48 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 50 | + if( !$this->isReviewPostId( $postId )) { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 49 | 53 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 50 | 54 | glsr( CountsManager::class )->increase( $review ); |
| 51 | 55 | } |
@@ -57,7 +61,9 @@ discard block |
||
| 57 | 61 | */ |
| 58 | 62 | public function onBeforeDelete( $postId ) |
| 59 | 63 | { |
| 60 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 64 | + if( !$this->isReviewPostId( $postId )) { |
|
| 65 | + return; |
|
| 66 | + } |
|
| 61 | 67 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 62 | 68 | glsr( CountsManager::class )->decrease( $review ); |
| 63 | 69 | } |
@@ -74,9 +80,13 @@ discard block |
||
| 74 | 80 | { |
| 75 | 81 | if( !$this->isReviewPostId( $postId ) |
| 76 | 82 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 77 | - )return; |
|
| 83 | + ) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 78 | 86 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 79 | - if( $review->$metaKey == $metaValue )return; |
|
| 87 | + if( $review->$metaKey == $metaValue ) { |
|
| 88 | + return; |
|
| 89 | + } |
|
| 80 | 90 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 81 | 91 | call_user_func( [$this, $method], $review, $metaValue ); |
| 82 | 92 | } |
@@ -122,7 +132,9 @@ discard block |
||
| 122 | 132 | */ |
| 123 | 133 | public function onChangeStatus( $newStatus, $oldStatus, WP_Post $post ) |
| 124 | 134 | { |
| 125 | - if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 135 | + if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
| 136 | + return; |
|
| 137 | + } |
|
| 126 | 138 | $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
| 127 | 139 | if( $post->post_status == 'publish' ) { |
| 128 | 140 | glsr( CountsManager::class )->increase( $review ); |
@@ -54,7 +54,9 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function enqueuePolyfillService() |
| 56 | 56 | { |
| 57 | - if( !apply_filters( 'site-reviews/assets/polyfill', true ))return; |
|
| 57 | + if( !apply_filters( 'site-reviews/assets/polyfill', true )) { |
|
| 58 | + return; |
|
| 59 | + } |
|
| 58 | 60 | wp_enqueue_script( |
| 59 | 61 | Application::ID.'/polyfill', |
| 60 | 62 | 'https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.closest,Element.prototype.dataset,Event&flags=gated', |
@@ -68,7 +70,9 @@ discard block |
||
| 68 | 70 | */ |
| 69 | 71 | public function enqueueRecaptchaScript() |
| 70 | 72 | { |
| 71 | - if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' )return; |
|
| 73 | + if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' ) { |
|
| 74 | + return; |
|
| 75 | + } |
|
| 72 | 76 | $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
| 73 | 77 | wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
| 74 | 78 | 'hl' => $language, |
@@ -86,7 +90,9 @@ discard block |
||
| 86 | 90 | public function inlineStyles() |
| 87 | 91 | { |
| 88 | 92 | $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
| 89 | - if( !apply_filters( 'site-reviews/assets/css', true ))return; |
|
| 93 | + if( !apply_filters( 'site-reviews/assets/css', true )) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 90 | 96 | if( !file_exists( $inlineStylesheetPath )) { |
| 91 | 97 | glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
| 92 | 98 | return; |