@@ -48,7 +48,9 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | public function enqueueRecaptchaScript() |
| 50 | 50 | { |
| 51 | - if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' )return; |
|
| 51 | + if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' ) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 52 | 54 | $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
| 53 | 55 | wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
| 54 | 56 | 'hl' => $language, |
@@ -74,7 +74,9 @@ discard block |
||
| 74 | 74 | $generatedReview = []; |
| 75 | 75 | foreach( $review as $key => $value ) { |
| 76 | 76 | $method = glsr( Helper::class )->buildMethodName( $key, 'buildOption' ); |
| 77 | - if( !method_exists( $this, $method ))continue; |
|
| 77 | + if( !method_exists( $this, $method )) { |
|
| 78 | + continue; |
|
| 79 | + } |
|
| 78 | 80 | $generatedReview[$key] = $this->$method( $key, $value ); |
| 79 | 81 | } |
| 80 | 82 | return (object)$generatedReview; |
@@ -87,9 +89,13 @@ discard block |
||
| 87 | 89 | */ |
| 88 | 90 | protected function buildOptionAssignedTo( $key, $value ) |
| 89 | 91 | { |
| 90 | - if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' ))return; |
|
| 92 | + if( $this->isHiddenOrEmpty( $key, 'settings.reviews.assigned_links.enabled' )) { |
|
| 93 | + return; |
|
| 94 | + } |
|
| 91 | 95 | $post = get_post( intval( $value )); |
| 92 | - if( !( $post instanceof WP_Post ))return; |
|
| 96 | + if( !( $post instanceof WP_Post )) { |
|
| 97 | + return; |
|
| 98 | + } |
|
| 93 | 99 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 94 | 100 | 'href' => get_the_permalink( $post->ID ), |
| 95 | 101 | ]); |
@@ -104,7 +110,9 @@ discard block |
||
| 104 | 110 | */ |
| 105 | 111 | protected function buildOptionAuthor( $key, $value ) |
| 106 | 112 | { |
| 107 | - if( $this->isHidden( $key ))return; |
|
| 113 | + if( $this->isHidden( $key )) { |
|
| 114 | + return; |
|
| 115 | + } |
|
| 108 | 116 | $prefix = !$this->isOptionEnabled( 'settings.reviews.avatars.enabled' ) |
| 109 | 117 | ? apply_filters( 'site-reviews/review/author/prefix', '—' ) |
| 110 | 118 | : ''; |
@@ -118,7 +126,9 @@ discard block |
||
| 118 | 126 | */ |
| 119 | 127 | protected function buildOptionAvatar( $key, $value ) |
| 120 | 128 | { |
| 121 | - if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' ))return; |
|
| 129 | + if( $this->isHidden( $key, 'settings.reviews.avatars.enabled' )) { |
|
| 130 | + return; |
|
| 131 | + } |
|
| 122 | 132 | $size = $this->getOption( 'settings.reviews.avatars.size', 36 ); |
| 123 | 133 | return $this->wrap( $key, glsr( Builder::class )->img([ |
| 124 | 134 | 'src' => $value, |
@@ -135,7 +145,9 @@ discard block |
||
| 135 | 145 | protected function buildOptionContent( $key, $value ) |
| 136 | 146 | { |
| 137 | 147 | $text = $this->normalizeText( $value ); |
| 138 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 148 | + if( $this->isHiddenOrEmpty( $key, $text )) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 139 | 151 | return $this->wrap( $key, '<p>'.$text.'</p>' ); |
| 140 | 152 | } |
| 141 | 153 | |
@@ -146,7 +158,9 @@ discard block |
||
| 146 | 158 | */ |
| 147 | 159 | protected function buildOptionDate( $key, $value ) |
| 148 | 160 | { |
| 149 | - if( $this->isHidden( $key ))return; |
|
| 161 | + if( $this->isHidden( $key )) { |
|
| 162 | + return; |
|
| 163 | + } |
|
| 150 | 164 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 151 | 165 | if( $dateFormat == 'relative' ) { |
| 152 | 166 | $date = glsr( Date::class )->relative( $value ); |
@@ -167,7 +181,9 @@ discard block |
||
| 167 | 181 | */ |
| 168 | 182 | protected function buildOptionRating( $key, $value ) |
| 169 | 183 | { |
| 170 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 184 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 185 | + return; |
|
| 186 | + } |
|
| 171 | 187 | $rating = glsr( Html::class )->buildPartial( 'star-rating', [ |
| 172 | 188 | 'rating' => $value, |
| 173 | 189 | ]); |
@@ -181,7 +197,9 @@ discard block |
||
| 181 | 197 | */ |
| 182 | 198 | protected function buildOptionResponse( $key, $value ) |
| 183 | 199 | { |
| 184 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 200 | + if( $this->isHiddenOrEmpty( $key, $value )) { |
|
| 201 | + return; |
|
| 202 | + } |
|
| 185 | 203 | $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
| 186 | 204 | $text = $this->normalizeText( $value ); |
| 187 | 205 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
@@ -198,7 +216,9 @@ discard block |
||
| 198 | 216 | */ |
| 199 | 217 | protected function buildOptionTitle( $key, $value ) |
| 200 | 218 | { |
| 201 | - if( $this->isHidden( $key ))return; |
|
| 219 | + if( $this->isHidden( $key )) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 202 | 222 | if( empty( $value )) { |
| 203 | 223 | $value = __( 'No Title', 'site-reviews' ); |
| 204 | 224 | } |
@@ -210,7 +230,9 @@ discard block |
||
| 210 | 230 | */ |
| 211 | 231 | protected function generateSchema() |
| 212 | 232 | { |
| 213 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 233 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 234 | + return; |
|
| 235 | + } |
|
| 214 | 236 | glsr( Schema::class )->store( |
| 215 | 237 | glsr( Schema::class )->build( $this->args ) |
| 216 | 238 | ); |
@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $this->args = $args; |
| 36 | 36 | $this->reviews = glsr( Database::class )->getReviews( $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 | $this->args['text'] = _nx( |
@@ -146,7 +156,9 @@ discard block |
||
| 146 | 156 | */ |
| 147 | 157 | protected function generateSchema() |
| 148 | 158 | { |
| 149 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 159 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
| 160 | + return; |
|
| 161 | + } |
|
| 150 | 162 | glsr( Schema::class )->store( |
| 151 | 163 | glsr( Schema::class )->buildSummary( $this->args ) |
| 152 | 164 | ); |