@@ -46,9 +46,12 @@ |
||
| 46 | 46 | <option value="<?= $slug; ?>" class="hide-if-no-js"><?= $details['name']; ?></option> |
| 47 | 47 | <?php endforeach; ?> |
| 48 | 48 | </select> |
| 49 | - <?php else: ?> |
|
| 49 | + <?php else { |
|
| 50 | + : ?> |
|
| 50 | 51 | <?php foreach( $sites as $slug => $details ) : ?> |
| 51 | - <input type="hidden" name="{{ id }}[site]" value="<?= $slug; ?>"> |
|
| 52 | + <input type="hidden" name="{{ id }}[site]" value="<?= $slug; |
|
| 53 | +} |
|
| 54 | +?>"> |
|
| 52 | 55 | <?php endforeach; ?> |
| 53 | 56 | <?php endif; ?> |
| 54 | 57 | <input type="hidden" name="{{ id }}[action]" value="sync-reviews"> |
@@ -60,7 +60,9 @@ |
||
| 60 | 60 | */ |
| 61 | 61 | public function deactivate( $plugin ) |
| 62 | 62 | { |
| 63 | - if( $this->isValid() )return; |
|
| 63 | + if( $this->isValid() ) { |
|
| 64 | + return; |
|
| 65 | + } |
|
| 64 | 66 | $pluginSlug = plugin_basename( $this->file ); |
| 65 | 67 | if( $plugin == $pluginSlug ) { |
| 66 | 68 | $this->redirect(); //exit |
@@ -3,7 +3,9 @@ |
||
| 3 | 3 | defined( 'WP_UNINSTALL_PLUGIN' ) || die; |
| 4 | 4 | |
| 5 | 5 | require_once __DIR__.'/site-reviews.php'; |
| 6 | -if( !(new GL_Plugin_Check_v3( __FILE__ ))->isValid() )return; |
|
| 6 | +if( !(new GL_Plugin_Check_v3( __FILE__ ))->isValid() ) { |
|
| 7 | + return; |
|
| 8 | +} |
|
| 7 | 9 | |
| 8 | 10 | delete_option( GeminiLabs\SiteReviews\Database\OptionManager::databaseKey() ); |
| 9 | 11 | delete_option( 'widget_'.glsr()->id.'_site-reviews' ); |
@@ -21,7 +21,9 @@ |
||
| 21 | 21 | if( !class_exists( 'GL_Plugin_Check_v3' )) { |
| 22 | 22 | require_once __DIR__.'/activate.php'; |
| 23 | 23 | } |
| 24 | -if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() )return; |
|
| 24 | +if( !(new GL_Plugin_Check_v3( __FILE__ ))->canProceed() ) { |
|
| 25 | + return; |
|
| 26 | +} |
|
| 25 | 27 | require_once __DIR__.'/autoload.php'; |
| 26 | 28 | require_once __DIR__.'/compatibility.php'; |
| 27 | 29 | require_once __DIR__.'/helpers.php'; |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | public function routeAdminPostRequest() |
| 17 | 17 | { |
| 18 | 18 | $request = $this->getRequest(); |
| 19 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 19 | + if( !$this->isValidPostRequest( $request )) { |
|
| 20 | + return; |
|
| 21 | + } |
|
| 20 | 22 | check_admin_referer( $request['action'] ); |
| 21 | 23 | $this->routeRequest( 'admin', $request['action'], $request ); |
| 22 | 24 | } |
@@ -38,10 +40,16 @@ discard block |
||
| 38 | 40 | */ |
| 39 | 41 | public function routePublicPostRequest() |
| 40 | 42 | { |
| 41 | - if( is_admin() )return; |
|
| 43 | + if( is_admin() ) { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 42 | 46 | $request = $this->getRequest(); |
| 43 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 44 | - if( !$this->isValidPublicNonce( $request ))return; |
|
| 47 | + if( !$this->isValidPostRequest( $request )) { |
|
| 48 | + return; |
|
| 49 | + } |
|
| 50 | + if( !$this->isValidPublicNonce( $request )) { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 45 | 53 | $this->routeRequest( 'public', $request['action'], $request ); |
| 46 | 54 | } |
| 47 | 55 | |
@@ -50,7 +58,9 @@ discard block |
||
| 50 | 58 | */ |
| 51 | 59 | protected function checkAjaxNonce( array $request ) |
| 52 | 60 | { |
| 53 | - if( !is_user_logged_in() )return; |
|
| 61 | + if( !is_user_logged_in() ) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 54 | 64 | if( !isset( $request['nonce'] )) { |
| 55 | 65 | $this->sendAjaxError( 'The request is missing a nonce', $request ); |
| 56 | 66 | } |
@@ -83,7 +83,9 @@ discard block |
||
| 83 | 83 | $reviewValues = []; |
| 84 | 84 | foreach( $review as $key => $value ) { |
| 85 | 85 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
| 86 | - if( !method_exists( $this, $method ))continue; |
|
| 86 | + if( !method_exists( $this, $method )) { |
|
| 87 | + continue; |
|
| 88 | + } |
|
| 87 | 89 | $reviewValues[$key] = $this->$method( $key, $value ); |
| 88 | 90 | } |
| 89 | 91 | $reviewValues = apply_filters( 'site-reviews/review/build/after', $reviewValues ); |
@@ -97,9 +99,13 @@ discard block |
||
| 97 | 99 | */ |
| 98 | 100 | protected function buildOptionAssignedTo( $key, $value ) |
| 99 | 101 | { |
| 100 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
| 102 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' )) { |
|
| 103 | + return; |
|
| 104 | + } |
|
| 101 | 105 | $post = get_post( intval( $value )); |
| 102 | - if( !( $post instanceof WP_Post ))return; |
|
| 106 | + if( !( $post instanceof WP_Post )) { |
|
| 107 | + return; |
|
| 108 | + } |
|
| 103 | 109 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 104 | 110 | 'href' => get_the_permalink( $post->ID ), |
| 105 | 111 | ]); |
@@ -114,7 +120,9 @@ discard block |
||
| 114 | 120 | */ |
| 115 | 121 | protected function buildOptionAuthor( $key, $value ) |
| 116 | 122 | { |
| 117 | - if( $this->isHidden( $key ))return; |
|
| 123 | + if( $this->isHidden( $key )) { |
|
| 124 | + return; |
|
| 125 | + } |
|
| 118 | 126 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
| 119 | 127 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
| 120 | 128 | : ''; |
@@ -128,7 +136,9 @@ discard block |
||
| 128 | 136 | */ |
| 129 | 137 | protected function buildOptionAvatar( $key, $value ) |
| 130 | 138 | { |
| 131 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
| 139 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) { |
|
| 140 | + return; |
|
| 141 | + } |
|
| 132 | 142 | $size = $this->getOption( 'settings.reviews.avatars.size', 40 ); |
| 133 | 143 | return $this->wrap( $key, glsr( Builder::class )->img([ |
| 134 | 144 | 'src' => $this->generateAvatar( $value ), |
@@ -145,7 +155,9 @@ discard block |
||
| 145 | 155 | protected function buildOptionContent( $key, $value ) |
| 146 | 156 | { |
| 147 | 157 | $text = $this->normalizeText( $value ); |
| 148 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 158 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
| 159 | + return; |
|
| 160 | + } |
|
| 149 | 161 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
| 150 | 162 | } |
| 151 | 163 | |
@@ -156,7 +168,9 @@ discard block |
||
| 156 | 168 | */ |
| 157 | 169 | protected function buildOptionDate( $key, $value ) |
| 158 | 170 | { |
| 159 | - if( $this->isHidden( $key ))return; |
|
| 171 | + if( $this->isHidden( $key )) { |
|
| 172 | + return; |
|
| 173 | + } |
|
| 160 | 174 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 161 | 175 | if( $dateFormat == 'relative' ) { |
| 162 | 176 | $date = glsr( Date::class )->relative( $value ); |
@@ -177,7 +191,9 @@ discard block |
||
| 177 | 191 | */ |
| 178 | 192 | protected function buildOptionRating( $key, $value ) |
| 179 | 193 | { |
| 180 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 194 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 195 | + return; |
|
| 196 | + } |
|
| 181 | 197 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
| 182 | 198 | 'rating' => $value, |
| 183 | 199 | ]); |
@@ -191,7 +207,9 @@ discard block |
||
| 191 | 207 | */ |
| 192 | 208 | protected function buildOptionResponse( $key, $value ) |
| 193 | 209 | { |
| 194 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 210 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 211 | + return; |
|
| 212 | + } |
|
| 195 | 213 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
| 196 | 214 | $text = $this->normalizeText( $value ); |
| 197 | 215 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -208,7 +226,9 @@ discard block |
||
| 208 | 226 | */ |
| 209 | 227 | protected function buildOptionTitle( $key, $value ) |
| 210 | 228 | { |
| 211 | - if( $this->isHidden( $key ))return; |
|
| 229 | + if( $this->isHidden( $key )) { |
|
| 230 | + return; |
|
| 231 | + } |
|
| 212 | 232 | if( empty( $value )) { |
| 213 | 233 | $value = __( 'No Title', 'site-reviews' ); |
| 214 | 234 | } |
@@ -238,7 +258,9 @@ discard block |
||
| 238 | 258 | */ |
| 239 | 259 | protected function generateSchema() |
| 240 | 260 | { |
| 241 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 261 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 262 | + return; |
|
| 263 | + } |
|
| 242 | 264 | glsr( Schema::class )->store( |
| 243 | 265 | glsr( Schema::class )->build( $this->args ) |
| 244 | 266 | ); |
@@ -289,9 +311,13 @@ discard block |
||
| 289 | 311 | $words->setText( $text ); |
| 290 | 312 | $count = 0; |
| 291 | 313 | foreach( $words as $offset ){ |
| 292 | - if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
|
| 314 | + if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE ) { |
|
| 315 | + continue; |
|
| 316 | + } |
|
| 293 | 317 | $count++; |
| 294 | - if( $count != $limit )continue; |
|
| 318 | + if( $count != $limit ) { |
|
| 319 | + continue; |
|
| 320 | + } |
|
| 295 | 321 | return $offset; |
| 296 | 322 | } |
| 297 | 323 | return strlen( $text ); |
@@ -105,7 +105,9 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function revert( $postId ) |
| 107 | 107 | { |
| 108 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
| 108 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
| 109 | + return; |
|
| 110 | + } |
|
| 109 | 111 | delete_post_meta( $postId, '_edit_last' ); |
| 110 | 112 | $result = wp_update_post([ |
| 111 | 113 | 'ID' => $postId, |
@@ -123,7 +125,9 @@ discard block |
||
| 123 | 125 | */ |
| 124 | 126 | public function single( WP_Post $post ) |
| 125 | 127 | { |
| 126 | - if( $post->post_type != Application::POST_TYPE )return; |
|
| 128 | + if( $post->post_type != Application::POST_TYPE ) { |
|
| 129 | + return; |
|
| 130 | + } |
|
| 127 | 131 | $review = new Review( $post ); |
| 128 | 132 | return apply_filters( 'site-reviews/get/review', $review, $post ); |
| 129 | 133 | } |
@@ -150,7 +154,9 @@ discard block |
||
| 150 | 154 | $termIds = array_map( 'trim', explode( ',', $commaSeparatedTermIds )); |
| 151 | 155 | foreach( $termIds as $termId ) { |
| 152 | 156 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 153 | - if( !isset( $term['term_id'] ))continue; |
|
| 157 | + if( !isset( $term['term_id'] )) { |
|
| 158 | + continue; |
|
| 159 | + } |
|
| 154 | 160 | $terms[] = intval( $term['term_id'] ); |
| 155 | 161 | } |
| 156 | 162 | return $terms; |
@@ -164,7 +170,9 @@ discard block |
||
| 164 | 170 | protected function setTerms( $postId, $termIds ) |
| 165 | 171 | { |
| 166 | 172 | $terms = $this->normalizeTerms( $termIds ); |
| 167 | - if( empty( $terms ))return; |
|
| 173 | + if( empty( $terms )) { |
|
| 174 | + return; |
|
| 175 | + } |
|
| 168 | 176 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
| 169 | 177 | if( is_wp_error( $result )) { |
| 170 | 178 | glsr_log()->error( $result->get_error_message() ); |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | while( $reviews = glsr( SqlQueries::class )->getReviewRatings( $greaterThanId )) { |
| 24 | 24 | $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
| 25 | 25 | foreach( $types as $type ) { |
| 26 | - if( isset( $counts[$type] ))continue; |
|
| 26 | + if( isset( $counts[$type] )) { |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 27 | 29 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
| 28 | 30 | } |
| 29 | 31 | foreach( $reviews as $review ) { |
@@ -60,7 +62,9 @@ discard block |
||
| 60 | 62 | if( empty( $assignedTo )) { |
| 61 | 63 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
| 62 | 64 | } |
| 63 | - if( empty( $assignedTo ))return; |
|
| 65 | + if( empty( $assignedTo )) { |
|
| 66 | + return; |
|
| 67 | + } |
|
| 64 | 68 | $assignedPost = get_post( $assignedTo ); |
| 65 | 69 | if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
| 66 | 70 | return $assignedPost; |
@@ -103,7 +107,9 @@ discard block |
||
| 103 | 107 | array_walk( $counts, function( &$ratings ) use( $args ) { |
| 104 | 108 | $ratings[0] = 0; |
| 105 | 109 | foreach( $ratings as $index => &$num ) { |
| 106 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
| 110 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
| 111 | + continue; |
|
| 112 | + } |
|
| 107 | 113 | $num = 0; |
| 108 | 114 | } |
| 109 | 115 | }); |
@@ -173,7 +179,9 @@ discard block |
||
| 173 | 179 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
| 174 | 180 | $search = new WP_Query( $args ); |
| 175 | 181 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
| 176 | - if( !$search->have_posts() )return; |
|
| 182 | + if( !$search->have_posts() ) { |
|
| 183 | + return; |
|
| 184 | + } |
|
| 177 | 185 | $results = ''; |
| 178 | 186 | while( $search->have_posts() ) { |
| 179 | 187 | $search->the_post(); |
@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $this->args = $args; |
| 36 | 36 | $this->reviews = glsr( ReviewManager::class )->get( $args )->results; |
| 37 | - if( empty( $this->reviews ) && $this->isHidden( 'if_empty' ))return; |
|
| 37 | + if( empty( $this->reviews ) && $this->isHidden( 'if_empty' )) { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 38 | 40 | $this->rating = glsr( Rating::class )->getAverage( $this->reviews ); |
| 39 | 41 | $this->generateSchema(); |
| 40 | 42 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -54,7 +56,9 @@ discard block |
||
| 54 | 56 | */ |
| 55 | 57 | protected function buildPercentage() |
| 56 | 58 | { |
| 57 | - if( $this->isHidden( 'bars' ))return; |
|
| 59 | + if( $this->isHidden( 'bars' )) { |
|
| 60 | + return; |
|
| 61 | + } |
|
| 58 | 62 | $range = range( Rating::MAX_RATING, 1 ); |
| 59 | 63 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->reviews )); |
| 60 | 64 | $bars = array_reduce( $range, function( $carry, $level ) use( $percentages ) { |
@@ -104,7 +108,9 @@ discard block |
||
| 104 | 108 | */ |
| 105 | 109 | protected function buildRating() |
| 106 | 110 | { |
| 107 | - if( $this->isHidden( 'rating' ))return; |
|
| 111 | + if( $this->isHidden( 'rating' )) { |
|
| 112 | + return; |
|
| 113 | + } |
|
| 108 | 114 | return $this->wrap( 'rating', '<span>'.$this->rating.'</span>' ); |
| 109 | 115 | } |
| 110 | 116 | |
@@ -113,7 +119,9 @@ discard block |
||
| 113 | 119 | */ |
| 114 | 120 | protected function buildStars() |
| 115 | 121 | { |
| 116 | - if( $this->isHidden( 'stars' ))return; |
|
| 122 | + if( $this->isHidden( 'stars' )) { |
|
| 123 | + return; |
|
| 124 | + } |
|
| 117 | 125 | $stars = glsr( Partial::class )->build( 'star-rating', [ |
| 118 | 126 | 'rating' => $this->rating, |
| 119 | 127 | ]); |
@@ -125,7 +133,9 @@ discard block |
||
| 125 | 133 | */ |
| 126 | 134 | protected function buildText() |
| 127 | 135 | { |
| 128 | - if( $this->isHidden( 'summary' ))return; |
|
| 136 | + if( $this->isHidden( 'summary' )) { |
|
| 137 | + return; |
|
| 138 | + } |
|
| 129 | 139 | $count = count( $this->reviews ); |
| 130 | 140 | if( empty( $this->args['text'] )) { |
| 131 | 141 | // @todo document this change |
@@ -150,7 +160,9 @@ discard block |
||
| 150 | 160 | */ |
| 151 | 161 | protected function generateSchema() |
| 152 | 162 | { |
| 153 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 163 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 164 | + return; |
|
| 165 | + } |
|
| 154 | 166 | glsr( Schema::class )->store( |
| 155 | 167 | glsr( Schema::class )->buildSummary( $this->args ) |
| 156 | 168 | ); |