@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function deleteAllSessions( $sessionCookiePrefix ) |
| 25 | 25 | { |
| 26 | - return $this->db->query(" |
|
| 26 | + return $this->db->query( " |
|
| 27 | 27 | DELETE |
| 28 | 28 | FROM {$this->db->options} |
| 29 | 29 | WHERE option_name LIKE '{$sessionCookiePrefix}_%' |
| 30 | - "); |
|
| 30 | + " ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function deleteExpiredSessions( $expiredSessions ) |
| 38 | 38 | { |
| 39 | - return $this->db->query(" |
|
| 39 | + return $this->db->query( " |
|
| 40 | 40 | DELETE |
| 41 | 41 | FROM {$this->db->options} |
| 42 | 42 | WHERE option_name IN ('{$expiredSessions}') |
| 43 | - "); |
|
| 43 | + " ); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function getReviewCounts( $metaKey ) |
| 51 | 51 | { |
| 52 | - return (array) $this->db->get_results(" |
|
| 52 | + return (array)$this->db->get_results( " |
|
| 53 | 53 | SELECT m.meta_value AS name, COUNT(*) num_posts |
| 54 | 54 | FROM {$this->db->posts} AS p |
| 55 | 55 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
| 56 | 56 | WHERE p.post_type = '{$this->postType}' |
| 57 | 57 | AND m.meta_key = '{$metaKey}' |
| 58 | 58 | GROUP BY name |
| 59 | - "); |
|
| 59 | + " ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function getExpiredSessions( $sessionCookiePrefix, $limit ) |
| 68 | 68 | { |
| 69 | - return $this->db->get_results(" |
|
| 69 | + return $this->db->get_results( " |
|
| 70 | 70 | SELECT option_name AS name, option_value AS expiration |
| 71 | 71 | FROM {$this->db->options} |
| 72 | 72 | WHERE option_name LIKE '{$sessionCookiePrefix}_expires_%' |
| 73 | 73 | ORDER BY option_value ASC |
| 74 | 74 | LIMIT 0, {$limit} |
| 75 | - "); |
|
| 75 | + " ); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function getReviewPostId( $metaReviewId ) |
| 83 | 83 | { |
| 84 | - $postId = $this->db->get_var(" |
|
| 84 | + $postId = $this->db->get_var( " |
|
| 85 | 85 | SELECT p.ID |
| 86 | 86 | FROM {$this->db->posts} AS p |
| 87 | 87 | INNER JOIN {$this->db->postmeta} AS pm ON p.ID = pm.post_id |
| 88 | 88 | WHERE p.post_type = '{$this->postType}' |
| 89 | 89 | AND pm.meta_key = 'review_id' |
| 90 | 90 | AND pm.meta_value = '{$metaReviewId}' |
| 91 | - "); |
|
| 91 | + " ); |
|
| 92 | 92 | return intval( $postId ); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function getReviewIdsByType( $metaReviewType ) |
| 100 | 100 | { |
| 101 | - $query = $this->db->get_col(" |
|
| 101 | + $query = $this->db->get_col( " |
|
| 102 | 102 | SELECT m1.meta_value AS review_id |
| 103 | 103 | FROM {$this->db->posts} AS p |
| 104 | 104 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | AND m1.meta_key = 'review_id' |
| 108 | 108 | AND m2.meta_key = 'review_type' |
| 109 | 109 | AND m2.meta_value = '{$metaReviewType}' |
| 110 | - "); |
|
| 111 | - return array_keys( array_flip( $query )); |
|
| 110 | + " ); |
|
| 111 | + return array_keys( array_flip( $query ) ); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function getReviewRatings( $greaterThanId = 0, $limit = 100 ) |
| 120 | 120 | { |
| 121 | - return $this->db->get_results(" |
|
| 121 | + return $this->db->get_results( " |
|
| 122 | 122 | SELECT p.ID, m1.meta_value as rating, m2.meta_value as type |
| 123 | 123 | FROM {$this->db->posts} AS p |
| 124 | 124 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | sort( $postIds ); |
| 144 | 144 | $postIds = array_slice( $postIds, array_search( $greaterThanId, $postIds ), $limit ); |
| 145 | 145 | $postIds = implode( ',', $postIds ); |
| 146 | - return $this->db->get_results(" |
|
| 146 | + return $this->db->get_results( " |
|
| 147 | 147 | SELECT p.ID, m.meta_value as rating |
| 148 | 148 | FROM {$this->db->posts} AS p |
| 149 | 149 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
@@ -167,13 +167,13 @@ discard block |
||
| 167 | 167 | $queryBuilder = glsr( QueryBuilder::class ); |
| 168 | 168 | $key = $queryBuilder->buildSqlOr( $key, "pm.meta_key = '%s'" ); |
| 169 | 169 | $status = $queryBuilder->buildSqlOr( $status, "p.post_status = '%s'" ); |
| 170 | - return $this->db->get_col(" |
|
| 170 | + return $this->db->get_col( " |
|
| 171 | 171 | SELECT DISTINCT pm.meta_value FROM {$this->db->postmeta} pm |
| 172 | 172 | LEFT JOIN {$this->db->posts} p ON p.ID = pm.post_id |
| 173 | 173 | WHERE p.post_type = '{$this->postType}' |
| 174 | 174 | AND ({$key}) |
| 175 | 175 | AND ({$status}) |
| 176 | 176 | ORDER BY pm.meta_value |
| 177 | - "); |
|
| 177 | + " ); |
|
| 178 | 178 | } |
| 179 | 179 | } |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $counts = []; |
| 22 | 22 | $greaterThanId = 0; |
| 23 | - while( $reviews = glsr( SqlQueries::class )->getReviewRatings( $greaterThanId )) { |
|
| 24 | - $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
|
| 23 | + while( $reviews = glsr( SqlQueries::class )->getReviewRatings( $greaterThanId ) ) { |
|
| 24 | + $types = array_keys( array_flip( array_column( $reviews, 'type' ) ) ); |
|
| 25 | 25 | foreach( $types as $type ) { |
| 26 | - if( isset( $counts[$type] ))continue; |
|
| 26 | + if( isset($counts[$type]) )continue; |
|
| 27 | 27 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
| 28 | 28 | } |
| 29 | 29 | foreach( $reviews as $review ) { |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $counts = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
| 43 | 43 | $greaterThanId = 0; |
| 44 | - while( $reviews = glsr( SqlQueries::class )->getReviewRatingsFromIds( $postIds, $greaterThanId )) { |
|
| 44 | + while( $reviews = glsr( SqlQueries::class )->getReviewRatingsFromIds( $postIds, $greaterThanId ) ) { |
|
| 45 | 45 | foreach( $reviews as $review ) { |
| 46 | 46 | $counts[$review->rating]++; |
| 47 | 47 | } |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function getAssignedToPost( $postId, $assignedTo = '' ) |
| 59 | 59 | { |
| 60 | - if( empty( $assignedTo )) { |
|
| 60 | + if( empty($assignedTo) ) { |
|
| 61 | 61 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
| 62 | 62 | } |
| 63 | - if( empty( $assignedTo ))return; |
|
| 63 | + if( empty($assignedTo) )return; |
|
| 64 | 64 | $assignedPost = get_post( $assignedTo ); |
| 65 | 65 | if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
| 66 | 66 | return $assignedPost; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | if( !$metaValue ) { |
| 82 | 82 | return $counts; |
| 83 | 83 | } |
| 84 | - return isset( $counts[$metaValue] ) |
|
| 84 | + return isset($counts[$metaValue]) |
|
| 85 | 85 | ? $counts[$metaValue] |
| 86 | 86 | : 0; |
| 87 | 87 | } |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | 'max' => Rating::MAX_RATING, |
| 96 | 96 | 'min' => Rating::MIN_RATING, |
| 97 | 97 | 'types' => 'local', |
| 98 | - ]); |
|
| 98 | + ] ); |
|
| 99 | 99 | $counts = array_intersect_key( |
| 100 | 100 | glsr( OptionManager::class )->get( 'counts', [] ), |
| 101 | - array_flip( array_intersect( glsr()->reviewTypes, (array)$args['types'] )) |
|
| 101 | + array_flip( array_intersect( glsr()->reviewTypes, (array)$args['types'] ) ) |
|
| 102 | 102 | ); |
| 103 | - array_walk( $counts, function( &$ratings ) use( $args ) { |
|
| 103 | + array_walk( $counts, function( &$ratings ) use($args) { |
|
| 104 | 104 | $ratings[0] = 0; |
| 105 | 105 | foreach( $ratings as $index => &$num ) { |
| 106 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
| 106 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue; |
|
| 107 | 107 | $num = 0; |
| 108 | 108 | } |
| 109 | 109 | }); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function getReviewsMeta( $key, $status = 'publish' ) |
| 128 | 128 | { |
| 129 | - if( $status == 'all' || empty( $status )) { |
|
| 129 | + if( $status == 'all' || empty($status) ) { |
|
| 130 | 130 | $status = get_post_stati( ['exclude_from_search' => false] ); |
| 131 | 131 | } |
| 132 | 132 | return glsr( SqlQueries::class )->getReviewsMeta( $key, $status ); |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | 'fields' => 'id=>name', |
| 142 | 142 | 'hide_empty' => false, |
| 143 | 143 | 'taxonomy' => Application::TAXONOMY, |
| 144 | - ]); |
|
| 145 | - unset( $args['count'] ); // we don't want a term count |
|
| 144 | + ] ); |
|
| 145 | + unset($args['count']); // we don't want a term count |
|
| 146 | 146 | $terms = get_terms( $args ); |
| 147 | - if( is_wp_error( $terms )) { |
|
| 147 | + if( is_wp_error( $terms ) ) { |
|
| 148 | 148 | glsr_log()->error( $terms->get_error_message() ); |
| 149 | 149 | return []; |
| 150 | 150 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | 'post_status' => 'publish', |
| 162 | 162 | 'post_type' => 'any', |
| 163 | 163 | ]; |
| 164 | - if( is_numeric( $searchTerm )) { |
|
| 164 | + if( is_numeric( $searchTerm ) ) { |
|
| 165 | 165 | $args['post__in'] = [$searchTerm]; |
| 166 | 166 | } |
| 167 | 167 | else { |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | ob_start(); |
| 181 | 181 | glsr()->render( 'partials/editor/search-result', [ |
| 182 | 182 | 'ID' => get_the_ID(), |
| 183 | - 'permalink' => esc_url( (string) get_permalink() ), |
|
| 183 | + 'permalink' => esc_url( (string)get_permalink() ), |
|
| 184 | 184 | 'title' => esc_attr( get_the_title() ), |
| 185 | - ]); |
|
| 185 | + ] ); |
|
| 186 | 186 | $results .= ob_get_clean(); |
| 187 | 187 | } |
| 188 | 188 | wp_reset_postdata(); |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | while( $reviews = glsr( SqlQueries::class )->getReviewRatings( $greaterThanId )) { |
| 24 | 24 | $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
| 25 | 25 | foreach( $types as $type ) { |
| 26 | - if( isset( $counts[$type] ))continue; |
|
| 26 | + if( isset( $counts[$type] )) { |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 27 | 29 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
| 28 | 30 | } |
| 29 | 31 | foreach( $reviews as $review ) { |
@@ -60,7 +62,9 @@ discard block |
||
| 60 | 62 | if( empty( $assignedTo )) { |
| 61 | 63 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
| 62 | 64 | } |
| 63 | - if( empty( $assignedTo ))return; |
|
| 65 | + if( empty( $assignedTo )) { |
|
| 66 | + return; |
|
| 67 | + } |
|
| 64 | 68 | $assignedPost = get_post( $assignedTo ); |
| 65 | 69 | if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
| 66 | 70 | return $assignedPost; |
@@ -103,7 +107,9 @@ discard block |
||
| 103 | 107 | array_walk( $counts, function( &$ratings ) use( $args ) { |
| 104 | 108 | $ratings[0] = 0; |
| 105 | 109 | foreach( $ratings as $index => &$num ) { |
| 106 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
| 110 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
| 111 | + continue; |
|
| 112 | + } |
|
| 107 | 113 | $num = 0; |
| 108 | 114 | } |
| 109 | 115 | }); |
@@ -173,7 +179,9 @@ discard block |
||
| 173 | 179 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
| 174 | 180 | $search = new WP_Query( $args ); |
| 175 | 181 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
| 176 | - if( !$search->have_posts() )return; |
|
| 182 | + if( !$search->have_posts() ) { |
|
| 183 | + return; |
|
| 184 | + } |
|
| 177 | 185 | $results = ''; |
| 178 | 186 | while( $search->have_posts() ) { |
| 179 | 187 | $search->the_post(); |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | if( $review->review_type != 'local' )continue; |
| 38 | 38 | $reviews[] = $this->buildReview( $review ); |
| 39 | 39 | } |
| 40 | - if( !empty( $reviews )) { |
|
| 40 | + if( !empty($reviews) ) { |
|
| 41 | 41 | array_walk( $reviews, function( &$review ) { |
| 42 | - unset( $review['@context'] ); |
|
| 43 | - unset( $review['itemReviewed'] ); |
|
| 42 | + unset($review['@context']); |
|
| 43 | + unset($review['itemReviewed']); |
|
| 44 | 44 | }); |
| 45 | 45 | $schema['review'] = $reviews; |
| 46 | 46 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function buildSummary( $args = null ) |
| 55 | 55 | { |
| 56 | - if( is_array( $args )) { |
|
| 56 | + if( is_array( $args ) ) { |
|
| 57 | 57 | $this->args = $args; |
| 58 | 58 | } |
| 59 | 59 | $buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' ); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $schema = method_exists( $this, $buildSummary ) |
| 62 | 62 | ? $this->$buildSummary() |
| 63 | 63 | : $this->buildSummaryForCustom(); |
| 64 | - if( !empty( $count )) { |
|
| 64 | + if( !empty($count) ) { |
|
| 65 | 65 | $schema->aggregateRating( |
| 66 | 66 | $this->getSchemaType( 'AggregateRating' ) |
| 67 | 67 | ->ratingValue( $this->getRatingValue() ) |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function render() |
| 81 | 81 | { |
| 82 | - if( is_null( glsr()->schemas ))return; |
|
| 82 | + if( is_null( glsr()->schemas ) )return; |
|
| 83 | 83 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
| 84 | 84 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
| 85 | 85 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
| 86 | - )); |
|
| 86 | + ) ); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | $schemas = glsr()->schemas; |
| 95 | 95 | $schemas[] = $schema; |
| 96 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
| 96 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -103,16 +103,16 @@ discard block |
||
| 103 | 103 | protected function buildReview( $review ) |
| 104 | 104 | { |
| 105 | 105 | $schema = $this->getSchemaType( 'Review' ) |
| 106 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
| 106 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) { |
|
| 107 | 107 | $schema->name( $review->title ); |
| 108 | 108 | }) |
| 109 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
| 109 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) { |
|
| 110 | 110 | $schema->reviewBody( $review->content ); |
| 111 | 111 | }) |
| 112 | - ->datePublished(( new DateTime( $review->date ))) |
|
| 113 | - ->author( $this->getSchemaType( 'Person' )->name( $review->author )) |
|
| 114 | - ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ))); |
|
| 115 | - if( !empty( $review->rating )) { |
|
| 112 | + ->datePublished( (new DateTime( $review->date )) ) |
|
| 113 | + ->author( $this->getSchemaType( 'Person' )->name( $review->author ) ) |
|
| 114 | + ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) ); |
|
| 115 | + if( !empty($review->rating) ) { |
|
| 116 | 116 | $schema->reviewRating( |
| 117 | 117 | $this->getSchemaType( 'Rating' ) |
| 118 | 118 | ->ratingValue( $review->rating ) |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | foreach( $values as $value ) { |
| 133 | 133 | $option = $this->getSchemaOptionValue( $value ); |
| 134 | - if( empty( $option ))continue; |
|
| 134 | + if( empty($option) )continue; |
|
| 135 | 135 | $schema->$value( $option ); |
| 136 | 136 | } |
| 137 | 137 | return $schema; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | return $this->buildSchemaValues( $this->getSchemaType(), [ |
| 146 | 146 | 'description', 'image', 'name', 'url', |
| 147 | - ]); |
|
| 147 | + ] ); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | { |
| 155 | 155 | return $this->buildSchemaValues( $this->buildSummaryForCustom(), [ |
| 156 | 156 | 'address', 'priceRange', 'telephone', |
| 157 | - ]); |
|
| 157 | + ] ); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | { |
| 165 | 165 | $offers = $this->buildSchemaValues( $this->getSchemaType( 'AggregateOffer' ), [ |
| 166 | 166 | 'highPrice', 'lowPrice', 'priceCurrency', |
| 167 | - ]); |
|
| 167 | + ] ); |
|
| 168 | 168 | return $this->buildSummaryForCustom() |
| 169 | 169 | ->offers( $offers ) |
| 170 | - ->setProperty( '@id', $this->getSchemaOptionValue( 'url' )); |
|
| 170 | + ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ) ); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | protected function getReviewCounts() |
| 185 | 185 | { |
| 186 | - if( !isset( $this->reviewCounts )) { |
|
| 187 | - $this->reviewCounts = glsr( Database::class )->getReviewCounts([ |
|
| 186 | + if( !isset($this->reviewCounts) ) { |
|
| 187 | + $this->reviewCounts = glsr( Database::class )->getReviewCounts( [ |
|
| 188 | 188 | 'min' => $this->args['rating'], |
| 189 | - ]); |
|
| 189 | + ] ); |
|
| 190 | 190 | } |
| 191 | 191 | return $this->reviewCounts; |
| 192 | 192 | } |
@@ -199,14 +199,14 @@ discard block |
||
| 199 | 199 | protected function getSchemaOption( $option, $fallback ) |
| 200 | 200 | { |
| 201 | 201 | $option = strtolower( $option ); |
| 202 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
| 202 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
| 203 | 203 | return $schemaOption; |
| 204 | 204 | } |
| 205 | 205 | $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option ); |
| 206 | - if( is_array( $setting )) { |
|
| 206 | + if( is_array( $setting ) ) { |
|
| 207 | 207 | return $this->getSchemaOptionDefault( $setting, $fallback ); |
| 208 | 208 | } |
| 209 | - return !empty( $setting ) |
|
| 209 | + return !empty($setting) |
|
| 210 | 210 | ? $setting |
| 211 | 211 | : $fallback; |
| 212 | 212 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $setting = wp_parse_args( $setting, [ |
| 221 | 221 | 'custom' => '', |
| 222 | 222 | 'default' => $fallback, |
| 223 | - ]); |
|
| 223 | + ] ); |
|
| 224 | 224 | return $setting['default'] != 'custom' |
| 225 | 225 | ? $setting['default'] |
| 226 | 226 | : $setting['custom']; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | if( !is_single() && !is_page() )return; |
| 241 | 241 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
| 242 | - if( method_exists( $this, $method )) { |
|
| 242 | + if( method_exists( $this, $method ) ) { |
|
| 243 | 243 | return $this->$method(); |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | protected function getSchemaType( $type = null ) |
| 252 | 252 | { |
| 253 | - if( !is_string( $type )) { |
|
| 253 | + if( !is_string( $type ) ) { |
|
| 254 | 254 | $type = $this->getSchemaOption( 'type', 'LocalBusiness' ); |
| 255 | 255 | } |
| 256 | 256 | $className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' ); |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | protected function getThingDescription() |
| 266 | 266 | { |
| 267 | 267 | $post = get_post(); |
| 268 | - if( !( $post instanceof WP_Post )) { |
|
| 268 | + if( !($post instanceof WP_Post) ) { |
|
| 269 | 269 | return ''; |
| 270 | 270 | } |
| 271 | - $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt )); |
|
| 272 | - return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 )); |
|
| 271 | + $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) ); |
|
| 272 | + return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) ); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | foreach( glsr( ReviewManager::class )->get( $this->args )->results as $review ) { |
| 35 | 35 | // Only include critic reviews that have been directly produced by your site, not reviews from third- party sites or syndicated reviews. |
| 36 | 36 | // @see https://developers.google.com/search/docs/data-types/review |
| 37 | - if( $review->review_type != 'local' )continue; |
|
| 37 | + if( $review->review_type != 'local' ) { |
|
| 38 | + continue; |
|
| 39 | + } |
|
| 38 | 40 | $reviews[] = $this->buildReview( $review ); |
| 39 | 41 | } |
| 40 | 42 | if( !empty( $reviews )) { |
@@ -79,7 +81,9 @@ discard block |
||
| 79 | 81 | */ |
| 80 | 82 | public function render() |
| 81 | 83 | { |
| 82 | - if( is_null( glsr()->schemas ))return; |
|
| 84 | + if( is_null( glsr()->schemas )) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 83 | 87 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
| 84 | 88 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
| 85 | 89 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
@@ -131,7 +135,9 @@ discard block |
||
| 131 | 135 | { |
| 132 | 136 | foreach( $values as $value ) { |
| 133 | 137 | $option = $this->getSchemaOptionValue( $value ); |
| 134 | - if( empty( $option ))continue; |
|
| 138 | + if( empty( $option )) { |
|
| 139 | + continue; |
|
| 140 | + } |
|
| 135 | 141 | $schema->$value( $option ); |
| 136 | 142 | } |
| 137 | 143 | return $schema; |
@@ -237,7 +243,9 @@ discard block |
||
| 237 | 243 | if( $value != $fallback ) { |
| 238 | 244 | return $value; |
| 239 | 245 | } |
| 240 | - if( !is_single() && !is_page() )return; |
|
| 246 | + if( !is_single() && !is_page() ) { |
|
| 247 | + return; |
|
| 248 | + } |
|
| 241 | 249 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
| 242 | 250 | if( method_exists( $this, $method )) { |
| 243 | 251 | return $this->$method(); |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | $counts = $this->flattenCounts( $reviewCounts ); |
| 51 | 51 | $average = array_sum( $counts ); |
| 52 | 52 | if( $average > 0 ) { |
| 53 | - $average = round( $this->getTotalSum( $counts ) / $average, intval( $roundBy )); |
|
| 53 | + $average = round( $this->getTotalSum( $counts ) / $average, intval( $roundBy ) ); |
|
| 54 | 54 | } |
| 55 | - return floatval( apply_filters( 'site-reviews/rating/average', $average, $counts, $reviewCounts )); |
|
| 55 | + return floatval( apply_filters( 'site-reviews/rating/average', $average, $counts, $reviewCounts ) ); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | $z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
| 75 | 75 | $phat = 1 * $upDownRatings[1] / $numRatings; |
| 76 | - return ( $phat + $z * $z / ( 2 * $numRatings ) - $z * sqrt(( $phat * ( 1 - $phat ) + $z * $z / ( 4 * $numRatings )) / $numRatings )) / ( 1 + $z * $z / $numRatings ); |
|
| 76 | + return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $counts = $this->flattenCounts( $reviewCounts ); |
| 93 | 93 | $total = array_sum( $counts ); |
| 94 | 94 | foreach( $counts as $index => $count ) { |
| 95 | - if( empty( $count ))continue; |
|
| 95 | + if( empty($count) )continue; |
|
| 96 | 96 | $counts[$index] = $count / $total * 100; |
| 97 | 97 | } |
| 98 | 98 | return $this->getRoundedPercentages( $counts ); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $this->getRankingUsingImdb( $counts ), |
| 109 | 109 | $counts, |
| 110 | 110 | $this |
| 111 | - )); |
|
| 111 | + ) ); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | protected function flattenCounts( array $reviewCounts ) |
| 118 | 118 | { |
| 119 | 119 | $counts = []; |
| 120 | - array_walk_recursive( $reviewCounts, function( $num, $index ) use( &$counts ) { |
|
| 120 | + array_walk_recursive( $reviewCounts, function( $num, $index ) use(&$counts) { |
|
| 121 | 121 | $counts[$index] = isset($counts[$index]) |
| 122 | 122 | ? $num + $counts[$index] |
| 123 | 123 | : $num; |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | $avgRating = $this->getAverage( $ratingCounts ); |
| 141 | 141 | // Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error. |
| 142 | 142 | // This could also be the average score of all items instead of a fixed value. |
| 143 | - $bayesMean = ( $confidencePercentage / 100 ) * static::MAX_RATING; // prior, 70% = 3.5 |
|
| 143 | + $bayesMean = ($confidencePercentage / 100) * static::MAX_RATING; // prior, 70% = 3.5 |
|
| 144 | 144 | // Represents the number of ratings expected to begin observing a pattern that would put confidence in the prior. |
| 145 | 145 | $bayesMinimal = 10; // confidence |
| 146 | 146 | $numOfReviews = array_sum( $ratingCounts ); |
| 147 | 147 | return $avgRating > 0 |
| 148 | - ? (( $bayesMinimal * $bayesMean ) + ( $avgRating * $numOfReviews )) / ( $bayesMinimal + $numOfReviews ) |
|
| 148 | + ? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews) |
|
| 149 | 149 | : 0; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | $weight = $this->getWeight( $ratingCounts, $ratingCountsSum ); |
| 166 | 166 | $weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true ); |
| 167 | 167 | $zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
| 168 | - return $weight - $zScore * sqrt(( $weightPow2 - pow( $weight, 2 )) / ( $ratingCountsSum + 1 )); |
|
| 168 | + return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) ); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -185,14 +185,14 @@ discard block |
||
| 185 | 185 | $remainders = array_column( $percentages, 'remainder' ); |
| 186 | 186 | array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages ); |
| 187 | 187 | $i = 0; |
| 188 | - if( array_sum( array_column( $percentages, 'percent' )) > 0 ) { |
|
| 189 | - while( array_sum( array_column( $percentages, 'percent' )) < $totalPercent ) { |
|
| 188 | + if( array_sum( array_column( $percentages, 'percent' ) ) > 0 ) { |
|
| 189 | + while( array_sum( array_column( $percentages, 'percent' ) ) < $totalPercent ) { |
|
| 190 | 190 | $percentages[$i]['percent']++; |
| 191 | 191 | $i++; |
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | array_multisort( $indexes, SORT_DESC, $percentages ); |
| 195 | - return array_combine( $indexes, array_column( $percentages, 'percent' )); |
|
| 195 | + return array_combine( $indexes, array_column( $percentages, 'percent' ) ); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false ) |
| 214 | 214 | { |
| 215 | 215 | return array_reduce( array_keys( $ratingCounts ), |
| 216 | - function( $count, $rating ) use( $ratingCounts, $ratingCountsSum, $powerOf2 ) { |
|
| 216 | + function( $count, $rating ) use($ratingCounts, $ratingCountsSum, $powerOf2) { |
|
| 217 | 217 | $ratingLevel = $powerOf2 |
| 218 | 218 | ? pow( $rating, 2 ) |
| 219 | 219 | : $rating; |
| 220 | - return $count + ( $ratingLevel * ( $ratingCounts[$rating] + 1 )) / $ratingCountsSum; |
|
| 220 | + return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum; |
|
| 221 | 221 | } |
| 222 | 222 | ); |
| 223 | 223 | } |
@@ -92,7 +92,9 @@ |
||
| 92 | 92 | $counts = $this->flattenCounts( $reviewCounts ); |
| 93 | 93 | $total = array_sum( $counts ); |
| 94 | 94 | foreach( $counts as $index => $count ) { |
| 95 | - if( empty( $count ))continue; |
|
| 95 | + if( empty( $count )) { |
|
| 96 | + continue; |
|
| 97 | + } |
|
| 96 | 98 | $counts[$index] = $count / $total * 100; |
| 97 | 99 | } |
| 98 | 100 | return $this->getRoundedPercentages( $counts ); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | natsort( $routines ); |
| 18 | 18 | array_walk( $routines, function( $routine ) { |
| 19 | 19 | $parts = explode( '__', $routine ); |
| 20 | - if( version_compare( glsr()->version, end( $parts ), '>=' ))return; |
|
| 20 | + if( version_compare( glsr()->version, end( $parts ), '>=' ) )return; |
|
| 21 | 21 | call_user_func( [$this, $routine] ); |
| 22 | 22 | }); |
| 23 | 23 | $this->updateVersion(); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | public function updateVersion() |
| 30 | 30 | { |
| 31 | 31 | $currentVersion = glsr( OptionManager::class )->get( 'version' ); |
| 32 | - if( version_compare( $currentVersion, glsr()->version, '<' )) { |
|
| 32 | + if( version_compare( $currentVersion, glsr()->version, '<' ) ) { |
|
| 33 | 33 | glsr( OptionManager::class )->set( 'version', glsr()->version ); |
| 34 | 34 | } |
| 35 | 35 | if( $currentVersion != glsr()->version ) { |
@@ -17,7 +17,9 @@ |
||
| 17 | 17 | natsort( $routines ); |
| 18 | 18 | array_walk( $routines, function( $routine ) { |
| 19 | 19 | $parts = explode( '__', $routine ); |
| 20 | - if( version_compare( glsr()->version, end( $parts ), '>=' ))return; |
|
| 20 | + if( version_compare( glsr()->version, end( $parts ), '>=' )) { |
|
| 21 | + return; |
|
| 22 | + } |
|
| 21 | 23 | call_user_func( [$this, $routine] ); |
| 22 | 24 | }); |
| 23 | 25 | $this->updateVersion(); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | 'setting' => 'Plugin Settings', |
| 39 | 39 | 'reviews' => 'Review Counts', |
| 40 | 40 | ]; |
| 41 | - $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) { |
|
| 41 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) { |
|
| 42 | 42 | $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' ); |
| 43 | 43 | if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
| 44 | 44 | return $carry.$this->implode( $details[$key], $systemDetails ); |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $plugins = get_plugins(); |
| 57 | 57 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 58 | - $inactive = array_diff_key( $plugins, array_flip( $activePlugins )); |
|
| 59 | - return $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 58 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
| 59 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | public function getInactivePluginDetails() |
| 81 | 81 | { |
| 82 | 82 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 83 | - return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
| 83 | + return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | { |
| 91 | 91 | $plugins = array_merge( |
| 92 | 92 | get_mu_plugins(), |
| 93 | - get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
|
| 93 | + get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) ) |
|
| 94 | 94 | ); |
| 95 | - if( empty( $plugins ))return; |
|
| 95 | + if( empty($plugins) )return; |
|
| 96 | 96 | return $this->normalizePluginList( $plugins ); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function getMultisitePluginDetails() |
| 103 | 103 | { |
| 104 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
| 104 | + if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return; |
|
| 105 | 105 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | 'Max Input Vars' => ini_get( 'max_input_vars' ), |
| 128 | 128 | 'Memory Limit' => ini_get( 'memory_limit' ), |
| 129 | 129 | 'Post Max Size' => ini_get( 'post_max_size' ), |
| 130 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
| 131 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
| 132 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
| 133 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ), |
|
| 134 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
| 130 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
| 131 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
| 132 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
| 133 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
| 134 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
| 135 | 135 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
| 136 | 136 | ]; |
| 137 | 137 | } |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | ksort( $settings ); |
| 177 | 177 | $details = []; |
| 178 | 178 | foreach( $settings as $key => $value ) { |
| 179 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
| 180 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
| 179 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
| 180 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
| 181 | 181 | $details[$key] = $value; |
| 182 | 182 | } |
| 183 | 183 | return $details; |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | 'WPE_APIKEY' => 'WP Engine', |
| 250 | 250 | ]; |
| 251 | 251 | foreach( $checks as $key => $value ) { |
| 252 | - if( !$this->isWebhostCheckValid( $key ))continue; |
|
| 252 | + if( !$this->isWebhostCheckValid( $key ) )continue; |
|
| 253 | 253 | return $value; |
| 254 | 254 | } |
| 255 | - return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] )); |
|
| 255 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | $plugins = get_plugins(); |
| 275 | 275 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 276 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
| 277 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 276 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
| 277 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 278 | 278 | return $active + $inactive; |
| 279 | 279 | } |
| 280 | 280 | |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | protected function implode( $title, array $details ) |
| 286 | 286 | { |
| 287 | 287 | $strings = ['['.$title.']']; |
| 288 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
| 288 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
| 289 | 289 | $padding = max( [$padding, static::PAD] ); |
| 290 | 290 | foreach( $details as $key => $value ) { |
| 291 | 291 | $strings[] = is_string( $key ) |
@@ -328,9 +328,9 @@ discard block |
||
| 328 | 328 | $keys = [ |
| 329 | 329 | 'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret', |
| 330 | 330 | ]; |
| 331 | - array_walk( $settings, function( &$value, $setting ) use( $keys ) { |
|
| 331 | + array_walk( $settings, function( &$value, $setting ) use($keys) { |
|
| 332 | 332 | foreach( $keys as $key ) { |
| 333 | - if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue; |
|
| 333 | + if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue; |
|
| 334 | 334 | $value = str_repeat( '•', 13 ); |
| 335 | 335 | return; |
| 336 | 336 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function saveAssignedToMetabox( $postId ) |
| 87 | 87 | { |
| 88 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 88 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ) )return; |
|
| 89 | 89 | $assignedTo = glsr( Helper::class )->filterInput( 'assigned_to' ); |
| 90 | 90 | $assignedTo || $assignedTo = ''; |
| 91 | 91 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function saveResponseMetabox( $postId ) |
| 102 | 102 | { |
| 103 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
| 103 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ) )return; |
|
| 104 | 104 | $response = glsr( Helper::class )->filterInput( 'response' ); |
| 105 | 105 | $response || $response = ''; |
| 106 | 106 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
| 107 | 107 | 'a' => ['href' => [], 'title' => []], |
| 108 | 108 | 'em' => [], |
| 109 | 109 | 'strong' => [], |
| 110 | - ]))); |
|
| 110 | + ] ) ) ); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | protected function getAssignedToPostId( $postId ) |
| 118 | 118 | { |
| 119 | - $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true )); |
|
| 120 | - if(( $post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
| 119 | + $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true ) ); |
|
| 120 | + if( ($post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
| 121 | 121 | return $post->ID; |
| 122 | 122 | } |
| 123 | 123 | return false; |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | $meta = wp_parse_args( $meta, [ |
| 132 | 132 | 'rating' => get_post_meta( $review->ID, 'rating', true ), |
| 133 | 133 | 'review_type' => get_post_meta( $review->ID, 'review_type', true ), |
| 134 | - ]); |
|
| 134 | + ] ); |
|
| 135 | 135 | if( !in_array( $meta['review_type'], glsr()->reviewTypes ) |
| 136 | 136 | || intval( $meta['rating'] ) > Rating::MAX_RATING |
| 137 | 137 | )return; |
| 138 | 138 | $counts = glsr( OptionManager::class )->get( 'counts.'.$meta['review_type'], [] ); |
| 139 | 139 | foreach( range( 0, Rating::MAX_RATING ) as $rating ) { |
| 140 | - if( isset( $counts[$rating] ))continue; |
|
| 140 | + if( isset($counts[$rating]) )continue; |
|
| 141 | 141 | $counts[$rating] = 0; |
| 142 | 142 | } |
| 143 | 143 | ksort( $counts ); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | protected function setReviewCounts( WP_Post $review, array $counts ) |
| 151 | 151 | { |
| 152 | 152 | $type = get_post_meta( $review->ID, 'review_type', true ); |
| 153 | - if( !in_array( $type, glsr()->reviewTypes ))return; |
|
| 153 | + if( !in_array( $type, glsr()->reviewTypes ) )return; |
|
| 154 | 154 | glsr( OptionManager::class )->set( 'counts.'.$type, $counts ); |
| 155 | 155 | } |
| 156 | 156 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | protected function increaseReviewCount( WP_Post $review, array $meta = [] ) |
| 161 | 161 | { |
| 162 | - if( $counts = $this->getReviewCounts( $review, $meta )) { |
|
| 162 | + if( $counts = $this->getReviewCounts( $review, $meta ) ) { |
|
| 163 | 163 | $counts[$rating] -= 1; |
| 164 | 164 | $this->setReviewCounts( $review, $counts ); |
| 165 | 165 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | protected function decreaseReviewCount( WP_Post $review, array $meta = [] ) |
| 172 | 172 | { |
| 173 | - if( $counts = $this->getReviewCounts( $review, $meta )) { |
|
| 173 | + if( $counts = $this->getReviewCounts( $review, $meta ) ) { |
|
| 174 | 174 | $counts[$rating] += 1; |
| 175 | 175 | $this->setReviewCounts( $review, $counts ); |
| 176 | 176 | } |
@@ -197,19 +197,19 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | protected function updateAssignedToPost( WP_Post $review ) |
| 199 | 199 | { |
| 200 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
| 201 | - $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
| 202 | - if( empty( $reviewIds ))return; |
|
| 200 | + if( !($postId = $this->getAssignedToPostId( $review->ID )) )return; |
|
| 201 | + $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
| 202 | + if( empty($reviewIds) )return; |
|
| 203 | 203 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
| 204 | - $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
| 205 | - if( empty( $updatedReviewIds )) { |
|
| 204 | + $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
| 205 | + if( empty($updatedReviewIds) ) { |
|
| 206 | 206 | delete_post_meta( $postId, static::META_RANKING ); |
| 207 | 207 | delete_post_meta( $postId, static::META_REVIEW_ID ); |
| 208 | 208 | } |
| 209 | - else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds )) { |
|
| 209 | + else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds ) ) { |
|
| 210 | 210 | $counts = glsr( Database::class )->buildReviewCountsFromIds( $updatedReviewIds ); |
| 211 | - update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results )); |
|
| 212 | - update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results )); |
|
| 211 | + update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results ) ); |
|
| 212 | + update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results ) ); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | if( $review->post_status != 'publish' ) { |
| 223 | 223 | delete_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
| 224 | 224 | } |
| 225 | - else if( !in_array( $review->ID, $reviewIds )) { |
|
| 225 | + else if( !in_array( $review->ID, $reviewIds ) ) { |
|
| 226 | 226 | add_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | public function onBeforeUpdateReview( WP_Post $review, $metaKey, $metaValue ) |
| 24 | 24 | { |
| 25 | 25 | $previousValue = get_post_meta( $review->ID, $metaKey, true ); |
| 26 | - if( $previousValue == $metaValue )return; |
|
| 26 | + if( $previousValue == $metaValue ) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 27 | 29 | $this->decreaseReviewCount( $review ); |
| 28 | 30 | $this->increaseReviewCount( $review, [$metaKey => $metaValue] ); |
| 29 | 31 | } |
@@ -36,7 +38,9 @@ discard block |
||
| 36 | 38 | */ |
| 37 | 39 | public function onCreateReview( $postData, $meta, $postId ) |
| 38 | 40 | { |
| 39 | - if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE )return; |
|
| 41 | + if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE ) { |
|
| 42 | + return; |
|
| 43 | + } |
|
| 40 | 44 | $review = get_post( $postId ); |
| 41 | 45 | $this->updateAssignedToPost( $review ); |
| 42 | 46 | $this->increaseReviewCount( $review ); |
@@ -48,7 +52,9 @@ discard block |
||
| 48 | 52 | */ |
| 49 | 53 | public function onDeleteReview( $postId ) |
| 50 | 54 | { |
| 51 | - if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE )return; |
|
| 55 | + if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE ) { |
|
| 56 | + return; |
|
| 57 | + } |
|
| 52 | 58 | $review = get_post( $postId ); |
| 53 | 59 | $review->post_status = 'deleted'; // important to change the post_status here first! |
| 54 | 60 | $this->updateAssignedToPost( $review ); |
@@ -85,7 +91,9 @@ discard block |
||
| 85 | 91 | */ |
| 86 | 92 | public function saveAssignedToMetabox( $postId ) |
| 87 | 93 | { |
| 88 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 94 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 89 | 97 | $assignedTo = glsr( Helper::class )->filterInput( 'assigned_to' ); |
| 90 | 98 | $assignedTo || $assignedTo = ''; |
| 91 | 99 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -100,7 +108,9 @@ discard block |
||
| 100 | 108 | */ |
| 101 | 109 | public function saveResponseMetabox( $postId ) |
| 102 | 110 | { |
| 103 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
| 111 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) { |
|
| 112 | + return; |
|
| 113 | + } |
|
| 104 | 114 | $response = glsr( Helper::class )->filterInput( 'response' ); |
| 105 | 115 | $response || $response = ''; |
| 106 | 116 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
@@ -134,10 +144,14 @@ discard block |
||
| 134 | 144 | ]); |
| 135 | 145 | if( !in_array( $meta['review_type'], glsr()->reviewTypes ) |
| 136 | 146 | || intval( $meta['rating'] ) > Rating::MAX_RATING |
| 137 | - )return; |
|
| 147 | + ) { |
|
| 148 | + return; |
|
| 149 | + } |
|
| 138 | 150 | $counts = glsr( OptionManager::class )->get( 'counts.'.$meta['review_type'], [] ); |
| 139 | 151 | foreach( range( 0, Rating::MAX_RATING ) as $rating ) { |
| 140 | - if( isset( $counts[$rating] ))continue; |
|
| 152 | + if( isset( $counts[$rating] )) { |
|
| 153 | + continue; |
|
| 154 | + } |
|
| 141 | 155 | $counts[$rating] = 0; |
| 142 | 156 | } |
| 143 | 157 | ksort( $counts ); |
@@ -150,7 +164,9 @@ discard block |
||
| 150 | 164 | protected function setReviewCounts( WP_Post $review, array $counts ) |
| 151 | 165 | { |
| 152 | 166 | $type = get_post_meta( $review->ID, 'review_type', true ); |
| 153 | - if( !in_array( $type, glsr()->reviewTypes ))return; |
|
| 167 | + if( !in_array( $type, glsr()->reviewTypes )) { |
|
| 168 | + return; |
|
| 169 | + } |
|
| 154 | 170 | glsr( OptionManager::class )->set( 'counts.'.$type, $counts ); |
| 155 | 171 | } |
| 156 | 172 | |
@@ -197,9 +213,13 @@ discard block |
||
| 197 | 213 | */ |
| 198 | 214 | protected function updateAssignedToPost( WP_Post $review ) |
| 199 | 215 | { |
| 200 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
| 216 | + if( !( $postId = $this->getAssignedToPostId( $review->ID ))) { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 201 | 219 | $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 202 | - if( empty( $reviewIds ))return; |
|
| 220 | + if( empty( $reviewIds )) { |
|
| 221 | + return; |
|
| 222 | + } |
|
| 203 | 223 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
| 204 | 224 | $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 205 | 225 | if( empty( $updatedReviewIds )) { |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function enqueueAssets() |
| 26 | 26 | { |
| 27 | - $command = new EnqueueAdminAssets([ |
|
| 27 | + $command = new EnqueueAdminAssets( [ |
|
| 28 | 28 | 'pointers' => [[ |
| 29 | 29 | 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
| 30 | 30 | 'id' => 'glsr-pointer-pinned', |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | 'target' => '#misc-pub-pinned', |
| 37 | 37 | 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
| 38 | 38 | ]], |
| 39 | - ]); |
|
| 39 | + ] ); |
|
| 40 | 40 | $this->execute( $command ); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
| 50 | 50 | 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
| 51 | - ]); |
|
| 51 | + ] ); |
|
| 52 | 52 | return $links; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -59,19 +59,19 @@ discard block |
||
| 59 | 59 | public function filterDashboardGlanceItems( array $items ) |
| 60 | 60 | { |
| 61 | 61 | $postCount = wp_count_posts( Application::POST_TYPE ); |
| 62 | - if( empty( $postCount->publish )) { |
|
| 62 | + if( empty($postCount->publish) ) { |
|
| 63 | 63 | return $items; |
| 64 | 64 | } |
| 65 | 65 | $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
| 66 | - $text = sprintf( $text, number_format_i18n( $postCount->publish )); |
|
| 66 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
| 67 | 67 | $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
| 68 | 68 | ? glsr( Builder::class )->a( $text, [ |
| 69 | 69 | 'class' => 'glsr-review-count', |
| 70 | 70 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
| 71 | - ]) |
|
| 71 | + ] ) |
|
| 72 | 72 | : glsr( Builder::class )->span( $text, [ |
| 73 | 73 | 'class' => 'glsr-review-count', |
| 74 | - ]); |
|
| 74 | + ] ); |
|
| 75 | 75 | return $items; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public function filterTinymcePlugins( array $plugins ) |
| 83 | 83 | { |
| 84 | 84 | if( user_can_richedit() |
| 85 | - && ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ))) { |
|
| 85 | + && (current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) ) { |
|
| 86 | 86 | $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
| 87 | 87 | } |
| 88 | 88 | return $plugins; |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function registerShortcodeButtons() |
| 96 | 96 | { |
| 97 | - $command = new RegisterShortcodeButtons([ |
|
| 97 | + $command = new RegisterShortcodeButtons( [ |
|
| 98 | 98 | 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
| 99 | 99 | 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
| 100 | 100 | 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
| 101 | - ]); |
|
| 101 | + ] ); |
|
| 102 | 102 | $this->execute( $command ); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function renderReviewEditor( WP_Post $post ) |
| 110 | 110 | { |
| 111 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 111 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 112 | 112 | glsr()->render( 'partials/editor/review', [ |
| 113 | 113 | 'post' => $post, |
| 114 | - ]); |
|
| 114 | + ] ); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function renderReviewNotice( WP_Post $post ) |
| 122 | 122 | { |
| 123 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 124 | - glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' )); |
|
| 123 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 124 | + glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ) ); |
|
| 125 | 125 | glsr( Html::class )->renderTemplate( 'partials/editor/notice', [ |
| 126 | 126 | 'context' => [ |
| 127 | 127 | 'notices' => glsr( Notice::class )->get(), |
| 128 | 128 | ], |
| 129 | - ]); |
|
| 129 | + ] ); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | if( glsr_current_screen()->base != 'post' )return; |
| 139 | 139 | $shortcodes = []; |
| 140 | 140 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
| 141 | - if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ))continue; |
|
| 141 | + if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ) )continue; |
|
| 142 | 142 | $shortcodes[$shortcode] = $values; |
| 143 | 143 | } |
| 144 | - if( empty( $shortcodes ))return; |
|
| 144 | + if( empty($shortcodes) )return; |
|
| 145 | 145 | glsr()->render( 'partials/editor/tinymce', [ |
| 146 | 146 | 'shortcodes' => $shortcodes, |
| 147 | - ]); |
|
| 147 | + ] ); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | public function routerClearConsole() |
| 154 | 154 | { |
| 155 | 155 | glsr( Console::class )->clear(); |
| 156 | - glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' )); |
|
| 156 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | $counts = glsr( Database::class )->buildReviewCounts(); |
| 165 | 165 | glsr( OptionManager::class )->set( 'counts', $counts ); |
| 166 | - glsr( Notice::class )->addSuccess( __( 'Recalculated review counts.', 'site-reviews' )); |
|
| 166 | + glsr( Notice::class )->addSuccess( __( 'Recalculated review counts.', 'site-reviews' ) ); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -197,17 +197,17 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | $file = $_FILES['import-file']; |
| 199 | 199 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
| 200 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
| 200 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
| 201 | 201 | } |
| 202 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
| 203 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
| 202 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
| 203 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
| 204 | 204 | } |
| 205 | 205 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
| 206 | - if( empty( $settings )) { |
|
| 207 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
| 206 | + if( empty($settings) ) { |
|
| 207 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
| 208 | 208 | } |
| 209 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
| 210 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
| 209 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
| 210 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
| 226 | 226 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
| 227 | 227 | ]; |
| 228 | - return !isset( $errors[$errorCode] ) |
|
| 228 | + return !isset($errors[$errorCode]) |
|
| 229 | 229 | ? __( 'Unknown upload error.', 'site-reviews' ) |
| 230 | 230 | : $errors[$errorCode]; |
| 231 | 231 | } |