@@ -28,7 +28,7 @@ |
||
28 | 28 | register_rest_route( $this->namespace, '/types', [ |
29 | 29 | 'callback' => [$this, 'get_types'], |
30 | 30 | 'methods' => Server::READABLE, |
31 | - ]); |
|
31 | + ] ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -33,6 +33,6 @@ |
||
33 | 33 | 'permission_callback' => [$this, 'get_items_permissions_check'], |
34 | 34 | ], |
35 | 35 | 'schema' => [$this, 'get_public_item_schema'], |
36 | - ]); |
|
36 | + ] ); |
|
37 | 37 | } |
38 | 38 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | 'title' => 'Images', |
18 | 18 | ], |
19 | 19 | 'plugin' => 'site-reviews-images/site-reviews-images.php', |
20 | - ]); |
|
20 | + ] ); |
|
21 | 21 | $template->render( 'partials/addons/addon', [ |
22 | 22 | 'context' => [ |
23 | 23 | 'description' => __( 'Sync your Tripadvisor reviews to your website and manage them with Site Reviews.', 'site-reviews' ), |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'title' => 'Tripadvisor Reviews', |
27 | 27 | ], |
28 | 28 | 'plugin' => 'site-reviews-tripadvisor/site-reviews-tripadvisor.php', |
29 | - ]); |
|
29 | + ] ); |
|
30 | 30 | ?> |
31 | 31 | </div> |
32 | 32 | </div> |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | 'savePending' => __( 'Save as Unapproved', 'site-reviews' ), |
18 | 18 | 'published' => __( 'Approved', 'site-reviews' ), |
19 | 19 | ]; |
20 | - if( $this->canModifyTranslation() && isset( $wp_scripts->registered['post']->extra['data'] )) { |
|
20 | + if( $this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data']) ) { |
|
21 | 21 | $l10n = &$wp_scripts->registered['post']->extra['data']; |
22 | 22 | foreach( $strings as $search => $replace ) { |
23 | 23 | $l10n = preg_replace( '/("'.$search.'":")([^"]+)/', "$1".$replace, $l10n ); |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function filterPostStatusLabels( $translation, $text, $domain ) |
35 | 35 | { |
36 | - if( $this->canModifyTranslation( $domain )) { |
|
36 | + if( $this->canModifyTranslation( $domain ) ) { |
|
37 | 37 | $replacements = $this->getStatusLabels(); |
38 | - if( array_key_exists( $text, $replacements )) { |
|
38 | + if( array_key_exists( $text, $replacements ) ) { |
|
39 | 39 | $translation = $replacements[$text]; |
40 | 40 | } |
41 | 41 | } |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | public function filterUpdateMessages( array $messages ) |
49 | 49 | { |
50 | 50 | $post = get_post(); |
51 | - if( !( $post instanceof WP_Post ))return; |
|
51 | + if( !($post instanceof WP_Post) )return; |
|
52 | 52 | $strings = $this->getReviewLabels(); |
53 | 53 | $restored = filter_input( INPUT_GET, 'revision' ); |
54 | - if( $revisionTitle = wp_post_revision_title( intval( $restored ), false )) { |
|
54 | + if( $revisionTitle = wp_post_revision_title( intval( $restored ), false ) ) { |
|
55 | 55 | $restored = sprintf( $strings['restored'], $revisionTitle ); |
56 | 56 | } |
57 | - $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date )); |
|
58 | - $messages[ Application::POST_TYPE ] = [ |
|
57 | + $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) ); |
|
58 | + $messages[Application::POST_TYPE] = [ |
|
59 | 59 | 1 => $strings['updated'], |
60 | 60 | 4 => $strings['updated'], |
61 | 61 | 5 => $restored, |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | protected function canModifyTranslation( $domain = 'default' ) |
79 | 79 | { |
80 | - if( $domain != 'default' || empty( glsr_current_screen()->base )) { |
|
80 | + if( $domain != 'default' || empty(glsr_current_screen()->base) ) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | return glsr_current_screen()->post_type == Application::POST_TYPE |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | protected function getStatusLabels() |
113 | 113 | { |
114 | 114 | static $labels; |
115 | - if( empty( $labels )) { |
|
115 | + if( empty($labels) ) { |
|
116 | 116 | $labels = [ |
117 | 117 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
118 | 118 | 'Pending Review' => __( 'Unapproved', 'site-reviews' ), |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function handle( Command $command ) |
15 | 15 | { |
16 | - $postId = wp_update_post([ |
|
16 | + $postId = wp_update_post( [ |
|
17 | 17 | 'ID' => $command->id, |
18 | 18 | 'post_status' => $command->status, |
19 | - ]); |
|
20 | - if( is_wp_error( $postId )) { |
|
19 | + ] ); |
|
20 | + if( is_wp_error( $postId ) ) { |
|
21 | 21 | glsr_log()->error( $postId->get_error_message() ); |
22 | 22 | return []; |
23 | 23 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | 'aria-label' => '“'.esc_attr( $title ).'” ('.__( 'Edit', 'site-reviews' ).')', |
40 | 40 | 'class' => 'row-title', |
41 | 41 | 'href' => get_edit_post_link( $postId ), |
42 | - ]); |
|
42 | + ] ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | protected function getPostState( $postId ) |
50 | 50 | { |
51 | 51 | ob_start(); |
52 | - _post_states( get_post( $postId )); |
|
52 | + _post_states( get_post( $postId ) ); |
|
53 | 53 | return ob_get_clean(); |
54 | 54 | } |
55 | 55 | |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | protected function getStatusLinks() |
60 | 60 | { |
61 | 61 | global $avail_post_stati; |
62 | - require_once( ABSPATH.'wp-admin/includes/class-wp-posts-list-table.php' ); |
|
62 | + require_once(ABSPATH.'wp-admin/includes/class-wp-posts-list-table.php'); |
|
63 | 63 | $hookName = 'edit-'.Application::POST_TYPE; |
64 | 64 | set_current_screen( $hookName ); |
65 | 65 | $avail_post_stati = get_available_post_statuses( Application::POST_TYPE ); |
66 | 66 | $table = new \WP_Posts_List_Table( ['screen' => $hookName] ); |
67 | 67 | $views = apply_filters( 'views_'.$hookName, $table->get_views() ); // uses compat get_views() |
68 | - if( empty( $views ))return; |
|
68 | + if( empty($views) )return; |
|
69 | 69 | foreach( $views as $class => $view ) { |
70 | 70 | $views[$class] = "\t<li class='$class'>$view"; |
71 | 71 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $className = str_replace( '.php', '', $file ); |
25 | 25 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
26 | 26 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
27 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
27 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ) )return; |
|
28 | 28 | glsr( 'Modules\\Upgrader\\'.$className ); |
29 | 29 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
30 | 30 | }); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $this->setReviewCounts(); |
42 | 42 | $this->updateVersionFrom( $version ); |
43 | 43 | } |
44 | - else if( !glsr( OptionManager::class )->get( 'last_review_count', false )) { |
|
44 | + else if( !glsr( OptionManager::class )->get( 'last_review_count', false ) ) { |
|
45 | 45 | $this->setReviewCounts(); |
46 | 46 | } |
47 | 47 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | foreach( $this->rules as $attribute => $rules ) { |
75 | 75 | foreach( $rules as $rule ) { |
76 | 76 | $this->validateAttribute( $attribute, $rule ); |
77 | - if( $this->shouldStopValidating( $attribute ))break; |
|
77 | + if( $this->shouldStopValidating( $attribute ) )break; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | return $this->errors; |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function validateAttribute( $attribute, $rule ) |
91 | 91 | { |
92 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
92 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
93 | 93 | if( $rule == '' )return; |
94 | 94 | $value = $this->getValue( $attribute ); |
95 | - if( !method_exists( $this, $method = 'validate'.$rule )) { |
|
95 | + if( !method_exists( $this, $method = 'validate'.$rule ) ) { |
|
96 | 96 | throw new BadMethodCallException( "Method [$method] does not exist." ); |
97 | 97 | } |
98 | - if( !$this->$method( $value, $attribute, $parameters )) { |
|
98 | + if( !$this->$method( $value, $attribute, $parameters ) ) { |
|
99 | 99 | $this->addFailure( $attribute, $rule, $parameters ); |
100 | 100 | } |
101 | 101 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | protected function getMessage( $attribute, $rule, array $parameters ) |
146 | 146 | { |
147 | - if( in_array( $rule, $this->sizeRules )) { |
|
147 | + if( in_array( $rule, $this->sizeRules ) ) { |
|
148 | 148 | return $this->getSizeMessage( $attribute, $rule, $parameters ); |
149 | 149 | } |
150 | 150 | $lowerRule = glsr( Helper::class )->snakeCase( $rule ); |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | */ |
160 | 160 | protected function getRule( $attribute, $rules ) |
161 | 161 | { |
162 | - if( !array_key_exists( $attribute, $this->rules ))return; |
|
162 | + if( !array_key_exists( $attribute, $this->rules ) )return; |
|
163 | 163 | $rules = (array)$rules; |
164 | 164 | foreach( $this->rules[$attribute] as $rule ) { |
165 | - list( $rule, $parameters ) = $this->parseRule( $rule ); |
|
166 | - if( in_array( $rule, $rules )) { |
|
165 | + list($rule, $parameters) = $this->parseRule( $rule ); |
|
166 | + if( in_array( $rule, $rules ) ) { |
|
167 | 167 | return [$rule, $parameters]; |
168 | 168 | } |
169 | 169 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | if( is_numeric( $value ) && $hasNumeric ) { |
182 | 182 | return $value; |
183 | 183 | } |
184 | - else if( is_array( $value )) { |
|
184 | + else if( is_array( $value ) ) { |
|
185 | 185 | return count( $value ); |
186 | 186 | } |
187 | 187 | return function_exists( 'mb_strlen' ) |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function getValue( $attribute ) |
211 | 211 | { |
212 | - if( isset( $this->data[$attribute] )) { |
|
212 | + if( isset($this->data[$attribute]) ) { |
|
213 | 213 | return $this->data[$attribute]; |
214 | 214 | } |
215 | 215 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | protected function hasRule( $attribute, $rules ) |
224 | 224 | { |
225 | - return !is_null( $this->getRule( $attribute, $rules )); |
|
225 | + return !is_null( $this->getRule( $attribute, $rules ) ); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | { |
261 | 261 | $parameters = []; |
262 | 262 | if( strpos( $rule, ':' ) !== false ) { |
263 | - list( $rule, $parameter ) = explode( ':', $rule, 2 ); |
|
263 | + list($rule, $parameter) = explode( ':', $rule, 2 ); |
|
264 | 264 | $parameters = $this->parseParameters( $rule, $parameter ); |
265 | 265 | } |
266 | 266 | $rule = glsr( Helper::class )->camelCase( $rule ); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | protected function shouldStopValidating( $attribute ) |
290 | 290 | { |
291 | 291 | return $this->hasRule( $attribute, $this->implicitRules ) |
292 | - && isset( $this->failedRules[$attribute] ) |
|
292 | + && isset($this->failedRules[$attribute]) |
|
293 | 293 | && array_intersect( array_keys( $this->failedRules[$attribute] ), $this->implicitRules ); |
294 | 294 | } |
295 | 295 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | protected function translator( $key, array $parameters ) |
303 | 303 | { |
304 | 304 | $strings = glsr( ValidationStringsDefaults::class )->defaults(); |
305 | - if( isset( $strings[$key] )) { |
|
305 | + if( isset($strings[$key]) ) { |
|
306 | 306 | return $this->replace( $strings[$key], $parameters ); |
307 | 307 | } |
308 | 308 | return "error"; |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | public function defaults() |
14 | 14 | { |
15 | 15 | $settings = $this->settings(); |
16 | - $defaults = array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' )); |
|
16 | + $defaults = array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' ) ); |
|
17 | 17 | return wp_parse_args( $defaults, [ |
18 | 18 | 'version' => '', |
19 | 19 | 'version_upgraded_from' => '', |
20 | - ]); |
|
20 | + ] ); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function settings() |
48 | 48 | { |
49 | - $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' )); |
|
49 | + $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' ) ); |
|
50 | 50 | return $this->normalize( $settings ); |
51 | 51 | } |
52 | 52 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | protected function normalize( array $settings ) |
57 | 57 | { |
58 | 58 | array_walk( $settings, function( &$setting ) { |
59 | - if( isset( $setting['default'] ))return; |
|
59 | + if( isset($setting['default']) )return; |
|
60 | 60 | $setting['default'] = ''; |
61 | 61 | }); |
62 | 62 | return $settings; |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | { |
50 | 50 | $average = array_sum( $ratingCounts ); |
51 | 51 | if( $average > 0 ) { |
52 | - $average = round( $this->getTotalSum( $ratingCounts ) / $average, intval( $roundBy )); |
|
52 | + $average = round( $this->getTotalSum( $ratingCounts ) / $average, intval( $roundBy ) ); |
|
53 | 53 | } |
54 | - return floatval( apply_filters( 'site-reviews/rating/average', $average, $ratingCounts )); |
|
54 | + return floatval( apply_filters( 'site-reviews/rating/average', $average, $ratingCounts ) ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | $z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
74 | 74 | $phat = 1 * $upDownCounts[1] / $numRatings; |
75 | - return ( $phat + $z * $z / ( 2 * $numRatings ) - $z * sqrt(( $phat * ( 1 - $phat ) + $z * $z / ( 4 * $numRatings )) / $numRatings )) / ( 1 + $z * $z / $numRatings ); |
|
75 | + return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | { |
91 | 91 | $total = array_sum( $ratingCounts ); |
92 | 92 | foreach( $ratingCounts as $index => $count ) { |
93 | - if( empty( $count ))continue; |
|
93 | + if( empty($count) )continue; |
|
94 | 94 | $ratingCounts[$index] = $count / $total * 100; |
95 | 95 | } |
96 | 96 | return $this->getRoundedPercentages( $ratingCounts ); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $this->getRankingUsingImdb( $ratingCounts ), |
106 | 106 | $ratingCounts, |
107 | 107 | $this |
108 | - )); |
|
108 | + ) ); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | $avgRating = $this->getAverage( $ratingCounts ); |
124 | 124 | // Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error. |
125 | 125 | // This could also be the average score of all items instead of a fixed value. |
126 | - $bayesMean = ( $confidencePercentage / 100 ) * static::MAX_RATING; // prior, 70% = 3.5 |
|
126 | + $bayesMean = ($confidencePercentage / 100) * static::MAX_RATING; // prior, 70% = 3.5 |
|
127 | 127 | // Represents the number of ratings expected to begin observing a pattern that would put confidence in the prior. |
128 | 128 | $bayesMinimal = 10; // confidence |
129 | 129 | $numOfReviews = array_sum( $ratingCounts ); |
130 | 130 | return $avgRating > 0 |
131 | - ? (( $bayesMinimal * $bayesMean ) + ( $avgRating * $numOfReviews )) / ( $bayesMinimal + $numOfReviews ) |
|
131 | + ? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews) |
|
132 | 132 | : 0; |
133 | 133 | } |
134 | 134 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $weight = $this->getWeight( $ratingCounts, $ratingCountsSum ); |
149 | 149 | $weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true ); |
150 | 150 | $zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
151 | - return $weight - $zScore * sqrt(( $weightPow2 - pow( $weight, 2 )) / ( $ratingCountsSum + 1 )); |
|
151 | + return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -168,14 +168,14 @@ discard block |
||
168 | 168 | $remainders = glsr_array_column( $percentages, 'remainder' ); |
169 | 169 | array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages ); |
170 | 170 | $i = 0; |
171 | - if( array_sum( glsr_array_column( $percentages, 'percent' )) > 0 ) { |
|
172 | - while( array_sum( glsr_array_column( $percentages, 'percent' )) < $totalPercent ) { |
|
171 | + if( array_sum( glsr_array_column( $percentages, 'percent' ) ) > 0 ) { |
|
172 | + while( array_sum( glsr_array_column( $percentages, 'percent' ) ) < $totalPercent ) { |
|
173 | 173 | $percentages[$i]['percent']++; |
174 | 174 | $i++; |
175 | 175 | } |
176 | 176 | } |
177 | 177 | array_multisort( $indexes, SORT_DESC, $percentages ); |
178 | - return array_combine( $indexes, glsr_array_column( $percentages, 'percent' )); |
|
178 | + return array_combine( $indexes, glsr_array_column( $percentages, 'percent' ) ); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | */ |
184 | 184 | protected function getTotalSum( array $ratingCounts ) |
185 | 185 | { |
186 | - return array_reduce( array_keys( $ratingCounts ), function( $carry, $index ) use( $ratingCounts ) { |
|
187 | - return $carry + ( $index * $ratingCounts[$index] ); |
|
186 | + return array_reduce( array_keys( $ratingCounts ), function( $carry, $index ) use($ratingCounts) { |
|
187 | + return $carry + ($index * $ratingCounts[$index]); |
|
188 | 188 | }); |
189 | 189 | } |
190 | 190 | |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false ) |
197 | 197 | { |
198 | 198 | return array_reduce( array_keys( $ratingCounts ), |
199 | - function( $count, $rating ) use( $ratingCounts, $ratingCountsSum, $powerOf2 ) { |
|
199 | + function( $count, $rating ) use($ratingCounts, $ratingCountsSum, $powerOf2) { |
|
200 | 200 | $ratingLevel = $powerOf2 |
201 | 201 | ? pow( $rating, 2 ) |
202 | 202 | : $rating; |
203 | - return $count + ( $ratingLevel * ( $ratingCounts[$rating] + 1 )) / $ratingCountsSum; |
|
203 | + return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum; |
|
204 | 204 | } |
205 | 205 | ); |
206 | 206 | } |