@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | 'class' => 'widefat', |
| 21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
| 22 | 22 | 'name' => 'title', |
| 23 | - ]); |
|
| 23 | + ] ); |
|
| 24 | 24 | $this->renderField( 'number', [ |
| 25 | 25 | 'class' => 'small-text', |
| 26 | 26 | 'default' => 5, |
| 27 | 27 | 'label' => __( 'How many reviews would you like to display?', 'site-reviews' ), |
| 28 | 28 | 'max' => 100, |
| 29 | 29 | 'name' => 'count', |
| 30 | - ]); |
|
| 30 | + ] ); |
|
| 31 | 31 | $this->renderField( 'select', [ |
| 32 | 32 | 'label' => __( 'What is the minimum rating to display?', 'site-reviews' ), |
| 33 | 33 | 'name' => 'rating', |
@@ -38,22 +38,22 @@ discard block |
||
| 38 | 38 | '2' => sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ), |
| 39 | 39 | '1' => sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ), |
| 40 | 40 | ], |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | if( count( glsr()->reviewTypes ) > 1 ) { |
| 43 | 43 | $this->renderField( 'select', [ |
| 44 | 44 | 'class' => 'widefat', |
| 45 | 45 | 'label' => __( 'Which type of review would you like to display?', 'site-reviews' ), |
| 46 | 46 | 'name' => 'type', |
| 47 | 47 | 'options' => ['' => __( 'All Reviews', 'site-reviews' )] + glsr()->reviewTypes, |
| 48 | - ]); |
|
| 48 | + ] ); |
|
| 49 | 49 | } |
| 50 | - if( !empty( $terms )) { |
|
| 50 | + if( !empty($terms) ) { |
|
| 51 | 51 | $this->renderField( 'select', [ |
| 52 | 52 | 'class' => 'widefat', |
| 53 | 53 | 'label' => __( 'Limit reviews to this category', 'site-reviews' ), |
| 54 | 54 | 'name' => 'category', |
| 55 | 55 | 'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms, |
| 56 | - ]); |
|
| 56 | + ] ); |
|
| 57 | 57 | } |
| 58 | 58 | $this->renderField( 'text', [ |
| 59 | 59 | 'class' => 'widefat', |
@@ -61,16 +61,16 @@ discard block |
||
| 61 | 61 | 'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ), |
| 62 | 62 | 'label' => __( 'Limit reviews to those assigned to this page/post ID', 'site-reviews' ), |
| 63 | 63 | 'name' => 'assigned_to', |
| 64 | - ]); |
|
| 64 | + ] ); |
|
| 65 | 65 | $this->renderField( 'text', [ |
| 66 | 66 | 'class' => 'widefat', |
| 67 | 67 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
| 68 | 68 | 'name' => 'class', |
| 69 | - ]); |
|
| 69 | + ] ); |
|
| 70 | 70 | $this->renderField( 'checkbox', [ |
| 71 | 71 | 'name' => 'hide', |
| 72 | 72 | 'options' => glsr( SiteReviewsShortcode::class )->getHideOptions(), |
| 73 | - ]); |
|
| 73 | + ] ); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function update( $newInstance, $oldInstance ) |
| 82 | 82 | { |
| 83 | - if( !is_numeric( $newInstance['count'] )) { |
|
| 83 | + if( !is_numeric( $newInstance['count'] ) ) { |
|
| 84 | 84 | $newInstance['count'] = 10; |
| 85 | 85 | } |
| 86 | - $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ))); |
|
| 86 | + $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ) ) ); |
|
| 87 | 87 | return parent::update( $newInstance, $oldInstance ); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -20,34 +20,34 @@ |
||
| 20 | 20 | 'class' => 'widefat', |
| 21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
| 22 | 22 | 'name' => 'title', |
| 23 | - ]); |
|
| 23 | + ] ); |
|
| 24 | 24 | $this->renderField( 'textarea', [ |
| 25 | 25 | 'class' => 'widefat', |
| 26 | 26 | 'label' => __( 'Description', 'site-reviews' ), |
| 27 | 27 | 'name' => 'description', |
| 28 | - ]); |
|
| 28 | + ] ); |
|
| 29 | 29 | $this->renderField( 'select', [ |
| 30 | 30 | 'class' => 'widefat', |
| 31 | 31 | 'label' => __( 'Automatically assign a category', 'site-reviews' ), |
| 32 | 32 | 'name' => 'category', |
| 33 | 33 | 'options' => ['' => __( 'Do not assign a category', 'site-reviews' )] + $terms, |
| 34 | - ]); |
|
| 34 | + ] ); |
|
| 35 | 35 | $this->renderField( 'text', [ |
| 36 | 36 | 'class' => 'widefat', |
| 37 | 37 | 'default' => '', |
| 38 | 38 | 'description' => sprintf( __( 'You may also enter %s to assign to the current post.', 'site-reviews' ), '<code>post_id</code>' ), |
| 39 | 39 | 'label' => __( 'Assign reviews to a custom page/post ID', 'site-reviews' ), |
| 40 | 40 | 'name' => 'assign_to', |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | $this->renderField( 'text', [ |
| 43 | 43 | 'class' => 'widefat', |
| 44 | 44 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
| 45 | 45 | 'name' => 'class', |
| 46 | - ]); |
|
| 46 | + ] ); |
|
| 47 | 47 | $this->renderField( 'checkbox', [ |
| 48 | 48 | 'name' => 'hide', |
| 49 | 49 | 'options' => glsr( SiteReviewsFormShortcode::class )->getHideOptions(), |
| 50 | - ]); |
|
| 50 | + ] ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -20,22 +20,22 @@ discard block |
||
| 20 | 20 | 'class' => 'widefat', |
| 21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
| 22 | 22 | 'name' => 'title', |
| 23 | - ]); |
|
| 23 | + ] ); |
|
| 24 | 24 | if( count( glsr()->reviewTypes ) > 1 ) { |
| 25 | 25 | $this->renderField( 'select', [ |
| 26 | 26 | 'class' => 'widefat', |
| 27 | 27 | 'label' => __( 'Which type of review would you like to use?', 'site-reviews' ), |
| 28 | 28 | 'name' => 'type', |
| 29 | 29 | 'options' => ['' => __( 'All review types', 'site-reviews' )] + glsr()->reviewTypes, |
| 30 | - ]); |
|
| 30 | + ] ); |
|
| 31 | 31 | } |
| 32 | - if( !empty( $terms )) { |
|
| 32 | + if( !empty($terms) ) { |
|
| 33 | 33 | $this->renderField( 'select', [ |
| 34 | 34 | 'class' => 'widefat', |
| 35 | 35 | 'label' => __( 'Limit summary to this category', 'site-reviews' ), |
| 36 | 36 | 'name' => 'category', |
| 37 | 37 | 'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms, |
| 38 | - ]); |
|
| 38 | + ] ); |
|
| 39 | 39 | } |
| 40 | 40 | $this->renderField( 'text', [ |
| 41 | 41 | 'class' => 'widefat', |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | 'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ), |
| 44 | 44 | 'label' => __( 'Limit summary to reviews assigned to a page/post ID', 'site-reviews' ), |
| 45 | 45 | 'name' => 'assigned_to', |
| 46 | - ]); |
|
| 46 | + ] ); |
|
| 47 | 47 | $this->renderField( 'text', [ |
| 48 | 48 | 'class' => 'widefat', |
| 49 | 49 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
| 50 | 50 | 'name' => 'class', |
| 51 | - ]); |
|
| 51 | + ] ); |
|
| 52 | 52 | $this->renderField( 'checkbox', [ |
| 53 | 53 | 'name' => 'hide', |
| 54 | 54 | 'options' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(), |
| 55 | - ]); |
|
| 55 | + ] ); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function compose( Review $review, array $notification ) |
| 37 | 37 | { |
| 38 | - if( empty( $this->endpoint )) { |
|
| 38 | + if( empty($this->endpoint) ) { |
|
| 39 | 39 | return $this; |
| 40 | 40 | } |
| 41 | 41 | $args = shortcode_atts( glsr( SlackDefaults::class )->defaults(), $notification ); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function send() |
| 62 | 62 | { |
| 63 | - if( empty( $this->endpoint )) { |
|
| 63 | + if( empty($this->endpoint) ) { |
|
| 64 | 64 | return new WP_Error( 'slack', 'Slack notification was not sent: missing endpoint' ); |
| 65 | 65 | } |
| 66 | 66 | return wp_remote_post( $this->endpoint, [ |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | 'redirection' => 5, |
| 73 | 73 | 'sslverify' => false, |
| 74 | 74 | 'timeout' => 45, |
| 75 | - ]); |
|
| 75 | + ] ); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | protected function buildAuthorField() |
| 94 | 94 | { |
| 95 | - $email = !empty( $this->review->email ) |
|
| 95 | + $email = !empty($this->review->email) |
|
| 96 | 96 | ? '<'.$this->review->email.'>' |
| 97 | 97 | : ''; |
| 98 | 98 | $author = trim( rtrim( $this->review->author ).' '.$email ); |
| 99 | - return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ))]; |
|
| 99 | + return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ) )]; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | protected function buildContentField() |
| 106 | 106 | { |
| 107 | - return !empty( $this->review->content ) |
|
| 107 | + return !empty($this->review->content) |
|
| 108 | 108 | ? ['value' => $this->review->content] |
| 109 | 109 | : []; |
| 110 | 110 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | protected function buildStarsField() |
| 130 | 130 | { |
| 131 | 131 | $solidStars = str_repeat( '★', $this->review->rating ); |
| 132 | - $emptyStars = str_repeat( '☆', max( 0, Rating::MAX_RATING - $this->review->rating )); |
|
| 132 | + $emptyStars = str_repeat( '☆', max( 0, Rating::MAX_RATING - $this->review->rating ) ); |
|
| 133 | 133 | $stars = $solidStars.$emptyStars; |
| 134 | 134 | $stars = apply_filters( 'site-reviews/slack/stars', $stars, $this->review->rating, Rating::MAX_RATING ); |
| 135 | 135 | return ['title' => $stars]; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | protected function buildTitleField() |
| 142 | 142 | { |
| 143 | - return !empty( $this->review->title ) |
|
| 143 | + return !empty($this->review->title) |
|
| 144 | 144 | ? ['title' => $this->review->title] |
| 145 | 145 | : []; |
| 146 | 146 | } |
@@ -150,7 +150,9 @@ discard block |
||
| 150 | 150 | if( !empty( $sessions )) { |
| 151 | 151 | $now = time(); |
| 152 | 152 | foreach( $sessions as $session ) { |
| 153 | - if( $now <= $session->expiration )continue; |
|
| 153 | + if( $now <= $session->expiration ) { |
|
| 154 | + continue; |
|
| 155 | + } |
|
| 154 | 156 | $expiredSessions[] = $session->name; |
| 155 | 157 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
| 156 | 158 | } |
@@ -193,7 +195,9 @@ discard block |
||
| 193 | 195 | */ |
| 194 | 196 | protected function setCookie() |
| 195 | 197 | { |
| 196 | - if( headers_sent() )return; |
|
| 198 | + if( headers_sent() ) { |
|
| 199 | + return; |
|
| 200 | + } |
|
| 197 | 201 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
| 198 | 202 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
| 199 | 203 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ); |
| 40 | 40 | if( strpos( $cookieId, static::DELIMITER ) !== false ) { |
| 41 | - $cookie = explode( static::DELIMITER, stripslashes( $cookieId )); |
|
| 41 | + $cookie = explode( static::DELIMITER, stripslashes( $cookieId ) ); |
|
| 42 | 42 | $this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] ); |
| 43 | 43 | $this->expiryTimestamp = absint( $cookie[1] ); |
| 44 | 44 | $this->expiryTimestampReset = absint( $cookie[2] ); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function deleteExpiredSessions( $limit = 1000 ) |
| 79 | 79 | { |
| 80 | - if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) { |
|
| 80 | + if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) { |
|
| 81 | 81 | glsr( SqlQueries::class )->deleteExpiredSessions( $expiredSessions ); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | public function get( $key, $fallback = '', $unset = false ) |
| 92 | 92 | { |
| 93 | 93 | $key = sanitize_key( $key ); |
| 94 | - $value = isset( $this->sessionData[$key] ) |
|
| 94 | + $value = isset($this->sessionData[$key]) |
|
| 95 | 95 | ? maybe_unserialize( $this->sessionData[$key] ) |
| 96 | 96 | : $fallback; |
| 97 | - if( isset( $this->sessionData[$key] ) && $unset ) { |
|
| 98 | - unset( $this->sessionData[$key] ); |
|
| 97 | + if( isset($this->sessionData[$key]) && $unset ) { |
|
| 98 | + unset($this->sessionData[$key]); |
|
| 99 | 99 | $this->updateSession(); |
| 100 | 100 | } |
| 101 | 101 | return $value; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | protected function deleteSession() |
| 130 | 130 | { |
| 131 | 131 | delete_option( $this->getSessionId() ); |
| 132 | - delete_option( $this->getSessionId( 'expires' )); |
|
| 132 | + delete_option( $this->getSessionId( 'expires' ) ); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | protected function generateSessionId() |
| 139 | 139 | { |
| 140 | - return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 )); |
|
| 140 | + return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) ); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | protected function getExpiredSessions( $limit ) |
| 148 | 148 | { |
| 149 | 149 | $expiredSessions = []; |
| 150 | - $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit )); |
|
| 151 | - if( !empty( $sessions )) { |
|
| 150 | + $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit ) ); |
|
| 151 | + if( !empty($sessions) ) { |
|
| 152 | 152 | $now = time(); |
| 153 | 153 | foreach( $sessions as $session ) { |
| 154 | 154 | if( $now <= $session->expiration )continue; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | protected function getSessionId( $separator = '' ) |
| 167 | 167 | { |
| 168 | - return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] )); |
|
| 168 | + return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) ); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | { |
| 197 | 197 | if( headers_sent() )return; |
| 198 | 198 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
| 199 | - $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
|
| 199 | + $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ) ) ); |
|
| 200 | 200 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
| 201 | 201 | } |
| 202 | 202 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function updateSession() |
| 216 | 216 | { |
| 217 | - if( false === get_option( $this->getSessionId() )) { |
|
| 217 | + if( false === get_option( $this->getSessionId() ) ) { |
|
| 218 | 218 | return $this->createSession(); |
| 219 | 219 | } |
| 220 | 220 | update_option( $this->getSessionId(), $this->sessionData, false ); |
@@ -175,8 +175,12 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | protected function validateAkismet() |
| 177 | 177 | { |
| 178 | - if( !empty( $this->error ))return; |
|
| 179 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
| 178 | + if( !empty( $this->error )) { |
|
| 179 | + return; |
|
| 180 | + } |
|
| 181 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
| 182 | + return; |
|
| 183 | + } |
|
| 180 | 184 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
| 181 | 185 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
| 182 | 186 | } |
@@ -186,8 +190,12 @@ discard block |
||
| 186 | 190 | */ |
| 187 | 191 | protected function validateBlacklist() |
| 188 | 192 | { |
| 189 | - if( !empty( $this->error ))return; |
|
| 190 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
| 193 | + if( !empty( $this->error )) { |
|
| 194 | + return; |
|
| 195 | + } |
|
| 196 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
| 197 | + return; |
|
| 198 | + } |
|
| 191 | 199 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
| 192 | 200 | if( $blacklistAction == 'reject' ) { |
| 193 | 201 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -202,9 +210,13 @@ discard block |
||
| 202 | 210 | */ |
| 203 | 211 | protected function validateCustom() |
| 204 | 212 | { |
| 205 | - if( !empty( $this->error ))return; |
|
| 213 | + if( !empty( $this->error )) { |
|
| 214 | + return; |
|
| 215 | + } |
|
| 206 | 216 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
| 207 | - if( $validated === true )return; |
|
| 217 | + if( $validated === true ) { |
|
| 218 | + return; |
|
| 219 | + } |
|
| 208 | 220 | $this->setSessionValues( 'errors', [] ); |
| 209 | 221 | $this->setSessionValues( 'values', $this->request ); |
| 210 | 222 | $this->error = is_string( $validated ) |
@@ -217,8 +229,12 @@ discard block |
||
| 217 | 229 | */ |
| 218 | 230 | protected function validateHoneyPot() |
| 219 | 231 | { |
| 220 | - if( !empty( $this->error ))return; |
|
| 221 | - if( empty( $this->request['gotcha'] ))return; |
|
| 232 | + if( !empty( $this->error )) { |
|
| 233 | + return; |
|
| 234 | + } |
|
| 235 | + if( empty( $this->request['gotcha'] )) { |
|
| 236 | + return; |
|
| 237 | + } |
|
| 222 | 238 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
| 223 | 239 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
| 224 | 240 | } |
@@ -228,9 +244,13 @@ discard block |
||
| 228 | 244 | */ |
| 229 | 245 | protected function validateRecaptcha() |
| 230 | 246 | { |
| 231 | - if( !empty( $this->error ))return; |
|
| 247 | + if( !empty( $this->error )) { |
|
| 248 | + return; |
|
| 249 | + } |
|
| 232 | 250 | $status = $this->getRecaptchaStatus(); |
| 233 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
| 251 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] )) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 234 | 254 | if( $status == static::RECAPTCHA_EMPTY ) { |
| 235 | 255 | $this->setSessionValues( 'recaptcha', 'unset' ); |
| 236 | 256 | $this->recaptchaIsUnset = true; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $this->validateBlacklist(); |
| 68 | 68 | $this->validateAkismet(); |
| 69 | 69 | $this->validateRecaptcha(); |
| 70 | - if( !empty( $this->error )) { |
|
| 70 | + if( !empty($this->error) ) { |
|
| 71 | 71 | $this->setSessionValues( 'message', $this->error ); |
| 72 | 72 | } |
| 73 | 73 | return $this; |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
| 92 | 92 | return static::RECAPTCHA_DISABLED; |
| 93 | 93 | } |
| 94 | - if( empty( $this->request['_recaptcha-token'] )) { |
|
| 95 | - return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 )) |
|
| 94 | + if( empty($this->request['_recaptcha-token']) ) { |
|
| 95 | + return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) ) |
|
| 96 | 96 | ? static::RECAPTCHA_EMPTY |
| 97 | 97 | : static::RECAPTCHA_FAILED; |
| 98 | 98 | } |
@@ -104,17 +104,17 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | protected function getRecaptchaTokenStatus() |
| 106 | 106 | { |
| 107 | - $endpoint = add_query_arg([ |
|
| 107 | + $endpoint = add_query_arg( [ |
|
| 108 | 108 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
| 109 | 109 | 'response' => $this->request['_recaptcha-token'], |
| 110 | 110 | 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
| 111 | 111 | ], static::RECAPTCHA_ENDPOINT ); |
| 112 | - if( is_wp_error( $response = wp_remote_get( $endpoint ))) { |
|
| 112 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
| 113 | 113 | glsr_log()->error( $response->get_error_message() ); |
| 114 | 114 | return static::RECAPTCHA_FAILED; |
| 115 | 115 | } |
| 116 | - $response = json_decode( wp_remote_retrieve_body( $response )); |
|
| 117 | - if( !empty( $response->success )) { |
|
| 116 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 117 | + if( !empty($response->success) ) { |
|
| 118 | 118 | return boolval( $response->success ) |
| 119 | 119 | ? static::RECAPTCHA_VALID |
| 120 | 120 | : static::RECAPTCHA_INVALID; |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $rules = array_intersect_key( |
| 134 | 134 | apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ), |
| 135 | - array_flip( $this->getOption( 'settings.submissions.required', [] )) |
|
| 135 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
| 136 | 136 | ); |
| 137 | - $excluded = explode( ',', glsr_get( $request, 'excluded' )); |
|
| 138 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
| 137 | + $excluded = explode( ',', glsr_get( $request, 'excluded' ) ); |
|
| 138 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | $rules = $this->getValidationRules( $request ); |
| 147 | 147 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
| 148 | - if( empty( $errors )) { |
|
| 148 | + if( empty($errors) ) { |
|
| 149 | 149 | return true; |
| 150 | 150 | } |
| 151 | 151 | $this->setSessionValues( 'errors', $errors ); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
| 163 | 163 | { |
| 164 | 164 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
| 165 | - if( !empty( $loggedMessage )) { |
|
| 165 | + if( !empty($loggedMessage) ) { |
|
| 166 | 166 | glsr_log()->warning( $loggedMessage )->debug( $this->request ); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | protected function validateAkismet() |
| 174 | 174 | { |
| 175 | - if( !empty( $this->error ))return; |
|
| 176 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
| 175 | + if( !empty($this->error) )return; |
|
| 176 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
| 177 | 177 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
| 178 | 178 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
| 179 | 179 | } |
@@ -183,8 +183,8 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | protected function validateBlacklist() |
| 185 | 185 | { |
| 186 | - if( !empty( $this->error ))return; |
|
| 187 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
| 186 | + if( !empty($this->error) )return; |
|
| 187 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
| 188 | 188 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
| 189 | 189 | if( $blacklistAction == 'reject' ) { |
| 190 | 190 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | protected function validateCustom() |
| 201 | 201 | { |
| 202 | - if( !empty( $this->error ))return; |
|
| 202 | + if( !empty($this->error) )return; |
|
| 203 | 203 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
| 204 | 204 | if( $validated === true )return; |
| 205 | 205 | $this->setSessionValues( 'errors', [] ); |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function validateHoneyPot() |
| 216 | 216 | { |
| 217 | - if( !empty( $this->error ))return; |
|
| 218 | - if( empty( $this->request['gotcha'] ))return; |
|
| 217 | + if( !empty($this->error) )return; |
|
| 218 | + if( empty($this->request['gotcha']) )return; |
|
| 219 | 219 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
| 220 | 220 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
| 221 | 221 | } |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | protected function validateRecaptcha() |
| 227 | 227 | { |
| 228 | - if( !empty( $this->error ))return; |
|
| 228 | + if( !empty($this->error) )return; |
|
| 229 | 229 | $status = $this->getRecaptchaStatus(); |
| 230 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
| 230 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) )return; |
|
| 231 | 231 | if( $status == static::RECAPTCHA_EMPTY ) { |
| 232 | 232 | $this->setSessionValues( 'recaptcha', 'unset' ); |
| 233 | 233 | $this->recaptchaIsUnset = true; |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | protected function validateRequest( array $request ) |
| 249 | 249 | { |
| 250 | - if( !$this->isRequestValid( $request )) { |
|
| 250 | + if( !$this->isRequestValid( $request ) ) { |
|
| 251 | 251 | $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
| 252 | 252 | return $request; |
| 253 | 253 | } |
@@ -60,7 +60,9 @@ discard block |
||
| 60 | 60 | public function catchFatalError() |
| 61 | 61 | { |
| 62 | 62 | $error = error_get_last(); |
| 63 | - if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false )return; |
|
| 63 | + if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false ) { |
|
| 64 | + return; |
|
| 65 | + } |
|
| 64 | 66 | glsr_log()->error( $error['message'] ); |
| 65 | 67 | } |
| 66 | 68 | |
@@ -111,7 +113,9 @@ discard block |
||
| 111 | 113 | $filePaths[] = $this->path( $view ); |
| 112 | 114 | $filePaths[] = $this->path( 'views/'.$view ); |
| 113 | 115 | foreach( $filePaths as $file ) { |
| 114 | - if( !file_exists( $file ))continue; |
|
| 116 | + if( !file_exists( $file )) { |
|
| 117 | + continue; |
|
| 118 | + } |
|
| 115 | 119 | return $file; |
| 116 | 120 | } |
| 117 | 121 | } |
@@ -215,7 +219,9 @@ discard block |
||
| 215 | 219 | */ |
| 216 | 220 | public function scheduleCronJob() |
| 217 | 221 | { |
| 218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 222 | + if( wp_next_scheduled( static::CRON_EVENT )) { |
|
| 223 | + return; |
|
| 224 | + } |
|
| 219 | 225 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 220 | 226 | } |
| 221 | 227 | |
@@ -255,7 +261,9 @@ discard block |
||
| 255 | 261 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
| 256 | 262 | || $data['action'] != 'update' |
| 257 | 263 | || $data['type'] != 'plugin' |
| 258 | - )return; |
|
| 264 | + ) { |
|
| 265 | + return; |
|
| 266 | + } |
|
| 259 | 267 | $this->upgrade(); |
| 260 | 268 | } |
| 261 | 269 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function __construct() |
| 34 | 34 | { |
| 35 | 35 | static::$instance = $this; |
| 36 | - $this->file = realpath( trailingslashit( dirname( __DIR__ )).static::ID.'.php' ); |
|
| 36 | + $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' ); |
|
| 37 | 37 | $plugin = get_file_data( $this->file, [ |
| 38 | 38 | 'languages' => 'Domain Path', |
| 39 | 39 | 'name' => 'Plugin Name', |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $constant = $className.'::'.$property; |
| 87 | 87 | return defined( $constant ) |
| 88 | - ? apply_filters( 'site-reviews/const/'.$property, constant( $constant )) |
|
| 88 | + ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) ) |
|
| 89 | 89 | : ''; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function file( $view ) |
| 105 | 105 | { |
| 106 | - $view.= '.php'; |
|
| 106 | + $view .= '.php'; |
|
| 107 | 107 | $filePaths = []; |
| 108 | - if( glsr( Helper::class )->startsWith( 'templates/', $view )) { |
|
| 109 | - $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view )); |
|
| 108 | + if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) { |
|
| 109 | + $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) ); |
|
| 110 | 110 | } |
| 111 | 111 | $filePaths[] = $this->path( $view ); |
| 112 | 112 | $filePaths[] = $this->path( 'views/'.$view ); |
| 113 | 113 | foreach( $filePaths as $file ) { |
| 114 | - if( !file_exists( $file ))continue; |
|
| 114 | + if( !file_exists( $file ) )continue; |
|
| 115 | 115 | return $file; |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getDefaults() |
| 123 | 123 | { |
| 124 | - if( empty( $this->defaults )) { |
|
| 124 | + if( empty($this->defaults) ) { |
|
| 125 | 125 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
| 126 | 126 | $this->upgrade(); |
| 127 | 127 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | 'addons' => 'install_plugins', |
| 138 | 138 | 'settings' => 'manage_options', |
| 139 | 139 | ]; |
| 140 | - return glsr_get( $permissions, $page, $this->constant( 'CAPABILITY' )); |
|
| 140 | + return glsr_get( $permissions, $page, $this->constant( 'CAPABILITY' ) ); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | public function hasPermission( $page = '' ) |
| 147 | 147 | { |
| 148 | 148 | $isAdmin = $this->isAdmin(); |
| 149 | - return !$isAdmin || ( $isAdmin && current_user_can( $this->getPermission( $page ))); |
|
| 149 | + return !$isAdmin || ($isAdmin && current_user_can( $this->getPermission( $page ) )); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | { |
| 175 | 175 | $path = plugin_dir_path( $this->file ); |
| 176 | 176 | if( !$realpath ) { |
| 177 | - $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file )); |
|
| 177 | + $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) ); |
|
| 178 | 178 | } |
| 179 | 179 | $path = trailingslashit( $path ).ltrim( trim( $file ), '/' ); |
| 180 | 180 | return apply_filters( 'site-reviews/path', $path, $file ); |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
| 207 | 207 | $this->reviewTypes = wp_parse_args( $types, [ |
| 208 | 208 | 'local' => __( 'Local', 'site-reviews' ), |
| 209 | - ]); |
|
| 209 | + ] ); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | { |
| 218 | 218 | $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
| 219 | 219 | $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
| 220 | - if( !file_exists( $file )) { |
|
| 220 | + if( !file_exists( $file ) ) { |
|
| 221 | 221 | glsr_log()->error( 'File not found: '.$file ); |
| 222 | 222 | return; |
| 223 | 223 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | public function scheduleCronJob() |
| 233 | 233 | { |
| 234 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 234 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
| 235 | 235 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public function unscheduleCronJob() |
| 251 | 251 | { |
| 252 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
| 252 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public function url( $path = '' ) |
| 283 | 283 | { |
| 284 | - $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
| 284 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
| 285 | 285 | return apply_filters( 'site-reviews/url', $url, $path ); |
| 286 | 286 | } |
| 287 | 287 | } |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | foreach( glsr( ReviewManager::class )->get( $this->args ) as $review ) { |
| 36 | 36 | // Only include critic reviews that have been directly produced by your site, not reviews from third- party sites or syndicated reviews. |
| 37 | 37 | // @see https://developers.google.com/search/docs/data-types/review |
| 38 | - if( $review->review_type != 'local' )continue; |
|
| 38 | + if( $review->review_type != 'local' ) { |
|
| 39 | + continue; |
|
| 40 | + } |
|
| 39 | 41 | $reviews[] = $this->buildReview( $review ); |
| 40 | 42 | } |
| 41 | 43 | if( !empty( $reviews )) { |
@@ -80,7 +82,9 @@ discard block |
||
| 80 | 82 | */ |
| 81 | 83 | public function render() |
| 82 | 84 | { |
| 83 | - if( empty( glsr()->schemas ))return; |
|
| 85 | + if( empty( glsr()->schemas )) { |
|
| 86 | + return; |
|
| 87 | + } |
|
| 84 | 88 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
| 85 | 89 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
| 86 | 90 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -132,7 +136,9 @@ discard block |
||
| 132 | 136 | { |
| 133 | 137 | foreach( $values as $value ) { |
| 134 | 138 | $option = $this->getSchemaOptionValue( $value ); |
| 135 | - if( empty( $option ))continue; |
|
| 139 | + if( empty( $option )) { |
|
| 140 | + continue; |
|
| 141 | + } |
|
| 136 | 142 | $schema->$value( $option ); |
| 137 | 143 | } |
| 138 | 144 | return $schema; |
@@ -242,7 +248,9 @@ discard block |
||
| 242 | 248 | if( $value != $fallback ) { |
| 243 | 249 | return $value; |
| 244 | 250 | } |
| 245 | - if( !is_single() && !is_page() )return; |
|
| 251 | + if( !is_single() && !is_page() ) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 246 | 254 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
| 247 | 255 | if( method_exists( $this, $method )) { |
| 248 | 256 | return $this->$method(); |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | if( $review->review_type != 'local' )continue; |
| 39 | 39 | $reviews[] = $this->buildReview( $review ); |
| 40 | 40 | } |
| 41 | - if( !empty( $reviews )) { |
|
| 41 | + if( !empty($reviews) ) { |
|
| 42 | 42 | array_walk( $reviews, function( &$review ) { |
| 43 | - unset( $review['@context'] ); |
|
| 44 | - unset( $review['itemReviewed'] ); |
|
| 43 | + unset($review['@context']); |
|
| 44 | + unset($review['itemReviewed']); |
|
| 45 | 45 | }); |
| 46 | 46 | $schema['review'] = $reviews; |
| 47 | 47 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function buildSummary( $args = null ) |
| 56 | 56 | { |
| 57 | - if( is_array( $args )) { |
|
| 57 | + if( is_array( $args ) ) { |
|
| 58 | 58 | $this->args = $args; |
| 59 | 59 | } |
| 60 | 60 | $buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' ); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $schema = method_exists( $this, $buildSummary ) |
| 63 | 63 | ? $this->$buildSummary() |
| 64 | 64 | : $this->buildSummaryForCustom(); |
| 65 | - if( !empty( $count )) { |
|
| 65 | + if( !empty($count) ) { |
|
| 66 | 66 | $schema->aggregateRating( |
| 67 | 67 | $this->getSchemaType( 'AggregateRating' ) |
| 68 | 68 | ->ratingValue( $this->getRatingValue() ) |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function render() |
| 82 | 82 | { |
| 83 | - if( empty( glsr()->schemas ))return; |
|
| 83 | + if( empty(glsr()->schemas) )return; |
|
| 84 | 84 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
| 85 | 85 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
| 86 | 86 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
| 87 | - )); |
|
| 87 | + ) ); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | $schemas = glsr()->schemas; |
| 96 | 96 | $schemas[] = $schema; |
| 97 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
| 97 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -104,16 +104,16 @@ discard block |
||
| 104 | 104 | protected function buildReview( $review ) |
| 105 | 105 | { |
| 106 | 106 | $schema = $this->getSchemaType( 'Review' ) |
| 107 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
| 107 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) { |
|
| 108 | 108 | $schema->name( $review->title ); |
| 109 | 109 | }) |
| 110 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
| 110 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) { |
|
| 111 | 111 | $schema->reviewBody( $review->content ); |
| 112 | 112 | }) |
| 113 | - ->datePublished(( new DateTime( $review->date ))) |
|
| 114 | - ->author( $this->getSchemaType( 'Person' )->name( $review->author )) |
|
| 115 | - ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ))); |
|
| 116 | - if( !empty( $review->rating )) { |
|
| 113 | + ->datePublished( (new DateTime( $review->date )) ) |
|
| 114 | + ->author( $this->getSchemaType( 'Person' )->name( $review->author ) ) |
|
| 115 | + ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) ); |
|
| 116 | + if( !empty($review->rating) ) { |
|
| 117 | 117 | $schema->reviewRating( |
| 118 | 118 | $this->getSchemaType( 'Rating' ) |
| 119 | 119 | ->ratingValue( $review->rating ) |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | foreach( $values as $value ) { |
| 134 | 134 | $option = $this->getSchemaOptionValue( $value ); |
| 135 | - if( empty( $option ))continue; |
|
| 135 | + if( empty($option) )continue; |
|
| 136 | 136 | $schema->$value( $option ); |
| 137 | 137 | } |
| 138 | 138 | return $schema; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | return $this->buildSchemaValues( $this->getSchemaType(), [ |
| 147 | 147 | 'description', 'image', 'name', 'url', |
| 148 | - ]); |
|
| 148 | + ] ); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | return $this->buildSchemaValues( $this->buildSummaryForCustom(), [ |
| 157 | 157 | 'address', 'priceRange', 'telephone', |
| 158 | - ]); |
|
| 158 | + ] ); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | $offerType = $this->getSchemaOption( 'offerType', 'AggregateOffer' ); |
| 167 | 167 | $offers = $this->buildSchemaValues( $this->getSchemaType( $offerType ), [ |
| 168 | 168 | 'highPrice', 'lowPrice', 'price', 'priceCurrency', |
| 169 | - ]); |
|
| 169 | + ] ); |
|
| 170 | 170 | return $this->buildSummaryForCustom() |
| 171 | - ->doIf( !empty( $offers->getProperties() ), function( $schema ) use( $offers ) { |
|
| 171 | + ->doIf( !empty($offers->getProperties()), function( $schema ) use($offers) { |
|
| 172 | 172 | $schema->offers( $offers ); |
| 173 | 173 | }) |
| 174 | 174 | ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' ); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | protected function getRatingCounts() |
| 181 | 181 | { |
| 182 | - if( !isset( $this->ratingCounts )) { |
|
| 182 | + if( !isset($this->ratingCounts) ) { |
|
| 183 | 183 | $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $this->args ); |
| 184 | 184 | } |
| 185 | 185 | return $this->ratingCounts; |
@@ -201,14 +201,14 @@ discard block |
||
| 201 | 201 | protected function getSchemaOption( $option, $fallback ) |
| 202 | 202 | { |
| 203 | 203 | $option = strtolower( $option ); |
| 204 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
| 204 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
| 205 | 205 | return $schemaOption; |
| 206 | 206 | } |
| 207 | 207 | $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option ); |
| 208 | - if( is_array( $setting )) { |
|
| 208 | + if( is_array( $setting ) ) { |
|
| 209 | 209 | return $this->getSchemaOptionDefault( $setting, $fallback ); |
| 210 | 210 | } |
| 211 | - return !empty( $setting ) |
|
| 211 | + return !empty($setting) |
|
| 212 | 212 | ? $setting |
| 213 | 213 | : $fallback; |
| 214 | 214 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $setting = wp_parse_args( $setting, [ |
| 223 | 223 | 'custom' => '', |
| 224 | 224 | 'default' => $fallback, |
| 225 | - ]); |
|
| 225 | + ] ); |
|
| 226 | 226 | return $setting['default'] != 'custom' |
| 227 | 227 | ? $setting['default'] |
| 228 | 228 | : $setting['custom']; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | if( !is_single() && !is_page() )return; |
| 243 | 243 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
| 244 | - if( method_exists( $this, $method )) { |
|
| 244 | + if( method_exists( $this, $method ) ) { |
|
| 245 | 245 | return $this->$method(); |
| 246 | 246 | } |
| 247 | 247 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | protected function getSchemaType( $type = null ) |
| 254 | 254 | { |
| 255 | - if( !is_string( $type )) { |
|
| 255 | + if( !is_string( $type ) ) { |
|
| 256 | 256 | $type = $this->getSchemaOption( 'type', 'LocalBusiness' ); |
| 257 | 257 | } |
| 258 | 258 | $className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' ); |
@@ -267,11 +267,11 @@ discard block |
||
| 267 | 267 | protected function getThingDescription() |
| 268 | 268 | { |
| 269 | 269 | $post = get_post(); |
| 270 | - if( !( $post instanceof WP_Post )) { |
|
| 270 | + if( !($post instanceof WP_Post) ) { |
|
| 271 | 271 | return ''; |
| 272 | 272 | } |
| 273 | - $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt )); |
|
| 274 | - return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 )); |
|
| 273 | + $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) ); |
|
| 274 | + return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) ); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | public function __construct( array $values = [] ) |
| 16 | 16 | { |
| 17 | 17 | $this->values = $values; |
| 18 | - parent::__construct( $values, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
| 18 | + parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function __toString() |
| 35 | 35 | { |
| 36 | - if( empty( $this->values ))return; |
|
| 36 | + if( empty($this->values) )return; |
|
| 37 | 37 | return glsr( Template::class )->build( 'templates/review', [ |
| 38 | 38 | 'context' => $this->values, |
| 39 | - ]); |
|
| 39 | + ] ); |
|
| 40 | 40 | } |
| 41 | 41 | } |
@@ -33,7 +33,9 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | public function __toString() |
| 35 | 35 | { |
| 36 | - if( empty( $this->values ))return; |
|
| 36 | + if( empty( $this->values )) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 37 | 39 | return glsr( Template::class )->build( 'templates/review', [ |
| 38 | 40 | 'context' => $this->values, |
| 39 | 41 | ]); |