@@ -3,7 +3,9 @@ |
||
| 3 | 3 | defined( 'WP_UNINSTALL_PLUGIN' ) || die; |
| 4 | 4 | |
| 5 | 5 | require_once __DIR__.'/site-reviews.php'; |
| 6 | -if( !GL_Plugin_Check_v2::isValid( array( 'wordpress' => '4.7.0' )))return; |
|
| 6 | +if( !GL_Plugin_Check_v2::isValid( array( 'wordpress' => '4.7.0' ))) { |
|
| 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_v2' )) { |
| 22 | 22 | require_once __DIR__.'/activate.php'; |
| 23 | 23 | } |
| 24 | -if( GL_Plugin_Check_v2::shouldDeactivate( __FILE__, array( 'wordpress' => '4.7.0' )))return; |
|
| 24 | +if( GL_Plugin_Check_v2::shouldDeactivate( __FILE__, array( 'wordpress' => '4.7.0' ))) { |
|
| 25 | + return; |
|
| 26 | +} |
|
| 25 | 27 | require_once __DIR__.'/autoload.php'; |
| 26 | 28 | require_once __DIR__.'/helpers.php'; |
| 27 | 29 | |
@@ -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 | // @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 | ); |
@@ -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 | } |
@@ -40,10 +42,16 @@ discard block |
||
| 40 | 42 | */ |
| 41 | 43 | public function routePublicPostRequest() |
| 42 | 44 | { |
| 43 | - if( is_admin() )return; |
|
| 45 | + if( is_admin() ) { |
|
| 46 | + return; |
|
| 47 | + } |
|
| 44 | 48 | $request = $this->getRequest(); |
| 45 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 46 | - if( !$this->isValidPublicNonce( $request ))return; |
|
| 49 | + if( !$this->isValidPostRequest( $request )) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 52 | + if( !$this->isValidPublicNonce( $request )) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 47 | 55 | $this->routeRequest( 'public', $request['action'], $request ); |
| 48 | 56 | } |
| 49 | 57 | |
@@ -52,7 +60,9 @@ discard block |
||
| 52 | 60 | */ |
| 53 | 61 | protected function checkAjaxNonce( array $request ) |
| 54 | 62 | { |
| 55 | - if( !is_user_logged_in() )return; |
|
| 63 | + if( !is_user_logged_in() ) { |
|
| 64 | + return; |
|
| 65 | + } |
|
| 56 | 66 | if( !isset( $request['nonce'] )) { |
| 57 | 67 | glsr_log()->error( 'The AJAX request must include a nonce' )->info( $request ); |
| 58 | 68 | wp_die(); |