@@ -39,20 +39,20 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - public function render(array $attributes) |
|
42 | + public function render( array $attributes ) |
|
43 | 43 | { |
44 | 44 | $attributes['class'] = $attributes['className']; |
45 | - $shortcode = glsr(Shortcode::class); |
|
46 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
45 | + $shortcode = glsr( Shortcode::class ); |
|
46 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
47 | 47 | $this->filterFormFields(); |
48 | 48 | $this->filterRatingField(); |
49 | 49 | $this->filterShortcodeClass(); |
50 | 50 | $this->filterSubmitButton(); |
51 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
51 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
52 | 52 | $this->filterInterpolation(); |
53 | 53 | } |
54 | 54 | } |
55 | - return $shortcode->buildShortcode($attributes); |
|
55 | + return $shortcode->buildShortcode( $attributes ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | */ |
61 | 61 | protected function filterFormFields() |
62 | 62 | { |
63 | - add_filter('site-reviews/config/forms/submission-form', function (array $config) { |
|
64 | - array_walk($config, function (&$field) { |
|
63 | + add_filter( 'site-reviews/config/forms/submission-form', function( array $config ) { |
|
64 | + array_walk( $config, function( &$field ) { |
|
65 | 65 | $field['disabled'] = true; |
66 | 66 | $field['tabindex'] = '-1'; |
67 | 67 | }); |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | protected function filterInterpolation() |
76 | 76 | { |
77 | - add_filter('site-reviews/interpolate/reviews-form', function ($context) { |
|
77 | + add_filter( 'site-reviews/interpolate/reviews-form', function( $context ) { |
|
78 | 78 | $context['class'] = 'glsr-default glsr-block-disabled'; |
79 | - $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
79 | + $context['fields'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
80 | 80 | $context['response'] = ''; |
81 | 81 | $context['submit_button'] = ''; |
82 | 82 | return $context; |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected function filterRatingField() |
90 | 90 | { |
91 | - add_filter('site-reviews/rendered/field', function ($html, $type, $args) { |
|
92 | - if ('rating' == $args['path']) { |
|
91 | + add_filter( 'site-reviews/rendered/field', function( $html, $type, $args ) { |
|
92 | + if( 'rating' == $args['path'] ) { |
|
93 | 93 | $stars = '<span class="glsr-stars">'; |
94 | - $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class)); |
|
95 | - $stars.= '</span>'; |
|
96 | - $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html); |
|
94 | + $stars .= str_repeat( '<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int)glsr()->constant( 'MAX_RATING', Rating::class ) ); |
|
95 | + $stars .= '</span>'; |
|
96 | + $html = preg_replace( '/(.*)(<select.*)(<\/select>)(.*)/u', '$1'.$stars.'$4', $html ); |
|
97 | 97 | } |
98 | 98 | return $html; |
99 | - }, 10, 3); |
|
99 | + }, 10, 3 ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function filterShortcodeClass() |
106 | 106 | { |
107 | - add_filter('site-reviews/style', function () { |
|
107 | + add_filter( 'site-reviews/style', function() { |
|
108 | 108 | return 'default'; |
109 | 109 | }); |
110 | 110 | } |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function filterSubmitButton() |
116 | 116 | { |
117 | - add_filter('site-reviews/rendered/template/form/submit-button', function ($template) { |
|
118 | - return str_replace('type="submit"', 'tabindex="-1"', $template); |
|
117 | + add_filter( 'site-reviews/rendered/template/form/submit-button', function( $template ) { |
|
118 | + return str_replace( 'type="submit"', 'tabindex="-1"', $template ); |
|
119 | 119 | }); |
120 | 120 | } |
121 | 121 | } |
@@ -62,21 +62,21 @@ discard block |
||
62 | 62 | /** |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function render(array $attributes) |
|
65 | + public function render( array $attributes ) |
|
66 | 66 | { |
67 | 67 | $attributes['class'] = $attributes['className']; |
68 | - $shortcode = glsr(Shortcode::class); |
|
69 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
70 | - $attributes = $this->normalize($attributes); |
|
68 | + $shortcode = glsr( Shortcode::class ); |
|
69 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
70 | + $attributes = $this->normalize( $attributes ); |
|
71 | 71 | $this->filterReviewLinks(); |
72 | 72 | $this->filterShortcodeClass(); |
73 | - $this->filterShowMoreLinks('content'); |
|
74 | - $this->filterShowMoreLinks('response'); |
|
75 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
73 | + $this->filterShowMoreLinks( 'content' ); |
|
74 | + $this->filterShowMoreLinks( 'response' ); |
|
75 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
76 | 76 | $this->filterInterpolation(); |
77 | 77 | } |
78 | 78 | } |
79 | - return $shortcode->buildShortcode($attributes); |
|
79 | + return $shortcode->buildShortcode( $attributes ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function filterInterpolation() |
86 | 86 | { |
87 | - add_filter('site-reviews/interpolate/reviews', function ($context) { |
|
87 | + add_filter( 'site-reviews/interpolate/reviews', function( $context ) { |
|
88 | 88 | $context['class'] = 'glsr-default glsr-block-disabled'; |
89 | - $context['reviews'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
89 | + $context['reviews'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
90 | 90 | return $context; |
91 | 91 | }); |
92 | 92 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function filterReviewLinks() |
98 | 98 | { |
99 | - add_filter('site-reviews/rendered/template/reviews', function ($template) { |
|
100 | - return str_replace('<a', '<a tabindex="-1"', $template); |
|
99 | + add_filter( 'site-reviews/rendered/template/reviews', function( $template ) { |
|
100 | + return str_replace( '<a', '<a tabindex="-1"', $template ); |
|
101 | 101 | }); |
102 | 102 | } |
103 | 103 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function filterShortcodeClass() |
108 | 108 | { |
109 | - add_filter('site-reviews/style', function () { |
|
109 | + add_filter( 'site-reviews/style', function() { |
|
110 | 110 | return 'default'; |
111 | 111 | }); |
112 | 112 | } |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | * @param string $field |
116 | 116 | * @return void |
117 | 117 | */ |
118 | - protected function filterShowMoreLinks($field) |
|
118 | + protected function filterShowMoreLinks( $field ) |
|
119 | 119 | { |
120 | - add_filter('site-reviews/review/wrap/'.$field, function ($value) { |
|
120 | + add_filter( 'site-reviews/review/wrap/'.$field, function( $value ) { |
|
121 | 121 | $value = preg_replace( |
122 | 122 | '/(.*)(<span class="glsr-hidden)(.*)(<\/span>)(.*)/us', |
123 | - '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__('Show more', 'site-reviews').'</a>$5', |
|
123 | + '$1... <a href="#" class="glsr-read-more" tabindex="-1">'.__( 'Show more', 'site-reviews' ).'</a>$5', |
|
124 | 124 | $value |
125 | 125 | ); |
126 | 126 | return $value; |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <div class="notice is-dismissible glsr-notice" data-dismiss="trustalyze"> |
2 | 2 | <div class="glsr-notice-icon"> |
3 | - <img width="96" height="96" src="<?= glsr()->url('assets/images/trustalyze-badge.png'); ?>"> |
|
3 | + <img width="96" height="96" src="<?= glsr()->url( 'assets/images/trustalyze-badge.png' ); ?>"> |
|
4 | 4 | </div> |
5 | 5 | <div class="glsr-notice-content"> |
6 | 6 | <h3>Validate Your Reviews on the Blockchain With the Trustalyze Confidence System</h3> |
7 | 7 | <p>Site Reviews integrates with the <a href="https://trustalyze.com/plans?ref=105">Trustalyze Confidence System</a>, a service which uses blockchain technology to verify to your visitors and customers that your reviews are authentic.</p> |
8 | - <a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general'); ?>" class="button">Enable the integration</a> |
|
8 | + <a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-general' ); ?>" class="button">Enable the integration</a> |
|
9 | 9 | </div> |
10 | 10 | </div> |
@@ -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->trustalyzeKey, false); |
|
32 | - if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) { |
|
33 | - $settings = $this->sanitizeTrustalyzeSettings($settings); |
|
29 | + $isApiKeyModified = $this->isEmptyOrModified( $this->apiKey, $settings ); |
|
30 | + $isEmailModified = $this->isEmptyOrModified( $this->emailKey, $settings ); |
|
31 | + $isAccountVerified = glsr( OptionManager::class )->getWP( $this->trustalyzeKey, false ); |
|
32 | + if( !$isAccountVerified || $isApiKeyModified || $isEmailModified ) { |
|
33 | + $settings = $this->sanitizeTrustalyzeSettings( $settings ); |
|
34 | 34 | } |
35 | 35 | return $settings; |
36 | 36 | } |
@@ -40,17 +40,17 @@ 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 | - $isAccountValidated = !empty(glsr(OptionManager::class)->getWP($this->trustalyzeKey)); |
|
49 | - $isIntegrationEnabled = glsr(OptionManager::class)->getBool('settings.general.trustalyze'); |
|
50 | - if ($isAccountValidated && $isIntegrationEnabled) { |
|
48 | + $isAccountValidated = !empty(glsr( OptionManager::class )->getWP( $this->trustalyzeKey )); |
|
49 | + $isIntegrationEnabled = glsr( OptionManager::class )->getBool( 'settings.general.trustalyze' ); |
|
50 | + if( $isAccountValidated && $isIntegrationEnabled ) { |
|
51 | 51 | return $context; |
52 | 52 | } |
53 | - $context['field'].= $this->buildCreateButton(); |
|
53 | + $context['field'] .= $this->buildCreateButton(); |
|
54 | 54 | return $context; |
55 | 55 | } |
56 | 56 | |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | * @return void |
60 | 60 | * @action site-reviews/review/created |
61 | 61 | */ |
62 | - public function onCreated(Review $review) |
|
62 | + public function onCreated( Review $review ) |
|
63 | 63 | { |
64 | - if (!$this->canPostReview($review)) { |
|
64 | + if( !$this->canPostReview( $review ) ) { |
|
65 | 65 | return; |
66 | 66 | } |
67 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
68 | - if ($trustalyze->success) { |
|
69 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
67 | + $trustalyze = glsr( Trustalyze::class )->sendReview( $review ); |
|
68 | + if( $trustalyze->success ) { |
|
69 | + glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id ); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | * @return void |
76 | 76 | * @action site-reviews/review/reverted |
77 | 77 | */ |
78 | - public function onReverted(Review $review) |
|
78 | + public function onReverted( Review $review ) |
|
79 | 79 | { |
80 | - if (!$this->canPostReview($review)) { |
|
80 | + if( !$this->canPostReview( $review ) ) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
84 | - if ($trustalyze->success) { |
|
85 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
83 | + $trustalyze = glsr( Trustalyze::class )->sendReview( $review ); |
|
84 | + if( $trustalyze->success ) { |
|
85 | + glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id ); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | * @return void |
92 | 92 | * @action site-reviews/review/saved |
93 | 93 | */ |
94 | - public function onSaved(Review $review) |
|
94 | + public function onSaved( Review $review ) |
|
95 | 95 | { |
96 | - if (!$this->canPostReview($review)) { |
|
96 | + if( !$this->canPostReview( $review ) ) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | - $trustalyze = glsr(Trustalyze::class)->sendReview($review); |
|
100 | - if ($trustalyze->success) { |
|
101 | - glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id); |
|
99 | + $trustalyze = glsr( Trustalyze::class )->sendReview( $review ); |
|
100 | + if( $trustalyze->success ) { |
|
101 | + glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id ); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * @return void |
111 | 111 | * @action updated_postmeta |
112 | 112 | */ |
113 | - public function onUpdatedMeta($metaId, $postId, $metaKey) |
|
113 | + public function onUpdatedMeta( $metaId, $postId, $metaKey ) |
|
114 | 114 | { |
115 | - $review = glsr_get_review($postId); |
|
116 | - if (!$this->canPostResponse($review) || '_response' !== $metaKey) { |
|
115 | + $review = glsr_get_review( $postId ); |
|
116 | + if( !$this->canPostResponse( $review ) || '_response' !== $metaKey ) { |
|
117 | 117 | return; |
118 | 118 | } |
119 | - $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review); |
|
120 | - if ($trustalyze->success) { |
|
121 | - glsr(Database::class)->set($review->ID, 'trustalyze_response', true); |
|
119 | + $trustalyze = glsr( Trustalyze::class )->sendReviewResponse( $review ); |
|
120 | + if( $trustalyze->success ) { |
|
121 | + glsr( Database::class )->set( $review->ID, 'trustalyze_response', true ); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -127,32 +127,32 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildCreateButton() |
129 | 129 | { |
130 | - return glsr(Builder::class)->a(__('Create Your Trustalyze Account', 'site-reviews'), [ |
|
130 | + return glsr( Builder::class )->a( __( 'Create Your Trustalyze Account', 'site-reviews' ), [ |
|
131 | 131 | 'class' => 'button', |
132 | 132 | 'href' => Trustalyze::WEB_URL, |
133 | 133 | 'target' => '_blank', |
134 | - ]); |
|
134 | + ] ); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
138 | 138 | * @return bool |
139 | 139 | */ |
140 | - protected function canPostResponse(Review $review) |
|
140 | + protected function canPostResponse( Review $review ) |
|
141 | 141 | { |
142 | 142 | $requiredValues = [ |
143 | - glsr(Database::class)->get($review->ID, 'trustalyze'), |
|
143 | + glsr( Database::class )->get( $review->ID, 'trustalyze' ), |
|
144 | 144 | $review->response, |
145 | 145 | $review->review_id, |
146 | 146 | ]; |
147 | - return $this->canProceed($review, 'trustalyze_response') |
|
147 | + return $this->canProceed( $review, 'trustalyze_response' ) |
|
148 | 148 | && 'publish' === $review->status |
149 | - && 3 === count(array_filter($requiredValues)); |
|
149 | + && 3 === count( array_filter( $requiredValues ) ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * @return bool |
154 | 154 | */ |
155 | - protected function canPostReview(Review $review) |
|
155 | + protected function canPostReview( Review $review ) |
|
156 | 156 | { |
157 | 157 | $requiredValues = [ |
158 | 158 | $review->author, |
@@ -161,60 +161,60 @@ discard block |
||
161 | 161 | $review->review_id, |
162 | 162 | $review->title, |
163 | 163 | ]; |
164 | - return $this->canProceed($review) |
|
164 | + return $this->canProceed( $review ) |
|
165 | 165 | && 'publish' === $review->status |
166 | - && 5 === count(array_filter($requiredValues)); |
|
166 | + && 5 === count( array_filter( $requiredValues ) ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
170 | 170 | * @param string $metaKey |
171 | 171 | * @return bool |
172 | 172 | */ |
173 | - protected function canProceed(Review $review, $metaKey = 'trustalyze') |
|
173 | + protected function canProceed( Review $review, $metaKey = 'trustalyze' ) |
|
174 | 174 | { |
175 | - return glsr(OptionManager::class)->getBool($this->enabledKey) |
|
176 | - && $this->isReviewPostId($review->ID) |
|
177 | - && !$this->hasMetaKey($review, $metaKey); |
|
175 | + return glsr( OptionManager::class )->getBool( $this->enabledKey ) |
|
176 | + && $this->isReviewPostId( $review->ID ) |
|
177 | + && !$this->hasMetaKey( $review, $metaKey ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | 181 | * @param string $metaKey |
182 | 182 | * @return bool |
183 | 183 | */ |
184 | - protected function hasMetaKey(Review $review, $metaKey = 'trustalyze') |
|
184 | + protected function hasMetaKey( Review $review, $metaKey = 'trustalyze' ) |
|
185 | 185 | { |
186 | - return '' !== glsr(Database::class)->get($review->ID, $metaKey); |
|
186 | + return '' !== glsr( Database::class )->get( $review->ID, $metaKey ); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | 190 | * @param string $key |
191 | 191 | * @return bool |
192 | 192 | */ |
193 | - protected function isEmptyOrModified($key, array $settings) |
|
193 | + protected function isEmptyOrModified( $key, array $settings ) |
|
194 | 194 | { |
195 | - $oldValue = glsr_get_option($key); |
|
196 | - $newValue = Arr::get($settings, $key); |
|
195 | + $oldValue = glsr_get_option( $key ); |
|
196 | + $newValue = Arr::get( $settings, $key ); |
|
197 | 197 | return empty($newValue) || $newValue !== $oldValue; |
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
201 | 201 | * @return array |
202 | 202 | */ |
203 | - protected function sanitizeTrustalyzeSettings(array $settings) |
|
203 | + protected function sanitizeTrustalyzeSettings( array $settings ) |
|
204 | 204 | { |
205 | - $trustalyze = glsr(Trustalyze::class)->activateKey( |
|
206 | - Arr::get($settings, $this->apiKey), |
|
207 | - Arr::get($settings, $this->emailKey) |
|
205 | + $trustalyze = glsr( Trustalyze::class )->activateKey( |
|
206 | + Arr::get( $settings, $this->apiKey ), |
|
207 | + Arr::get( $settings, $this->emailKey ) |
|
208 | 208 | ); |
209 | - if ($trustalyze->success) { |
|
210 | - update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype')); |
|
209 | + if( $trustalyze->success ) { |
|
210 | + update_option( $this->trustalyzeKey, Arr::get( $trustalyze->response, 'producttype' ) ); |
|
211 | 211 | } else { |
212 | - delete_option($this->trustalyzeKey); |
|
213 | - $settings = Arr::set($settings, $this->enabledKey, 'no'); |
|
214 | - glsr(Notice::class)->addError(sprintf( |
|
215 | - __('Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews'), |
|
212 | + delete_option( $this->trustalyzeKey ); |
|
213 | + $settings = Arr::set( $settings, $this->enabledKey, 'no' ); |
|
214 | + glsr( Notice::class )->addError( sprintf( |
|
215 | + __( 'Your Trustalyze account details could not be verified, please try again. %s', 'site-reviews' ), |
|
216 | 216 | '('.$trustalyze->message.')' |
217 | - )); |
|
217 | + ) ); |
|
218 | 218 | } |
219 | 219 | return $settings; |
220 | 220 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public $translator; |
18 | 18 | |
19 | - public function __construct(Translator $translator) |
|
19 | + public function __construct( Translator $translator ) |
|
20 | 20 | { |
21 | 21 | $this->translator = $translator; |
22 | 22 | } |
@@ -27,17 +27,17 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function addTranslationFilters() |
29 | 29 | { |
30 | - if (empty(glsr(Translation::class)->translations())) { |
|
30 | + if( empty(glsr( Translation::class )->translations()) ) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | - add_filter('gettext', [$this, 'filterGettext'], 9, 3); |
|
34 | - add_filter('site-reviews/gettext/site-reviews', [$this, 'filterGettextSiteReviews'], 10, 2); |
|
35 | - add_filter('gettext_with_context', [$this, 'filterGettextWithContext'], 9, 4); |
|
36 | - add_filter('site-reviews/gettext_with_context/site-reviews', [$this, 'filterGettextWithContextSiteReviews'], 10, 3); |
|
37 | - add_filter('ngettext', [$this, 'filterNgettext'], 9, 5); |
|
38 | - add_filter('site-reviews/ngettext/site-reviews', [$this, 'filterNgettextSiteReviews'], 10, 4); |
|
39 | - add_filter('ngettext_with_context', [$this, 'filterNgettextWithContext'], 9, 6); |
|
40 | - add_filter('site-reviews/ngettext_with_context/site-reviews', [$this, 'filterNgettextWithContextSiteReviews'], 10, 5); |
|
33 | + add_filter( 'gettext', [$this, 'filterGettext'], 9, 3 ); |
|
34 | + add_filter( 'site-reviews/gettext/site-reviews', [$this, 'filterGettextSiteReviews'], 10, 2 ); |
|
35 | + add_filter( 'gettext_with_context', [$this, 'filterGettextWithContext'], 9, 4 ); |
|
36 | + add_filter( 'site-reviews/gettext_with_context/site-reviews', [$this, 'filterGettextWithContextSiteReviews'], 10, 3 ); |
|
37 | + add_filter( 'ngettext', [$this, 'filterNgettext'], 9, 5 ); |
|
38 | + add_filter( 'site-reviews/ngettext/site-reviews', [$this, 'filterNgettextSiteReviews'], 10, 4 ); |
|
39 | + add_filter( 'ngettext_with_context', [$this, 'filterNgettextWithContext'], 9, 6 ); |
|
40 | + add_filter( 'site-reviews/ngettext_with_context/site-reviews', [$this, 'filterNgettextWithContextSiteReviews'], 10, 5 ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | * @return array |
46 | 46 | * @filter bulk_post_updated_messages |
47 | 47 | */ |
48 | - public function filterBulkUpdateMessages($messages, array $counts) |
|
48 | + public function filterBulkUpdateMessages( $messages, array $counts ) |
|
49 | 49 | { |
50 | - $messages = Arr::consolidateArray($messages); |
|
50 | + $messages = Arr::consolidateArray( $messages ); |
|
51 | 51 | $messages[Application::POST_TYPE] = [ |
52 | - 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
53 | - 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
54 | - 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
55 | - 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
56 | - 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
52 | + 'updated' => _n( '%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews' ), |
|
53 | + 'locked' => _n( '%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews' ), |
|
54 | + 'deleted' => _n( '%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews' ), |
|
55 | + 'trashed' => _n( '%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews' ), |
|
56 | + 'untrashed' => _n( '%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews' ), |
|
57 | 57 | ]; |
58 | 58 | return $messages; |
59 | 59 | } |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @return string |
66 | 66 | * @filter gettext |
67 | 67 | */ |
68 | - public function filterGettext($translation, $text, $domain) |
|
68 | + public function filterGettext( $translation, $text, $domain ) |
|
69 | 69 | { |
70 | - return apply_filters('site-reviews/gettext/'.$domain, $translation, $text); |
|
70 | + return apply_filters( 'site-reviews/gettext/'.$domain, $translation, $text ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | * @return string |
77 | 77 | * @filter site-reviews/gettext/site-reviews |
78 | 78 | */ |
79 | - public function filterGettextSiteReviews($translation, $text) |
|
79 | + public function filterGettextSiteReviews( $translation, $text ) |
|
80 | 80 | { |
81 | - return $this->translator->translate($translation, Application::ID, [ |
|
81 | + return $this->translator->translate( $translation, Application::ID, [ |
|
82 | 82 | 'single' => $text, |
83 | - ]); |
|
83 | + ] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @return string |
92 | 92 | * @filter gettext_with_context |
93 | 93 | */ |
94 | - public function filterGettextWithContext($translation, $text, $context, $domain) |
|
94 | + public function filterGettextWithContext( $translation, $text, $context, $domain ) |
|
95 | 95 | { |
96 | - return apply_filters('site-reviews/gettext_with_context/'.$domain, $translation, $text, $context); |
|
96 | + return apply_filters( 'site-reviews/gettext_with_context/'.$domain, $translation, $text, $context ); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | * @return string |
104 | 104 | * @filter site-reviews/gettext_with_context/site-reviews |
105 | 105 | */ |
106 | - public function filterGettextWithContextSiteReviews($translation, $text, $context) |
|
106 | + public function filterGettextWithContextSiteReviews( $translation, $text, $context ) |
|
107 | 107 | { |
108 | - return $this->translator->translate($translation, Application::ID, [ |
|
108 | + return $this->translator->translate( $translation, Application::ID, [ |
|
109 | 109 | 'context' => $context, |
110 | 110 | 'single' => $text, |
111 | - ]); |
|
111 | + ] ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * @return string |
121 | 121 | * @filter ngettext |
122 | 122 | */ |
123 | - public function filterNgettext($translation, $single, $plural, $number, $domain) |
|
123 | + public function filterNgettext( $translation, $single, $plural, $number, $domain ) |
|
124 | 124 | { |
125 | - return apply_filters('site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number); |
|
125 | + return apply_filters( 'site-reviews/ngettext/'.$domain, $translation, $single, $plural, $number ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | * @return string |
134 | 134 | * @filter site-reviews/ngettext/site-reviews |
135 | 135 | */ |
136 | - public function filterNgettextSiteReviews($translation, $single, $plural, $number) |
|
136 | + public function filterNgettextSiteReviews( $translation, $single, $plural, $number ) |
|
137 | 137 | { |
138 | - return $this->translator->translate($translation, Application::ID, [ |
|
138 | + return $this->translator->translate( $translation, Application::ID, [ |
|
139 | 139 | 'number' => $number, |
140 | 140 | 'plural' => $plural, |
141 | 141 | 'single' => $single, |
142 | - ]); |
|
142 | + ] ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | * @return string |
153 | 153 | * @filter ngettext_with_context |
154 | 154 | */ |
155 | - public function filterNgettextWithContext($translation, $single, $plural, $number, $context, $domain) |
|
155 | + public function filterNgettextWithContext( $translation, $single, $plural, $number, $context, $domain ) |
|
156 | 156 | { |
157 | - return apply_filters('site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context); |
|
157 | + return apply_filters( 'site-reviews/ngettext_with_context/'.$domain, $translation, $single, $plural, $number, $context ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | * @return string |
167 | 167 | * @filter site-reviews/ngettext_with_context/site-reviews |
168 | 168 | */ |
169 | - public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context) |
|
169 | + public function filterNgettextWithContextSiteReviews( $translation, $single, $plural, $number, $context ) |
|
170 | 170 | { |
171 | - return $this->translator->translate($translation, Application::ID, [ |
|
171 | + return $this->translator->translate( $translation, Application::ID, [ |
|
172 | 172 | 'context' => $context, |
173 | 173 | 'number' => $number, |
174 | 174 | 'plural' => $plural, |
175 | 175 | 'single' => $single, |
176 | - ]); |
|
176 | + ] ); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | * @return array |
183 | 183 | * @filter display_post_states |
184 | 184 | */ |
185 | - public function filterPostStates($postStates, $post) |
|
185 | + public function filterPostStates( $postStates, $post ) |
|
186 | 186 | { |
187 | - $postStates = Arr::consolidateArray($postStates); |
|
188 | - if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
189 | - $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
187 | + $postStates = Arr::consolidateArray( $postStates ); |
|
188 | + if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) && array_key_exists( 'pending', $postStates ) ) { |
|
189 | + $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
|
190 | 190 | } |
191 | 191 | return $postStates; |
192 | 192 | } |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | * @filter site-reviews/gettext/default |
199 | 199 | * @filter site-reviews/gettext_with_context/default |
200 | 200 | */ |
201 | - public function filterPostStatusLabels($translation, $text) |
|
201 | + public function filterPostStatusLabels( $translation, $text ) |
|
202 | 202 | { |
203 | 203 | return $this->canModifyTranslation() |
204 | - ? glsr(Labels::class)->filterPostStatusLabels($translation, $text) |
|
204 | + ? glsr( Labels::class )->filterPostStatusLabels( $translation, $text ) |
|
205 | 205 | : $translation; |
206 | 206 | } |
207 | 207 | |
@@ -213,22 +213,22 @@ discard block |
||
213 | 213 | * @return string |
214 | 214 | * @filter site-reviews/ngettext/default |
215 | 215 | */ |
216 | - public function filterPostStatusText($translation, $single, $plural, $number) |
|
216 | + public function filterPostStatusText( $translation, $single, $plural, $number ) |
|
217 | 217 | { |
218 | - if ($this->canModifyTranslation()) { |
|
218 | + if( $this->canModifyTranslation() ) { |
|
219 | 219 | $strings = [ |
220 | - 'Published' => __('Approved', 'site-reviews'), |
|
221 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
220 | + 'Published' => __( 'Approved', 'site-reviews' ), |
|
221 | + 'Pending' => __( 'Unapproved', 'site-reviews' ), |
|
222 | 222 | ]; |
223 | - foreach ($strings as $search => $replace) { |
|
224 | - if (!Str::contains($single, $search)) { |
|
223 | + foreach( $strings as $search => $replace ) { |
|
224 | + if( !Str::contains( $single, $search ) ) { |
|
225 | 225 | continue; |
226 | 226 | } |
227 | - return $this->translator->getTranslation([ |
|
227 | + return $this->translator->getTranslation( [ |
|
228 | 228 | 'number' => $number, |
229 | - 'plural' => str_replace($search, $replace, $plural), |
|
230 | - 'single' => str_replace($search, $replace, $single), |
|
231 | - ]); |
|
229 | + 'plural' => str_replace( $search, $replace, $plural ), |
|
230 | + 'single' => str_replace( $search, $replace, $single ), |
|
231 | + ] ); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | return $translation; |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function translatePostStatusLabels() |
242 | 242 | { |
243 | - if ($this->canModifyTranslation()) { |
|
244 | - glsr(Labels::class)->translatePostStatusLabels(); |
|
243 | + if( $this->canModifyTranslation() ) { |
|
244 | + glsr( Labels::class )->translatePostStatusLabels(); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
@@ -252,6 +252,6 @@ discard block |
||
252 | 252 | { |
253 | 253 | $screen = glsr_current_screen(); |
254 | 254 | return Application::POST_TYPE == $screen->post_type |
255 | - && in_array($screen->base, ['edit', 'post']); |
|
255 | + && in_array( $screen->base, ['edit', 'post'] ); |
|
256 | 256 | } |
257 | 257 | } |
@@ -40,24 +40,24 @@ discard block |
||
40 | 40 | protected $trustalyze; |
41 | 41 | protected $welcome; |
42 | 42 | |
43 | - public function __construct(Application $app ) { |
|
43 | + public function __construct( Application $app ) { |
|
44 | 44 | $this->app = $app; |
45 | - $this->admin = $app->make(AdminController::class); |
|
46 | - $this->blocks = $app->make(BlocksController::class); |
|
47 | - $this->console = $app->make(Console::class); |
|
48 | - $this->editor = $app->make(EditorController::class); |
|
49 | - $this->listtable = $app->make(ListTableController::class); |
|
50 | - $this->main = $app->make(MainController::class); |
|
51 | - $this->menu = $app->make(MenuController::class); |
|
52 | - $this->notices = $app->make(NoticeController::class); |
|
53 | - $this->public = $app->make(PublicController::class); |
|
54 | - $this->review = $app->make(ReviewController::class); |
|
55 | - $this->router = $app->make(Router::class); |
|
56 | - $this->settings = $app->make(SettingsController::class); |
|
57 | - $this->taxonomy = $app->make(TaxonomyController::class); |
|
58 | - $this->translator = $app->make(TranslationController::class); |
|
59 | - $this->trustalyze = $app->make(TrustalyzeController::class); |
|
60 | - $this->welcome = $app->make(WelcomeController::class); |
|
45 | + $this->admin = $app->make( AdminController::class ); |
|
46 | + $this->blocks = $app->make( BlocksController::class ); |
|
47 | + $this->console = $app->make( Console::class ); |
|
48 | + $this->editor = $app->make( EditorController::class ); |
|
49 | + $this->listtable = $app->make( ListTableController::class ); |
|
50 | + $this->main = $app->make( MainController::class ); |
|
51 | + $this->menu = $app->make( MenuController::class ); |
|
52 | + $this->notices = $app->make( NoticeController::class ); |
|
53 | + $this->public = $app->make( PublicController::class ); |
|
54 | + $this->review = $app->make( ReviewController::class ); |
|
55 | + $this->router = $app->make( Router::class ); |
|
56 | + $this->settings = $app->make( SettingsController::class ); |
|
57 | + $this->taxonomy = $app->make( TaxonomyController::class ); |
|
58 | + $this->translator = $app->make( TranslationController::class ); |
|
59 | + $this->trustalyze = $app->make( TrustalyzeController::class ); |
|
60 | + $this->welcome = $app->make( WelcomeController::class ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,68 +65,68 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function run() |
67 | 67 | { |
68 | - add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
69 | - add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
70 | - add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
71 | - add_action('admin_init', [$this->admin, 'runMigrations']); |
|
72 | - add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
73 | - add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
74 | - add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
75 | - add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
76 | - add_action('admin_init', [$this->app, 'setDefaults']); |
|
77 | - add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
78 | - add_action('init', [$this->blocks, 'registerBlocks']); |
|
79 | - add_action('admin_footer', [$this->console, 'logOnce']); |
|
80 | - add_action('wp_footer', [$this->console, 'logOnce']); |
|
81 | - add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
82 | - add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
83 | - add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
84 | - add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
85 | - add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
86 | - add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
87 | - add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
88 | - add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3); |
|
89 | - add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
90 | - add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
91 | - add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
92 | - add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
93 | - add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
94 | - add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
95 | - add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
96 | - add_action('init', [$this->main, 'registerPostType'], 8); |
|
97 | - add_action('init', [$this->main, 'registerShortcodes']); |
|
98 | - add_action('init', [$this->main, 'registerTaxonomy']); |
|
99 | - add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
100 | - add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
101 | - add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
102 | - add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
103 | - add_action('admin_notices', [$this->notices, 'filterAdminNotices']); |
|
104 | - add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
105 | - add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
106 | - add_action('wp_footer', [$this->public, 'renderSchema']); |
|
107 | - add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
108 | - add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
109 | - add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
110 | - add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
111 | - add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
112 | - add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
113 | - add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
114 | - add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
115 | - add_action('init', [$this->router, 'routePublicPostRequest']); |
|
116 | - add_action('admin_init', [$this->settings, 'registerSettings']); |
|
117 | - add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
118 | - add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
119 | - add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
120 | - add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
121 | - add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
122 | - add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
123 | - add_action('plugins_loaded', [$this->translator, 'addTranslationFilters']); |
|
124 | - add_action('admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels']); |
|
125 | - add_action('site-reviews/review/created', [$this->trustalyze, 'onCreated']); |
|
126 | - add_action('site-reviews/review/reverted', [$this->trustalyze, 'onReverted']); |
|
127 | - add_action('site-reviews/review/saved', [$this->trustalyze, 'onSaved']); |
|
128 | - add_action('updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3); |
|
129 | - add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
130 | - add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
68 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
69 | + add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
70 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
71 | + add_action( 'admin_init', [$this->admin, 'runMigrations'] ); |
|
72 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
73 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
74 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
75 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
76 | + add_action( 'admin_init', [$this->app, 'setDefaults'] ); |
|
77 | + add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
78 | + add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
79 | + add_action( 'admin_footer', [$this->console, 'logOnce'] ); |
|
80 | + add_action( 'wp_footer', [$this->console, 'logOnce'] ); |
|
81 | + add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
82 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
83 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
84 | + add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
85 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
86 | + add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
87 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
88 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3 ); |
|
89 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
90 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
91 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
92 | + add_action( 'manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
93 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
94 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
95 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
96 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
97 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
98 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
99 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
100 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
101 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
102 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
103 | + add_action( 'admin_notices', [$this->notices, 'filterAdminNotices'] ); |
|
104 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
105 | + add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
106 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
107 | + add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
108 | + add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
109 | + add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
110 | + add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
111 | + add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
112 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
113 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
114 | + add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
115 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
116 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
117 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
118 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
119 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
120 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
121 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
122 | + add_action( 'set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6 ); |
|
123 | + add_action( 'plugins_loaded', [$this->translator, 'addTranslationFilters'] ); |
|
124 | + add_action( 'admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels'] ); |
|
125 | + add_action( 'site-reviews/review/created', [$this->trustalyze, 'onCreated'] ); |
|
126 | + add_action( 'site-reviews/review/reverted', [$this->trustalyze, 'onReverted'] ); |
|
127 | + add_action( 'site-reviews/review/saved', [$this->trustalyze, 'onSaved'] ); |
|
128 | + add_action( 'updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3 ); |
|
129 | + add_action( 'activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2 ); |
|
130 | + add_action( 'admin_menu', [$this->welcome, 'registerPage'] ); |
|
131 | 131 | } |
132 | 132 | } |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | protected $trustalyze; |
27 | 27 | protected $welcome; |
28 | 28 | |
29 | - public function __construct(Application $app) |
|
29 | + public function __construct( Application $app ) |
|
30 | 30 | { |
31 | 31 | $this->app = $app; |
32 | - $this->admin = $app->make(AdminController::class); |
|
33 | - $this->basename = plugin_basename($app->file); |
|
34 | - $this->blocks = $app->make(BlocksController::class); |
|
35 | - $this->editor = $app->make(EditorController::class); |
|
36 | - $this->listtable = $app->make(ListTableController::class); |
|
37 | - $this->public = $app->make(PublicController::class); |
|
38 | - $this->translator = $app->make(TranslationController::class); |
|
39 | - $this->trustalyze = $app->make(TrustalyzeController::class); |
|
40 | - $this->welcome = $app->make(WelcomeController::class); |
|
32 | + $this->admin = $app->make( AdminController::class ); |
|
33 | + $this->basename = plugin_basename( $app->file ); |
|
34 | + $this->blocks = $app->make( BlocksController::class ); |
|
35 | + $this->editor = $app->make( EditorController::class ); |
|
36 | + $this->listtable = $app->make( ListTableController::class ); |
|
37 | + $this->public = $app->make( PublicController::class ); |
|
38 | + $this->translator = $app->make( TranslationController::class ); |
|
39 | + $this->trustalyze = $app->make( TrustalyzeController::class ); |
|
40 | + $this->welcome = $app->make( WelcomeController::class ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -45,34 +45,34 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function run() |
47 | 47 | { |
48 | - add_filter('map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2); |
|
49 | - add_filter('mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15); |
|
50 | - add_filter('plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks']); |
|
51 | - add_filter('dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems']); |
|
52 | - add_filter('block_categories', [$this->blocks, 'filterBlockCategories']); |
|
53 | - add_filter('classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2); |
|
54 | - add_filter('use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2); |
|
55 | - add_filter('wp_editor_settings', [$this->editor, 'filterEditorSettings']); |
|
56 | - add_filter('the_editor', [$this->editor, 'filterEditorTextarea']); |
|
57 | - add_filter('is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3); |
|
58 | - add_filter('post_updated_messages', [$this->editor, 'filterUpdateMessages']); |
|
59 | - add_filter('manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType']); |
|
60 | - add_filter('post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2); |
|
61 | - add_filter('default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2); |
|
62 | - add_filter('post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2); |
|
63 | - add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns']); |
|
64 | - add_filter('script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2); |
|
65 | - add_filter('site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11); |
|
66 | - add_filter('site-reviews/render/view', [$this->public, 'filterRenderView']); |
|
67 | - add_filter('bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2); |
|
68 | - add_filter('display_post_states', [$this->translator, 'filterPostStates'], 10, 2); |
|
69 | - add_filter('site-reviews/gettext/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
70 | - add_filter('site-reviews/gettext_with_context/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
71 | - add_filter('site-reviews/ngettext/default', [$this->translator, 'filterPostStatusText'], 10, 4); |
|
72 | - add_filter('site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback']); |
|
73 | - add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3); |
|
74 | - add_filter('plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9); |
|
75 | - add_filter('admin_title', [$this->welcome, 'filterAdminTitle']); |
|
76 | - add_filter('admin_footer_text', [$this->welcome, 'filterFooterText']); |
|
48 | + add_filter( 'map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2 ); |
|
49 | + add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 ); |
|
50 | + add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] ); |
|
51 | + add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] ); |
|
52 | + add_filter( 'block_categories', [$this->blocks, 'filterBlockCategories'] ); |
|
53 | + add_filter( 'classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2 ); |
|
54 | + add_filter( 'use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2 ); |
|
55 | + add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] ); |
|
56 | + add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] ); |
|
57 | + add_filter( 'is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3 ); |
|
58 | + add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] ); |
|
59 | + add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] ); |
|
60 | + add_filter( 'post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2 ); |
|
61 | + add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 ); |
|
62 | + add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 ); |
|
63 | + add_filter( 'manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns'] ); |
|
64 | + add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2 ); |
|
65 | + add_filter( 'site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11 ); |
|
66 | + add_filter( 'site-reviews/render/view', [$this->public, 'filterRenderView'] ); |
|
67 | + add_filter( 'bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2 ); |
|
68 | + add_filter( 'display_post_states', [$this->translator, 'filterPostStates'], 10, 2 ); |
|
69 | + add_filter( 'site-reviews/gettext/default', [$this->translator, 'filterPostStatusLabels'], 10, 2 ); |
|
70 | + add_filter( 'site-reviews/gettext_with_context/default', [$this->translator, 'filterPostStatusLabels'], 10, 2 ); |
|
71 | + add_filter( 'site-reviews/ngettext/default', [$this->translator, 'filterPostStatusText'], 10, 4 ); |
|
72 | + add_filter( 'site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback'] ); |
|
73 | + add_filter( 'site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3 ); |
|
74 | + add_filter( 'plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9 ); |
|
75 | + add_filter( 'admin_title', [$this->welcome, 'filterAdminTitle'] ); |
|
76 | + add_filter( 'admin_footer_text', [$this->welcome, 'filterFooterText'] ); |
|
77 | 77 | } |
78 | 78 | } |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | * @param int $postId |
15 | 15 | * @return void|string |
16 | 16 | */ |
17 | - public function buildColumnAssignedTo($postId) |
|
17 | + public function buildColumnAssignedTo( $postId ) |
|
18 | 18 | { |
19 | - $assignedPost = glsr(Database::class)->getAssignedToPost($postId); |
|
20 | - if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) { |
|
21 | - return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [ |
|
22 | - 'href' => (string) get_the_permalink($assignedPost->ID), |
|
23 | - ]); |
|
19 | + $assignedPost = glsr( Database::class )->getAssignedToPost( $postId ); |
|
20 | + if( $assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status ) { |
|
21 | + return glsr( Builder::class )->a( get_the_title( $assignedPost->ID ), [ |
|
22 | + 'href' => (string)get_the_permalink( $assignedPost->ID ), |
|
23 | + ] ); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * @param int $postId |
29 | 29 | * @return void|string |
30 | 30 | */ |
31 | - public function buildColumnEmail($postId) |
|
31 | + public function buildColumnEmail( $postId ) |
|
32 | 32 | { |
33 | - if ($email = glsr(Database::class)->get($postId, 'email')) { |
|
33 | + if( $email = glsr( Database::class )->get( $postId, 'email' ) ) { |
|
34 | 34 | return $email; |
35 | 35 | } |
36 | 36 | } |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | * @param int $postId |
40 | 40 | * @return void|string |
41 | 41 | */ |
42 | - public function buildColumnIpAddress($postId) |
|
42 | + public function buildColumnIpAddress( $postId ) |
|
43 | 43 | { |
44 | - if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) { |
|
44 | + if( $ipAddress = glsr( Database::class )->get( $postId, 'ip_address' ) ) { |
|
45 | 45 | return $ipAddress; |
46 | 46 | } |
47 | 47 | } |
@@ -50,41 +50,41 @@ discard block |
||
50 | 50 | * @param int $postId |
51 | 51 | * @return string |
52 | 52 | */ |
53 | - public function buildColumnPinned($postId) |
|
53 | + public function buildColumnPinned( $postId ) |
|
54 | 54 | { |
55 | - $pinned = glsr(Database::class)->get($postId, 'pinned') |
|
55 | + $pinned = glsr( Database::class )->get( $postId, 'pinned' ) |
|
56 | 56 | ? 'pinned ' |
57 | 57 | : ''; |
58 | - if (glsr()->can('edit_others_posts')) { |
|
59 | - $pinned.= 'pin-review '; |
|
58 | + if( glsr()->can( 'edit_others_posts' ) ) { |
|
59 | + $pinned .= 'pin-review '; |
|
60 | 60 | } |
61 | - return glsr(Builder::class)->i([ |
|
61 | + return glsr( Builder::class )->i( [ |
|
62 | 62 | 'class' => $pinned.'dashicons dashicons-sticky', |
63 | 63 | 'data-id' => $postId, |
64 | - ]); |
|
64 | + ] ); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @param int $postId |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - public function buildColumnResponse($postId) |
|
71 | + public function buildColumnResponse( $postId ) |
|
72 | 72 | { |
73 | - return glsr(Database::class)->get($postId, 'response') |
|
74 | - ? __('Yes', 'site-reviews') |
|
75 | - : __('No', 'site-reviews'); |
|
73 | + return glsr( Database::class )->get( $postId, 'response' ) |
|
74 | + ? __( 'Yes', 'site-reviews' ) |
|
75 | + : __( 'No', 'site-reviews' ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @param int $postId |
80 | 80 | * @return string |
81 | 81 | */ |
82 | - public function buildColumnReviewer($postId) |
|
82 | + public function buildColumnReviewer( $postId ) |
|
83 | 83 | { |
84 | - $author = strval(glsr(Database::class)->get($postId, 'author')); |
|
85 | - $userId = Helper::castToInt(get_post($postId)->post_author); |
|
84 | + $author = strval( glsr( Database::class )->get( $postId, 'author' ) ); |
|
85 | + $userId = Helper::castToInt( get_post( $postId )->post_author ); |
|
86 | 86 | return !empty($userId) |
87 | - ? glsr(Builder::class)->a($author, ['href' => get_author_posts_url($userId)]) |
|
87 | + ? glsr( Builder::class )->a( $author, ['href' => get_author_posts_url( $userId )] ) |
|
88 | 88 | : $author; |
89 | 89 | } |
90 | 90 | |
@@ -93,39 +93,39 @@ discard block |
||
93 | 93 | * @param int|null $rating |
94 | 94 | * @return string |
95 | 95 | */ |
96 | - public function buildColumnRating($postId) |
|
96 | + public function buildColumnRating( $postId ) |
|
97 | 97 | { |
98 | - return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating'))); |
|
98 | + return glsr_star_rating( intval( glsr( Database::class )->get( $postId, 'rating' ) ) ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
102 | 102 | * @param int $postId |
103 | 103 | * @return string |
104 | 104 | */ |
105 | - public function buildColumnReviewType($postId) |
|
105 | + public function buildColumnReviewType( $postId ) |
|
106 | 106 | { |
107 | - $type = glsr(Database::class)->get($postId, 'review_type'); |
|
108 | - return array_key_exists($type, glsr()->reviewTypes) |
|
107 | + $type = glsr( Database::class )->get( $postId, 'review_type' ); |
|
108 | + return array_key_exists( $type, glsr()->reviewTypes ) |
|
109 | 109 | ? glsr()->reviewTypes[$type] |
110 | - : __('Unsupported Type', 'site-reviews'); |
|
110 | + : __( 'Unsupported Type', 'site-reviews' ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
114 | 114 | * @param string $postType |
115 | 115 | * @return void |
116 | 116 | */ |
117 | - public function renderFilters($postType) |
|
117 | + public function renderFilters( $postType ) |
|
118 | 118 | { |
119 | - if (Application::POST_TYPE !== $postType) { |
|
119 | + if( Application::POST_TYPE !== $postType ) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | - if (!($status = filter_input(INPUT_GET, 'post_status'))) { |
|
122 | + if( !($status = filter_input( INPUT_GET, 'post_status' )) ) { |
|
123 | 123 | $status = 'publish'; |
124 | 124 | } |
125 | - $ratings = glsr(Database::class)->getReviewsMeta('rating', $status); |
|
126 | - $types = glsr(Database::class)->getReviewsMeta('review_type', $status); |
|
127 | - $this->renderFilterRatings($ratings); |
|
128 | - $this->renderFilterTypes($types); |
|
125 | + $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status ); |
|
126 | + $types = glsr( Database::class )->getReviewsMeta( 'review_type', $status ); |
|
127 | + $this->renderFilterRatings( $ratings ); |
|
128 | + $this->renderFilterTypes( $types ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -133,14 +133,14 @@ discard block |
||
133 | 133 | * @param int $postId |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function renderValues($column, $postId) |
|
136 | + public function renderValues( $column, $postId ) |
|
137 | 137 | { |
138 | - $method = Helper::buildMethodName($column, 'buildColumn'); |
|
139 | - $value = method_exists($this, $method) |
|
140 | - ? call_user_func([$this, $method], $postId) |
|
138 | + $method = Helper::buildMethodName( $column, 'buildColumn' ); |
|
139 | + $value = method_exists( $this, $method ) |
|
140 | + ? call_user_func( [$this, $method], $postId ) |
|
141 | 141 | : ''; |
142 | - $value = apply_filters('site-reviews/columns/'.$column, $value, $postId); |
|
143 | - if (0 !== $value && empty($value)) { |
|
142 | + $value = apply_filters( 'site-reviews/columns/'.$column, $value, $postId ); |
|
143 | + if( 0 !== $value && empty($value) ) { |
|
144 | 144 | $value = '—'; |
145 | 145 | } |
146 | 146 | echo $value; |
@@ -150,44 +150,44 @@ discard block |
||
150 | 150 | * @param array $ratings |
151 | 151 | * @return void |
152 | 152 | */ |
153 | - protected function renderFilterRatings($ratings) |
|
153 | + protected function renderFilterRatings( $ratings ) |
|
154 | 154 | { |
155 | - if (empty($ratings)) { |
|
155 | + if( empty($ratings) ) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | - $ratings = array_flip(array_reverse($ratings)); |
|
159 | - array_walk($ratings, function (&$value, $key) { |
|
160 | - $label = _n('%s star', '%s stars', $key, 'site-reviews'); |
|
161 | - $value = sprintf($label, $key); |
|
158 | + $ratings = array_flip( array_reverse( $ratings ) ); |
|
159 | + array_walk( $ratings, function( &$value, $key ) { |
|
160 | + $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
|
161 | + $value = sprintf( $label, $key ); |
|
162 | 162 | }); |
163 | - echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [ |
|
163 | + echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [ |
|
164 | 164 | 'class' => 'screen-reader-text', |
165 | 165 | 'for' => 'rating', |
166 | - ]); |
|
167 | - echo glsr(Builder::class)->select([ |
|
166 | + ] ); |
|
167 | + echo glsr( Builder::class )->select( [ |
|
168 | 168 | 'name' => 'rating', |
169 | - 'options' => ['' => __('All ratings', 'site-reviews')] + $ratings, |
|
170 | - 'value' => filter_input(INPUT_GET, 'rating'), |
|
171 | - ]); |
|
169 | + 'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings, |
|
170 | + 'value' => filter_input( INPUT_GET, 'rating' ), |
|
171 | + ] ); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
175 | 175 | * @param array $types |
176 | 176 | * @return void |
177 | 177 | */ |
178 | - protected function renderFilterTypes($types) |
|
178 | + protected function renderFilterTypes( $types ) |
|
179 | 179 | { |
180 | - if (count(glsr()->reviewTypes) < 2) { |
|
180 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
181 | 181 | return; |
182 | 182 | } |
183 | - echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [ |
|
183 | + echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
|
184 | 184 | 'class' => 'screen-reader-text', |
185 | 185 | 'for' => 'review_type', |
186 | - ]); |
|
187 | - echo glsr(Builder::class)->select([ |
|
186 | + ] ); |
|
187 | + echo glsr( Builder::class )->select( [ |
|
188 | 188 | 'name' => 'review_type', |
189 | - 'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes, |
|
190 | - 'value' => filter_input(INPUT_GET, 'review_type'), |
|
191 | - ]); |
|
189 | + 'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes, |
|
190 | + 'value' => filter_input( INPUT_GET, 'review_type' ), |
|
191 | + ] ); |
|
192 | 192 | } |
193 | 193 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | 5 | /* |
6 | 6 | * Alternate method of using the functions without having to use `function_exists()` |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @param mixed ... |
9 | 9 | * @return mixed |
10 | 10 | */ |
11 | -add_filter('plugins_loaded', function () { |
|
11 | +add_filter( 'plugins_loaded', function() { |
|
12 | 12 | $hooks = array( |
13 | 13 | 'glsr_calculate_ratings' => 1, |
14 | 14 | 'glsr_create_review' => 2, |
@@ -22,23 +22,23 @@ discard block |
||
22 | 22 | 'glsr_log' => 3, |
23 | 23 | 'glsr_star_rating' => 2, |
24 | 24 | ); |
25 | - foreach ($hooks as $function => $acceptedArgs) { |
|
26 | - add_filter($function, function () use ($function) { |
|
25 | + foreach( $hooks as $function => $acceptedArgs ) { |
|
26 | + add_filter( $function, function() use ($function) { |
|
27 | 27 | $args = func_get_args(); |
28 | - array_shift($args); // remove the fallback value |
|
29 | - return call_user_func_array($function, $args); |
|
30 | - }, 10, $acceptedArgs); |
|
28 | + array_shift( $args ); // remove the fallback value |
|
29 | + return call_user_func_array( $function, $args ); |
|
30 | + }, 10, $acceptedArgs ); |
|
31 | 31 | } |
32 | 32 | }); |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @return mixed |
36 | 36 | */ |
37 | -function glsr($alias = null) |
|
37 | +function glsr( $alias = null ) |
|
38 | 38 | { |
39 | 39 | $app = \GeminiLabs\SiteReviews\Application::load(); |
40 | - return !is_null($alias) |
|
41 | - ? $app->make($alias) |
|
40 | + return !is_null( $alias ) |
|
41 | + ? $app->make( $alias ) |
|
42 | 42 | : $app; |
43 | 43 | } |
44 | 44 | |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | * @param $column string |
48 | 48 | * @return array |
49 | 49 | */ |
50 | -function glsr_array_column(array $array, $column) |
|
50 | +function glsr_array_column( array $array, $column ) |
|
51 | 51 | { |
52 | 52 | $result = array(); |
53 | - foreach ($array as $subarray) { |
|
54 | - $subarray = (array) $subarray; |
|
55 | - if (!isset($subarray[$column])) { |
|
53 | + foreach( $array as $subarray ) { |
|
54 | + $subarray = (array)$subarray; |
|
55 | + if( !isset($subarray[$column]) ) { |
|
56 | 56 | continue; |
57 | 57 | } |
58 | 58 | $result[] = $subarray[$column]; |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | */ |
66 | 66 | function glsr_calculate_ratings() |
67 | 67 | { |
68 | - glsr('Database\CountsManager')->updateAll(); |
|
69 | - glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
68 | + glsr( 'Database\CountsManager' )->updateAll(); |
|
69 | + glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @return \GeminiLabs\SiteReviews\Review|false |
74 | 74 | */ |
75 | -function glsr_create_review($reviewValues = array()) |
|
75 | +function glsr_create_review( $reviewValues = array() ) |
|
76 | 76 | { |
77 | 77 | $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
78 | - \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($reviewValues) |
|
78 | + \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray( $reviewValues ) |
|
79 | 79 | ); |
80 | - return glsr('Database\ReviewManager')->create($review); |
|
80 | + return glsr( 'Database\ReviewManager' )->create( $review ); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function glsr_current_screen() |
87 | 87 | { |
88 | - if (function_exists('get_current_screen')) { |
|
88 | + if( function_exists( 'get_current_screen' ) ) { |
|
89 | 89 | $screen = get_current_screen(); |
90 | 90 | } |
91 | 91 | return empty($screen) |
92 | - ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
92 | + ? (object)array_fill_keys( ['base', 'id', 'post_type'], null ) |
|
93 | 93 | : $screen; |
94 | 94 | } |
95 | 95 | |
@@ -97,15 +97,15 @@ discard block |
||
97 | 97 | * @param mixed ...$vars |
98 | 98 | * @return void |
99 | 99 | */ |
100 | -function glsr_debug(...$vars) |
|
100 | +function glsr_debug( ...$vars ) |
|
101 | 101 | { |
102 | - if (1 == count($vars)) { |
|
103 | - $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
104 | - printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
102 | + if( 1 == count( $vars ) ) { |
|
103 | + $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
|
104 | + printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
|
105 | 105 | } else { |
106 | 106 | echo '<div class="glsr-debug-group">'; |
107 | - foreach ($vars as $var) { |
|
108 | - glsr_debug($var); |
|
107 | + foreach( $vars as $var ) { |
|
108 | + glsr_debug( $var ); |
|
109 | 109 | } |
110 | 110 | echo '</div>'; |
111 | 111 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | * @param mixed $fallback |
118 | 118 | * @return mixed |
119 | 119 | */ |
120 | -function glsr_get($array, $path = '', $fallback = '') |
|
120 | +function glsr_get( $array, $path = '', $fallback = '' ) |
|
121 | 121 | { |
122 | - return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback); |
|
122 | + return \GeminiLabs\SiteReviews\Helpers\Arr::get( $array, $path, $fallback ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @param string $cast |
129 | 129 | * @return string|array |
130 | 130 | */ |
131 | -function glsr_get_option($path = '', $fallback = '', $cast = '') |
|
131 | +function glsr_get_option( $path = '', $fallback = '', $cast = '' ) |
|
132 | 132 | { |
133 | - return is_string($path) |
|
134 | - ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast) |
|
133 | + return is_string( $path ) |
|
134 | + ? glsr( 'Database\OptionManager' )->get( \GeminiLabs\SiteReviews\Helpers\Str::prefix( 'settings.', $path ), $fallback, $cast ) |
|
135 | 135 | : $fallback; |
136 | 136 | } |
137 | 137 | |
@@ -140,22 +140,22 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function glsr_get_options() |
142 | 142 | { |
143 | - return glsr('Database\OptionManager')->get('settings'); |
|
143 | + return glsr( 'Database\OptionManager' )->get( 'settings' ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | 147 | * @return object |
148 | 148 | */ |
149 | -function glsr_get_rating($args = array()) |
|
149 | +function glsr_get_rating( $args = array() ) |
|
150 | 150 | { |
151 | - $args = \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args); |
|
152 | - $counts = glsr('Database\ReviewManager')->getRatingCounts($args); |
|
153 | - return (object) array( |
|
154 | - 'average' => glsr('Modules\Rating')->getAverage($counts), |
|
155 | - 'maximum' => glsr()->constant('MAX_RATING', \GeminiLabs\SiteReviews\Modules\Rating::class), |
|
156 | - 'minimum' => glsr()->constant('MIN_RATING', \GeminiLabs\SiteReviews\Modules\Rating::class), |
|
151 | + $args = \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray( $args ); |
|
152 | + $counts = glsr( 'Database\ReviewManager' )->getRatingCounts( $args ); |
|
153 | + return (object)array( |
|
154 | + 'average' => glsr( 'Modules\Rating' )->getAverage( $counts ), |
|
155 | + 'maximum' => glsr()->constant( 'MAX_RATING', \GeminiLabs\SiteReviews\Modules\Rating::class ), |
|
156 | + 'minimum' => glsr()->constant( 'MIN_RATING', \GeminiLabs\SiteReviews\Modules\Rating::class ), |
|
157 | 157 | 'ratings' => $counts, |
158 | - 'reviews' => array_sum($counts), |
|
158 | + 'reviews' => array_sum( $counts ), |
|
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
@@ -163,23 +163,23 @@ discard block |
||
163 | 163 | * @param \WP_Post|int $post |
164 | 164 | * @return \GeminiLabs\SiteReviews\Review |
165 | 165 | */ |
166 | -function glsr_get_review($post) |
|
166 | +function glsr_get_review( $post ) |
|
167 | 167 | { |
168 | - if (is_numeric($post)) { |
|
169 | - $post = get_post($post); |
|
168 | + if( is_numeric( $post ) ) { |
|
169 | + $post = get_post( $post ); |
|
170 | 170 | } |
171 | - if (!($post instanceof WP_Post)) { |
|
172 | - $post = new WP_Post((object) []); |
|
171 | + if( !($post instanceof WP_Post) ) { |
|
172 | + $post = new WP_Post( (object)[] ); |
|
173 | 173 | } |
174 | - return glsr('Database\ReviewManager')->single($post); |
|
174 | + return glsr( 'Database\ReviewManager' )->single( $post ); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | 178 | * @return array |
179 | 179 | */ |
180 | -function glsr_get_reviews($args = array()) |
|
180 | +function glsr_get_reviews( $args = array() ) |
|
181 | 181 | { |
182 | - return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args)); |
|
182 | + return glsr( 'Database\ReviewManager' )->get( \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray( $args ) ); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | function glsr_log() |
189 | 189 | { |
190 | 190 | $args = func_get_args(); |
191 | - $console = glsr('Modules\Console'); |
|
192 | - if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) { |
|
193 | - return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', [])); |
|
191 | + $console = glsr( 'Modules\Console' ); |
|
192 | + if( $value = \GeminiLabs\SiteReviews\Helpers\Arr::get( $args, '0' ) ) { |
|
193 | + return $console->debug( $value, \GeminiLabs\SiteReviews\Helpers\Arr::get( $args, '1', [] ) ); |
|
194 | 194 | } |
195 | 195 | return $console; |
196 | 196 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | /** |
199 | 199 | * @return string |
200 | 200 | */ |
201 | -function glsr_star_rating($rating) |
|
201 | +function glsr_star_rating( $rating ) |
|
202 | 202 | { |
203 | - return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
203 | + return glsr( 'Modules\Html\Partial' )->build( 'star-rating', ['rating' => $rating] ); |
|
204 | 204 | } |