@@ -33,6 +33,6 @@ |
||
33 | 33 | 'permission_callback' => [$this, 'get_items_permissions_check'], |
34 | 34 | ], |
35 | 35 | 'schema' => [$this, 'get_public_item_schema'], |
36 | - ]); |
|
36 | + ] ); |
|
37 | 37 | } |
38 | 38 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | 'title' => 'Images', |
18 | 18 | ], |
19 | 19 | 'plugin' => 'site-reviews-images/site-reviews-images.php', |
20 | - ]); |
|
20 | + ] ); |
|
21 | 21 | $template->render( 'partials/addons/addon', [ |
22 | 22 | 'context' => [ |
23 | 23 | 'description' => __( 'Sync your Tripadvisor reviews to your website and manage them with Site Reviews.', 'site-reviews' ), |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'title' => 'Tripadvisor Reviews', |
27 | 27 | ], |
28 | 28 | 'plugin' => 'site-reviews-tripadvisor/site-reviews-tripadvisor.php', |
29 | - ]); |
|
29 | + ] ); |
|
30 | 30 | ?> |
31 | 31 | </div> |
32 | 32 | </div> |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function renderTaxonomyFilter() |
37 | 37 | { |
38 | - if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ))return; |
|
38 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ) )return; |
|
39 | 39 | echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
40 | 40 | 'class' => 'screen-reader-text', |
41 | 41 | 'for' => Application::TAXONOMY, |
42 | - ]); |
|
43 | - wp_dropdown_categories([ |
|
42 | + ] ); |
|
43 | + wp_dropdown_categories( [ |
|
44 | 44 | 'depth' => 3, |
45 | 45 | 'hide_empty' => true, |
46 | 46 | 'hide_if_empty' => true, |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'show_option_all' => $this->getShowOptionAll(), |
53 | 53 | 'taxonomy' => Application::TAXONOMY, |
54 | 54 | 'value_field' => 'slug', |
55 | - ]); |
|
55 | + ] ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | protected function getSelected() |
62 | 62 | { |
63 | 63 | global $wp_query; |
64 | - return isset( $wp_query->query[Application::TAXONOMY] ) |
|
64 | + return isset($wp_query->query[Application::TAXONOMY]) |
|
65 | 65 | ? $wp_query->query[Application::TAXONOMY] |
66 | 66 | : ''; |
67 | 67 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | $taxonomy = get_taxonomy( Application::TAXONOMY ); |
75 | 75 | return $taxonomy |
76 | - ? ucfirst( strtolower( $taxonomy->labels->all_items )) |
|
76 | + ? ucfirst( strtolower( $taxonomy->labels->all_items ) ) |
|
77 | 77 | : ''; |
78 | 78 | } |
79 | 79 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | 'savePending' => __( 'Save as Unapproved', 'site-reviews' ), |
18 | 18 | 'published' => __( 'Approved', 'site-reviews' ), |
19 | 19 | ]; |
20 | - if( $this->canModifyTranslation() && isset( $wp_scripts->registered['post']->extra['data'] )) { |
|
20 | + if( $this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data']) ) { |
|
21 | 21 | $l10n = &$wp_scripts->registered['post']->extra['data']; |
22 | 22 | foreach( $strings as $search => $replace ) { |
23 | 23 | $l10n = preg_replace( '/("'.$search.'":")([^"]+)/', "$1".$replace, $l10n ); |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function filterPostStatusLabels( $translation, $text, $domain ) |
35 | 35 | { |
36 | - if( $this->canModifyTranslation( $domain )) { |
|
36 | + if( $this->canModifyTranslation( $domain ) ) { |
|
37 | 37 | $replacements = $this->getStatusLabels(); |
38 | - if( array_key_exists( $text, $replacements )) { |
|
38 | + if( array_key_exists( $text, $replacements ) ) { |
|
39 | 39 | $translation = $replacements[$text]; |
40 | 40 | } |
41 | 41 | } |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | public function filterUpdateMessages( array $messages ) |
49 | 49 | { |
50 | 50 | $post = get_post(); |
51 | - if( !( $post instanceof WP_Post ))return; |
|
51 | + if( !($post instanceof WP_Post) )return; |
|
52 | 52 | $strings = $this->getReviewLabels(); |
53 | 53 | $restored = filter_input( INPUT_GET, 'revision' ); |
54 | - if( $revisionTitle = wp_post_revision_title( intval( $restored ), false )) { |
|
54 | + if( $revisionTitle = wp_post_revision_title( intval( $restored ), false ) ) { |
|
55 | 55 | $restored = sprintf( $strings['restored'], $revisionTitle ); |
56 | 56 | } |
57 | - $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date )); |
|
58 | - $messages[ Application::POST_TYPE ] = [ |
|
57 | + $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) ); |
|
58 | + $messages[Application::POST_TYPE] = [ |
|
59 | 59 | 1 => $strings['updated'], |
60 | 60 | 4 => $strings['updated'], |
61 | 61 | 5 => $restored, |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | protected function canModifyTranslation( $domain = 'default' ) |
79 | 79 | { |
80 | - if( $domain != 'default' || empty( glsr_current_screen()->base )) { |
|
80 | + if( $domain != 'default' || empty(glsr_current_screen()->base) ) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | return glsr_current_screen()->post_type == Application::POST_TYPE |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | protected function getStatusLabels() |
113 | 113 | { |
114 | 114 | static $labels; |
115 | - if( empty( $labels )) { |
|
115 | + if( empty($labels) ) { |
|
116 | 116 | $labels = [ |
117 | 117 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
118 | 118 | 'Pending Review' => __( 'Unapproved', 'site-reviews' ), |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | 'post_type' => Application::POST_TYPE, |
36 | 36 | ]; |
37 | 37 | $postId = wp_insert_post( $postValues, true ); |
38 | - if( is_wp_error( $postId )) { |
|
38 | + if( is_wp_error( $postId ) ) { |
|
39 | 39 | glsr_log()->error( $postId->get_error_message() )->debug( $postValues ); |
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | $this->setTerms( $postId, $command->category ); |
43 | - $review = $this->single( get_post( $postId )); |
|
43 | + $review = $this->single( get_post( $postId ) ); |
|
44 | 44 | do_action( 'site-reviews/review/created', $review, $command ); |
45 | 45 | return $review; |
46 | 46 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function delete( $metaReviewId ) |
53 | 53 | { |
54 | - if( $postId = $this->getPostId( $metaReviewId )) { |
|
54 | + if( $postId = $this->getPostId( $metaReviewId ) ) { |
|
55 | 55 | wp_delete_post( $postId, true ); |
56 | 56 | } |
57 | 57 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $paged = glsr( QueryBuilder::class )->getPaged( |
74 | 74 | wp_validate_boolean( $args['pagination'] ) |
75 | 75 | ); |
76 | - $reviews = new WP_Query([ |
|
76 | + $reviews = new WP_Query( [ |
|
77 | 77 | 'meta_key' => 'pinned', |
78 | 78 | 'meta_query' => $metaQuery, |
79 | 79 | 'offset' => $args['offset'], |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'post_type' => Application::POST_TYPE, |
87 | 87 | 'posts_per_page' => $args['count'], |
88 | 88 | 'tax_query' => $taxQuery, |
89 | - ]); |
|
89 | + ] ); |
|
90 | 90 | return (object)[ |
91 | 91 | 'results' => array_map( [$this, 'single'], $reviews->posts ), |
92 | 92 | 'max_num_pages' => $reviews->max_num_pages, |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | $terms = []; |
112 | 112 | $termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds ); |
113 | 113 | foreach( $termIds as $termId ) { |
114 | - if( is_numeric( $termId )) { |
|
114 | + if( is_numeric( $termId ) ) { |
|
115 | 115 | $termId = intval( $termId ); |
116 | 116 | } |
117 | 117 | $term = term_exists( $termId, Application::TAXONOMY ); |
118 | - if( !isset( $term['term_id'] ))continue; |
|
118 | + if( !isset($term['term_id']) )continue; |
|
119 | 119 | $terms[] = intval( $term['term_id'] ); |
120 | 120 | } |
121 | 121 | return $terms; |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | { |
130 | 130 | if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
131 | 131 | delete_post_meta( $postId, '_edit_last' ); |
132 | - $result = wp_update_post([ |
|
132 | + $result = wp_update_post( [ |
|
133 | 133 | 'ID' => $postId, |
134 | 134 | 'post_content' => get_post_meta( $postId, 'content', true ), |
135 | 135 | 'post_date' => get_post_meta( $postId, 'date', true ), |
136 | 136 | 'post_title' => get_post_meta( $postId, 'title', true ), |
137 | - ]); |
|
138 | - if( is_wp_error( $result )) { |
|
137 | + ] ); |
|
138 | + if( is_wp_error( $result ) ) { |
|
139 | 139 | glsr_log()->error( $result->get_error_message() ); |
140 | 140 | } |
141 | 141 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | protected function getNewPostStatus( array $review, $isBlacklisted ) |
158 | 158 | { |
159 | 159 | $requireApprovalOption = glsr( OptionManager::class )->get( 'settings.general.require.approval' ); |
160 | - return $review['review_type'] == 'local' && ( $requireApprovalOption == 'yes' || $isBlacklisted ) |
|
160 | + return $review['review_type'] == 'local' && ($requireApprovalOption == 'yes' || $isBlacklisted) |
|
161 | 161 | ? 'pending' |
162 | 162 | : 'publish'; |
163 | 163 | } |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | protected function setTerms( $postId, $termIds ) |
171 | 171 | { |
172 | 172 | $terms = $this->normalizeTerms( $termIds ); |
173 | - if( empty( $terms ))return; |
|
173 | + if( empty($terms) )return; |
|
174 | 174 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
175 | - if( is_wp_error( $result )) { |
|
175 | + if( is_wp_error( $result ) ) { |
|
176 | 176 | glsr_log()->error( $result->get_error_message() ); |
177 | 177 | } |
178 | 178 | } |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | public function build( array $args = [] ) |
36 | 36 | { |
37 | 37 | $this->args = $args; |
38 | - $counts = glsr( CountsManager::class )->get([ |
|
38 | + $counts = glsr( CountsManager::class )->get( [ |
|
39 | 39 | 'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ), |
40 | 40 | 'term_ids' => glsr( ReviewManager::class )->normalizeTerms( $args['category'] ), |
41 | 41 | 'type' => $args['type'], |
42 | - ]); |
|
42 | + ] ); |
|
43 | 43 | $this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [ |
44 | 44 | 'min' => $args['rating'], |
45 | - ]); |
|
46 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
45 | + ] ); |
|
46 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) )return; |
|
47 | 47 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
48 | 48 | $this->generateSchema(); |
49 | 49 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'stars' => $this->buildStars(), |
56 | 56 | 'text' => $this->buildText(), |
57 | 57 | ], |
58 | - ]); |
|
58 | + ] ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function buildPercentage() |
65 | 65 | { |
66 | - if( $this->isHidden( 'bars' ))return; |
|
67 | - $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
|
68 | - $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) { |
|
66 | + if( $this->isHidden( 'bars' ) )return; |
|
67 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) ); |
|
68 | + $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use($percentages) { |
|
69 | 69 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
70 | 70 | $background = $this->buildPercentageBackground( $percentages[$level] ); |
71 | 71 | $count = apply_filters( 'site-reviews/summary/counts', |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $percent = $this->buildPercentageCount( $count ); |
76 | 76 | return $carry.glsr( Builder::class )->div( $label.$background.$percent, [ |
77 | 77 | 'class' => 'glsr-bar', |
78 | - ]); |
|
78 | + ] ); |
|
79 | 79 | }); |
80 | 80 | return $this->wrap( 'percentage', $bars ); |
81 | 81 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | */ |
87 | 87 | protected function buildPercentageBackground( $percent ) |
88 | 88 | { |
89 | - $backgroundPercent = glsr( Builder::class )->span([ |
|
89 | + $backgroundPercent = glsr( Builder::class )->span( [ |
|
90 | 90 | 'class' => 'glsr-bar-background-percent', |
91 | 91 | 'style' => 'width:'.$percent, |
92 | - ]); |
|
92 | + ] ); |
|
93 | 93 | return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
94 | 94 | } |
95 | 95 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function buildRating() |
118 | 118 | { |
119 | - if( $this->isHidden( 'rating' ))return; |
|
119 | + if( $this->isHidden( 'rating' ) )return; |
|
120 | 120 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
121 | 121 | } |
122 | 122 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function buildStars() |
127 | 127 | { |
128 | - if( $this->isHidden( 'stars' ))return; |
|
128 | + if( $this->isHidden( 'stars' ) )return; |
|
129 | 129 | $stars = glsr( Partial::class )->build( 'star-rating', ['rating' => $this->averageRating] ); |
130 | 130 | return $this->wrap( 'stars', $stars ); |
131 | 131 | } |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | */ |
136 | 136 | protected function buildText() |
137 | 137 | { |
138 | - if( $this->isHidden( 'summary' ))return; |
|
139 | - $count = intval( array_sum( $this->ratingCounts )); |
|
140 | - if( empty( $this->args['text'] )) { |
|
138 | + if( $this->isHidden( 'summary' ) )return; |
|
139 | + $count = intval( array_sum( $this->ratingCounts ) ); |
|
140 | + if( empty($this->args['text']) ) { |
|
141 | 141 | // @todo document this change |
142 | 142 | $this->args['text'] = _nx( |
143 | 143 | '{rating} out of {max} stars (based on {num} review)', |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | ); |
149 | 149 | } |
150 | 150 | $summary = str_replace( |
151 | - ['{rating}','{max}', '{num}'], |
|
151 | + ['{rating}', '{max}', '{num}'], |
|
152 | 152 | [$this->averageRating, Rating::MAX_RATING, $count], |
153 | 153 | $this->args['text'] |
154 | 154 | ); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | protected function generateSchema() |
162 | 162 | { |
163 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
163 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
164 | 164 | glsr( Schema::class )->store( |
165 | 165 | glsr( Schema::class )->buildSummary( $this->args ) |
166 | 166 | ); |
@@ -192,6 +192,6 @@ discard block |
||
192 | 192 | { |
193 | 193 | return glsr( Builder::class )->div( $value, [ |
194 | 194 | 'class' => 'glsr-summary-'.$key, |
195 | - ]); |
|
195 | + ] ); |
|
196 | 196 | } |
197 | 197 | } |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function __get( $key ) |
48 | 48 | { |
49 | - if( property_exists( $this, $key )) { |
|
49 | + if( property_exists( $this, $key ) ) { |
|
50 | 50 | return $this->$key; |
51 | 51 | } |
52 | - if( is_array( $this->custom ) && array_key_exists( $key, $this->custom )) { |
|
52 | + if( is_array( $this->custom ) && array_key_exists( $key, $this->custom ) ) { |
|
53 | 53 | return $this->custom[$key]; |
54 | 54 | } |
55 | 55 | return ''; |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | 'review_type' => 'local', |
78 | 78 | ]; |
79 | 79 | $meta = array_filter( |
80 | - array_map( 'array_shift', (array)get_post_meta( $post->ID )), |
|
80 | + array_map( 'array_shift', (array)get_post_meta( $post->ID ) ), |
|
81 | 81 | 'strlen' |
82 | 82 | ); |
83 | - $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
|
83 | + $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) ); |
|
84 | 84 | $this->modified = $this->isModified( $properties ); |
85 | 85 | array_walk( $properties, function( $value, $key ) { |
86 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
86 | + if( !property_exists( $this, $key ) || isset($this->$key) )return; |
|
87 | 87 | $this->$key = maybe_unserialize( $value ); |
88 | 88 | }); |
89 | 89 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | protected function setTermIds( WP_Post $post ) |
95 | 95 | { |
96 | 96 | $this->term_ids = []; |
97 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
97 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return; |
|
98 | 98 | foreach( $terms as $term ) { |
99 | 99 | $this->term_ids[] = $term->term_id; |
100 | 100 | } |
@@ -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( strtoupper( $details[$key] ), $systemDetails ); |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | { |
58 | 58 | $plugins = get_plugins(); |
59 | 59 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
60 | - $inactive = array_diff_key( $plugins, array_flip( $activePlugins )); |
|
61 | - return $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
60 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
61 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function getInactivePluginDetails() |
93 | 93 | { |
94 | 94 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
95 | - return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
95 | + return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | { |
103 | 103 | $plugins = array_merge( |
104 | 104 | get_mu_plugins(), |
105 | - get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
|
105 | + get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) ) |
|
106 | 106 | ); |
107 | - if( empty( $plugins ))return; |
|
107 | + if( empty($plugins) )return; |
|
108 | 108 | return $this->normalizePluginList( $plugins ); |
109 | 109 | } |
110 | 110 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getMultisitePluginDetails() |
115 | 115 | { |
116 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
116 | + if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return; |
|
117 | 117 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
118 | 118 | } |
119 | 119 | |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | 'Max Input Vars' => ini_get( 'max_input_vars' ), |
140 | 140 | 'Memory Limit' => ini_get( 'memory_limit' ), |
141 | 141 | 'Post Max Size' => ini_get( 'post_max_size' ), |
142 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
143 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
144 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
145 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ), |
|
146 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
142 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
143 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
144 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
145 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
146 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
147 | 147 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
148 | 148 | ]; |
149 | 149 | } |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | { |
156 | 156 | $counts = glsr( CountsManager::class )->getCounts(); |
157 | 157 | $counts = glsr( Helper::class )->flattenArray( $counts ); |
158 | - array_walk( $counts, function( &$ratings ) use( $counts ) { |
|
159 | - if( !is_array( $ratings )) { |
|
158 | + array_walk( $counts, function( &$ratings ) use($counts) { |
|
159 | + if( !is_array( $ratings ) ) { |
|
160 | 160 | glsr_log() |
161 | 161 | ->error( '$ratings is not an array, possibly due to incorrectly imported reviews that are missing their review type.' ) |
162 | 162 | ->debug( $ratings ) |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | ksort( $settings ); |
196 | 196 | $details = []; |
197 | 197 | foreach( $settings as $key => $value ) { |
198 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
199 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
198 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
199 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
200 | 200 | $details[$key] = $value; |
201 | 201 | } |
202 | 202 | return $details; |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | 'WPE_APIKEY' => 'WP Engine', |
269 | 269 | ]; |
270 | 270 | foreach( $checks as $key => $value ) { |
271 | - if( !$this->isWebhostCheckValid( $key ))continue; |
|
271 | + if( !$this->isWebhostCheckValid( $key ) )continue; |
|
272 | 272 | return $value; |
273 | 273 | } |
274 | - return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] )); |
|
274 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | { |
293 | 293 | $plugins = get_plugins(); |
294 | 294 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
295 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
296 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
295 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
296 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
297 | 297 | return $active + $inactive; |
298 | 298 | } |
299 | 299 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | protected function implode( $title, array $details ) |
305 | 305 | { |
306 | 306 | $strings = ['['.$title.']']; |
307 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
307 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
308 | 308 | $padding = max( [$padding, static::PAD] ); |
309 | 309 | foreach( $details as $key => $value ) { |
310 | 310 | $strings[] = is_string( $key ) |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | $keys = [ |
348 | 348 | 'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret', |
349 | 349 | ]; |
350 | - array_walk( $settings, function( &$value, $setting ) use( $keys ) { |
|
350 | + array_walk( $settings, function( &$value, $setting ) use($keys) { |
|
351 | 351 | foreach( $keys as $key ) { |
352 | - if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue; |
|
352 | + if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue; |
|
353 | 353 | $value = str_repeat( '•', 13 ); |
354 | 354 | return; |
355 | 355 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $this->getCounts(), |
67 | 67 | $review->review_type, |
68 | 68 | $review->rating |
69 | - )); |
|
69 | + ) ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function decreasePostCounts( Review $review ) |
76 | 76 | { |
77 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
77 | + if( empty($counts = $this->getPostCounts( $review->assigned_to )) )return; |
|
78 | 78 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
79 | 79 | $this->setPostCounts( $review->assigned_to, $counts ); |
80 | 80 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function decreaseTermCounts( Review $review ) |
86 | 86 | { |
87 | 87 | foreach( $review->term_ids as $termId ) { |
88 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
88 | + if( empty($counts = $this->getTermCounts( $termId )) )continue; |
|
89 | 89 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
90 | 90 | $this->setTermCounts( $termId, $counts ); |
91 | 91 | } |
@@ -97,17 +97,17 @@ discard block |
||
97 | 97 | public function flatten( array $reviewCounts, array $args = [] ) |
98 | 98 | { |
99 | 99 | $counts = []; |
100 | - array_walk_recursive( $reviewCounts, function( $num, $index ) use( &$counts ) { |
|
101 | - $counts[$index] = isset( $counts[$index] ) |
|
100 | + array_walk_recursive( $reviewCounts, function( $num, $index ) use(&$counts) { |
|
101 | + $counts[$index] = isset($counts[$index]) |
|
102 | 102 | ? $num + $counts[$index] |
103 | 103 | : $num; |
104 | 104 | }); |
105 | 105 | $args = wp_parse_args( $args, [ |
106 | 106 | 'max' => Rating::MAX_RATING, |
107 | 107 | 'min' => Rating::MIN_RATING, |
108 | - ]); |
|
108 | + ] ); |
|
109 | 109 | foreach( $counts as $index => &$num ) { |
110 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
110 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue; |
|
111 | 111 | $num = 0; |
112 | 112 | } |
113 | 113 | return $counts; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'post_ids' => [], |
123 | 123 | 'term_ids' => [], |
124 | 124 | 'type' => 'local', |
125 | - ]); |
|
125 | + ] ); |
|
126 | 126 | $counts = []; |
127 | 127 | foreach( glsr( Polylang::class )->getPostIds( $args['post_ids'] ) as $postId ) { |
128 | 128 | $counts[] = $this->getPostCounts( $postId ); |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | foreach( $args['term_ids'] as $termId ) { |
131 | 131 | $counts[] = $this->getTermCounts( $termId ); |
132 | 132 | } |
133 | - if( empty( $counts )) { |
|
133 | + if( empty($counts) ) { |
|
134 | 134 | $counts[] = $this->getCounts(); |
135 | 135 | } |
136 | 136 | return in_array( $args['type'], ['', 'all'] ) |
137 | 137 | ? $this->normalize( [$this->flatten( $counts )] ) |
138 | - : $this->normalize( array_column( $counts, $args['type'] )); |
|
138 | + : $this->normalize( array_column( $counts, $args['type'] ) ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public function getCounts() |
145 | 145 | { |
146 | 146 | $counts = glsr( OptionManager::class )->get( 'counts', [] ); |
147 | - if( !is_array( $counts )) { |
|
147 | + if( !is_array( $counts ) ) { |
|
148 | 148 | glsr_log()->error( 'CountsManager: counts is not an array' )->debug( $counts ); |
149 | 149 | return []; |
150 | 150 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function getPostCounts( $postId ) |
159 | 159 | { |
160 | - return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true )); |
|
160 | + return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ) ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function getTermCounts( $termId ) |
168 | 168 | { |
169 | - return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true )); |
|
169 | + return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ) ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function increaseCounts( Review $review ) |
186 | 186 | { |
187 | - if( empty( $counts = $this->getCounts() )) { |
|
187 | + if( empty($counts = $this->getCounts()) ) { |
|
188 | 188 | $counts = $this->buildCounts(); |
189 | 189 | } |
190 | 190 | $this->setCounts( $this->increaseRating( |
191 | 191 | $counts, |
192 | 192 | $review->review_type, |
193 | 193 | $review->rating |
194 | - )); |
|
194 | + ) ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function increasePostCounts( Review $review ) |
201 | 201 | { |
202 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
202 | + if( !(get_post( $review->assigned_to ) instanceof WP_Post) )return; |
|
203 | 203 | $counts = $this->getPostCounts( $review->assigned_to ); |
204 | - $counts = empty( $counts ) |
|
204 | + $counts = empty($counts) |
|
205 | 205 | ? $this->buildPostCounts( $review->assigned_to ) |
206 | 206 | : $this->increaseRating( $counts, $review->review_type, $review->rating ); |
207 | 207 | $this->setPostCounts( $review->assigned_to, $counts ); |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function increaseTermCounts( Review $review ) |
214 | 214 | { |
215 | - $termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids )); |
|
215 | + $termIds = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) ); |
|
216 | 216 | foreach( $termIds as $termId ) { |
217 | 217 | $counts = $this->getTermCounts( $termId ); |
218 | - $counts = empty( $counts ) |
|
218 | + $counts = empty($counts) |
|
219 | 219 | ? $this->buildTermCounts( $termId ) |
220 | 220 | : $this->increaseRating( $counts, $review->review_type, $review->rating ); |
221 | 221 | $this->setTermCounts( $termId, $counts ); |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | { |
239 | 239 | $ratingCounts = $this->flatten( $reviewCounts ); |
240 | 240 | update_post_meta( $postId, static::META_COUNT, $reviewCounts ); |
241 | - update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
|
242 | - update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts )); |
|
241 | + update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) ); |
|
242 | + update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) ); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function setTermCounts( $termId, array $reviewCounts ) |
250 | 250 | { |
251 | - if( !term_exists( $termId ))return; |
|
251 | + if( !term_exists( $termId ) )return; |
|
252 | 252 | $ratingCounts = $this->flatten( $reviewCounts ); |
253 | 253 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
254 | - update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
|
255 | - update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts )); |
|
254 | + update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) ); |
|
255 | + update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) ); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | { |
264 | 264 | $counts = []; |
265 | 265 | $lastPostId = 0; |
266 | - while( $reviews = $this->queryReviews( $args, $lastPostId, $limit )) { |
|
267 | - $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
|
266 | + while( $reviews = $this->queryReviews( $args, $lastPostId, $limit ) ) { |
|
267 | + $types = array_keys( array_flip( array_column( $reviews, 'type' ) ) ); |
|
268 | 268 | foreach( $types as $type ) { |
269 | - if( isset( $counts[$type] ))continue; |
|
269 | + if( isset($counts[$type]) )continue; |
|
270 | 270 | $type = $this->normalizeType( $type ); |
271 | 271 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
272 | 272 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | protected function decreaseRating( array $reviewCounts, $type, $rating ) |
288 | 288 | { |
289 | - if( isset( $reviewCounts[$type][$rating] )) { |
|
289 | + if( isset($reviewCounts[$type][$rating]) ) { |
|
290 | 290 | $reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 ); |
291 | 291 | } |
292 | 292 | return $reviewCounts; |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | */ |
300 | 300 | protected function increaseRating( array $reviewCounts, $type, $rating ) |
301 | 301 | { |
302 | - if( !array_key_exists( $type, glsr()->reviewTypes )) { |
|
302 | + if( !array_key_exists( $type, glsr()->reviewTypes ) ) { |
|
303 | 303 | return $reviewCounts; |
304 | 304 | } |
305 | - if( !array_key_exists( $type, $reviewCounts )) { |
|
305 | + if( !array_key_exists( $type, $reviewCounts ) ) { |
|
306 | 306 | $reviewCounts[$type] = []; |
307 | 307 | } |
308 | 308 | $reviewCounts = $this->normalize( $reviewCounts ); |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | */ |
316 | 316 | protected function normalize( array $reviewCounts ) |
317 | 317 | { |
318 | - if( empty( $reviewCounts )) { |
|
318 | + if( empty($reviewCounts) ) { |
|
319 | 319 | $reviewCounts = [[]]; |
320 | 320 | } |
321 | 321 | foreach( $reviewCounts as &$counts ) { |
322 | 322 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
323 | - if( isset( $counts[$index] ))continue; |
|
323 | + if( isset($counts[$index]) )continue; |
|
324 | 324 | $counts[$index] = 0; |
325 | 325 | } |
326 | 326 | ksort( $counts ); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | */ |
335 | 335 | protected function normalizeType( $type ) |
336 | 336 | { |
337 | - return empty( $type ) || !is_string( $type ) |
|
337 | + return empty($type) || !is_string( $type ) |
|
338 | 338 | ? 'local' |
339 | 339 | : $type; |
340 | 340 | } |
@@ -346,14 +346,14 @@ discard block |
||
346 | 346 | */ |
347 | 347 | protected function queryReviews( array $args = [], $lastPostId, $limit ) |
348 | 348 | { |
349 | - $args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' )); |
|
350 | - if( empty( array_filter( $args ))) { |
|
349 | + $args = wp_parse_args( $args, array_fill_keys( ['post_id', 'term_id'], '' ) ); |
|
350 | + if( empty(array_filter( $args )) ) { |
|
351 | 351 | return glsr( SqlQueries::class )->getReviewCounts( $lastPostId, $limit ); |
352 | 352 | } |
353 | - if( !empty( $args['post_id'] )) { |
|
353 | + if( !empty($args['post_id']) ) { |
|
354 | 354 | return glsr( SqlQueries::class )->getReviewPostCounts( $args['post_id'], $lastPostId, $limit ); |
355 | 355 | } |
356 | - if( !empty( $args['term_id'] )) { |
|
356 | + if( !empty($args['term_id']) ) { |
|
357 | 357 | return glsr( SqlQueries::class )->getReviewTermCounts( $args['term_id'], $lastPostId, $limit ); |
358 | 358 | } |
359 | 359 | } |