@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | { |
| 15 | 15 | $args = $this->normalize( $args ); |
| 16 | 16 | $file = glsr()->path( 'views/'.$templatePath.'.php' ); |
| 17 | - if( !file_exists( $file )) { |
|
| 17 | + if( !file_exists( $file ) ) { |
|
| 18 | 18 | glsr_log()->error( 'Template missing: '.$file ); |
| 19 | 19 | return; |
| 20 | 20 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $args = shortcode_atts( array_fill_keys( ['context', 'globals'], [] ), $args ); |
| 60 | 60 | foreach( $args as $key => $value ) { |
| 61 | - if( is_array( $value ))continue; |
|
| 61 | + if( is_array( $value ) )continue; |
|
| 62 | 62 | $args[$key] = []; |
| 63 | 63 | } |
| 64 | 64 | return $args; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | protected function filterAttributes( array $allowedAttributeKeys ) |
| 114 | 114 | { |
| 115 | - return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys )); |
|
| 115 | + return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys ) ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $globalAttributes = $this->filterAttributes( static::GLOBAL_ATTRIBUTES ); |
| 124 | 124 | $wildcards = []; |
| 125 | 125 | foreach( static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard ) { |
| 126 | - $newWildcards = array_filter( $this->attributes, function( $key ) use( $wildcard ) { |
|
| 126 | + $newWildcards = array_filter( $this->attributes, function( $key ) use($wildcard) { |
|
| 127 | 127 | return glsr( Helper::class )->startsWith( $wildcard, $key ); |
| 128 | 128 | }, ARRAY_FILTER_USE_KEY ); |
| 129 | 129 | $wildcards = array_merge( $wildcards, $newWildcards ); |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | protected function normalizeBooleanAttributes() |
| 178 | 178 | { |
| 179 | 179 | foreach( $this->attributes as $key => $value ) { |
| 180 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
| 180 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
| 181 | 181 | $key = $value; |
| 182 | 182 | $value = true; |
| 183 | 183 | } |
| 184 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
| 184 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ) )continue; |
|
| 185 | 185 | $this->attributes[$key] = wp_validate_boolean( $value ); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -192,12 +192,12 @@ discard block |
||
| 192 | 192 | protected function normalizeDataAttributes() |
| 193 | 193 | { |
| 194 | 194 | foreach( $this->attributes as $key => $value ) { |
| 195 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
| 195 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
| 196 | 196 | $key = $value; |
| 197 | 197 | $value = ''; |
| 198 | 198 | } |
| 199 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
| 200 | - if( is_array( $value )) { |
|
| 199 | + if( !glsr( Helper::class )->startsWith( 'data-', $key ) )continue; |
|
| 200 | + if( is_array( $value ) ) { |
|
| 201 | 201 | $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); |
| 202 | 202 | } |
| 203 | 203 | $this->attributes[$key] = $value; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | protected function normalizeStringAttributes() |
| 211 | 211 | { |
| 212 | 212 | foreach( $this->attributes as $key => $value ) { |
| 213 | - if( !is_string( $value ))continue; |
|
| 213 | + if( !is_string( $value ) )continue; |
|
| 214 | 214 | $this->attributes[$key] = trim( $value ); |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | if( $method != 'input' )return; |
| 225 | 225 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
| 226 | - if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
|
| 226 | + if( !in_array( $attributes['type'], static::INPUT_TYPES ) ) { |
|
| 227 | 227 | $this->attributes['type'] = 'text'; |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | $dataAttributes = []; |
| 238 | 238 | foreach( $this->attributes as $key => $value ) { |
| 239 | 239 | if( in_array( $key, static::BOOLEAN_ATTRIBUTES ) && !$value ) { |
| 240 | - unset( $attributes[$key] ); |
|
| 240 | + unset($attributes[$key]); |
|
| 241 | 241 | } |
| 242 | - if( glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
| 242 | + if( glsr( Helper::class )->startsWith( 'data-', $key ) ) { |
|
| 243 | 243 | $dataAttributes[$key] = $value; |
| 244 | - unset( $attributes[$key] ); |
|
| 244 | + unset($attributes[$key]); |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | $this->attributes = array_merge( array_filter( $attributes ), $dataAttributes ); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | public function build( $partialPath, array $args = [] ) |
| 14 | 14 | { |
| 15 | 15 | $className = glsr( Helper::class )->buildClassName( $partialPath, 'Modules\Html\Partials' ); |
| 16 | - if( !class_exists( $className )) { |
|
| 16 | + if( !class_exists( $className ) ) { |
|
| 17 | 17 | glsr_log()->error( 'Partial missing: '.$className ); |
| 18 | 18 | return; |
| 19 | 19 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function get() |
| 110 | 110 | { |
| 111 | - return empty( $this->log ) |
|
| 111 | + return empty($this->log) |
|
| 112 | 112 | ? __( 'Log is empty', 'site-reviews' ) |
| 113 | 113 | : $this->log; |
| 114 | 114 | } |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
| 136 | 136 | $constants = (array)apply_filters( Application::ID.'/log-levels', $constants ); |
| 137 | - if( in_array( $level, $constants, true )) { |
|
| 137 | + if( in_array( $level, $constants, true ) ) { |
|
| 138 | 138 | $entry = $this->buildLogEntry( $level, $message, $context ); |
| 139 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
| 139 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
| 140 | 140 | $this->reset(); |
| 141 | 141 | } |
| 142 | 142 | return $this; |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | protected function getDebugInformation() |
| 187 | 187 | { |
| 188 | 188 | $caller = debug_backtrace( false, 6 ); |
| 189 | - $index = array_search( 'log', array_column( $caller, 'function' )); |
|
| 189 | + $index = array_search( 'log', array_column( $caller, 'function' ) ); |
|
| 190 | 190 | if( $index === false |
| 191 | - || !isset( $caller[$index+2]['class'] ) |
|
| 192 | - || !isset( $caller[$index+2]['function'] ) |
|
| 191 | + || !isset($caller[$index + 2]['class']) |
|
| 192 | + || !isset($caller[$index + 2]['function']) |
|
| 193 | 193 | )return; |
| 194 | 194 | return sprintf( '[%s()->%s:%s] ', |
| 195 | - $caller[$index+2]['class'], |
|
| 196 | - $caller[$index+2]['function'], |
|
| 197 | - $caller[$index+1]['line'] |
|
| 195 | + $caller[$index + 2]['class'], |
|
| 196 | + $caller[$index + 2]['function'], |
|
| 197 | + $caller[$index + 1]['line'] |
|
| 198 | 198 | ); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | protected function interpolate( $message, $context = [] ) |
| 208 | 208 | { |
| 209 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
| 209 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
| 210 | 210 | return print_r( $message, true ); |
| 211 | 211 | } |
| 212 | 212 | $replace = []; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | if( $value instanceof DateTime ) { |
| 235 | 235 | $value = $value->format( 'Y-m-d H:i:s' ); |
| 236 | 236 | } |
| 237 | - else if( $this->isObjectOrArray( $value )) { |
|
| 237 | + else if( $this->isObjectOrArray( $value ) ) { |
|
| 238 | 238 | $value = json_encode( $value ); |
| 239 | 239 | } |
| 240 | 240 | return (string)$value; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $this->clear(); |
| 251 | 251 | file_put_contents( |
| 252 | 252 | $this->file, |
| 253 | - $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' )) |
|
| 253 | + $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' ) ) |
|
| 254 | 254 | ); |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | { |
| 51 | 51 | $average = count( $reviews ); |
| 52 | 52 | if( $average > 0 ) { |
| 53 | - $average = round( $this->getTotal( $reviews ) / $average, intval( $roundBy )); |
|
| 53 | + $average = round( $this->getTotal( $reviews ) / $average, intval( $roundBy ) ); |
|
| 54 | 54 | } |
| 55 | - return floatval( apply_filters( 'site-reviews/rating/average', $average, $reviews )); |
|
| 55 | + return floatval( apply_filters( 'site-reviews/rating/average', $average, $reviews ) ); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -60,12 +60,12 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function getCounts( array $reviews ) |
| 62 | 62 | { |
| 63 | - $counts = array_fill_keys( [5,4,3,2,1], [] ); |
|
| 64 | - array_walk( $counts, function( &$count, $key ) use( $reviews ) { |
|
| 65 | - $count = count( array_filter( $reviews, function( $review ) use( $key ) { |
|
| 66 | - if( !isset( $review->rating ))return; |
|
| 63 | + $counts = array_fill_keys( [5, 4, 3, 2, 1], [] ); |
|
| 64 | + array_walk( $counts, function( &$count, $key ) use($reviews) { |
|
| 65 | + $count = count( array_filter( $reviews, function( $review ) use($key) { |
|
| 66 | + if( !isset($review->rating) )return; |
|
| 67 | 67 | return $review->rating == $key; |
| 68 | - })); |
|
| 68 | + }) ); |
|
| 69 | 69 | }); |
| 70 | 70 | return $counts; |
| 71 | 71 | } |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | if( !$numRatings )return 0; |
| 87 | 87 | $positiveRatings = count( array_filter( $upDownRatings, function( $value ) { |
| 88 | 88 | return $value > 0; |
| 89 | - })); |
|
| 89 | + }) ); |
|
| 90 | 90 | $z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
| 91 | 91 | $phat = 1 * $positiveRatings / $numRatings; |
| 92 | - return ( $phat + $z * $z / ( 2 * $numRatings ) - $z * sqrt(( $phat * ( 1 - $phat ) + $z * $z / ( 4 * $numRatings )) / $numRatings )) / ( 1 + $z * $z / $numRatings ); |
|
| 92 | + return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | public function getPercentages( array $reviews ) |
| 109 | 109 | { |
| 110 | 110 | $counts = $this->getCounts( $reviews ); |
| 111 | - array_walk( $counts, function( &$count, $rating ) use( $counts ) { |
|
| 111 | + array_walk( $counts, function( &$count, $rating ) use($counts) { |
|
| 112 | 112 | $total = array_sum( $counts ); |
| 113 | - $count = !empty( $total ) && !empty( $counts[$rating] ) |
|
| 113 | + $count = !empty($total) && !empty($counts[$rating]) |
|
| 114 | 114 | ? $counts[$rating] / array_sum( $counts ) * 100 |
| 115 | 115 | : 0; |
| 116 | 116 | }); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $this->getRankingUsingImdb( $reviews ), |
| 128 | 128 | $reviews, |
| 129 | 129 | $this |
| 130 | - )); |
|
| 130 | + ) ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | $bayesMinimal = 10; // confidence |
| 158 | 158 | // Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error. |
| 159 | 159 | // This could also be the average score of all items instead of a fixed value. |
| 160 | - $bayesMean = ( $confidencePercentage / 100 ) * static::MAX_RATING; // prior, 70% = 3.5 |
|
| 160 | + $bayesMean = ($confidencePercentage / 100) * static::MAX_RATING; // prior, 70% = 3.5 |
|
| 161 | 161 | $numOfReviews = count( $reviews ); |
| 162 | 162 | $avgRating = $this->getAverage( $reviews ); |
| 163 | 163 | return $avgRating > 0 |
| 164 | - ? (( $bayesMinimal * $bayesMean ) + ( $avgRating * $numOfReviews )) / ( $bayesMinimal + $numOfReviews ) |
|
| 164 | + ? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews) |
|
| 165 | 165 | : 0; |
| 166 | 166 | } |
| 167 | 167 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $weight = $this->getWeight( $ratingCounts, $ratingCountsSum ); |
| 183 | 183 | $weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true ); |
| 184 | 184 | $zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
| 185 | - return $weight - $zScore * sqrt(( $weightPow2 - pow( $weight, 2 )) / ( $ratingCountsSum + 1 )); |
|
| 185 | + return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -202,14 +202,14 @@ discard block |
||
| 202 | 202 | $remainders = array_column( $percentages, 'remainder' ); |
| 203 | 203 | array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages ); |
| 204 | 204 | $i = 0; |
| 205 | - if( array_sum( array_column( $percentages, 'percent' )) > 0 ) { |
|
| 206 | - while( array_sum( array_column( $percentages, 'percent' )) < $target ) { |
|
| 205 | + if( array_sum( array_column( $percentages, 'percent' ) ) > 0 ) { |
|
| 206 | + while( array_sum( array_column( $percentages, 'percent' ) ) < $target ) { |
|
| 207 | 207 | $percentages[$i]['percent']++; |
| 208 | 208 | $i++; |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | array_multisort( $indexes, SORT_DESC, $percentages ); |
| 212 | - return array_combine( $indexes, array_column( $percentages, 'percent' )); |
|
| 212 | + return array_combine( $indexes, array_column( $percentages, 'percent' ) ); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -220,9 +220,9 @@ discard block |
||
| 220 | 220 | protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false ) |
| 221 | 221 | { |
| 222 | 222 | return array_reduce( array_keys( $ratingCounts ), |
| 223 | - function( $count, $rating ) use( $ratingCounts, $ratingCountsSum, $powerOf2 ) { |
|
| 223 | + function( $count, $rating ) use($ratingCounts, $ratingCountsSum, $powerOf2) { |
|
| 224 | 224 | $ratingLevel = $powerOf2 ? pow( $rating, 2 ) : $rating; |
| 225 | - return $count + ( $ratingLevel * ( $ratingCounts[$rating] + 1 )) / $ratingCountsSum; |
|
| 225 | + return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum; |
|
| 226 | 226 | } |
| 227 | 227 | ); |
| 228 | 228 | } |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | foreach( glsr( Database::class )->getReviews( $this->args )->reviews as $review ) { |
| 33 | 33 | $reviews[] = $this->buildReview( $review ); |
| 34 | 34 | } |
| 35 | - if( !empty( $reviews )) { |
|
| 35 | + if( !empty($reviews) ) { |
|
| 36 | 36 | array_walk( $reviews, function( &$review ) { |
| 37 | - unset( $review['@context'] ); |
|
| 38 | - unset( $review['itemReviewed'] ); |
|
| 37 | + unset($review['@context']); |
|
| 38 | + unset($review['itemReviewed']); |
|
| 39 | 39 | }); |
| 40 | 40 | $schema['review'] = $reviews; |
| 41 | 41 | } |
@@ -49,20 +49,20 @@ discard block |
||
| 49 | 49 | public function buildReview( $review ) |
| 50 | 50 | { |
| 51 | 51 | $schema = SchemaOrg::Review() |
| 52 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
| 52 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
| 53 | 53 | $schema->name( $review->title ); |
| 54 | 54 | }) |
| 55 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
| 55 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
| 56 | 56 | $schema->reviewBody( $review->content ); |
| 57 | 57 | }) |
| 58 | - ->datePublished(( new DateTime( $review->date ))->format( DateTime::ISO8601 )) |
|
| 58 | + ->datePublished( (new DateTime( $review->date ))->format( DateTime::ISO8601 ) ) |
|
| 59 | 59 | ->author( SchemaOrg::Person() |
| 60 | 60 | ->name( $review->author ) |
| 61 | 61 | ) |
| 62 | 62 | ->itemReviewed( $this->getSchemaType() |
| 63 | 63 | ->name( $this->getThingName() ) |
| 64 | 64 | ); |
| 65 | - if( !empty( $review->rating )) { |
|
| 65 | + if( !empty($review->rating) ) { |
|
| 66 | 66 | $schema->reviewRating( SchemaOrg::Rating() |
| 67 | 67 | ->ratingValue( $review->rating ) |
| 68 | 68 | ->bestRating( Rating::MAX_RATING ) |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function buildSummary( $args = null ) |
| 80 | 80 | { |
| 81 | - if( is_array( $args )) { |
|
| 81 | + if( is_array( $args ) ) { |
|
| 82 | 82 | $this->args = $args; |
| 83 | 83 | } |
| 84 | 84 | $schema = $this->getSchemaType() |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | ->image( $this->getThingImage() ) |
| 91 | 91 | ->url( $this->getThingUrl() ); |
| 92 | 92 | $count = $this->getReviewCount(); |
| 93 | - if( !empty( $count )) { |
|
| 93 | + if( !empty($count) ) { |
|
| 94 | 94 | $schema->aggregateRating( SchemaOrg::AggregateRating() |
| 95 | 95 | ->ratingValue( $this->getRatingValue() ) |
| 96 | 96 | ->reviewCount( $count ) |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function render() |
| 110 | 110 | { |
| 111 | - if( is_null( glsr()->schemas ))return; |
|
| 111 | + if( is_null( glsr()->schemas ) )return; |
|
| 112 | 112 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
| 113 | 113 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
| 114 | 114 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
| 115 | - )); |
|
| 115 | + ) ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function store( array $schema ) |
| 122 | 122 | { |
| 123 | - $schemas = (array) glsr()->schemas; |
|
| 123 | + $schemas = (array)glsr()->schemas; |
|
| 124 | 124 | $schemas[] = $schema; |
| 125 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
| 125 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | protected function getSchemaOption( $option, $fallback ) |
| 163 | 163 | { |
| 164 | - if( $schemaOption = trim( get_post_meta( get_the_ID(), 'schema_'.$option, true ))) { |
|
| 164 | + if( $schemaOption = trim( get_post_meta( get_the_ID(), 'schema_'.$option, true ) ) ) { |
|
| 165 | 165 | return $schemaOption; |
| 166 | 166 | } |
| 167 | 167 | $default = glsr( OptionManager::class )->get( 'settings.reviews.schema.'.$option.'.default', $fallback ); |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | // 'is_test' => 1, |
| 32 | 32 | ]; |
| 33 | 33 | foreach( $_SERVER as $key => $value ) { |
| 34 | - if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ))continue; |
|
| 34 | + if( is_array( $value ) || in_array( $key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'] ) )continue; |
|
| 35 | 35 | $submission[$key] = $value; |
| 36 | 36 | } |
| 37 | - return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review )); |
|
| 37 | + return $this->check( apply_filters( 'site-reviews/akismet/submission', $submission, $review ) ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $query = []; |
| 59 | 59 | foreach( $data as $key => $value ) { |
| 60 | - if( is_array( $value ) || is_object( $value ))continue; |
|
| 60 | + if( is_array( $value ) || is_object( $value ) )continue; |
|
| 61 | 61 | if( $value === false ) { |
| 62 | 62 | $value = '0'; |
| 63 | 63 | } |
| 64 | 64 | $value = trim( $value ); |
| 65 | - if( !strlen( $value ))continue; |
|
| 65 | + if( !strlen( $value ) )continue; |
|
| 66 | 66 | $query[] = urlencode( $key ).'='.urlencode( $value ); |
| 67 | 67 | } |
| 68 | 68 | return implode( '&', $query ); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | || !is_callable( ['Akismet', 'get_api_key'] ) |
| 78 | 78 | || !is_callable( ['Akismet', 'http_post'] ) |
| 79 | 79 | ? false |
| 80 | - : (bool) AkismetPlugin::get_api_key(); |
|
| 80 | + : (bool)AkismetPlugin::get_api_key(); |
|
| 81 | 81 | return apply_filters( 'site-reviews/akismet/is-active', $check ); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -29,13 +29,13 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | foreach( $args as $key => $value ) { |
| 31 | 31 | $property = glsr( Helper::class )->buildPropertyName( $key ); |
| 32 | - if( !property_exists( $this, $property ))continue; |
|
| 32 | + if( !property_exists( $this, $property ) )continue; |
|
| 33 | 33 | $this->$property = $value; |
| 34 | - unset( $args[$key] ); |
|
| 34 | + unset($args[$key]); |
|
| 35 | 35 | } |
| 36 | 36 | $this->args = wp_parse_args( $args, [ |
| 37 | 37 | 'menu_name' => $this->plural, |
| 38 | - ]); |
|
| 38 | + ] ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | 'singular_name' => $this->single, |
| 59 | 59 | 'uploaded_to_this_item' => sprintf( _x( 'Uploaded to this %s', 'Uploaded to this Post', 'site-reviews' ), $this->single ), |
| 60 | 60 | 'view_item' => sprintf( _x( 'View %s', 'View Post', 'site-reviews' ), $this->single ), |
| 61 | - ]); |
|
| 62 | - unset( $this->args['menu_name'] ); |
|
| 61 | + ] ); |
|
| 62 | + unset($this->args['menu_name']); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | protected function normalizeColumns() |
| 69 | 69 | { |
| 70 | 70 | $this->columns = ['cb' => ''] + $this->columns; |
| 71 | - if( array_key_exists( 'category', $this->columns )) { |
|
| 71 | + if( array_key_exists( 'category', $this->columns ) ) { |
|
| 72 | 72 | $keys = array_keys( $this->columns ); |
| 73 | 73 | $keys[array_search( 'category', $keys )] = 'taxonomy-'.Application::TAXONOMY; |
| 74 | 74 | $this->columns = array_combine( $keys, $this->columns ); |
| 75 | 75 | } |
| 76 | - if( array_key_exists( 'pinned', $this->columns )) { |
|
| 76 | + if( array_key_exists( 'pinned', $this->columns ) ) { |
|
| 77 | 77 | $stickyValue = '<span class="pinned-icon"><span>'.$this->columns['pinned'].'</span></span>'; |
| 78 | 78 | $this->columns['pinned'] = $stickyValue; |
| 79 | 79 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | public function __construct( $input ) |
| 11 | 11 | { |
| 12 | 12 | $this->id = $input['id']; |
| 13 | - $this->pinned = isset( $input['pinned'] ) |
|
| 13 | + $this->pinned = isset($input['pinned']) |
|
| 14 | 14 | ? wp_validate_boolean( $input['pinned'] ) |
| 15 | 15 | : null; |
| 16 | 16 | } |