@@ -57,7 +57,7 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | protected function isReviewEditable() |
| 59 | 59 | { |
| 60 | - $postId = intval( filter_input( INPUT_GET, 'post' )); |
|
| 60 | + $postId = intval( filter_input( INPUT_GET, 'post' ) ); |
|
| 61 | 61 | return $postId > 0 |
| 62 | 62 | && get_post_meta( $postId, 'review_type', true ) == 'local' |
| 63 | 63 | && $this->isReviewEditor(); |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function removeAutosave() |
| 41 | 41 | { |
| 42 | - if( !$this->isReviewEditor() || $this->isReviewEditable() )return; |
|
| 42 | + if( !$this->isReviewEditor() || $this->isReviewEditable() ) { |
|
| 43 | + return; |
|
| 44 | + } |
|
| 43 | 45 | wp_deregister_script( 'autosave' ); |
| 44 | 46 | } |
| 45 | 47 | |
@@ -56,7 +58,9 @@ discard block |
||
| 56 | 58 | */ |
| 57 | 59 | public function removePostTypeSupport() |
| 58 | 60 | { |
| 59 | - if( !$this->isReviewEditor() || $this->isReviewEditable() )return; |
|
| 61 | + if( !$this->isReviewEditor() || $this->isReviewEditable() ) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 60 | 64 | remove_post_type_support( Application::POST_TYPE, 'title' ); |
| 61 | 65 | remove_post_type_support( Application::POST_TYPE, 'editor' ); |
| 62 | 66 | } |
@@ -72,7 +72,9 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function send() |
| 74 | 74 | { |
| 75 | - if( !$this->message || !$this->subject || !$this->to )return; |
|
| 75 | + if( !$this->message || !$this->subject || !$this->to ) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 76 | 78 | $sent = wp_mail( |
| 77 | 79 | $this->to, |
| 78 | 80 | $this->subject, |
@@ -90,8 +92,12 @@ discard block |
||
| 90 | 92 | */ |
| 91 | 93 | public function buildPlainTextMessage( PHPMailer $phpmailer ) |
| 92 | 94 | { |
| 93 | - if( empty( $this->email ))return; |
|
| 94 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 95 | + if( empty( $this->email )) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 98 | + if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody )) { |
|
| 99 | + return; |
|
| 100 | + } |
|
| 95 | 101 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 96 | 102 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 97 | 103 | } |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function buildPlainTextMessage( PHPMailer $phpmailer ) |
| 92 | 92 | { |
| 93 | - if( empty( $this->email ))return; |
|
| 94 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 93 | + if( empty($this->email) )return; |
|
| 94 | + if( $phpmailer->ContentType === 'text/plain' || !empty($phpmailer->AltBody) )return; |
|
| 95 | 95 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 96 | 96 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 97 | 97 | } |
@@ -104,10 +104,10 @@ discard block |
||
| 104 | 104 | $allowed = [ |
| 105 | 105 | 'bcc', 'cc', 'from', 'reply-to', |
| 106 | 106 | ]; |
| 107 | - $headers = array_intersect_key( $this->email, array_flip( $allowed )); |
|
| 107 | + $headers = array_intersect_key( $this->email, array_flip( $allowed ) ); |
|
| 108 | 108 | $headers = array_filter( $headers ); |
| 109 | 109 | foreach( $headers as $key => $value ) { |
| 110 | - unset( $headers[$key] ); |
|
| 110 | + unset($headers[$key]); |
|
| 111 | 111 | $headers[] = $key.': '.$value; |
| 112 | 112 | } |
| 113 | 113 | $headers[] = 'Content-Type: text/html'; |
@@ -119,16 +119,16 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | protected function buildHtmlMessage() |
| 121 | 121 | { |
| 122 | - $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' )); |
|
| 123 | - if( !empty( $template )) { |
|
| 122 | + $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) ); |
|
| 123 | + if( !empty($template) ) { |
|
| 124 | 124 | $message = glsr( Template::class )->interpolate( $template, $this->email['template-tags'] ); |
| 125 | 125 | } |
| 126 | 126 | else if( $this->email['template'] ) { |
| 127 | 127 | $message = glsr( Template::class )->build( 'templates/'.$this->email['template'], [ |
| 128 | 128 | 'context' => $this->email['template-tags'], |
| 129 | - ]); |
|
| 129 | + ] ); |
|
| 130 | 130 | } |
| 131 | - if( !isset( $message )) { |
|
| 131 | + if( !isset($message) ) { |
|
| 132 | 132 | $message = $this->email['message']; |
| 133 | 133 | } |
| 134 | 134 | $message = $this->email['before'].$message.$this->email['after']; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $message = str_replace( ']]>', ']]>', $message ); |
| 140 | 140 | $message = glsr( Template::class )->build( 'partials/email/index', [ |
| 141 | 141 | 'context' => ['message' => $message], |
| 142 | - ]); |
|
| 142 | + ] ); |
|
| 143 | 143 | return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this ); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | protected function normalize( array $email = [] ) |
| 150 | 150 | { |
| 151 | 151 | $email = shortcode_atts( glsr( EmailDefaults::class )->defaults(), $email ); |
| 152 | - if( empty( $email['reply-to'] )) { |
|
| 152 | + if( empty($email['reply-to']) ) { |
|
| 153 | 153 | $email['reply-to'] = $email['from']; |
| 154 | 154 | } |
| 155 | 155 | $this->email = apply_filters( 'site-reviews/email/compose', $email, $this ); |
@@ -212,7 +212,9 @@ discard block |
||
| 212 | 212 | $newParents = $parents; |
| 213 | 213 | foreach( $parents as $parent ) { |
| 214 | 214 | $parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ ); |
| 215 | - if( !class_exists( $parentClass ))continue; |
|
| 215 | + if( !class_exists( $parentClass )) { |
|
| 216 | + continue; |
|
| 217 | + } |
|
| 216 | 218 | $newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents )); |
| 217 | 219 | } |
| 218 | 220 | return array_values( array_unique( $newParents )); |
@@ -226,7 +228,9 @@ discard block |
||
| 226 | 228 | $parents = $this->getParents(); |
| 227 | 229 | foreach( $parents as $parent ) { |
| 228 | 230 | $parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ ); |
| 229 | - if( !class_exists( $parentClass ))continue; |
|
| 231 | + if( !class_exists( $parentClass )) { |
|
| 232 | + continue; |
|
| 233 | + } |
|
| 230 | 234 | $this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed ))); |
| 231 | 235 | } |
| 232 | 236 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function __call( $method, array $arguments ) |
| 41 | 41 | { |
| 42 | - $value = isset( $arguments[0] ) |
|
| 42 | + $value = isset($arguments[0]) |
|
| 43 | 43 | ? $arguments[0] |
| 44 | 44 | : ''; |
| 45 | 45 | return $this->setProperty( $method, $value ); |
@@ -96,9 +96,9 @@ discard block |
||
| 96 | 96 | * @param mixed $default |
| 97 | 97 | * @return mixed |
| 98 | 98 | */ |
| 99 | - public function getProperty( $property, $default = null) |
|
| 99 | + public function getProperty( $property, $default = null ) |
|
| 100 | 100 | { |
| 101 | - return isset( $this->properties[$property] ) |
|
| 101 | + return isset($this->properties[$property]) |
|
| 102 | 102 | ? $this->properties[$property] |
| 103 | 103 | : $default; |
| 104 | 104 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function offsetUnset( $offset ) |
| 168 | 168 | { |
| 169 | - unset( $this->properties[$offset] ); |
|
| 169 | + unset($this->properties[$offset]); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -212,16 +212,16 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | protected function getParents( $parents = null ) |
| 214 | 214 | { |
| 215 | - if( !isset( $parents )) { |
|
| 215 | + if( !isset($parents) ) { |
|
| 216 | 216 | $parents = $this->parents; |
| 217 | 217 | } |
| 218 | 218 | $newParents = $parents; |
| 219 | 219 | foreach( $parents as $parent ) { |
| 220 | 220 | $parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ ); |
| 221 | - if( !class_exists( $parentClass ))continue; |
|
| 222 | - $newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents )); |
|
| 221 | + if( !class_exists( $parentClass ) )continue; |
|
| 222 | + $newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents ) ); |
|
| 223 | 223 | } |
| 224 | - return array_values( array_unique( $newParents )); |
|
| 224 | + return array_values( array_unique( $newParents ) ); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -232,8 +232,8 @@ discard block |
||
| 232 | 232 | $parents = $this->getParents(); |
| 233 | 233 | foreach( $parents as $parent ) { |
| 234 | 234 | $parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ ); |
| 235 | - if( !class_exists( $parentClass ))continue; |
|
| 236 | - $this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed ))); |
|
| 235 | + if( !class_exists( $parentClass ) )continue; |
|
| 236 | + $this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed ) ) ); |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
@@ -243,17 +243,17 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | protected function serializeProperty( $property ) |
| 245 | 245 | { |
| 246 | - if( is_array( $property )) { |
|
| 246 | + if( is_array( $property ) ) { |
|
| 247 | 247 | return array_map( [$this, 'serializeProperty'], $property ); |
| 248 | 248 | } |
| 249 | 249 | if( $property instanceof Type ) { |
| 250 | 250 | $property = $property->toArray(); |
| 251 | - unset( $property['@context'] ); |
|
| 251 | + unset($property['@context']); |
|
| 252 | 252 | } |
| 253 | 253 | if( $property instanceof DateTimeInterface ) { |
| 254 | 254 | $property = $property->format( DateTime::ATOM ); |
| 255 | 255 | } |
| 256 | - if( is_object( $property )) { |
|
| 256 | + if( is_object( $property ) ) { |
|
| 257 | 257 | throw new InvalidProperty(); |
| 258 | 258 | } |
| 259 | 259 | return $property; |
@@ -91,7 +91,9 @@ discard block |
||
| 91 | 91 | get_mu_plugins(), |
| 92 | 92 | get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
| 93 | 93 | ); |
| 94 | - if( empty( $plugins ))return; |
|
| 94 | + if( empty( $plugins )) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 95 | 97 | return $this->normalizePluginList( $plugins ); |
| 96 | 98 | } |
| 97 | 99 | |
@@ -100,7 +102,9 @@ discard block |
||
| 100 | 102 | */ |
| 101 | 103 | public function getMultisitePluginDetails() |
| 102 | 104 | { |
| 103 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
| 105 | + if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] ))) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 104 | 108 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
| 105 | 109 | } |
| 106 | 110 | |
@@ -157,7 +161,9 @@ discard block |
||
| 157 | 161 | ksort( $settings ); |
| 158 | 162 | $details = []; |
| 159 | 163 | foreach( $settings as $key => $value ) { |
| 160 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
| 164 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key )) { |
|
| 165 | + continue; |
|
| 166 | + } |
|
| 161 | 167 | $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
| 162 | 168 | $details[$key] = $value; |
| 163 | 169 | } |
@@ -230,7 +236,9 @@ discard block |
||
| 230 | 236 | 'WPE_APIKEY' => 'WP Engine', |
| 231 | 237 | ]; |
| 232 | 238 | foreach( $checks as $key => $value ) { |
| 233 | - if( !$this->isWebhostCheckValid( $key ))continue; |
|
| 239 | + if( !$this->isWebhostCheckValid( $key )) { |
|
| 240 | + continue; |
|
| 241 | + } |
|
| 234 | 242 | return $value; |
| 235 | 243 | } |
| 236 | 244 | return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] )); |
@@ -311,7 +319,9 @@ discard block |
||
| 311 | 319 | ]; |
| 312 | 320 | array_walk( $settings, function( &$value, $setting ) use( $keys ) { |
| 313 | 321 | foreach( $keys as $key ) { |
| 314 | - if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue; |
|
| 322 | + if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value )) { |
|
| 323 | + continue; |
|
| 324 | + } |
|
| 315 | 325 | $value = str_repeat( '•', 13 ); |
| 316 | 326 | return; |
| 317 | 327 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'setting' => 'Plugin Settings', |
| 41 | 41 | 'reviews' => 'Review Counts', |
| 42 | 42 | ]; |
| 43 | - $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) { |
|
| 43 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) { |
|
| 44 | 44 | $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' ); |
| 45 | 45 | if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
| 46 | 46 | return $carry.$this->implode( |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $plugins = get_plugins(); |
| 62 | 62 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 63 | - $inactive = array_diff_key( $plugins, array_flip( $activePlugins )); |
|
| 64 | - return $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 63 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
| 64 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public function getInactivePluginDetails() |
| 96 | 96 | { |
| 97 | 97 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 98 | - return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
| 98 | + return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $plugins = array_merge( |
| 107 | 107 | get_mu_plugins(), |
| 108 | - get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
|
| 108 | + get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) ) |
|
| 109 | 109 | ); |
| 110 | - if( empty( $plugins ))return; |
|
| 110 | + if( empty($plugins) )return; |
|
| 111 | 111 | return $this->normalizePluginList( $plugins ); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function getMultisitePluginDetails() |
| 118 | 118 | { |
| 119 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
| 119 | + if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return; |
|
| 120 | 120 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | 'Max Input Vars' => ini_get( 'max_input_vars' ), |
| 144 | 144 | 'Memory Limit' => ini_get( 'memory_limit' ), |
| 145 | 145 | 'Post Max Size' => ini_get( 'post_max_size' ), |
| 146 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
| 147 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
| 148 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
| 149 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ), |
|
| 150 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
| 146 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
| 147 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
| 148 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
| 149 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
| 150 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
| 151 | 151 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
| 152 | 152 | ]; |
| 153 | 153 | } |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $counts = glsr( CountsManager::class )->getCounts(); |
| 161 | 161 | $counts = glsr( Helper::class )->flattenArray( $counts ); |
| 162 | - array_walk( $counts, function( &$ratings ) use( $counts ) { |
|
| 163 | - if( !is_array( $ratings )) { |
|
| 162 | + array_walk( $counts, function( &$ratings ) use($counts) { |
|
| 163 | + if( !is_array( $ratings ) ) { |
|
| 164 | 164 | glsr_log() |
| 165 | 165 | ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' ) |
| 166 | 166 | ->debug( $ratings ) |
@@ -199,8 +199,8 @@ discard block |
||
| 199 | 199 | ksort( $settings ); |
| 200 | 200 | $details = []; |
| 201 | 201 | foreach( $settings as $key => $value ) { |
| 202 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
| 203 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
| 202 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
| 203 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
| 204 | 204 | $details[$key] = $value; |
| 205 | 205 | } |
| 206 | 206 | return $details; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | { |
| 214 | 214 | return [ |
| 215 | 215 | 'Console size' => glsr( Console::class )->humanSize( '0' ), |
| 216 | - 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' )), |
|
| 216 | + 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ), |
|
| 217 | 217 | 'Version (current)' => glsr()->version, |
| 218 | 218 | 'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ), |
| 219 | 219 | ]; |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | 'WPE_APIKEY' => 'WP Engine', |
| 274 | 274 | ]; |
| 275 | 275 | foreach( $checks as $key => $value ) { |
| 276 | - if( !$this->isWebhostCheckValid( $key ))continue; |
|
| 276 | + if( !$this->isWebhostCheckValid( $key ) )continue; |
|
| 277 | 277 | return $value; |
| 278 | 278 | } |
| 279 | - return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] )); |
|
| 279 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | { |
| 298 | 298 | $plugins = get_plugins(); |
| 299 | 299 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 300 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
| 301 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 300 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
| 301 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 302 | 302 | return $active + $inactive; |
| 303 | 303 | } |
| 304 | 304 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | protected function implode( $title, array $details ) |
| 310 | 310 | { |
| 311 | 311 | $strings = ['['.$title.']']; |
| 312 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
| 312 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
| 313 | 313 | $padding = max( [$padding, static::PAD] ); |
| 314 | 314 | foreach( $details as $key => $value ) { |
| 315 | 315 | $strings[] = is_string( $key ) |
@@ -352,9 +352,9 @@ discard block |
||
| 352 | 352 | $keys = [ |
| 353 | 353 | 'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret', |
| 354 | 354 | ]; |
| 355 | - array_walk( $settings, function( &$value, $setting ) use( $keys ) { |
|
| 355 | + array_walk( $settings, function( &$value, $setting ) use($keys) { |
|
| 356 | 356 | foreach( $keys as $key ) { |
| 357 | - if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue; |
|
| 357 | + if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue; |
|
| 358 | 358 | $value = str_repeat( '•', 13 ); |
| 359 | 359 | return; |
| 360 | 360 | } |
@@ -10,13 +10,13 @@ |
||
| 10 | 10 | <p>{{ description }}</p> |
| 11 | 11 | </div> |
| 12 | 12 | <div class="glsr-addon-footer"> |
| 13 | - <?php if( !is_wp_error( validate_plugin( $plugin ))) : ?> |
|
| 14 | - <?php if( is_plugin_active( $plugin )) : ?> |
|
| 13 | + <?php if( !is_wp_error( validate_plugin( $plugin ) ) ) : ?> |
|
| 14 | + <?php if( is_plugin_active( $plugin ) ) : ?> |
|
| 15 | 15 | <span class="glsr-addon-link button button-secondary" disabled> |
| 16 | 16 | <?= __( 'Installed', 'site-reviews' ); ?> |
| 17 | 17 | </span> |
| 18 | 18 | <?php else: ?> |
| 19 | - <a href="<?= wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin='.$plugin ), 'activate-plugin_'.$plugin );?>" class="glsr-addon-link button button-secondary"> |
|
| 19 | + <a href="<?= wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin='.$plugin ), 'activate-plugin_'.$plugin ); ?>" class="glsr-addon-link button button-secondary"> |
|
| 20 | 20 | <?= __( 'Activate', 'site-reviews' ); ?> |
| 21 | 21 | </a> |
| 22 | 22 | <?php endif; ?> |
@@ -15,14 +15,20 @@ |
||
| 15 | 15 | <span class="glsr-addon-link button button-secondary" disabled> |
| 16 | 16 | <?= __( 'Installed', 'site-reviews' ); ?> |
| 17 | 17 | </span> |
| 18 | - <?php else: ?> |
|
| 19 | - <a href="<?= wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin='.$plugin ), 'activate-plugin_'.$plugin );?>" class="glsr-addon-link button button-secondary"> |
|
| 18 | + <?php else { |
|
| 19 | + : ?> |
|
| 20 | + <a href="<?= wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin='.$plugin ), 'activate-plugin_'.$plugin ); |
|
| 21 | +} |
|
| 22 | +?>" class="glsr-addon-link button button-secondary"> |
|
| 20 | 23 | <?= __( 'Activate', 'site-reviews' ); ?> |
| 21 | 24 | </a> |
| 22 | 25 | <?php endif; ?> |
| 23 | - <?php else: ?> |
|
| 26 | + <?php else { |
|
| 27 | + : ?> |
|
| 24 | 28 | <a href="{{ link }}" class="glsr-addon-link glsr-external button button-secondary"> |
| 25 | - <?= __( 'More Info', 'site-reviews' ); ?> |
|
| 29 | + <?= __( 'More Info', 'site-reviews' ); |
|
| 30 | +} |
|
| 31 | +?> |
|
| 26 | 32 | </a> |
| 27 | 33 | <?php endif; ?> |
| 28 | 34 | </div> |
@@ -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 |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $this->versions = wp_parse_args( $versions, array( |
| 31 | 31 | 'php' => static::MIN_PHP_VERSION, |
| 32 | 32 | 'wordpress' => static::MIN_WORDPRESS_VERSION, |
| 33 | - )); |
|
| 33 | + ) ); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | if( $this->isValid() ) { |
| 42 | 42 | return true; |
| 43 | 43 | } |
| 44 | - add_action( 'activated_plugin', array( $this, 'deactivate' )); |
|
| 45 | - add_action( 'admin_notices', array( $this, 'deactivate' )); |
|
| 44 | + add_action( 'activated_plugin', array( $this, 'deactivate' ) ); |
|
| 45 | + add_action( 'admin_notices', array( $this, 'deactivate' ) ); |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | filter_input( INPUT_GET, 'plugin_status' ), |
| 138 | 138 | filter_input( INPUT_GET, 'paged' ), |
| 139 | 139 | filter_input( INPUT_GET, 's' ) |
| 140 | - ))); |
|
| 140 | + ) ) ); |
|
| 141 | 141 | exit; |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -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,11 +21,11 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function approve() |
| 23 | 23 | { |
| 24 | - check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
|
| 25 | - wp_update_post([ |
|
| 24 | + check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) ); |
|
| 25 | + wp_update_post( [ |
|
| 26 | 26 | 'ID' => $postId, |
| 27 | 27 | 'post_status' => 'publish', |
| 28 | - ]); |
|
| 28 | + ] ); |
|
| 29 | 29 | wp_safe_redirect( wp_get_referer() ); |
| 30 | 30 | exit; |
| 31 | 31 | } |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 56 | 56 | foreach( $postTypeColumns as $key => &$value ) { |
| 57 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
| 57 | + if( !array_key_exists( $key, $columns ) || !empty($value) )continue; |
|
| 58 | 58 | $value = $columns[$key]; |
| 59 | 59 | } |
| 60 | - if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
|
| 61 | - unset( $postTypeColumns['review_type'] ); |
|
| 60 | + if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) { |
|
| 61 | + unset($postTypeColumns['review_type']); |
|
| 62 | 62 | } |
| 63 | 63 | return array_filter( $postTypeColumns, 'strlen' ); |
| 64 | 64 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function filterPostStates( array $postStates, WP_Post $post ) { |
| 96 | 96 | if( $post->post_type == Application::POST_TYPE |
| 97 | - && array_key_exists( 'pending', $postStates )) { |
|
| 97 | + && array_key_exists( 'pending', $postStates ) ) { |
|
| 98 | 98 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
| 99 | 99 | } |
| 100 | 100 | return $postStates; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if( $post->post_type != Application::POST_TYPE || $post->post_status == 'trash' ) { |
| 110 | 110 | return $actions; |
| 111 | 111 | } |
| 112 | - unset( $actions['inline hide-if-no-js'] ); //Remove Quick-edit |
|
| 112 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
| 113 | 113 | $rowActions = [ |
| 114 | 114 | 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
| 115 | 115 | 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | admin_url( 'post.php?post='.$post->ID.'&action='.$key ), |
| 124 | 124 | $key.'-review_'.$post->ID |
| 125 | 125 | ), |
| 126 | - ]); |
|
| 126 | + ] ); |
|
| 127 | 127 | } |
| 128 | 128 | return $newActions + $actions; |
| 129 | 129 | } |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | public function filterSortableColumns( array $columns ) |
| 136 | 136 | { |
| 137 | 137 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 138 | - unset( $postTypeColumns['cb'] ); |
|
| 138 | + unset($postTypeColumns['cb']); |
|
| 139 | 139 | foreach( $postTypeColumns as $key => $value ) { |
| 140 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 140 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) )continue; |
|
| 141 | 141 | $columns[$key] = $key; |
| 142 | 142 | } |
| 143 | 143 | return $columns; |
@@ -155,18 +155,18 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function filterStatusText( $translation, $single, $plural, $number, $domain ) |
| 157 | 157 | { |
| 158 | - if( $this->canModifyTranslation( $domain )) { |
|
| 158 | + if( $this->canModifyTranslation( $domain ) ) { |
|
| 159 | 159 | $strings = [ |
| 160 | 160 | 'Published' => __( 'Approved', 'site-reviews' ), |
| 161 | 161 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 162 | 162 | ]; |
| 163 | 163 | foreach( $strings as $search => $replace ) { |
| 164 | 164 | if( strpos( $single, $search ) === false )continue; |
| 165 | - $translation = $this->getTranslation([ |
|
| 165 | + $translation = $this->getTranslation( [ |
|
| 166 | 166 | 'number' => $number, |
| 167 | 167 | 'plural' => str_replace( $search, $replace, $plural ), |
| 168 | 168 | 'single' => str_replace( $search, $replace, $single ), |
| 169 | - ]); |
|
| 169 | + ] ); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | return $translation; |
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function saveBulkEditFields( $postId ) |
| 215 | 215 | { |
| 216 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 216 | + if( !current_user_can( 'edit_posts' ) )return; |
|
| 217 | 217 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 218 | - if( $assignedTo && get_post( $assignedTo )) { |
|
| 218 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
| 219 | 219 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -226,10 +226,10 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function setQueryForColumn( WP_Query $query ) |
| 228 | 228 | { |
| 229 | - if( !$this->hasPermission( $query ))return; |
|
| 229 | + if( !$this->hasPermission( $query ) )return; |
|
| 230 | 230 | $this->setMetaQuery( $query, [ |
| 231 | 231 | 'rating', 'review_type', |
| 232 | - ]); |
|
| 232 | + ] ); |
|
| 233 | 233 | $this->setOrderby( $query ); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | public function unapprove() |
| 241 | 241 | { |
| 242 | - check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
|
| 243 | - wp_update_post([ |
|
| 242 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
| 243 | + wp_update_post( [ |
|
| 244 | 244 | 'ID' => $postId, |
| 245 | 245 | 'post_status' => 'pending', |
| 246 | - ]); |
|
| 246 | + ] ); |
|
| 247 | 247 | wp_safe_redirect( wp_get_referer() ); |
| 248 | 248 | exit; |
| 249 | 249 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | 'single' => '', |
| 274 | 274 | 'text' => '', |
| 275 | 275 | ]; |
| 276 | - $args = (object) wp_parse_args( $args, $defaults ); |
|
| 276 | + $args = (object)wp_parse_args( $args, $defaults ); |
|
| 277 | 277 | $translations = get_translations_for_domain( Application::ID ); |
| 278 | 278 | return $args->text |
| 279 | 279 | ? $translations->translate( $args->text ) |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 299 | 299 | { |
| 300 | 300 | foreach( $metaKeys as $key ) { |
| 301 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 301 | + if( !($value = filter_input( INPUT_GET, $key )) )continue; |
|
| 302 | 302 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 303 | 303 | $metaQuery[] = [ |
| 304 | 304 | 'key' => $key, |
@@ -315,8 +315,8 @@ discard block |
||
| 315 | 315 | { |
| 316 | 316 | $orderby = $query->get( 'orderby' ); |
| 317 | 317 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 318 | - unset( $columns['cb'], $columns['title'], $columns['date'] ); |
|
| 319 | - if( in_array( $orderby, array_keys( $columns ))) { |
|
| 318 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
| 319 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
| 320 | 320 | $query->set( 'meta_key', $orderby ); |
| 321 | 321 | $query->set( 'orderby', 'meta_value' ); |
| 322 | 322 | } |
@@ -54,7 +54,9 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 56 | 56 | foreach( $postTypeColumns as $key => &$value ) { |
| 57 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
| 57 | + if( !array_key_exists( $key, $columns ) || !empty( $value )) { |
|
| 58 | + continue; |
|
| 59 | + } |
|
| 58 | 60 | $value = $columns[$key]; |
| 59 | 61 | } |
| 60 | 62 | if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
@@ -92,7 +94,8 @@ discard block |
||
| 92 | 94 | * @return array |
| 93 | 95 | * @filter display_post_states |
| 94 | 96 | */ |
| 95 | - public function filterPostStates( array $postStates, WP_Post $post ) { |
|
| 97 | + public function filterPostStates( array $postStates, WP_Post $post ) |
|
| 98 | + { |
|
| 96 | 99 | if( $post->post_type == Application::POST_TYPE |
| 97 | 100 | && array_key_exists( 'pending', $postStates )) { |
| 98 | 101 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
@@ -137,7 +140,9 @@ discard block |
||
| 137 | 140 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 138 | 141 | unset( $postTypeColumns['cb'] ); |
| 139 | 142 | foreach( $postTypeColumns as $key => $value ) { |
| 140 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 143 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
| 144 | + continue; |
|
| 145 | + } |
|
| 141 | 146 | $columns[$key] = $key; |
| 142 | 147 | } |
| 143 | 148 | return $columns; |
@@ -161,7 +166,9 @@ discard block |
||
| 161 | 166 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 162 | 167 | ]; |
| 163 | 168 | foreach( $strings as $search => $replace ) { |
| 164 | - if( strpos( $single, $search ) === false )continue; |
|
| 169 | + if( strpos( $single, $search ) === false ) { |
|
| 170 | + continue; |
|
| 171 | + } |
|
| 165 | 172 | $translation = $this->getTranslation([ |
| 166 | 173 | 'number' => $number, |
| 167 | 174 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -213,7 +220,9 @@ discard block |
||
| 213 | 220 | */ |
| 214 | 221 | public function saveBulkEditFields( $postId ) |
| 215 | 222 | { |
| 216 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 223 | + if( !current_user_can( 'edit_posts' )) { |
|
| 224 | + return; |
|
| 225 | + } |
|
| 217 | 226 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 218 | 227 | if( $assignedTo && get_post( $assignedTo )) { |
| 219 | 228 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -226,7 +235,9 @@ discard block |
||
| 226 | 235 | */ |
| 227 | 236 | public function setQueryForColumn( WP_Query $query ) |
| 228 | 237 | { |
| 229 | - if( !$this->hasPermission( $query ))return; |
|
| 238 | + if( !$this->hasPermission( $query )) { |
|
| 239 | + return; |
|
| 240 | + } |
|
| 230 | 241 | $this->setMetaQuery( $query, [ |
| 231 | 242 | 'rating', 'review_type', |
| 232 | 243 | ]); |
@@ -298,7 +309,9 @@ discard block |
||
| 298 | 309 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 299 | 310 | { |
| 300 | 311 | foreach( $metaKeys as $key ) { |
| 301 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 312 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
| 313 | + continue; |
|
| 314 | + } |
|
| 302 | 315 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 303 | 316 | $metaQuery[] = [ |
| 304 | 317 | 'key' => $key, |
@@ -90,7 +90,9 @@ |
||
| 90 | 90 | { |
| 91 | 91 | $total = array_sum( $ratingCounts ); |
| 92 | 92 | foreach( $ratingCounts as $index => $count ) { |
| 93 | - if( empty( $count ))continue; |
|
| 93 | + if( empty( $count )) { |
|
| 94 | + continue; |
|
| 95 | + } |
|
| 94 | 96 | $ratingCounts[$index] = $count / $total * 100; |
| 95 | 97 | } |
| 96 | 98 | return $this->getRoundedPercentages( $ratingCounts ); |
@@ -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 | } |