@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * @return array |
22 | 22 | * @filter site-reviews/settings/callback |
23 | 23 | */ |
24 | - public function filterSettingsCallback(array $settings) |
|
24 | + public function filterSettingsCallback( array $settings ) |
|
25 | 25 | { |
26 | - if ('yes' !== Arr::get($settings, $this->enabledKey)) { |
|
26 | + if( 'yes' !== Arr::get( $settings, $this->enabledKey ) ) { |
|
27 | 27 | return $settings; |
28 | 28 | } |
29 | - $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings); |
|
30 | - $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings); |
|
31 | - $isAccountVerified = glsr(OptionManager::class)->getWP($this->rebusifyKey, false); |
|
32 | - if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) { |
|
33 | - $settings = $this->sanitizeRebusifySettings($settings); |
|
29 | + $isApiKeyModified = $this->isEmptyOrModified( $this->apiKey, $settings ); |
|
30 | + $isEmailModified = $this->isEmptyOrModified( $this->emailKey, $settings ); |
|
31 | + $isAccountVerified = glsr( OptionManager::class )->getWP( $this->rebusifyKey, false ); |
|
32 | + if( !$isAccountVerified || $isApiKeyModified || $isEmailModified ) { |
|
33 | + $settings = $this->sanitizeRebusifySettings( $settings ); |
|
34 | 34 | } |
35 | 35 | return $settings; |
36 | 36 | } |
@@ -40,21 +40,21 @@ discard block |
||
40 | 40 | * @return array |
41 | 41 | * @filter site-reviews/interpolate/partials/form/table-row-multiple |
42 | 42 | */ |
43 | - public function filterSettingsTableRow(array $context, $template, array $data) |
|
43 | + public function filterSettingsTableRow( array $context, $template, array $data ) |
|
44 | 44 | { |
45 | - if ($this->enabledKey !== Arr::get($data, 'field.path')) { |
|
45 | + if( $this->enabledKey !== Arr::get( $data, 'field.path' ) ) { |
|
46 | 46 | return $context; |
47 | 47 | } |
48 | - $rebusifyProductType = glsr(OptionManager::class)->getWP($this->rebusifyKey); |
|
49 | - if ('P' === $rebusifyProductType) { |
|
48 | + $rebusifyProductType = glsr( OptionManager::class )->getWP( $this->rebusifyKey ); |
|
49 | + if( 'P' === $rebusifyProductType ) { |
|
50 | 50 | return $context; |
51 | 51 | } |
52 | - if ('F' === $rebusifyProductType && 'yes' === glsr_get_option('general.rebusify')) { |
|
52 | + if( 'F' === $rebusifyProductType && 'yes' === glsr_get_option( 'general.rebusify' ) ) { |
|
53 | 53 | $button = $this->buildUpgradeButton(); |
54 | 54 | } else { |
55 | 55 | $button = $this->buildCreateButton(); |
56 | 56 | } |
57 | - $context['field'].= $button; |
|
57 | + $context['field'] .= $button; |
|
58 | 58 | return $context; |
59 | 59 | } |
60 | 60 | |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | * @return void |
64 | 64 | * @action site-reviews/review/created |
65 | 65 | */ |
66 | - public function onCreated(Review $review) |
|
66 | + public function onCreated( Review $review ) |
|
67 | 67 | { |
68 | - if (!$this->canPostReview($review)) { |
|
68 | + if( !$this->canPostReview( $review ) ) { |
|
69 | 69 | return; |
70 | 70 | } |
71 | - $rebusify = glsr(Rebusify::class)->sendReview($review); |
|
72 | - if ($rebusify->success) { |
|
73 | - glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id); |
|
71 | + $rebusify = glsr( Rebusify::class )->sendReview( $review ); |
|
72 | + if( $rebusify->success ) { |
|
73 | + glsr( Database::class )->set( $review->ID, 'rebusify', $rebusify->review_id ); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | * @action site-reviews/review/reverted |
81 | 81 | */ |
82 | - public function onReverted(Review $review) |
|
82 | + public function onReverted( Review $review ) |
|
83 | 83 | { |
84 | - if (!$this->canPostReview($review)) { |
|
84 | + if( !$this->canPostReview( $review ) ) { |
|
85 | 85 | return; |
86 | 86 | } |
87 | - $rebusify = glsr(Rebusify::class)->sendReview($review); |
|
88 | - if ($rebusify->success) { |
|
89 | - glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id); |
|
87 | + $rebusify = glsr( Rebusify::class )->sendReview( $review ); |
|
88 | + if( $rebusify->success ) { |
|
89 | + glsr( Database::class )->set( $review->ID, 'rebusify', $rebusify->review_id ); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | * @action site-reviews/review/saved |
97 | 97 | */ |
98 | - public function onSaved(Review $review) |
|
98 | + public function onSaved( Review $review ) |
|
99 | 99 | { |
100 | - if (!$this->canPostReview($review)) { |
|
100 | + if( !$this->canPostReview( $review ) ) { |
|
101 | 101 | return; |
102 | 102 | } |
103 | - $rebusify = glsr(Rebusify::class)->sendReview($review); |
|
104 | - if ($rebusify->success) { |
|
105 | - glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id); |
|
103 | + $rebusify = glsr( Rebusify::class )->sendReview( $review ); |
|
104 | + if( $rebusify->success ) { |
|
105 | + glsr( Database::class )->set( $review->ID, 'rebusify', $rebusify->review_id ); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @return void |
115 | 115 | * @action updated_postmeta |
116 | 116 | */ |
117 | - public function onUpdatedMeta($metaId, $postId, $metaKey) |
|
117 | + public function onUpdatedMeta( $metaId, $postId, $metaKey ) |
|
118 | 118 | { |
119 | - $review = glsr_get_review($postId); |
|
120 | - if (!$this->canPostResponse($review) || '_response' !== $metaKey) { |
|
119 | + $review = glsr_get_review( $postId ); |
|
120 | + if( !$this->canPostResponse( $review ) || '_response' !== $metaKey ) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | - $rebusify = glsr(Rebusify::class)->sendReviewResponse($review); |
|
124 | - if ($rebusify->success) { |
|
125 | - glsr(Database::class)->set($review->ID, 'rebusify_response', true); |
|
123 | + $rebusify = glsr( Rebusify::class )->sendReviewResponse( $review ); |
|
124 | + if( $rebusify->success ) { |
|
125 | + glsr( Database::class )->set( $review->ID, 'rebusify_response', true ); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | */ |
132 | 132 | protected function buildCreateButton() |
133 | 133 | { |
134 | - return glsr(Builder::class)->a(__('Create Your Rebusify Account', 'site-reviews'), [ |
|
134 | + return glsr( Builder::class )->a( __( 'Create Your Rebusify Account', 'site-reviews' ), [ |
|
135 | 135 | 'class' => 'button', |
136 | 136 | 'href' => Rebusify::WEB_URL, |
137 | 137 | 'target' => '_blank', |
138 | - ]); |
|
138 | + ] ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -143,37 +143,37 @@ discard block |
||
143 | 143 | */ |
144 | 144 | protected function buildUpgradeButton() |
145 | 145 | { |
146 | - $build = glsr(Builder::class); |
|
147 | - $notice = $build->p(__('Free Rebusify accounts are limited to 500 blockchain transactions per year.', 'site-reviews')); |
|
148 | - $button = $build->a(__('Upgrade Your Rebusify Plan', 'site-reviews'), [ |
|
146 | + $build = glsr( Builder::class ); |
|
147 | + $notice = $build->p( __( 'Free Rebusify accounts are limited to 500 blockchain transactions per year.', 'site-reviews' ) ); |
|
148 | + $button = $build->a( __( 'Upgrade Your Rebusify Plan', 'site-reviews' ), [ |
|
149 | 149 | 'class' => 'button', |
150 | 150 | 'href' => Rebusify::WEB_URL, |
151 | 151 | 'target' => '_blank', |
152 | - ]); |
|
153 | - return $build->div($notice.$button, [ |
|
152 | + ] ); |
|
153 | + return $build->div( $notice.$button, [ |
|
154 | 154 | 'class' => 'glsr-notice-inline', |
155 | - ]); |
|
155 | + ] ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @return bool |
160 | 160 | */ |
161 | - protected function canPostResponse(Review $review) |
|
161 | + protected function canPostResponse( Review $review ) |
|
162 | 162 | { |
163 | 163 | $requiredValues = [ |
164 | - glsr(Database::class)->get($review->ID, 'rebusify'), |
|
164 | + glsr( Database::class )->get( $review->ID, 'rebusify' ), |
|
165 | 165 | $review->response, |
166 | 166 | $review->review_id, |
167 | 167 | ]; |
168 | - return $this->canProceed($review, 'rebusify_response') |
|
168 | + return $this->canProceed( $review, 'rebusify_response' ) |
|
169 | 169 | && 'publish' === $review->status |
170 | - && 3 === count(array_filter($requiredValues)); |
|
170 | + && 3 === count( array_filter( $requiredValues ) ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | 174 | * @return bool |
175 | 175 | */ |
176 | - protected function canPostReview(Review $review) |
|
176 | + protected function canPostReview( Review $review ) |
|
177 | 177 | { |
178 | 178 | $requiredValues = [ |
179 | 179 | $review->author, |
@@ -182,60 +182,60 @@ discard block |
||
182 | 182 | $review->review_id, |
183 | 183 | $review->title, |
184 | 184 | ]; |
185 | - return $this->canProceed($review) |
|
185 | + return $this->canProceed( $review ) |
|
186 | 186 | && 'publish' === $review->status |
187 | - && 5 === count(array_filter($requiredValues)); |
|
187 | + && 5 === count( array_filter( $requiredValues ) ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * @param string $metaKey |
192 | 192 | * @return bool |
193 | 193 | */ |
194 | - protected function canProceed(Review $review, $metaKey = 'rebusify') |
|
194 | + protected function canProceed( Review $review, $metaKey = 'rebusify' ) |
|
195 | 195 | { |
196 | - return glsr(OptionManager::class)->getBool($this->enabledKey) |
|
197 | - && $this->isReviewPostId($review->ID) |
|
198 | - && !$this->hasMetaKey($review, $metaKey); |
|
196 | + return glsr( OptionManager::class )->getBool( $this->enabledKey ) |
|
197 | + && $this->isReviewPostId( $review->ID ) |
|
198 | + && !$this->hasMetaKey( $review, $metaKey ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
202 | 202 | * @param string $metaKey |
203 | 203 | * @return bool |
204 | 204 | */ |
205 | - protected function hasMetaKey(Review $review, $metaKey = 'rebusify') |
|
205 | + protected function hasMetaKey( Review $review, $metaKey = 'rebusify' ) |
|
206 | 206 | { |
207 | - return '' !== glsr(Database::class)->get($review->ID, $metaKey); |
|
207 | + return '' !== glsr( Database::class )->get( $review->ID, $metaKey ); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
211 | 211 | * @param string $key |
212 | 212 | * @return bool |
213 | 213 | */ |
214 | - protected function isEmptyOrModified($key, array $settings) |
|
214 | + protected function isEmptyOrModified( $key, array $settings ) |
|
215 | 215 | { |
216 | - $oldValue = glsr_get_option($key); |
|
217 | - $newValue = Arr::get($settings, $key); |
|
216 | + $oldValue = glsr_get_option( $key ); |
|
217 | + $newValue = Arr::get( $settings, $key ); |
|
218 | 218 | return empty($newValue) || $newValue !== $oldValue; |
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * @return array |
223 | 223 | */ |
224 | - protected function sanitizeRebusifySettings(array $settings) |
|
224 | + protected function sanitizeRebusifySettings( array $settings ) |
|
225 | 225 | { |
226 | - $rebusify = glsr(Rebusify::class)->activateKey( |
|
227 | - Arr::get($settings, $this->apiKey), |
|
228 | - Arr::get($settings, $this->emailKey) |
|
226 | + $rebusify = glsr( Rebusify::class )->activateKey( |
|
227 | + Arr::get( $settings, $this->apiKey ), |
|
228 | + Arr::get( $settings, $this->emailKey ) |
|
229 | 229 | ); |
230 | - if ($rebusify->success) { |
|
231 | - update_option($this->rebusifyKey, Arr::get($rebusify->response, 'producttype')); |
|
230 | + if( $rebusify->success ) { |
|
231 | + update_option( $this->rebusifyKey, Arr::get( $rebusify->response, 'producttype' ) ); |
|
232 | 232 | } else { |
233 | - delete_option($this->rebusifyKey); |
|
234 | - $settings = Arr::set($settings, $this->enabledKey, 'no'); |
|
235 | - glsr(Notice::class)->addError(sprintf( |
|
236 | - __('Your Rebusify account details could not be verified, please try again. %s', 'site-reviews'), |
|
233 | + delete_option( $this->rebusifyKey ); |
|
234 | + $settings = Arr::set( $settings, $this->enabledKey, 'no' ); |
|
235 | + glsr( Notice::class )->addError( sprintf( |
|
236 | + __( 'Your Rebusify account details could not be verified, please try again. %s', 'site-reviews' ), |
|
237 | 237 | '('.$rebusify->message.')' |
238 | - )); |
|
238 | + ) ); |
|
239 | 239 | } |
240 | 240 | return $settings; |
241 | 241 | } |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function renderTaxonomyFilter() |
38 | 38 | { |
39 | - if (!is_object_in_taxonomy(glsr_current_screen()->post_type, Application::TAXONOMY)) { |
|
39 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ) ) { |
|
40 | 40 | return; |
41 | 41 | } |
42 | - echo glsr(Builder::class)->label(__('Filter by category', 'site-reviews'), [ |
|
42 | + echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
|
43 | 43 | 'class' => 'screen-reader-text', |
44 | 44 | 'for' => Application::TAXONOMY, |
45 | - ]); |
|
46 | - wp_dropdown_categories([ |
|
45 | + ] ); |
|
46 | + wp_dropdown_categories( [ |
|
47 | 47 | 'depth' => 3, |
48 | 48 | 'hide_empty' => true, |
49 | 49 | 'hide_if_empty' => true, |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'show_option_all' => $this->getShowOptionAll(), |
56 | 56 | 'taxonomy' => Application::TAXONOMY, |
57 | 57 | 'value_field' => 'slug', |
58 | - ]); |
|
58 | + ] ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | * @return void |
69 | 69 | * @action set_object_terms |
70 | 70 | */ |
71 | - public function restrictTermSelection($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
71 | + public function restrictTermSelection( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds ) |
|
72 | 72 | { |
73 | - if (Application::TAXONOMY != $taxonomy || count($newTTIds) <= 1) { |
|
73 | + if( Application::TAXONOMY != $taxonomy || count( $newTTIds ) <= 1 ) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | - $diff = array_diff($newTTIds, $oldTTIds); |
|
77 | - if (empty($newTerm = array_shift($diff))) { |
|
78 | - $newTerm = array_shift($newTTIds); |
|
76 | + $diff = array_diff( $newTTIds, $oldTTIds ); |
|
77 | + if( empty($newTerm = array_shift( $diff )) ) { |
|
78 | + $newTerm = array_shift( $newTTIds ); |
|
79 | 79 | } |
80 | - if ($newTerm) { |
|
81 | - wp_set_object_terms($postId, intval($newTerm), $taxonomy); |
|
80 | + if( $newTerm ) { |
|
81 | + wp_set_object_terms( $postId, intval( $newTerm ), $taxonomy ); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | protected function getSelected() |
89 | 89 | { |
90 | 90 | global $wp_query; |
91 | - return Arr::get($wp_query->query, Application::TAXONOMY); |
|
91 | + return Arr::get( $wp_query->query, Application::TAXONOMY ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function getShowOptionAll() |
98 | 98 | { |
99 | - $taxonomy = get_taxonomy(Application::TAXONOMY); |
|
99 | + $taxonomy = get_taxonomy( Application::TAXONOMY ); |
|
100 | 100 | return $taxonomy |
101 | - ? ucfirst(strtolower($taxonomy->labels->all_items)) |
|
101 | + ? ucfirst( strtolower( $taxonomy->labels->all_items ) ) |
|
102 | 102 | : ''; |
103 | 103 | } |
104 | 104 | } |
@@ -14,17 +14,17 @@ discard block |
||
14 | 14 | * @return array |
15 | 15 | * @callback register_setting |
16 | 16 | */ |
17 | - public function callbackRegisterSettings($input) |
|
17 | + public function callbackRegisterSettings( $input ) |
|
18 | 18 | { |
19 | - $settings = Arr::consolidateArray($input); |
|
20 | - if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
21 | - $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
22 | - $options = $this->sanitizeGeneral($input, $options); |
|
23 | - $options = $this->sanitizeSubmissions($input, $options); |
|
24 | - $options = $this->sanitizeTranslations($input, $options); |
|
25 | - $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
26 | - if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
27 | - glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
19 | + $settings = Arr::consolidateArray( $input ); |
|
20 | + if( 1 === count( $settings ) && array_key_exists( 'settings', $settings ) ) { |
|
21 | + $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input ); |
|
22 | + $options = $this->sanitizeGeneral( $input, $options ); |
|
23 | + $options = $this->sanitizeSubmissions( $input, $options ); |
|
24 | + $options = $this->sanitizeTranslations( $input, $options ); |
|
25 | + $options = apply_filters( 'site-reviews/settings/callback', $options, $settings ); |
|
26 | + if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) { |
|
27 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
28 | 28 | } |
29 | 29 | return $options; |
30 | 30 | } |
@@ -37,31 +37,31 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function registerSettings() |
39 | 39 | { |
40 | - register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
40 | + register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
41 | 41 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
42 | - ]); |
|
42 | + ] ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @return array |
47 | 47 | */ |
48 | - protected function sanitizeGeneral(array $input, array $options) |
|
48 | + protected function sanitizeGeneral( array $input, array $options ) |
|
49 | 49 | { |
50 | 50 | $inputForm = $input['settings']['general']; |
51 | - if (!$this->hasMultilingualIntegration($inputForm['support']['multilingual'])) { |
|
51 | + if( !$this->hasMultilingualIntegration( $inputForm['support']['multilingual'] ) ) { |
|
52 | 52 | $options['settings']['general']['support']['multilingual'] = ''; |
53 | 53 | } |
54 | - if ('' == trim($inputForm['notification_message'])) { |
|
54 | + if( '' == trim( $inputForm['notification_message'] ) ) { |
|
55 | 55 | $options['settings']['general']['notification_message'] = glsr()->defaults['settings']['general']['notification_message']; |
56 | 56 | } |
57 | - $options['settings']['general']['notifications'] = Arr::get($inputForm, 'notifications', []); |
|
57 | + $options['settings']['general']['notifications'] = Arr::get( $inputForm, 'notifications', [] ); |
|
58 | 58 | return $options; |
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @return array |
63 | 63 | */ |
64 | - protected function sanitizeSubmissions(array $input, array $options) |
|
64 | + protected function sanitizeSubmissions( array $input, array $options ) |
|
65 | 65 | { |
66 | 66 | $inputForm = $input['settings']['submissions']; |
67 | 67 | $options['settings']['submissions']['required'] = isset($inputForm['required']) |
@@ -73,20 +73,20 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * @return array |
75 | 75 | */ |
76 | - protected function sanitizeTranslations(array $input, array $options) |
|
76 | + protected function sanitizeTranslations( array $input, array $options ) |
|
77 | 77 | { |
78 | - if (isset($input['settings']['strings'])) { |
|
79 | - $options['settings']['strings'] = array_values(array_filter($input['settings']['strings'])); |
|
78 | + if( isset($input['settings']['strings']) ) { |
|
79 | + $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) ); |
|
80 | 80 | $allowedTags = [ |
81 | 81 | 'a' => ['class' => [], 'href' => [], 'target' => []], |
82 | 82 | 'span' => ['class' => []], |
83 | 83 | ]; |
84 | - array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
85 | - if (isset($string['s2'])) { |
|
86 | - $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
84 | + array_walk( $options['settings']['strings'], function( &$string ) use ($allowedTags) { |
|
85 | + if( isset($string['s2']) ) { |
|
86 | + $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
|
87 | 87 | } |
88 | - if (isset($string['p2'])) { |
|
89 | - $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
88 | + if( isset($string['p2']) ) { |
|
89 | + $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
|
90 | 90 | } |
91 | 91 | }); |
92 | 92 | } |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | - protected function hasMultilingualIntegration($integration) |
|
99 | + protected function hasMultilingualIntegration( $integration ) |
|
100 | 100 | { |
101 | - if (!in_array($integration, ['polylang', 'wpml'])) { |
|
101 | + if( !in_array( $integration, ['polylang', 'wpml'] ) ) { |
|
102 | 102 | return false; |
103 | 103 | } |
104 | - $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration); |
|
105 | - if (!glsr($integrationClass)->isActive()) { |
|
106 | - glsr(Notice::class)->addError(sprintf( |
|
107 | - __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
108 | - constant($integrationClass.'::PLUGIN_NAME') |
|
109 | - )); |
|
104 | + $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst( $integration ); |
|
105 | + if( !glsr( $integrationClass )->isActive() ) { |
|
106 | + glsr( Notice::class )->addError( sprintf( |
|
107 | + __( 'Please install/activate the %s plugin to enable integration.', 'site-reviews' ), |
|
108 | + constant( $integrationClass.'::PLUGIN_NAME' ) |
|
109 | + ) ); |
|
110 | 110 | return false; |
111 | - } elseif (!glsr($integrationClass)->isSupported()) { |
|
112 | - glsr(Notice::class)->addError(sprintf( |
|
113 | - __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
114 | - constant($integrationClass.'::PLUGIN_NAME'), |
|
115 | - constant($integrationClass.'::SUPPORTED_VERSION') |
|
116 | - )); |
|
111 | + } elseif( !glsr( $integrationClass )->isSupported() ) { |
|
112 | + glsr( Notice::class )->addError( sprintf( |
|
113 | + __( 'Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews' ), |
|
114 | + constant( $integrationClass.'::PLUGIN_NAME' ), |
|
115 | + constant( $integrationClass.'::SUPPORTED_VERSION' ) |
|
116 | + ) ); |
|
117 | 117 | return false; |
118 | 118 | } |
119 | 119 | return true; |
@@ -23,22 +23,22 @@ discard block |
||
23 | 23 | * @return void |
24 | 24 | * @action set_object_terms |
25 | 25 | */ |
26 | - public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
26 | + public function onAfterChangeCategory( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds ) |
|
27 | 27 | { |
28 | - sort($newTTIds); |
|
29 | - sort($oldTTIds); |
|
30 | - if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) { |
|
28 | + sort( $newTTIds ); |
|
29 | + sort( $oldTTIds ); |
|
30 | + if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId ) ) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | - $review = glsr_get_review($postId); |
|
34 | - $ignoredIds = array_intersect($oldTTIds, $newTTIds); |
|
35 | - $decreasedIds = array_diff($oldTTIds, $ignoredIds); |
|
36 | - $increasedIds = array_diff($newTTIds, $ignoredIds); |
|
37 | - if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) { |
|
38 | - glsr(CountsManager::class)->decreaseTermCounts($review); |
|
33 | + $review = glsr_get_review( $postId ); |
|
34 | + $ignoredIds = array_intersect( $oldTTIds, $newTTIds ); |
|
35 | + $decreasedIds = array_diff( $oldTTIds, $ignoredIds ); |
|
36 | + $increasedIds = array_diff( $newTTIds, $ignoredIds ); |
|
37 | + if( $review->term_ids = glsr( Database::class )->getTermIds( $decreasedIds, 'term_taxonomy_id' ) ) { |
|
38 | + glsr( CountsManager::class )->decreaseTermCounts( $review ); |
|
39 | 39 | } |
40 | - if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) { |
|
41 | - glsr(CountsManager::class)->increaseTermCounts($review); |
|
40 | + if( $review->term_ids = glsr( Database::class )->getTermIds( $increasedIds, 'term_taxonomy_id' ) ) { |
|
41 | + glsr( CountsManager::class )->increaseTermCounts( $review ); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | * @action transition_post_status |
51 | 51 | */ |
52 | - public function onAfterChangeStatus($newStatus, $oldStatus, $post) |
|
52 | + public function onAfterChangeStatus( $newStatus, $oldStatus, $post ) |
|
53 | 53 | { |
54 | - if (Application::POST_TYPE != Arr::get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) { |
|
54 | + if( Application::POST_TYPE != Arr::get( $post, 'post_type' ) || in_array( $oldStatus, ['new', $newStatus] ) ) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | - $review = glsr_get_review($post); |
|
58 | - if ('publish' == $post->post_status) { |
|
59 | - glsr(CountsManager::class)->increase($review); |
|
57 | + $review = glsr_get_review( $post ); |
|
58 | + if( 'publish' == $post->post_status ) { |
|
59 | + glsr( CountsManager::class )->increase( $review ); |
|
60 | 60 | } else { |
61 | - glsr(CountsManager::class)->decrease($review); |
|
61 | + glsr( CountsManager::class )->decrease( $review ); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | * @return void |
67 | 67 | * @action site-reviews/review/created |
68 | 68 | */ |
69 | - public function onAfterCreate(Review $review) |
|
69 | + public function onAfterCreate( Review $review ) |
|
70 | 70 | { |
71 | - if ('publish' !== $review->status) { |
|
71 | + if( 'publish' !== $review->status ) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | - glsr(CountsManager::class)->increaseCounts($review); |
|
75 | - glsr(CountsManager::class)->increasePostCounts($review); |
|
74 | + glsr( CountsManager::class )->increaseCounts( $review ); |
|
75 | + glsr( CountsManager::class )->increasePostCounts( $review ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | * @return void |
81 | 81 | * @action before_delete_post |
82 | 82 | */ |
83 | - public function onBeforeDelete($postId) |
|
83 | + public function onBeforeDelete( $postId ) |
|
84 | 84 | { |
85 | - if (!$this->isReviewPostId($postId)) { |
|
85 | + if( !$this->isReviewPostId( $postId ) ) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | - $review = glsr_get_review($postId); |
|
89 | - if ('trash' !== $review->status) { // do not run for trashed posts |
|
90 | - glsr(CountsManager::class)->decrease($review); |
|
88 | + $review = glsr_get_review( $postId ); |
|
89 | + if( 'trash' !== $review->status ) { // do not run for trashed posts |
|
90 | + glsr( CountsManager::class )->decrease( $review ); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
@@ -99,53 +99,53 @@ discard block |
||
99 | 99 | * @return void |
100 | 100 | * @action update_postmeta |
101 | 101 | */ |
102 | - public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue) |
|
102 | + public function onBeforeUpdate( $metaId, $postId, $metaKey, $metaValue ) |
|
103 | 103 | { |
104 | - if (!$this->isReviewPostId($postId)) { |
|
104 | + if( !$this->isReviewPostId( $postId ) ) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | - $metaKey = Str::removePrefix('_', $metaKey); |
|
108 | - if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) { |
|
107 | + $metaKey = Str::removePrefix( '_', $metaKey ); |
|
108 | + if( !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) ) { |
|
109 | 109 | return; |
110 | 110 | } |
111 | - $review = glsr_get_review($postId); |
|
112 | - if ($review->$metaKey == $metaValue) { |
|
111 | + $review = glsr_get_review( $postId ); |
|
112 | + if( $review->$metaKey == $metaValue ) { |
|
113 | 113 | return; |
114 | 114 | } |
115 | - $method = Helper::buildMethodName($metaKey, 'onBeforeChange'); |
|
116 | - call_user_func([$this, $method], $review, $metaValue); |
|
115 | + $method = Helper::buildMethodName( $metaKey, 'onBeforeChange' ); |
|
116 | + call_user_func( [$this, $method], $review, $metaValue ); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
120 | 120 | * @param string|int $assignedTo |
121 | 121 | * @return void |
122 | 122 | */ |
123 | - public function onBeforeChangeAssignedTo(Review $review, $assignedTo) |
|
123 | + public function onBeforeChangeAssignedTo( Review $review, $assignedTo ) |
|
124 | 124 | { |
125 | - glsr(CountsManager::class)->decreasePostCounts($review); |
|
125 | + glsr( CountsManager::class )->decreasePostCounts( $review ); |
|
126 | 126 | $review->assigned_to = $assignedTo; |
127 | - glsr(CountsManager::class)->increasePostCounts($review); |
|
127 | + glsr( CountsManager::class )->increasePostCounts( $review ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * @param string|int $rating |
132 | 132 | * @return void |
133 | 133 | */ |
134 | - public function onBeforeChangeRating(Review $review, $rating) |
|
134 | + public function onBeforeChangeRating( Review $review, $rating ) |
|
135 | 135 | { |
136 | - glsr(CountsManager::class)->decrease($review); |
|
136 | + glsr( CountsManager::class )->decrease( $review ); |
|
137 | 137 | $review->rating = $rating; |
138 | - glsr(CountsManager::class)->increase($review); |
|
138 | + glsr( CountsManager::class )->increase( $review ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
142 | 142 | * @param string $reviewType |
143 | 143 | * @return void |
144 | 144 | */ |
145 | - public function onBeforeChangeReviewType(Review $review, $reviewType) |
|
145 | + public function onBeforeChangeReviewType( Review $review, $reviewType ) |
|
146 | 146 | { |
147 | - glsr(CountsManager::class)->decrease($review); |
|
147 | + glsr( CountsManager::class )->decrease( $review ); |
|
148 | 148 | $review->review_type = $reviewType; |
149 | - glsr(CountsManager::class)->increase($review); |
|
149 | + glsr( CountsManager::class )->increase( $review ); |
|
150 | 150 | } |
151 | 151 | } |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function enqueueAssets() |
24 | 24 | { |
25 | - $command = new EnqueueAdminAssets([ |
|
25 | + $command = new EnqueueAdminAssets( [ |
|
26 | 26 | 'pointers' => [[ |
27 | - 'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'), |
|
27 | + 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
|
28 | 28 | 'id' => 'glsr-pointer-pinned', |
29 | 29 | 'position' => [ |
30 | 30 | 'edge' => 'right', |
@@ -32,24 +32,24 @@ discard block |
||
32 | 32 | ], |
33 | 33 | 'screen' => Application::POST_TYPE, |
34 | 34 | 'target' => '#misc-pub-pinned', |
35 | - 'title' => __('Pin Your Reviews', 'site-reviews'), |
|
35 | + 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
|
36 | 36 | ]], |
37 | - ]); |
|
38 | - $this->execute($command); |
|
37 | + ] ); |
|
38 | + $this->execute( $command ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @return array |
43 | 43 | * @filter plugin_action_links_site-reviews/site-reviews.php |
44 | 44 | */ |
45 | - public function filterActionLinks(array $links) |
|
45 | + public function filterActionLinks( array $links ) |
|
46 | 46 | { |
47 | - $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [ |
|
48 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'), |
|
49 | - ]); |
|
50 | - $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [ |
|
51 | - 'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'), |
|
52 | - ]); |
|
47 | + $links['documentation'] = glsr( Builder::class )->a( __( 'Help', 'site-reviews' ), [ |
|
48 | + 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=documentation' ), |
|
49 | + ] ); |
|
50 | + $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
|
51 | + 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
|
52 | + ] ); |
|
53 | 53 | return $links; |
54 | 54 | } |
55 | 55 | |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | * @return array |
60 | 60 | * @filter map_meta_cap |
61 | 61 | */ |
62 | - public function filterCreateCapability($capabilities, $capability) |
|
62 | + public function filterCreateCapability( $capabilities, $capability ) |
|
63 | 63 | { |
64 | - if ($capability == 'create_'.Application::POST_TYPE) { |
|
64 | + if( $capability == 'create_'.Application::POST_TYPE ) { |
|
65 | 65 | $capabilities[] = 'do_not_allow'; |
66 | 66 | } |
67 | 67 | return $capabilities; |
@@ -72,23 +72,23 @@ discard block |
||
72 | 72 | * @return array |
73 | 73 | * @filter dashboard_glance_items |
74 | 74 | */ |
75 | - public function filterDashboardGlanceItems($items) |
|
75 | + public function filterDashboardGlanceItems( $items ) |
|
76 | 76 | { |
77 | - $postCount = wp_count_posts(Application::POST_TYPE); |
|
78 | - if (empty($postCount->publish)) { |
|
77 | + $postCount = wp_count_posts( Application::POST_TYPE ); |
|
78 | + if( empty($postCount->publish) ) { |
|
79 | 79 | return $items; |
80 | 80 | } |
81 | - $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews'); |
|
82 | - $text = sprintf($text, number_format_i18n($postCount->publish)); |
|
83 | - $items = Arr::consolidateArray($items); |
|
84 | - $items[] = current_user_can(get_post_type_object(Application::POST_TYPE)->cap->edit_posts) |
|
85 | - ? glsr(Builder::class)->a($text, [ |
|
81 | + $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
|
82 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
83 | + $items = Arr::consolidateArray( $items ); |
|
84 | + $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
|
85 | + ? glsr( Builder::class )->a( $text, [ |
|
86 | 86 | 'class' => 'glsr-review-count', |
87 | 87 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
88 | - ]) |
|
89 | - : glsr(Builder::class)->span($text, [ |
|
88 | + ] ) |
|
89 | + : glsr( Builder::class )->span( $text, [ |
|
90 | 90 | 'class' => 'glsr-review-count', |
91 | - ]); |
|
91 | + ] ); |
|
92 | 92 | return $items; |
93 | 93 | } |
94 | 94 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | * @return array |
98 | 98 | * @filter mce_external_plugins |
99 | 99 | */ |
100 | - public function filterTinymcePlugins($plugins) |
|
100 | + public function filterTinymcePlugins( $plugins ) |
|
101 | 101 | { |
102 | - if (current_user_can('edit_posts') || current_user_can('edit_pages')) { |
|
103 | - $plugins = Arr::consolidateArray($plugins); |
|
104 | - $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js'); |
|
102 | + if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) { |
|
103 | + $plugins = Arr::consolidateArray( $plugins ); |
|
104 | + $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
|
105 | 105 | } |
106 | 106 | return $plugins; |
107 | 107 | } |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function registerTinymcePopups() |
114 | 114 | { |
115 | - $command = new RegisterTinymcePopups([ |
|
116 | - 'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'), |
|
117 | - 'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'), |
|
118 | - 'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'), |
|
119 | - ]); |
|
120 | - $this->execute($command); |
|
115 | + $command = new RegisterTinymcePopups( [ |
|
116 | + 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
|
117 | + 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
|
118 | + 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
|
119 | + ] ); |
|
120 | + $this->execute( $command ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,22 +125,22 @@ discard block |
||
125 | 125 | * @return void|null |
126 | 126 | * @action media_buttons |
127 | 127 | */ |
128 | - public function renderTinymceButton($editorId) |
|
128 | + public function renderTinymceButton( $editorId ) |
|
129 | 129 | { |
130 | - $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId); |
|
131 | - if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) { |
|
130 | + $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId ); |
|
131 | + if( 'post' != glsr_current_screen()->base || !in_array( $editorId, $allowedEditors ) ) { |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | $shortcodes = []; |
135 | - foreach (glsr()->mceShortcodes as $shortcode => $values) { |
|
135 | + foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
|
136 | 136 | $shortcodes[$shortcode] = $values; |
137 | 137 | } |
138 | - if (empty($shortcodes)) { |
|
138 | + if( empty($shortcodes) ) { |
|
139 | 139 | return; |
140 | 140 | } |
141 | - glsr()->render('partials/editor/tinymce', [ |
|
141 | + glsr()->render( 'partials/editor/tinymce', [ |
|
142 | 142 | 'shortcodes' => $shortcodes, |
143 | - ]); |
|
143 | + ] ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function routerClearConsole() |
150 | 150 | { |
151 | - glsr(Console::class)->clear(); |
|
152 | - glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews')); |
|
151 | + glsr( Console::class )->clear(); |
|
152 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -157,19 +157,19 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function routerFetchConsole() |
159 | 159 | { |
160 | - glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews')); |
|
160 | + glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
164 | 164 | * @param bool $showNotice |
165 | 165 | * @return void |
166 | 166 | */ |
167 | - public function routerCountReviews($showNotice = true) |
|
167 | + public function routerCountReviews( $showNotice = true ) |
|
168 | 168 | { |
169 | - glsr(CountsManager::class)->countAll(); |
|
170 | - glsr(OptionManager::class)->set('last_review_count', current_time('timestamp')); |
|
171 | - if ($showNotice) { |
|
172 | - glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews')); |
|
169 | + glsr( CountsManager::class )->countAll(); |
|
170 | + glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) ); |
|
171 | + if( $showNotice ) { |
|
172 | + glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function routerDownloadConsole() |
180 | 180 | { |
181 | - $this->download(Application::ID.'-console.txt', glsr(Console::class)->get()); |
|
181 | + $this->download( Application::ID.'-console.txt', glsr( Console::class )->get() ); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function routerDownloadSystemInfo() |
188 | 188 | { |
189 | - $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get()); |
|
189 | + $this->download( Application::ID.'-system-info.txt', glsr( System::class )->get() ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function routerExportSettings() |
196 | 196 | { |
197 | - $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json()); |
|
197 | + $this->download( Application::ID.'-settings.json', glsr( OptionManager::class )->json() ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -203,35 +203,35 @@ discard block |
||
203 | 203 | public function routerImportSettings() |
204 | 204 | { |
205 | 205 | $file = $_FILES['import-file']; |
206 | - if (UPLOAD_ERR_OK !== $file['error']) { |
|
207 | - return glsr(Notice::class)->addError($this->getUploadError($file['error'])); |
|
206 | + if( UPLOAD_ERR_OK !== $file['error'] ) { |
|
207 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
208 | 208 | } |
209 | - if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) { |
|
210 | - return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews')); |
|
209 | + if( 'application/json' !== $file['type'] || !Str::endsWith( '.json', $file['name'] ) ) { |
|
210 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
211 | 211 | } |
212 | - $settings = json_decode(file_get_contents($file['tmp_name']), true); |
|
213 | - if (empty($settings)) { |
|
214 | - return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews')); |
|
212 | + $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
|
213 | + if( empty($settings) ) { |
|
214 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
215 | 215 | } |
216 | - glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings)); |
|
217 | - glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews')); |
|
216 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
217 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
221 | 221 | * @param int $errorCode |
222 | 222 | * @return string |
223 | 223 | */ |
224 | - protected function getUploadError($errorCode) |
|
224 | + protected function getUploadError( $errorCode ) |
|
225 | 225 | { |
226 | 226 | $errors = [ |
227 | - UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'), |
|
228 | - UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'), |
|
229 | - UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'), |
|
230 | - UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'), |
|
231 | - UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'), |
|
232 | - UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'), |
|
233 | - UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'), |
|
227 | + UPLOAD_ERR_INI_SIZE => __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews' ), |
|
228 | + UPLOAD_ERR_FORM_SIZE => __( 'The uploaded file is too big.', 'site-reviews' ), |
|
229 | + UPLOAD_ERR_PARTIAL => __( 'The uploaded file was only partially uploaded.', 'site-reviews' ), |
|
230 | + UPLOAD_ERR_NO_FILE => __( 'No file was uploaded.', 'site-reviews' ), |
|
231 | + UPLOAD_ERR_NO_TMP_DIR => __( 'Missing a temporary folder.', 'site-reviews' ), |
|
232 | + UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
|
233 | + UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
|
234 | 234 | ]; |
235 | - return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews')); |
|
235 | + return Arr::get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' ) ); |
|
236 | 236 | } |
237 | 237 | } |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | public function __construct() |
31 | 31 | { |
32 | 32 | static::$instance = $this; |
33 | - $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php'); |
|
34 | - $plugin = get_file_data($this->file, [ |
|
33 | + $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' ); |
|
34 | + $plugin = get_file_data( $this->file, [ |
|
35 | 35 | 'languages' => 'Domain Path', |
36 | 36 | 'name' => 'Plugin Name', |
37 | 37 | 'version' => 'Version', |
38 | - ], 'plugin'); |
|
39 | - array_walk($plugin, function ($value, $key) { |
|
38 | + ], 'plugin' ); |
|
39 | + array_walk( $plugin, function( $value, $key ) { |
|
40 | 40 | $this->$key = $value; |
41 | 41 | }); |
42 | 42 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function activate() |
48 | 48 | { |
49 | - $this->make(DefaultsManager::class)->set(); |
|
49 | + $this->make( DefaultsManager::class )->set(); |
|
50 | 50 | $this->scheduleCronJob(); |
51 | 51 | $this->upgrade(); |
52 | 52 | } |
@@ -57,34 +57,34 @@ discard block |
||
57 | 57 | public function catchFatalError() |
58 | 58 | { |
59 | 59 | $error = error_get_last(); |
60 | - if (E_ERROR !== $error['type'] || false === strpos($error['message'], $this->path())) { |
|
60 | + if( E_ERROR !== $error['type'] || false === strpos( $error['message'], $this->path() ) ) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | - glsr_log()->error($error['message']); |
|
63 | + glsr_log()->error( $error['message'] ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @param string $name |
68 | 68 | * @return array |
69 | 69 | */ |
70 | - public function config($name) |
|
70 | + public function config( $name ) |
|
71 | 71 | { |
72 | - $configFile = $this->path('config/'.$name.'.php'); |
|
73 | - $config = file_exists($configFile) |
|
72 | + $configFile = $this->path( 'config/'.$name.'.php' ); |
|
73 | + $config = file_exists( $configFile ) |
|
74 | 74 | ? include $configFile |
75 | 75 | : []; |
76 | - return apply_filters('site-reviews/config/'.$name, $config); |
|
76 | + return apply_filters( 'site-reviews/config/'.$name, $config ); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @param string $property |
81 | 81 | * @return string |
82 | 82 | */ |
83 | - public function constant($property, $className = 'static') |
|
83 | + public function constant( $property, $className = 'static' ) |
|
84 | 84 | { |
85 | 85 | $constant = $className.'::'.$property; |
86 | - return defined($constant) |
|
87 | - ? apply_filters('site-reviews/const/'.$property, constant($constant)) |
|
86 | + return defined( $constant ) |
|
87 | + ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) ) |
|
88 | 88 | : ''; |
89 | 89 | } |
90 | 90 | |
@@ -100,17 +100,17 @@ discard block |
||
100 | 100 | * @param string $view |
101 | 101 | * @return void|string |
102 | 102 | */ |
103 | - public function file($view) |
|
103 | + public function file( $view ) |
|
104 | 104 | { |
105 | - $view.= '.php'; |
|
105 | + $view .= '.php'; |
|
106 | 106 | $filePaths = []; |
107 | - if (Str::startsWith('templates/', $view)) { |
|
108 | - $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view)); |
|
107 | + if( Str::startsWith( 'templates/', $view ) ) { |
|
108 | + $filePaths[] = $this->themePath( Str::removePrefix( 'templates/', $view ) ); |
|
109 | 109 | } |
110 | - $filePaths[] = $this->path($view); |
|
111 | - $filePaths[] = $this->path('views/'.$view); |
|
112 | - foreach ($filePaths as $file) { |
|
113 | - if (!file_exists($file)) { |
|
110 | + $filePaths[] = $this->path( $view ); |
|
111 | + $filePaths[] = $this->path( 'views/'.$view ); |
|
112 | + foreach( $filePaths as $file ) { |
|
113 | + if( !file_exists( $file ) ) { |
|
114 | 114 | continue; |
115 | 115 | } |
116 | 116 | return $file; |
@@ -122,33 +122,33 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getDefaults() |
124 | 124 | { |
125 | - if (empty($this->defaults)) { |
|
126 | - $this->defaults = $this->make(DefaultsManager::class)->get(); |
|
125 | + if( empty($this->defaults) ) { |
|
126 | + $this->defaults = $this->make( DefaultsManager::class )->get(); |
|
127 | 127 | $this->upgrade(); |
128 | 128 | } |
129 | - return apply_filters('site-reviews/get/defaults', $this->defaults); |
|
129 | + return apply_filters( 'site-reviews/get/defaults', $this->defaults ); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - public function getPermission($page = '') |
|
135 | + public function getPermission( $page = '' ) |
|
136 | 136 | { |
137 | 137 | $permissions = [ |
138 | 138 | 'addons' => 'install_plugins', |
139 | 139 | 'settings' => 'manage_options', |
140 | 140 | // 'welcome' => 'activate_plugins', |
141 | 141 | ]; |
142 | - return Arr::get($permissions, $page, $this->constant('CAPABILITY')); |
|
142 | + return Arr::get( $permissions, $page, $this->constant( 'CAPABILITY' ) ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @return bool |
147 | 147 | */ |
148 | - public function hasPermission($page = '') |
|
148 | + public function hasPermission( $page = '' ) |
|
149 | 149 | { |
150 | 150 | $isAdmin = $this->isAdmin(); |
151 | - return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page))); |
|
151 | + return !$isAdmin || ($isAdmin && current_user_can( $this->getPermission( $page ) )); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function init() |
158 | 158 | { |
159 | - $this->make(Actions::class)->run(); |
|
160 | - $this->make(Filters::class)->run(); |
|
159 | + $this->make( Actions::class )->run(); |
|
160 | + $this->make( Filters::class )->run(); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | * @param string $file |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function path($file = '', $realpath = true) |
|
175 | + public function path( $file = '', $realpath = true ) |
|
176 | 176 | { |
177 | - $path = plugin_dir_path($this->file); |
|
178 | - if (!$realpath) { |
|
179 | - $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file)); |
|
177 | + $path = plugin_dir_path( $this->file ); |
|
178 | + if( !$realpath ) { |
|
179 | + $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) ); |
|
180 | 180 | } |
181 | - $path = trailingslashit($path).ltrim(trim($file), '/'); |
|
182 | - return apply_filters('site-reviews/path', $path, $file); |
|
181 | + $path = trailingslashit( $path ).ltrim( trim( $file ), '/' ); |
|
182 | + return apply_filters( 'site-reviews/path', $path, $file ); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function registerAddons() |
189 | 189 | { |
190 | - do_action('site-reviews/addon/register', $this); |
|
190 | + do_action( 'site-reviews/addon/register', $this ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function registerLanguages() |
197 | 197 | { |
198 | - load_plugin_textdomain(static::ID, false, |
|
199 | - trailingslashit(plugin_basename($this->path()).'/'.$this->languages) |
|
198 | + load_plugin_textdomain( static::ID, false, |
|
199 | + trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages ) |
|
200 | 200 | ); |
201 | 201 | } |
202 | 202 | |
@@ -205,26 +205,26 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function registerReviewTypes() |
207 | 207 | { |
208 | - $types = apply_filters('site-reviews/addon/types', []); |
|
209 | - $this->reviewTypes = wp_parse_args($types, [ |
|
210 | - 'local' => __('Local', 'site-reviews'), |
|
211 | - ]); |
|
208 | + $types = apply_filters( 'site-reviews/addon/types', [] ); |
|
209 | + $this->reviewTypes = wp_parse_args( $types, [ |
|
210 | + 'local' => __( 'Local', 'site-reviews' ), |
|
211 | + ] ); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
215 | 215 | * @param string $view |
216 | 216 | * @return void |
217 | 217 | */ |
218 | - public function render($view, array $data = []) |
|
218 | + public function render( $view, array $data = [] ) |
|
219 | 219 | { |
220 | - $view = apply_filters('site-reviews/render/view', $view, $data); |
|
221 | - $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data); |
|
222 | - if (!file_exists($file)) { |
|
223 | - glsr_log()->error('File not found: '.$file); |
|
220 | + $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
|
221 | + $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
|
222 | + if( !file_exists( $file ) ) { |
|
223 | + glsr_log()->error( 'File not found: '.$file ); |
|
224 | 224 | return; |
225 | 225 | } |
226 | - $data = apply_filters('site-reviews/views/data', $data, $view); |
|
227 | - extract($data); |
|
226 | + $data = apply_filters( 'site-reviews/views/data', $data, $view ); |
|
227 | + extract( $data ); |
|
228 | 228 | include $file; |
229 | 229 | } |
230 | 230 | |
@@ -233,19 +233,19 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function scheduleCronJob() |
235 | 235 | { |
236 | - if (wp_next_scheduled(static::CRON_EVENT)) { |
|
236 | + if( wp_next_scheduled( static::CRON_EVENT ) ) { |
|
237 | 237 | return; |
238 | 238 | } |
239 | - wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT); |
|
239 | + wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
243 | 243 | * @param string $file |
244 | 244 | * @return string |
245 | 245 | */ |
246 | - public function themePath($file = '') |
|
246 | + public function themePath( $file = '' ) |
|
247 | 247 | { |
248 | - return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/'); |
|
248 | + return get_stylesheet_directory().'/'.static::ID.'/'.ltrim( trim( $file ), '/' ); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function unscheduleCronJob() |
255 | 255 | { |
256 | - wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT); |
|
256 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function upgrade() |
263 | 263 | { |
264 | - $this->make(Upgrader::class)->run(); |
|
264 | + $this->make( Upgrader::class )->run(); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | * @return void |
270 | 270 | * @action upgrader_process_complete |
271 | 271 | */ |
272 | - public function upgraded($upgrader, array $data) |
|
272 | + public function upgraded( $upgrader, array $data ) |
|
273 | 273 | { |
274 | - if (array_key_exists('plugins', $data) |
|
275 | - && in_array(plugin_basename($this->file), $data['plugins']) |
|
274 | + if( array_key_exists( 'plugins', $data ) |
|
275 | + && in_array( plugin_basename( $this->file ), $data['plugins'] ) |
|
276 | 276 | && 'update' === $data['action'] |
277 | 277 | && 'plugin' === $data['type'] |
278 | 278 | ) { |
@@ -284,29 +284,29 @@ discard block |
||
284 | 284 | * @param string $path |
285 | 285 | * @return string |
286 | 286 | */ |
287 | - public function url($path = '') |
|
287 | + public function url( $path = '' ) |
|
288 | 288 | { |
289 | - $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
290 | - return apply_filters('site-reviews/url', $url, $path); |
|
289 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
290 | + return apply_filters( 'site-reviews/url', $url, $path ); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
294 | 294 | * @param string $versionLevel |
295 | 295 | * @return string |
296 | 296 | */ |
297 | - public function version($versionLevel = '') |
|
297 | + public function version( $versionLevel = '' ) |
|
298 | 298 | { |
299 | 299 | $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i'; |
300 | - preg_match($pattern, $this->version, $matches); |
|
301 | - switch ($versionLevel) { |
|
300 | + preg_match( $pattern, $this->version, $matches ); |
|
301 | + switch( $versionLevel ) { |
|
302 | 302 | case 'major': |
303 | - $version = Arr::get($matches, 1); |
|
303 | + $version = Arr::get( $matches, 1 ); |
|
304 | 304 | break; |
305 | 305 | case 'minor': |
306 | - $version = Arr::get($matches, 1).Arr::get($matches, 2); |
|
306 | + $version = Arr::get( $matches, 1 ).Arr::get( $matches, 2 ); |
|
307 | 307 | break; |
308 | 308 | case 'patch': |
309 | - $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3); |
|
309 | + $version = Arr::get( $matches, 1 ).Arr::get( $matches, 2 ).Arr::get( $matches, 3 ); |
|
310 | 310 | break; |
311 | 311 | } |
312 | 312 | return empty($version) |
@@ -14,26 +14,26 @@ discard block |
||
14 | 14 | * @return array |
15 | 15 | * @filter site-reviews/get/reviews/query |
16 | 16 | */ |
17 | - public function filterReviewsQuery(array $parameters, array $args) |
|
17 | + public function filterReviewsQuery( array $parameters, array $args ) |
|
18 | 18 | { |
19 | - if ($authorId = get_current_user_id()) { |
|
19 | + if( $authorId = get_current_user_id() ) { |
|
20 | 20 | $parameters['author'] = $authorId; |
21 | 21 | } |
22 | 22 | $parameters['post_status'] = ['pending', 'publish']; |
23 | - return apply_filters('site-reviews/reviews-limits/query', $parameters, $args); |
|
23 | + return apply_filters( 'site-reviews/reviews-limits/query', $parameters, $args ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @return bool |
28 | 28 | */ |
29 | - public function hasReachedLimit(array $request = []) |
|
29 | + public function hasReachedLimit( array $request = [] ) |
|
30 | 30 | { |
31 | 31 | $this->request = $request; |
32 | 32 | $method = Helper::buildMethodName( |
33 | - glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy' |
|
33 | + glsr( OptionManager::class )->get( 'settings.submissions.limit' ), 'validateBy' |
|
34 | 34 | ); |
35 | - return method_exists($this, $method) |
|
36 | - ? !call_user_func([$this, $method]) |
|
35 | + return method_exists( $this, $method ) |
|
36 | + ? !call_user_func( [$this, $method] ) |
|
37 | 37 | : false; |
38 | 38 | } |
39 | 39 | |
@@ -42,39 +42,39 @@ discard block |
||
42 | 42 | * @param string $whitelist |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function isWhitelisted($value, $whitelist) |
|
45 | + public function isWhitelisted( $value, $whitelist ) |
|
46 | 46 | { |
47 | - if (empty($whitelist)) { |
|
47 | + if( empty($whitelist) ) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | - return in_array($value, array_filter(explode("\n", $whitelist), 'trim')); |
|
50 | + return in_array( $value, array_filter( explode( "\n", $whitelist ), 'trim' ) ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param string $whitelistName |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - protected function getWhitelist($whitelistName) |
|
57 | + protected function getWhitelist( $whitelistName ) |
|
58 | 58 | { |
59 | - return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName); |
|
59 | + return glsr( OptionManager::class )->get( 'settings.submissions.limit_whitelist.'.$whitelistName ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @return bool |
64 | 64 | */ |
65 | - protected function validate($key, $value, $addMetaQuery = true) |
|
65 | + protected function validate( $key, $value, $addMetaQuery = true ) |
|
66 | 66 | { |
67 | - if ($this->isWhitelisted($value, $this->getWhitelist($key))) { |
|
67 | + if( $this->isWhitelisted( $value, $this->getWhitelist( $key ) ) ) { |
|
68 | 68 | return true; |
69 | 69 | } |
70 | - add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2); |
|
71 | - $args = ['assigned_to' => Arr::get($this->request, 'assign_to')]; |
|
72 | - if ($addMetaQuery) { |
|
70 | + add_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2 ); |
|
71 | + $args = ['assigned_to' => Arr::get( $this->request, 'assign_to' )]; |
|
72 | + if( $addMetaQuery ) { |
|
73 | 73 | $args[$key] = $value; |
74 | 74 | } |
75 | - $reviews = glsr_get_reviews($args); |
|
76 | - remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5); |
|
77 | - return 0 === count($reviews); |
|
75 | + $reviews = glsr_get_reviews( $args ); |
|
76 | + remove_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5 ); |
|
77 | + return 0 === count( $reviews ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | */ |
83 | 83 | protected function validateByEmail() |
84 | 84 | { |
85 | - glsr_log()->debug('Email is: '.Arr::get($this->request, 'email')); |
|
86 | - return $this->validate('email', Arr::get($this->request, 'email')); |
|
85 | + glsr_log()->debug( 'Email is: '.Arr::get( $this->request, 'email' ) ); |
|
86 | + return $this->validate( 'email', Arr::get( $this->request, 'email' ) ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected function validateByIpAddress() |
93 | 93 | { |
94 | - glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address')); |
|
95 | - return $this->validate('ip_address', Arr::get($this->request, 'ip_address')); |
|
94 | + glsr_log()->debug( 'IP Address is: '.Arr::get( $this->request, 'ip_address' ) ); |
|
95 | + return $this->validate( 'ip_address', Arr::get( $this->request, 'ip_address' ) ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | protected function validateByUsername() |
102 | 102 | { |
103 | 103 | $user = wp_get_current_user(); |
104 | - if (!$user->exists()) { |
|
104 | + if( !$user->exists() ) { |
|
105 | 105 | return true; |
106 | 106 | } |
107 | - glsr_log()->debug('Username is: '.$user->user_login); |
|
108 | - return $this->validate('username', $user->user_login, false); |
|
107 | + glsr_log()->debug( 'Username is: '.$user->user_login ); |
|
108 | + return $this->validate( 'username', $user->user_login, false ); |
|
109 | 109 | } |
110 | 110 | } |
@@ -20,25 +20,25 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @return mixed |
22 | 22 | */ |
23 | - public function __get($key) |
|
23 | + public function __get( $key ) |
|
24 | 24 | { |
25 | - return property_exists($this, $key) |
|
25 | + return property_exists( $this, $key ) |
|
26 | 26 | ? $this->$key |
27 | - : Arr::get($this->response, $key, null); |
|
27 | + : Arr::get( $this->response, $key, null ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @return self |
32 | 32 | */ |
33 | - public function activateKey($apiKey = '', $email = '') |
|
33 | + public function activateKey( $apiKey = '', $email = '' ) |
|
34 | 34 | { |
35 | - $this->send('api_key_activation.php', [ |
|
35 | + $this->send( 'api_key_activation.php', [ |
|
36 | 36 | 'body' => [ |
37 | 37 | 'apikey' => $apiKey ?: 0, |
38 | 38 | 'domain' => get_home_url(), |
39 | 39 | 'email' => $email ?: 0, |
40 | 40 | ], |
41 | - ]); |
|
41 | + ] ); |
|
42 | 42 | return $this; |
43 | 43 | } |
44 | 44 | |
@@ -56,77 +56,77 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * @return self |
58 | 58 | */ |
59 | - public function sendReview(Review $review) |
|
59 | + public function sendReview( Review $review ) |
|
60 | 60 | { |
61 | - $this->send('index.php', [ |
|
62 | - 'body' => $this->getBodyForReview($review), |
|
61 | + $this->send( 'index.php', [ |
|
62 | + 'body' => $this->getBodyForReview( $review ), |
|
63 | 63 | 'timeout' => 120, |
64 | - ]); |
|
64 | + ] ); |
|
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return self |
70 | 70 | */ |
71 | - public function sendReviewResponse(Review $review) |
|
71 | + public function sendReviewResponse( Review $review ) |
|
72 | 72 | { |
73 | - $this->send('fetch_customer_reply.php', [ |
|
74 | - 'body' => $this->getBodyForResponse($review), |
|
75 | - ]); |
|
73 | + $this->send( 'fetch_customer_reply.php', [ |
|
74 | + 'body' => $this->getBodyForResponse( $review ), |
|
75 | + ] ); |
|
76 | 76 | return $this; |
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @return array |
81 | 81 | */ |
82 | - protected function getBodyForResponse(Review $review) |
|
82 | + protected function getBodyForResponse( Review $review ) |
|
83 | 83 | { |
84 | 84 | $rebusifyResponse = [ |
85 | - 'reply' => Str::truncate($review->response, 300), |
|
86 | - 'review_id' => glsr(Database::class)->get($review->ID, 'rebusify'), // this is the rebusify review ID |
|
85 | + 'reply' => Str::truncate( $review->response, 300 ), |
|
86 | + 'review_id' => glsr( Database::class )->get( $review->ID, 'rebusify' ), // this is the rebusify review ID |
|
87 | 87 | 'review_transaction_id' => $review->review_id, |
88 | 88 | 'type' => 'M', |
89 | 89 | ]; |
90 | - return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review); |
|
90 | + return apply_filters( 'site-reviews/rebusify/response', $rebusifyResponse, $review ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @return array |
95 | 95 | */ |
96 | - protected function getBodyForReview(Review $review) |
|
96 | + protected function getBodyForReview( Review $review ) |
|
97 | 97 | { |
98 | 98 | $rebusifyReview = [ |
99 | 99 | 'domain' => get_home_url(), |
100 | - 'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25), |
|
100 | + 'firstname' => Str::truncate( Str::convertName( $review->author, 'first' ), 25 ), |
|
101 | 101 | 'rate' => $review->rating, |
102 | 102 | 'review_transaction_id' => $review->review_id, |
103 | - 'reviews' => Str::truncate($review->content, 280), |
|
104 | - 'title' => Str::truncate($review->title, 35), |
|
103 | + 'reviews' => Str::truncate( $review->content, 280 ), |
|
104 | + 'title' => Str::truncate( $review->title, 35 ), |
|
105 | 105 | 'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews |
106 | 106 | ]; |
107 | - return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review); |
|
107 | + return apply_filters( 'site-reviews/rebusify/review', $rebusifyReview, $review ); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
111 | 111 | * @param \WP_Error|array $response |
112 | 112 | * @return void |
113 | 113 | */ |
114 | - protected function handleResponse($response) |
|
114 | + protected function handleResponse( $response ) |
|
115 | 115 | { |
116 | - if (is_wp_error($response)) { |
|
116 | + if( is_wp_error( $response ) ) { |
|
117 | 117 | $this->message = $response->get_error_message(); |
118 | 118 | } else { |
119 | - $responseBody = wp_remote_retrieve_body($response); |
|
120 | - $responseCode = wp_remote_retrieve_response_code($response); |
|
121 | - $responseData = (array) json_decode($responseBody, true); |
|
122 | - $this->response = array_shift($responseData); |
|
123 | - $this->message = Arr::get($this->response, 'msg'); |
|
124 | - $this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack! |
|
125 | - if (200 !== $responseCode) { |
|
126 | - glsr_log()->error('Bad response code ['.$responseCode.']'); |
|
119 | + $responseBody = wp_remote_retrieve_body( $response ); |
|
120 | + $responseCode = wp_remote_retrieve_response_code( $response ); |
|
121 | + $responseData = (array)json_decode( $responseBody, true ); |
|
122 | + $this->response = array_shift( $responseData ); |
|
123 | + $this->message = Arr::get( $this->response, 'msg' ); |
|
124 | + $this->success = 'success' === Arr::get( $this->response, 'result' ) || 'yes' === Arr::get( $this->response, 'success' ); // @todo remove this ugly hack! |
|
125 | + if( 200 !== $responseCode ) { |
|
126 | + glsr_log()->error( 'Bad response code ['.$responseCode.']' ); |
|
127 | 127 | } |
128 | - if (!$this->success) { |
|
129 | - glsr_log()->error($this->message); |
|
128 | + if( !$this->success ) { |
|
129 | + glsr_log()->error( $this->message ); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
@@ -135,18 +135,18 @@ discard block |
||
135 | 135 | * @param string $endpoint |
136 | 136 | * @return void |
137 | 137 | */ |
138 | - protected function send($endpoint, array $args = []) |
|
138 | + protected function send( $endpoint, array $args = [] ) |
|
139 | 139 | { |
140 | - $args = wp_parse_args($args, [ |
|
140 | + $args = wp_parse_args( $args, [ |
|
141 | 141 | 'body' => null, |
142 | 142 | 'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'], |
143 | 143 | 'redirection' => 5, |
144 | 144 | 'sslverify' => false, |
145 | 145 | 'timeout' => 5, |
146 | - ]); |
|
146 | + ] ); |
|
147 | 147 | $this->reset(); |
148 | 148 | $this->handleResponse( |
149 | - wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args) |
|
149 | + wp_remote_post( trailingslashit( static::API_URL ).$endpoint, $args ) |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | } |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | 'setting' => 'Plugin Settings', |
42 | 42 | 'reviews' => 'Review Counts', |
43 | 43 | ]; |
44 | - $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) { |
|
45 | - $methodName = Helper::buildMethodName('get-'.$key.'-details'); |
|
46 | - if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) { |
|
44 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) { |
|
45 | + $methodName = Helper::buildMethodName( 'get-'.$key.'-details' ); |
|
46 | + if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
|
47 | 47 | return $carry.$this->implode( |
48 | - strtoupper($details[$key]), |
|
49 | - apply_filters('site-reviews/system/'.$key, $systemDetails) |
|
48 | + strtoupper( $details[$key] ), |
|
49 | + apply_filters( 'site-reviews/system/'.$key, $systemDetails ) |
|
50 | 50 | ); |
51 | 51 | } |
52 | 52 | return $carry; |
53 | 53 | }); |
54 | - return trim($systemInfo); |
|
54 | + return trim( $systemInfo ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | public function getActivePluginDetails() |
61 | 61 | { |
62 | 62 | $plugins = get_plugins(); |
63 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
64 | - $inactive = array_diff_key($plugins, array_flip($activePlugins)); |
|
65 | - return $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
63 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
64 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
65 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getAddonDetails() |
72 | 72 | { |
73 | - $details = apply_filters('site-reviews/addon/system-info', []); |
|
74 | - ksort($details); |
|
73 | + $details = apply_filters( 'site-reviews/addon/system-info', [] ); |
|
74 | + ksort( $details ); |
|
75 | 75 | return $details; |
76 | 76 | } |
77 | 77 | |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | public function getBrowserDetails() |
82 | 82 | { |
83 | 83 | $browser = new Browser(); |
84 | - $name = esc_attr($browser->getName()); |
|
85 | - $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString()); |
|
86 | - $version = esc_attr($browser->getVersion()); |
|
84 | + $name = esc_attr( $browser->getName() ); |
|
85 | + $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() ); |
|
86 | + $version = esc_attr( $browser->getVersion() ); |
|
87 | 87 | return [ |
88 | - 'Browser Name' => sprintf('%s %s', $name, $version), |
|
88 | + 'Browser Name' => sprintf( '%s %s', $name, $version ), |
|
89 | 89 | 'Browser UA' => $userAgent, |
90 | 90 | ]; |
91 | 91 | } |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getInactivePluginDetails() |
97 | 97 | { |
98 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
99 | - $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins))); |
|
98 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
99 | + $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
100 | 100 | $multisitePlugins = $this->getMultisitePluginDetails(); |
101 | 101 | return empty($multisitePlugins) |
102 | 102 | ? $inactivePlugins |
103 | - : array_diff($inactivePlugins, $multisitePlugins); |
|
103 | + : array_diff( $inactivePlugins, $multisitePlugins ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function getMuPluginDetails() |
110 | 110 | { |
111 | - if (empty($plugins = get_mu_plugins())) { |
|
111 | + if( empty($plugins = get_mu_plugins()) ) { |
|
112 | 112 | return []; |
113 | 113 | } |
114 | - return $this->normalizePluginList($plugins); |
|
114 | + return $this->normalizePluginList( $plugins ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function getMultisitePluginDetails() |
121 | 121 | { |
122 | - $activePlugins = (array) get_site_option('active_sitewide_plugins', []); |
|
123 | - if (!is_multisite() || empty($activePlugins)) { |
|
122 | + $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] ); |
|
123 | + if( !is_multisite() || empty($activePlugins) ) { |
|
124 | 124 | return []; |
125 | 125 | } |
126 | - return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins)); |
|
126 | + return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) ); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -131,31 +131,31 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function getPhpDetails() |
133 | 133 | { |
134 | - $displayErrors = ini_get('display_errors') |
|
135 | - ? 'On ('.ini_get('display_errors').')' |
|
134 | + $displayErrors = ini_get( 'display_errors' ) |
|
135 | + ? 'On ('.ini_get( 'display_errors' ).')' |
|
136 | 136 | : 'N/A'; |
137 | - $intlSupport = extension_loaded('intl') |
|
138 | - ? phpversion('intl') |
|
137 | + $intlSupport = extension_loaded( 'intl' ) |
|
138 | + ? phpversion( 'intl' ) |
|
139 | 139 | : 'false'; |
140 | 140 | return [ |
141 | - 'cURL' => var_export(function_exists('curl_init'), true), |
|
142 | - 'Default Charset' => ini_get('default_charset'), |
|
141 | + 'cURL' => var_export( function_exists( 'curl_init' ), true ), |
|
142 | + 'Default Charset' => ini_get( 'default_charset' ), |
|
143 | 143 | 'Display Errors' => $displayErrors, |
144 | - 'fsockopen' => var_export(function_exists('fsockopen'), true), |
|
144 | + 'fsockopen' => var_export( function_exists( 'fsockopen' ), true ), |
|
145 | 145 | 'Intl' => $intlSupport, |
146 | - 'IPv6' => var_export(defined('AF_INET6'), true), |
|
147 | - 'Max Execution Time' => ini_get('max_execution_time'), |
|
148 | - 'Max Input Nesting Level' => ini_get('max_input_nesting_level'), |
|
149 | - 'Max Input Vars' => ini_get('max_input_vars'), |
|
150 | - 'Memory Limit' => ini_get('memory_limit'), |
|
151 | - 'Post Max Size' => ini_get('post_max_size'), |
|
152 | - 'Sendmail Path' => ini_get('sendmail_path'), |
|
153 | - 'Session Cookie Path' => esc_html(ini_get('session.cookie_path')), |
|
154 | - 'Session Name' => esc_html(ini_get('session.name')), |
|
155 | - 'Session Save Path' => esc_html(ini_get('session.save_path')), |
|
156 | - 'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true), |
|
157 | - 'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true), |
|
158 | - 'Upload Max Filesize' => ini_get('upload_max_filesize'), |
|
146 | + 'IPv6' => var_export( defined( 'AF_INET6' ), true ), |
|
147 | + 'Max Execution Time' => ini_get( 'max_execution_time' ), |
|
148 | + 'Max Input Nesting Level' => ini_get( 'max_input_nesting_level' ), |
|
149 | + 'Max Input Vars' => ini_get( 'max_input_vars' ), |
|
150 | + 'Memory Limit' => ini_get( 'memory_limit' ), |
|
151 | + 'Post Max Size' => ini_get( 'post_max_size' ), |
|
152 | + 'Sendmail Path' => ini_get( 'sendmail_path' ), |
|
153 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
154 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
155 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
156 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
157 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
158 | + 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
|
159 | 159 | ]; |
160 | 160 | } |
161 | 161 | |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function getReviewsDetails() |
166 | 166 | { |
167 | - $counts = glsr(CountsManager::class)->getCounts(); |
|
168 | - $counts = Arr::flattenArray($counts); |
|
169 | - array_walk($counts, function (&$ratings) use ($counts) { |
|
170 | - if (!is_array($ratings)) { |
|
167 | + $counts = glsr( CountsManager::class )->getCounts(); |
|
168 | + $counts = Arr::flattenArray( $counts ); |
|
169 | + array_walk( $counts, function( &$ratings ) use ($counts) { |
|
170 | + if( !is_array( $ratings ) ) { |
|
171 | 171 | glsr_log() |
172 | - ->error('$ratings is not an array, possibly due to incorrectly imported reviews.') |
|
173 | - ->debug($ratings) |
|
174 | - ->debug($counts); |
|
172 | + ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' ) |
|
173 | + ->debug( $ratings ) |
|
174 | + ->debug( $counts ); |
|
175 | 175 | return; |
176 | 176 | } |
177 | - $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')'; |
|
177 | + $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')'; |
|
178 | 178 | }); |
179 | - ksort($counts); |
|
179 | + ksort( $counts ); |
|
180 | 180 | return $counts; |
181 | 181 | } |
182 | 182 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | 'Host Name' => $this->getHostName(), |
191 | 191 | 'MySQL Version' => $wpdb->db_version(), |
192 | 192 | 'PHP Version' => PHP_VERSION, |
193 | - 'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'), |
|
193 | + 'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ), |
|
194 | 194 | ]; |
195 | 195 | } |
196 | 196 | |
@@ -199,16 +199,16 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function getSettingDetails() |
201 | 201 | { |
202 | - $settings = glsr(OptionManager::class)->get('settings', []); |
|
203 | - $settings = Arr::flattenArray($settings, true); |
|
204 | - $settings = $this->purgeSensitiveData($settings); |
|
205 | - ksort($settings); |
|
202 | + $settings = glsr( OptionManager::class )->get( 'settings', [] ); |
|
203 | + $settings = Arr::flattenArray( $settings, true ); |
|
204 | + $settings = $this->purgeSensitiveData( $settings ); |
|
205 | + ksort( $settings ); |
|
206 | 206 | $details = []; |
207 | - foreach ($settings as $key => $value) { |
|
208 | - if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) { |
|
207 | + foreach( $settings as $key => $value ) { |
|
208 | + if( Str::startsWith( 'strings', $key ) && Str::endsWith( 'id', $key ) ) { |
|
209 | 209 | continue; |
210 | 210 | } |
211 | - $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8'); |
|
211 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
212 | 212 | $details[$key] = $value; |
213 | 213 | } |
214 | 214 | return $details; |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | public function getPluginDetails() |
221 | 221 | { |
222 | 222 | return [ |
223 | - 'Console level' => glsr(Console::class)->humanLevel(), |
|
224 | - 'Console size' => glsr(Console::class)->humanSize('0'), |
|
225 | - 'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')), |
|
223 | + 'Console level' => glsr( Console::class )->humanLevel(), |
|
224 | + 'Console size' => glsr( Console::class )->humanSize( '0' ), |
|
225 | + 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ), |
|
226 | 226 | 'Version (current)' => glsr()->version, |
227 | - 'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'), |
|
227 | + 'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ), |
|
228 | 228 | ]; |
229 | 229 | } |
230 | 230 | |
@@ -236,23 +236,23 @@ discard block |
||
236 | 236 | global $wpdb; |
237 | 237 | $theme = wp_get_theme(); |
238 | 238 | return [ |
239 | - 'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version), |
|
240 | - 'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1), |
|
239 | + 'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ), |
|
240 | + 'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ), |
|
241 | 241 | 'Home URL' => home_url(), |
242 | 242 | 'Language' => get_locale(), |
243 | 243 | 'Memory Limit' => WP_MEMORY_LIMIT, |
244 | - 'Multisite' => var_export(is_multisite(), true), |
|
245 | - 'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'), |
|
246 | - 'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'), |
|
247 | - 'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'), |
|
248 | - 'Post Stati' => implode(', ', get_post_stati()), |
|
249 | - 'Remote Post' => glsr(Cache::class)->getRemotePostTest(), |
|
250 | - 'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'), |
|
244 | + 'Multisite' => var_export( is_multisite(), true ), |
|
245 | + 'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ), |
|
246 | + 'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ), |
|
247 | + 'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ), |
|
248 | + 'Post Stati' => implode( ', ', get_post_stati() ), |
|
249 | + 'Remote Post' => glsr( Cache::class )->getRemotePostTest(), |
|
250 | + 'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ), |
|
251 | 251 | 'Site URL' => site_url(), |
252 | - 'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'), |
|
253 | - 'Version' => get_bloginfo('version'), |
|
254 | - 'WP Debug' => var_export(defined('WP_DEBUG'), true), |
|
255 | - 'WP Max Upload Size' => size_format(wp_max_upload_size()), |
|
252 | + 'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', ini_get( 'date.timezone' ).' (PHP)' ), |
|
253 | + 'Version' => get_bloginfo( 'version' ), |
|
254 | + 'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ), |
|
255 | + 'WP Max Upload Size' => size_format( wp_max_upload_size() ), |
|
256 | 256 | 'WP Memory Limit' => WP_MEMORY_LIMIT, |
257 | 257 | ]; |
258 | 258 | } |
@@ -282,13 +282,13 @@ discard block |
||
282 | 282 | 'secureserver.net' => 'GoDaddy', |
283 | 283 | 'WPE_APIKEY' => 'WP Engine', |
284 | 284 | ]; |
285 | - foreach ($checks as $key => $value) { |
|
286 | - if (!$this->isWebhostCheckValid($key)) { |
|
285 | + foreach( $checks as $key => $value ) { |
|
286 | + if( !$this->isWebhostCheckValid( $key ) ) { |
|
287 | 287 | continue; |
288 | 288 | } |
289 | 289 | return $value; |
290 | 290 | } |
291 | - return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')])); |
|
291 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | protected function getHostName() |
298 | 298 | { |
299 | - return sprintf('%s (%s)', |
|
299 | + return sprintf( '%s (%s)', |
|
300 | 300 | $this->detectWebhostProvider(), |
301 | 301 | Helper::getIpAddress() |
302 | 302 | ); |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | protected function getWordpressPlugins() |
309 | 309 | { |
310 | 310 | $plugins = get_plugins(); |
311 | - $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array'); |
|
312 | - $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins))); |
|
313 | - $active = $this->normalizePluginList(array_diff_key($plugins, $inactive)); |
|
311 | + $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' ); |
|
312 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
313 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
314 | 314 | return $active + $inactive; |
315 | 315 | } |
316 | 316 | |
@@ -318,48 +318,48 @@ discard block |
||
318 | 318 | * @param string $title |
319 | 319 | * @return string |
320 | 320 | */ |
321 | - protected function implode($title, array $details) |
|
321 | + protected function implode( $title, array $details ) |
|
322 | 322 | { |
323 | 323 | $strings = ['['.$title.']']; |
324 | - $padding = max(array_map('strlen', array_keys($details))); |
|
325 | - $padding = max([$padding, static::PAD]); |
|
326 | - foreach ($details as $key => $value) { |
|
327 | - $strings[] = is_string($key) |
|
328 | - ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value) |
|
324 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
325 | + $padding = max( [$padding, static::PAD] ); |
|
326 | + foreach( $details as $key => $value ) { |
|
327 | + $strings[] = is_string( $key ) |
|
328 | + ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value ) |
|
329 | 329 | : ' - '.$value; |
330 | 330 | } |
331 | - return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL; |
|
331 | + return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | 335 | * @param string $key |
336 | 336 | * @return bool |
337 | 337 | */ |
338 | - protected function isWebhostCheckValid($key) |
|
338 | + protected function isWebhostCheckValid( $key ) |
|
339 | 339 | { |
340 | - return defined($key) |
|
341 | - || filter_input(INPUT_SERVER, $key) |
|
342 | - || false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key) |
|
343 | - || false !== strpos(DB_HOST, $key) |
|
344 | - || false !== strpos(php_uname(), $key); |
|
340 | + return defined( $key ) |
|
341 | + || filter_input( INPUT_SERVER, $key ) |
|
342 | + || false !== strpos( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key ) |
|
343 | + || false !== strpos( DB_HOST, $key ) |
|
344 | + || false !== strpos( php_uname(), $key ); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
348 | 348 | * @return array |
349 | 349 | */ |
350 | - protected function normalizePluginList(array $plugins) |
|
350 | + protected function normalizePluginList( array $plugins ) |
|
351 | 351 | { |
352 | - $plugins = array_map(function ($plugin) { |
|
353 | - return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version')); |
|
354 | - }, $plugins); |
|
355 | - natcasesort($plugins); |
|
356 | - return array_flip($plugins); |
|
352 | + $plugins = array_map( function( $plugin ) { |
|
353 | + return sprintf( '%s v%s', Arr::get( $plugin, 'Name' ), Arr::get( $plugin, 'Version' ) ); |
|
354 | + }, $plugins ); |
|
355 | + natcasesort( $plugins ); |
|
356 | + return array_flip( $plugins ); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
360 | 360 | * @return array |
361 | 361 | */ |
362 | - protected function purgeSensitiveData(array $settings) |
|
362 | + protected function purgeSensitiveData( array $settings ) |
|
363 | 363 | { |
364 | 364 | $keys = [ |
365 | 365 | 'general.rebusify_serial', |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | 'submissions.recaptcha.key', |
368 | 368 | 'submissions.recaptcha.secret', |
369 | 369 | ]; |
370 | - array_walk($settings, function (&$value, $setting) use ($keys) { |
|
371 | - foreach ($keys as $key) { |
|
372 | - if (!Str::startsWith($key, $setting) || empty($value)) { |
|
370 | + array_walk( $settings, function( &$value, $setting ) use ($keys) { |
|
371 | + foreach( $keys as $key ) { |
|
372 | + if( !Str::startsWith( $key, $setting ) || empty($value) ) { |
|
373 | 373 | continue; |
374 | 374 | } |
375 | - $value = str_repeat('•', 13); |
|
375 | + $value = str_repeat( '•', 13 ); |
|
376 | 376 | return; |
377 | 377 | } |
378 | 378 | }); |