@@ -1,37 +1,37 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <form method="post" class="glsr-form-sync glsr-status"> |
4 | - <?php $selected = key($services); ?> |
|
4 | + <?php $selected = key( $services ); ?> |
|
5 | 5 | <table class="wp-list-table widefat fixed striped"> |
6 | 6 | <thead> |
7 | 7 | <tr> |
8 | 8 | <td class="check-column glsr-radio-column"><span class="dashicons-before dashicons-update"></span></td> |
9 | - <th scope="col" class="column-primary"><?= __('Service', 'site-reviews'); ?></th> |
|
10 | - <th scope="col" class="column-total_fetched"><?= __('Reviews', 'site-reviews'); ?></th> |
|
11 | - <th scope="col" class="column-last_sync"><?= __('Last Sync', 'site-reviews'); ?></th> |
|
9 | + <th scope="col" class="column-primary"><?= __( 'Service', 'site-reviews' ); ?></th> |
|
10 | + <th scope="col" class="column-total_fetched"><?= __( 'Reviews', 'site-reviews' ); ?></th> |
|
11 | + <th scope="col" class="column-last_sync"><?= __( 'Last Sync', 'site-reviews' ); ?></th> |
|
12 | 12 | </tr> |
13 | 13 | </thead> |
14 | 14 | <tbody> |
15 | - <?php foreach ($services as $slug => $details) : ?> |
|
15 | + <?php foreach( $services as $slug => $details ) : ?> |
|
16 | 16 | <tr class="service-<?= $slug; ?>"> |
17 | 17 | <th scope="row" class="check-column"> |
18 | - <input type="radio" name="{{ id }}[service]" value="<?= $slug; ?>" <?php checked($slug, $selected); ?>> |
|
18 | + <input type="radio" name="{{ id }}[service]" value="<?= $slug; ?>" <?php checked( $slug, $selected ); ?>> |
|
19 | 19 | </th> |
20 | 20 | <td class="column-primary has-row-actions"> |
21 | 21 | <strong><?= $details['name']; ?></strong> |
22 | 22 | <div class="row-actions"> |
23 | - <span><a href="{{ base_url }}&page=settings#!addons"><?= __('Settings', 'site-reviews'); ?></a> | </span> |
|
24 | - <span><a href="{{ base_url }}&page=settings#!licenses"><?= __('License', 'site-reviews'); ?></a> | </span> |
|
25 | - <span><a href="{{ base_url }}&page=documentation#!addons"><?= __('Documentation', 'site-reviews'); ?></a></span> |
|
23 | + <span><a href="{{ base_url }}&page=settings#!addons"><?= __( 'Settings', 'site-reviews' ); ?></a> | </span> |
|
24 | + <span><a href="{{ base_url }}&page=settings#!licenses"><?= __( 'License', 'site-reviews' ); ?></a> | </span> |
|
25 | + <span><a href="{{ base_url }}&page=documentation#!addons"><?= __( 'Documentation', 'site-reviews' ); ?></a></span> |
|
26 | 26 | </div> |
27 | 27 | <button type="button" class="toggle-row"> |
28 | - <span class="screen-reader-text"><?= __('Show more details', 'site-reviews'); ?></span> |
|
28 | + <span class="screen-reader-text"><?= __( 'Show more details', 'site-reviews' ); ?></span> |
|
29 | 29 | </button> |
30 | 30 | </td> |
31 | - <td class="column-total_fetched" data-colname="<?= __('Reviews', 'site-reviews'); ?>"> |
|
31 | + <td class="column-total_fetched" data-colname="<?= __( 'Reviews', 'site-reviews' ); ?>"> |
|
32 | 32 | <a href="<?= $details['reviews_url']; ?>"><?= $details['reviews_count']; ?></a> |
33 | 33 | </td> |
34 | - <td class="column-last_sync" data-colname="<?= __('Last Sync', 'site-reviews'); ?>"> |
|
34 | + <td class="column-last_sync" data-colname="<?= __( 'Last Sync', 'site-reviews' ); ?>"> |
|
35 | 35 | <?= $details['last_sync']; ?> |
36 | 36 | </td> |
37 | 37 | </tr> |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | <tfoot> |
41 | 41 | <tr> |
42 | 42 | <td colspan="4" class="no-items" style="display:table-cell!important;"> |
43 | - <div class="glsr-progress" data-active-text="<?= __('Please wait...', 'site-reviews'); ?>"> |
|
43 | + <div class="glsr-progress" data-active-text="<?= __( 'Please wait...', 'site-reviews' ); ?>"> |
|
44 | 44 | <div class="glsr-progress-bar" style="width: 0%;"> |
45 | - <span class="glsr-progress-status"><?= __('Inactive', 'site-reviews'); ?></span> |
|
45 | + <span class="glsr-progress-status"><?= __( 'Inactive', 'site-reviews' ); ?></span> |
|
46 | 46 | </div> |
47 | 47 | <div class="glsr-progress-background"> |
48 | - <span class="glsr-progress-status"><?= __('Inactive', 'site-reviews'); ?></span> |
|
48 | + <span class="glsr-progress-status"><?= __( 'Inactive', 'site-reviews' ); ?></span> |
|
49 | 49 | </div> |
50 | 50 | </div> |
51 | 51 | </td> |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | </table> |
55 | 55 | <div class="tablenav bottom"> |
56 | 56 | <button type="submit" class="glsr-button button" id="sync-reviews"> |
57 | - <span data-loading="<?= __('Syncing...', 'site-reviews'); ?>"><?= __('Sync Reviews', 'site-reviews'); ?></span> |
|
57 | + <span data-loading="<?= __( 'Syncing...', 'site-reviews' ); ?>"><?= __( 'Sync Reviews', 'site-reviews' ); ?></span> |
|
58 | 58 | </button> |
59 | 59 | </div> |
60 | 60 | </form> |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function approve() |
22 | 22 | { |
23 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
23 | + if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | - check_admin_referer('approve-review_'.($postId = $this->getPostId())); |
|
27 | - wp_update_post([ |
|
26 | + check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) ); |
|
27 | + wp_update_post( [ |
|
28 | 28 | 'ID' => $postId, |
29 | 29 | 'post_status' => 'publish', |
30 | - ]); |
|
31 | - wp_safe_redirect(wp_get_referer()); |
|
30 | + ] ); |
|
31 | + wp_safe_redirect( wp_get_referer() ); |
|
32 | 32 | exit; |
33 | 33 | } |
34 | 34 | |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | * @return array |
38 | 38 | * @filter bulk_post_updated_messages |
39 | 39 | */ |
40 | - public function filterBulkUpdateMessages($messages, array $counts) |
|
40 | + public function filterBulkUpdateMessages( $messages, array $counts ) |
|
41 | 41 | { |
42 | - $messages = Arr::consolidateArray($messages); |
|
42 | + $messages = Arr::consolidateArray( $messages ); |
|
43 | 43 | $messages[Application::POST_TYPE] = [ |
44 | - 'updated' => _n('%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews'), |
|
45 | - 'locked' => _n('%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews'), |
|
46 | - 'deleted' => _n('%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews'), |
|
47 | - 'trashed' => _n('%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews'), |
|
48 | - 'untrashed' => _n('%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews'), |
|
44 | + 'updated' => _n( '%s review updated.', '%s reviews updated.', $counts['updated'], 'site-reviews' ), |
|
45 | + 'locked' => _n( '%s review not updated, somebody is editing it.', '%s reviews not updated, somebody is editing them.', $counts['locked'], 'site-reviews' ), |
|
46 | + 'deleted' => _n( '%s review permanently deleted.', '%s reviews permanently deleted.', $counts['deleted'], 'site-reviews' ), |
|
47 | + 'trashed' => _n( '%s review moved to the Trash.', '%s reviews moved to the Trash.', $counts['trashed'], 'site-reviews' ), |
|
48 | + 'untrashed' => _n( '%s review restored from the Trash.', '%s reviews restored from the Trash.', $counts['untrashed'], 'site-reviews' ), |
|
49 | 49 | ]; |
50 | 50 | return $messages; |
51 | 51 | } |
@@ -55,20 +55,20 @@ discard block |
||
55 | 55 | * @return array |
56 | 56 | * @filter manage_.Application::POST_TYPE._posts_columns |
57 | 57 | */ |
58 | - public function filterColumnsForPostType($columns) |
|
58 | + public function filterColumnsForPostType( $columns ) |
|
59 | 59 | { |
60 | - $columns = Arr::consolidateArray($columns); |
|
60 | + $columns = Arr::consolidateArray( $columns ); |
|
61 | 61 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
62 | - foreach ($postTypeColumns as $key => &$value) { |
|
63 | - if (!array_key_exists($key, $columns) || !empty($value)) { |
|
62 | + foreach( $postTypeColumns as $key => &$value ) { |
|
63 | + if( !array_key_exists( $key, $columns ) || !empty($value) ) { |
|
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | $value = $columns[$key]; |
67 | 67 | } |
68 | - if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) { |
|
68 | + if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) { |
|
69 | 69 | unset($postTypeColumns['review_type']); |
70 | 70 | } |
71 | - return array_filter($postTypeColumns, 'strlen'); |
|
71 | + return array_filter( $postTypeColumns, 'strlen' ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | * @return string |
78 | 78 | * @filter post_date_column_status |
79 | 79 | */ |
80 | - public function filterDateColumnStatus($status, $post) |
|
80 | + public function filterDateColumnStatus( $status, $post ) |
|
81 | 81 | { |
82 | - if (Application::POST_TYPE == Arr::get($post, 'post_type')) { |
|
83 | - $status = __('Submitted', 'site-reviews'); |
|
82 | + if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) ) { |
|
83 | + $status = __( 'Submitted', 'site-reviews' ); |
|
84 | 84 | } |
85 | 85 | return $status; |
86 | 86 | } |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @return array |
92 | 92 | * @filter default_hidden_columns |
93 | 93 | */ |
94 | - public function filterDefaultHiddenColumns($hidden, $screen) |
|
94 | + public function filterDefaultHiddenColumns( $hidden, $screen ) |
|
95 | 95 | { |
96 | - if (Arr::get($screen, 'id') == 'edit-'.Application::POST_TYPE) { |
|
97 | - $hidden = Arr::consolidateArray($hidden); |
|
98 | - $hidden = array_unique(array_merge($hidden, [ |
|
96 | + if( Arr::get( $screen, 'id' ) == 'edit-'.Application::POST_TYPE ) { |
|
97 | + $hidden = Arr::consolidateArray( $hidden ); |
|
98 | + $hidden = array_unique( array_merge( $hidden, [ |
|
99 | 99 | 'email', 'ip_address', 'response', 'reviewer', |
100 | - ])); |
|
100 | + ] ) ); |
|
101 | 101 | } |
102 | 102 | return $hidden; |
103 | 103 | } |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | * @return array |
109 | 109 | * @filter display_post_states |
110 | 110 | */ |
111 | - public function filterPostStates($postStates, $post) |
|
111 | + public function filterPostStates( $postStates, $post ) |
|
112 | 112 | { |
113 | - $postStates = Arr::consolidateArray($postStates); |
|
114 | - if (Application::POST_TYPE == Arr::get($post, 'post_type') && array_key_exists('pending', $postStates)) { |
|
115 | - $postStates['pending'] = __('Unapproved', 'site-reviews'); |
|
113 | + $postStates = Arr::consolidateArray( $postStates ); |
|
114 | + if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) && array_key_exists( 'pending', $postStates ) ) { |
|
115 | + $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
|
116 | 116 | } |
117 | 117 | return $postStates; |
118 | 118 | } |
@@ -123,28 +123,28 @@ discard block |
||
123 | 123 | * @return array |
124 | 124 | * @filter post_row_actions |
125 | 125 | */ |
126 | - public function filterRowActions($actions, $post) |
|
126 | + public function filterRowActions( $actions, $post ) |
|
127 | 127 | { |
128 | - if (Application::POST_TYPE != Arr::get($post, 'post_type') || 'trash' == $post->post_status) { |
|
128 | + if( Application::POST_TYPE != Arr::get( $post, 'post_type' ) || 'trash' == $post->post_status ) { |
|
129 | 129 | return $actions; |
130 | 130 | } |
131 | 131 | unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
132 | 132 | $rowActions = [ |
133 | - 'approve' => esc_attr__('Approve', 'site-reviews'), |
|
134 | - 'unapprove' => esc_attr__('Unapprove', 'site-reviews'), |
|
133 | + 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
|
134 | + 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
|
135 | 135 | ]; |
136 | 136 | $newActions = []; |
137 | - foreach ($rowActions as $key => $text) { |
|
138 | - $newActions[$key] = glsr(Builder::class)->a($text, [ |
|
139 | - 'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text), |
|
137 | + foreach( $rowActions as $key => $text ) { |
|
138 | + $newActions[$key] = glsr( Builder::class )->a( $text, [ |
|
139 | + 'aria-label' => sprintf( esc_attr_x( '%s this review', 'Approve the review', 'site-reviews' ), $text ), |
|
140 | 140 | 'class' => 'glsr-change-status', |
141 | 141 | 'href' => wp_nonce_url( |
142 | - admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID), |
|
142 | + admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ), |
|
143 | 143 | $key.'-review_'.$post->ID |
144 | 144 | ), |
145 | - ]); |
|
145 | + ] ); |
|
146 | 146 | } |
147 | - return $newActions + Arr::consolidateArray($actions); |
|
147 | + return $newActions + Arr::consolidateArray( $actions ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | * @return array |
153 | 153 | * @filter manage_edit-.Application::POST_TYPE._sortable_columns |
154 | 154 | */ |
155 | - public function filterSortableColumns($columns) |
|
155 | + public function filterSortableColumns( $columns ) |
|
156 | 156 | { |
157 | - $columns = Arr::consolidateArray($columns); |
|
157 | + $columns = Arr::consolidateArray( $columns ); |
|
158 | 158 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
159 | 159 | unset($postTypeColumns['cb']); |
160 | - foreach ($postTypeColumns as $key => $value) { |
|
161 | - if (Str::startsWith('taxonomy', $key)) { |
|
160 | + foreach( $postTypeColumns as $key => $value ) { |
|
161 | + if( Str::startsWith( 'taxonomy', $key ) ) { |
|
162 | 162 | continue; |
163 | 163 | } |
164 | 164 | $columns[$key] = $key; |
@@ -176,22 +176,22 @@ discard block |
||
176 | 176 | * @return string |
177 | 177 | * @filter ngettext |
178 | 178 | */ |
179 | - public function filterStatusText($translation, $single, $plural, $number, $domain) |
|
179 | + public function filterStatusText( $translation, $single, $plural, $number, $domain ) |
|
180 | 180 | { |
181 | - if ($this->canModifyTranslation($domain)) { |
|
181 | + if( $this->canModifyTranslation( $domain ) ) { |
|
182 | 182 | $strings = [ |
183 | - 'Published' => __('Approved', 'site-reviews'), |
|
184 | - 'Pending' => __('Unapproved', 'site-reviews'), |
|
183 | + 'Published' => __( 'Approved', 'site-reviews' ), |
|
184 | + 'Pending' => __( 'Unapproved', 'site-reviews' ), |
|
185 | 185 | ]; |
186 | - foreach ($strings as $search => $replace) { |
|
187 | - if (false === strpos($single, $search)) { |
|
186 | + foreach( $strings as $search => $replace ) { |
|
187 | + if( false === strpos( $single, $search ) ) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | - $translation = $this->getTranslation([ |
|
190 | + $translation = $this->getTranslation( [ |
|
191 | 191 | 'number' => $number, |
192 | - 'plural' => str_replace($search, $replace, $plural), |
|
193 | - 'single' => str_replace($search, $replace, $single), |
|
194 | - ]); |
|
192 | + 'plural' => str_replace( $search, $replace, $plural ), |
|
193 | + 'single' => str_replace( $search, $replace, $single ), |
|
194 | + ] ); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | return $translation; |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | * @return void |
204 | 204 | * @action bulk_edit_custom_box |
205 | 205 | */ |
206 | - public function renderBulkEditFields($columnName, $postType) |
|
206 | + public function renderBulkEditFields( $columnName, $postType ) |
|
207 | 207 | { |
208 | - if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) { |
|
209 | - glsr()->render('partials/editor/bulk-edit-assigned-to'); |
|
208 | + if( 'assigned_to' == $columnName && Application::POST_TYPE == $postType ) { |
|
209 | + glsr()->render( 'partials/editor/bulk-edit-assigned-to' ); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | * @return void |
216 | 216 | * @action restrict_manage_posts |
217 | 217 | */ |
218 | - public function renderColumnFilters($postType) |
|
218 | + public function renderColumnFilters( $postType ) |
|
219 | 219 | { |
220 | - glsr(Columns::class)->renderFilters($postType); |
|
220 | + glsr( Columns::class )->renderFilters( $postType ); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | * @return void |
227 | 227 | * @action manage_posts_custom_column |
228 | 228 | */ |
229 | - public function renderColumnValues($column, $postId) |
|
229 | + public function renderColumnValues( $column, $postId ) |
|
230 | 230 | { |
231 | - glsr(Columns::class)->renderValues($column, $postId); |
|
231 | + glsr( Columns::class )->renderValues( $column, $postId ); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | * @return void |
237 | 237 | * @action save_post_.Application::POST_TYPE |
238 | 238 | */ |
239 | - public function saveBulkEditFields($postId) |
|
239 | + public function saveBulkEditFields( $postId ) |
|
240 | 240 | { |
241 | - if (!current_user_can('edit_posts')) { |
|
241 | + if( !current_user_can( 'edit_posts' ) ) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | - $assignedTo = filter_input(INPUT_GET, 'assigned_to'); |
|
245 | - if ($assignedTo && get_post($assignedTo)) { |
|
246 | - glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
244 | + $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
|
245 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
246 | + glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo ); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
@@ -251,15 +251,15 @@ discard block |
||
251 | 251 | * @return void |
252 | 252 | * @action pre_get_posts |
253 | 253 | */ |
254 | - public function setQueryForColumn(WP_Query $query) |
|
254 | + public function setQueryForColumn( WP_Query $query ) |
|
255 | 255 | { |
256 | - if (!$this->hasPermission($query)) { |
|
256 | + if( !$this->hasPermission( $query ) ) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | - $this->setMetaQuery($query, [ |
|
259 | + $this->setMetaQuery( $query, [ |
|
260 | 260 | 'rating', 'review_type', |
261 | - ]); |
|
262 | - $this->setOrderby($query); |
|
261 | + ] ); |
|
262 | + $this->setOrderby( $query ); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public function unapprove() |
270 | 270 | { |
271 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
271 | + if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) { |
|
272 | 272 | return; |
273 | 273 | } |
274 | - check_admin_referer('unapprove-review_'.($postId = $this->getPostId())); |
|
275 | - wp_update_post([ |
|
274 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
275 | + wp_update_post( [ |
|
276 | 276 | 'ID' => $postId, |
277 | 277 | 'post_status' => 'pending', |
278 | - ]); |
|
279 | - wp_safe_redirect(wp_get_referer()); |
|
278 | + ] ); |
|
279 | + wp_safe_redirect( wp_get_referer() ); |
|
280 | 280 | exit; |
281 | 281 | } |
282 | 282 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @param string $domain |
286 | 286 | * @return bool |
287 | 287 | */ |
288 | - protected function canModifyTranslation($domain = 'default') |
|
288 | + protected function canModifyTranslation( $domain = 'default' ) |
|
289 | 289 | { |
290 | 290 | $screen = glsr_current_screen(); |
291 | 291 | return 'default' == $domain |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * Get the modified translation string. |
298 | 298 | * @return string |
299 | 299 | */ |
300 | - protected function getTranslation(array $args) |
|
300 | + protected function getTranslation( array $args ) |
|
301 | 301 | { |
302 | 302 | $defaults = [ |
303 | 303 | 'number' => 0, |
@@ -305,57 +305,57 @@ discard block |
||
305 | 305 | 'single' => '', |
306 | 306 | 'text' => '', |
307 | 307 | ]; |
308 | - $args = (object) wp_parse_args($args, $defaults); |
|
309 | - $translations = get_translations_for_domain(Application::ID); |
|
308 | + $args = (object)wp_parse_args( $args, $defaults ); |
|
309 | + $translations = get_translations_for_domain( Application::ID ); |
|
310 | 310 | return $args->text |
311 | - ? $translations->translate($args->text) |
|
312 | - : $translations->translate_plural($args->single, $args->plural, $args->number); |
|
311 | + ? $translations->translate( $args->text ) |
|
312 | + : $translations->translate_plural( $args->single, $args->plural, $args->number ); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
316 | 316 | * @return bool |
317 | 317 | */ |
318 | - protected function hasPermission(WP_Query $query) |
|
318 | + protected function hasPermission( WP_Query $query ) |
|
319 | 319 | { |
320 | 320 | global $pagenow; |
321 | 321 | return is_admin() |
322 | 322 | && $query->is_main_query() |
323 | - && Application::POST_TYPE == $query->get('post_type') |
|
323 | + && Application::POST_TYPE == $query->get( 'post_type' ) |
|
324 | 324 | && 'edit.php' == $pagenow; |
325 | 325 | } |
326 | 326 | |
327 | 327 | /** |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - protected function setMetaQuery(WP_Query $query, array $metaKeys) |
|
330 | + protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
|
331 | 331 | { |
332 | - foreach ($metaKeys as $key) { |
|
333 | - if (!($value = filter_input(INPUT_GET, $key))) { |
|
332 | + foreach( $metaKeys as $key ) { |
|
333 | + if( !($value = filter_input( INPUT_GET, $key )) ) { |
|
334 | 334 | continue; |
335 | 335 | } |
336 | - $metaQuery = (array) $query->get('meta_query'); |
|
336 | + $metaQuery = (array)$query->get( 'meta_query' ); |
|
337 | 337 | $metaQuery[] = [ |
338 | - 'key' => Str::prefix('_', $key, '_'), |
|
338 | + 'key' => Str::prefix( '_', $key, '_' ), |
|
339 | 339 | 'value' => $value, |
340 | 340 | ]; |
341 | - $query->set('meta_query', $metaQuery); |
|
341 | + $query->set( 'meta_query', $metaQuery ); |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
346 | 346 | * @return void |
347 | 347 | */ |
348 | - protected function setOrderby(WP_Query $query) |
|
348 | + protected function setOrderby( WP_Query $query ) |
|
349 | 349 | { |
350 | - $orderby = $query->get('orderby'); |
|
350 | + $orderby = $query->get( 'orderby' ); |
|
351 | 351 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
352 | 352 | unset($columns['cb'], $columns['title'], $columns['date']); |
353 | - if (in_array($orderby, array_keys($columns))) { |
|
354 | - if ('reviewer' == $orderby) { |
|
353 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
354 | + if( 'reviewer' == $orderby ) { |
|
355 | 355 | $orderby = 'author'; |
356 | 356 | } |
357 | - $query->set('meta_key', Str::prefix('_', $orderby, '_')); |
|
358 | - $query->set('orderby', 'meta_value'); |
|
357 | + $query->set( 'meta_key', Str::prefix( '_', $orderby, '_' ) ); |
|
358 | + $query->set( 'orderby', 'meta_value' ); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | } |
@@ -16,34 +16,34 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function registerPostType() |
18 | 18 | { |
19 | - if (!glsr()->hasPermission()) { |
|
19 | + if( !glsr()->hasPermission() ) { |
|
20 | 20 | return; |
21 | 21 | } |
22 | - $command = new RegisterPostType([ |
|
22 | + $command = new RegisterPostType( [ |
|
23 | 23 | 'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE], |
24 | 24 | 'columns' => [ |
25 | 25 | 'title' => '', |
26 | 26 | 'category' => '', |
27 | - 'assigned_to' => __('Assigned To', 'site-reviews'), |
|
28 | - 'reviewer' => __('Author', 'site-reviews'), |
|
29 | - 'email' => __('Email', 'site-reviews'), |
|
30 | - 'ip_address' => __('IP Address', 'site-reviews'), |
|
31 | - 'response' => __('Response', 'site-reviews'), |
|
32 | - 'review_type' => __('Type', 'site-reviews'), |
|
33 | - 'rating' => __('Rating', 'site-reviews'), |
|
34 | - 'pinned' => __('Pinned', 'site-reviews'), |
|
27 | + 'assigned_to' => __( 'Assigned To', 'site-reviews' ), |
|
28 | + 'reviewer' => __( 'Author', 'site-reviews' ), |
|
29 | + 'email' => __( 'Email', 'site-reviews' ), |
|
30 | + 'ip_address' => __( 'IP Address', 'site-reviews' ), |
|
31 | + 'response' => __( 'Response', 'site-reviews' ), |
|
32 | + 'review_type' => __( 'Type', 'site-reviews' ), |
|
33 | + 'rating' => __( 'Rating', 'site-reviews' ), |
|
34 | + 'pinned' => __( 'Pinned', 'site-reviews' ), |
|
35 | 35 | 'date' => '', |
36 | 36 | ], |
37 | 37 | 'menu_icon' => 'dashicons-star-half', |
38 | 38 | 'menu_name' => glsr()->name, |
39 | 39 | 'map_meta_cap' => true, |
40 | - 'plural' => __('Reviews', 'site-reviews'), |
|
40 | + 'plural' => __( 'Reviews', 'site-reviews' ), |
|
41 | 41 | 'post_type' => Application::POST_TYPE, |
42 | 42 | 'rest_controller_class' => RestReviewController::class, |
43 | 43 | 'show_in_rest' => true, |
44 | - 'single' => __('Review', 'site-reviews'), |
|
45 | - ]); |
|
46 | - $this->execute($command); |
|
44 | + 'single' => __( 'Review', 'site-reviews' ), |
|
45 | + ] ); |
|
46 | + $this->execute( $command ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function registerShortcodes() |
54 | 54 | { |
55 | - $command = new RegisterShortcodes([ |
|
55 | + $command = new RegisterShortcodes( [ |
|
56 | 56 | 'site_reviews', |
57 | 57 | 'site_reviews_form', |
58 | 58 | 'site_reviews_summary', |
59 | - ]); |
|
60 | - $this->execute($command); |
|
59 | + ] ); |
|
60 | + $this->execute( $command ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function registerTaxonomy() |
68 | 68 | { |
69 | - $command = new RegisterTaxonomy([ |
|
69 | + $command = new RegisterTaxonomy( [ |
|
70 | 70 | 'hierarchical' => true, |
71 | - 'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'], |
|
71 | + 'meta_box_cb' => [glsr( EditorController::class ), 'renderTaxonomyMetabox'], |
|
72 | 72 | 'public' => false, |
73 | 73 | 'rest_controller_class' => RestCategoryController::class, |
74 | 74 | 'show_admin_column' => true, |
75 | 75 | 'show_in_rest' => true, |
76 | 76 | 'show_ui' => true, |
77 | - ]); |
|
78 | - $this->execute($command); |
|
77 | + ] ); |
|
78 | + $this->execute( $command ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function registerWidgets() |
86 | 86 | { |
87 | - $command = new RegisterWidgets([ |
|
87 | + $command = new RegisterWidgets( [ |
|
88 | 88 | 'site-reviews' => [ |
89 | 89 | 'class' => 'glsr-widget glsr-widget-site-reviews', |
90 | - 'description' => __('Site Reviews: Display your recent reviews.', 'site-reviews'), |
|
91 | - 'title' => __('Recent Reviews', 'site-reviews'), |
|
90 | + 'description' => __( 'Site Reviews: Display your recent reviews.', 'site-reviews' ), |
|
91 | + 'title' => __( 'Recent Reviews', 'site-reviews' ), |
|
92 | 92 | ], |
93 | 93 | 'site-reviews-form' => [ |
94 | 94 | 'class' => 'glsr-widget glsr-widget-site-reviews-form', |
95 | - 'description' => __('Site Reviews: Display a form to submit reviews.', 'site-reviews'), |
|
96 | - 'title' => __('Submit a Review', 'site-reviews'), |
|
95 | + 'description' => __( 'Site Reviews: Display a form to submit reviews.', 'site-reviews' ), |
|
96 | + 'title' => __( 'Submit a Review', 'site-reviews' ), |
|
97 | 97 | ], |
98 | 98 | 'site-reviews-summary' => [ |
99 | 99 | 'class' => 'glsr-widget glsr-widget-site-reviews-summary', |
100 | - 'description' => __('Site Reviews: Display a summary of your reviews.', 'site-reviews'), |
|
101 | - 'title' => __('Summary of Reviews', 'site-reviews'), |
|
100 | + 'description' => __( 'Site Reviews: Display a summary of your reviews.', 'site-reviews' ), |
|
101 | + 'title' => __( 'Summary of Reviews', 'site-reviews' ), |
|
102 | 102 | ], |
103 | - ]); |
|
104 | - $this->execute($command); |
|
103 | + ] ); |
|
104 | + $this->execute( $command ); |
|
105 | 105 | } |
106 | 106 | } |
@@ -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,35 +50,35 @@ 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 | - return glsr(Builder::class)->i([ |
|
58 | + return glsr( Builder::class )->i( [ |
|
59 | 59 | 'class' => $pinned.'dashicons dashicons-sticky', |
60 | 60 | 'data-id' => $postId, |
61 | - ]); |
|
61 | + ] ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @param int $postId |
66 | 66 | * @return string |
67 | 67 | */ |
68 | - public function buildColumnResponse($postId) |
|
68 | + public function buildColumnResponse( $postId ) |
|
69 | 69 | { |
70 | - return glsr(Database::class)->get($postId, 'response') |
|
71 | - ? __('Yes', 'site-reviews') |
|
72 | - : __('No', 'site-reviews'); |
|
70 | + return glsr( Database::class )->get( $postId, 'response' ) |
|
71 | + ? __( 'Yes', 'site-reviews' ) |
|
72 | + : __( 'No', 'site-reviews' ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @param int $postId |
77 | 77 | * @return string |
78 | 78 | */ |
79 | - public function buildColumnReviewer($postId) |
|
79 | + public function buildColumnReviewer( $postId ) |
|
80 | 80 | { |
81 | - return strval(glsr(Database::class)->get($postId, 'author')); |
|
81 | + return strval( glsr( Database::class )->get( $postId, 'author' ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -86,39 +86,39 @@ discard block |
||
86 | 86 | * @param int|null $rating |
87 | 87 | * @return string |
88 | 88 | */ |
89 | - public function buildColumnRating($postId) |
|
89 | + public function buildColumnRating( $postId ) |
|
90 | 90 | { |
91 | - return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating'))); |
|
91 | + return glsr_star_rating( intval( glsr( Database::class )->get( $postId, 'rating' ) ) ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
95 | 95 | * @param int $postId |
96 | 96 | * @return string |
97 | 97 | */ |
98 | - public function buildColumnReviewType($postId) |
|
98 | + public function buildColumnReviewType( $postId ) |
|
99 | 99 | { |
100 | - $type = glsr(Database::class)->get($postId, 'review_type'); |
|
101 | - return array_key_exists($type, glsr()->reviewTypes) |
|
100 | + $type = glsr( Database::class )->get( $postId, 'review_type' ); |
|
101 | + return array_key_exists( $type, glsr()->reviewTypes ) |
|
102 | 102 | ? glsr()->reviewTypes[$type] |
103 | - : __('Unsupported Type', 'site-reviews'); |
|
103 | + : __( 'Unsupported Type', 'site-reviews' ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @param string $postType |
108 | 108 | * @return void |
109 | 109 | */ |
110 | - public function renderFilters($postType) |
|
110 | + public function renderFilters( $postType ) |
|
111 | 111 | { |
112 | - if (Application::POST_TYPE !== $postType) { |
|
112 | + if( Application::POST_TYPE !== $postType ) { |
|
113 | 113 | return; |
114 | 114 | } |
115 | - if (!($status = filter_input(INPUT_GET, 'post_status'))) { |
|
115 | + if( !($status = filter_input( INPUT_GET, 'post_status' )) ) { |
|
116 | 116 | $status = 'publish'; |
117 | 117 | } |
118 | - $ratings = glsr(Database::class)->getReviewsMeta('rating', $status); |
|
119 | - $types = glsr(Database::class)->getReviewsMeta('review_type', $status); |
|
120 | - $this->renderFilterRatings($ratings); |
|
121 | - $this->renderFilterTypes($types); |
|
118 | + $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status ); |
|
119 | + $types = glsr( Database::class )->getReviewsMeta( 'review_type', $status ); |
|
120 | + $this->renderFilterRatings( $ratings ); |
|
121 | + $this->renderFilterTypes( $types ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | * @param int $postId |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - public function renderValues($column, $postId) |
|
129 | + public function renderValues( $column, $postId ) |
|
130 | 130 | { |
131 | - $method = Helper::buildMethodName($column, 'buildColumn'); |
|
132 | - $value = method_exists($this, $method) |
|
133 | - ? call_user_func([$this, $method], $postId) |
|
134 | - : apply_filters('site-reviews/columns/'.$column, '', $postId); |
|
135 | - if (empty($value)) { |
|
131 | + $method = Helper::buildMethodName( $column, 'buildColumn' ); |
|
132 | + $value = method_exists( $this, $method ) |
|
133 | + ? call_user_func( [$this, $method], $postId ) |
|
134 | + : apply_filters( 'site-reviews/columns/'.$column, '', $postId ); |
|
135 | + if( empty($value) ) { |
|
136 | 136 | $value = '—'; |
137 | 137 | } |
138 | 138 | echo $value; |
@@ -142,44 +142,44 @@ discard block |
||
142 | 142 | * @param array $ratings |
143 | 143 | * @return void |
144 | 144 | */ |
145 | - protected function renderFilterRatings($ratings) |
|
145 | + protected function renderFilterRatings( $ratings ) |
|
146 | 146 | { |
147 | - if (empty($ratings)) { |
|
147 | + if( empty($ratings) ) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | - $ratings = array_flip(array_reverse($ratings)); |
|
151 | - array_walk($ratings, function (&$value, $key) { |
|
152 | - $label = _n('%s star', '%s stars', $key, 'site-reviews'); |
|
153 | - $value = sprintf($label, $key); |
|
150 | + $ratings = array_flip( array_reverse( $ratings ) ); |
|
151 | + array_walk( $ratings, function( &$value, $key ) { |
|
152 | + $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
|
153 | + $value = sprintf( $label, $key ); |
|
154 | 154 | }); |
155 | - echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [ |
|
155 | + echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [ |
|
156 | 156 | 'class' => 'screen-reader-text', |
157 | 157 | 'for' => 'rating', |
158 | - ]); |
|
159 | - echo glsr(Builder::class)->select([ |
|
158 | + ] ); |
|
159 | + echo glsr( Builder::class )->select( [ |
|
160 | 160 | 'name' => 'rating', |
161 | - 'options' => ['' => __('All ratings', 'site-reviews')] + $ratings, |
|
162 | - 'value' => filter_input(INPUT_GET, 'rating'), |
|
163 | - ]); |
|
161 | + 'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings, |
|
162 | + 'value' => filter_input( INPUT_GET, 'rating' ), |
|
163 | + ] ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
167 | 167 | * @param array $types |
168 | 168 | * @return void |
169 | 169 | */ |
170 | - protected function renderFilterTypes($types) |
|
170 | + protected function renderFilterTypes( $types ) |
|
171 | 171 | { |
172 | - if (count(glsr()->reviewTypes) < 2) { |
|
172 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
173 | 173 | return; |
174 | 174 | } |
175 | - echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [ |
|
175 | + echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
|
176 | 176 | 'class' => 'screen-reader-text', |
177 | 177 | 'for' => 'review_type', |
178 | - ]); |
|
179 | - echo glsr(Builder::class)->select([ |
|
178 | + ] ); |
|
179 | + echo glsr( Builder::class )->select( [ |
|
180 | 180 | 'name' => 'review_type', |
181 | - 'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes, |
|
182 | - 'value' => filter_input(INPUT_GET, 'review_type'), |
|
183 | - ]); |
|
181 | + 'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes, |
|
182 | + 'value' => filter_input( INPUT_GET, 'review_type' ), |
|
183 | + ] ); |
|
184 | 184 | } |
185 | 185 | } |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @return void |
19 | 19 | */ |
20 | - public function routerChangeStatus(array $request) |
|
20 | + public function routerChangeStatus( array $request ) |
|
21 | 21 | { |
22 | - wp_send_json_success($this->execute(new ChangeStatus($request))); |
|
22 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function routerClearConsole() |
29 | 29 | { |
30 | - glsr(AdminController::class)->routerClearConsole(); |
|
31 | - wp_send_json_success([ |
|
32 | - 'console' => glsr(Console::class)->get(), |
|
33 | - 'notices' => glsr(Notice::class)->get(), |
|
34 | - ]); |
|
30 | + glsr( AdminController::class )->routerClearConsole(); |
|
31 | + wp_send_json_success( [ |
|
32 | + 'console' => glsr( Console::class )->get(), |
|
33 | + 'notices' => glsr( Notice::class )->get(), |
|
34 | + ] ); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,32 +39,32 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function routerCountReviews() |
41 | 41 | { |
42 | - glsr(AdminController::class)->routerCountReviews(); |
|
43 | - wp_send_json_success([ |
|
44 | - 'notices' => glsr(Notice::class)->get(), |
|
45 | - ]); |
|
42 | + glsr( AdminController::class )->routerCountReviews(); |
|
43 | + wp_send_json_success( [ |
|
44 | + 'notices' => glsr( Notice::class )->get(), |
|
45 | + ] ); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @return void |
50 | 50 | */ |
51 | - public function routerDismissNotice(array $request) |
|
51 | + public function routerDismissNotice( array $request ) |
|
52 | 52 | { |
53 | - glsr(NoticeController::class)->routerDismissNotice($request); |
|
53 | + glsr( NoticeController::class )->routerDismissNotice( $request ); |
|
54 | 54 | wp_send_json_success(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @return void |
59 | 59 | */ |
60 | - public function routerMceShortcode(array $request) |
|
60 | + public function routerMceShortcode( array $request ) |
|
61 | 61 | { |
62 | 62 | $shortcode = $request['shortcode']; |
63 | 63 | $response = false; |
64 | - if (array_key_exists($shortcode, glsr()->mceShortcodes)) { |
|
64 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
65 | 65 | $data = glsr()->mceShortcodes[$shortcode]; |
66 | - if (!empty($data['errors'])) { |
|
67 | - $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')]; |
|
66 | + if( !empty($data['errors']) ) { |
|
67 | + $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
|
68 | 68 | } |
69 | 69 | $response = [ |
70 | 70 | 'body' => $data['fields'], |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | 'title' => $data['title'], |
75 | 75 | ]; |
76 | 76 | } |
77 | - wp_send_json_success($response); |
|
77 | + wp_send_json_success( $response ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,96 +82,96 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function routerFetchConsole() |
84 | 84 | { |
85 | - glsr(AdminController::class)->routerFetchConsole(); |
|
86 | - wp_send_json_success([ |
|
87 | - 'console' => glsr(Console::class)->get(), |
|
88 | - 'notices' => glsr(Notice::class)->get(), |
|
89 | - ]); |
|
85 | + glsr( AdminController::class )->routerFetchConsole(); |
|
86 | + wp_send_json_success( [ |
|
87 | + 'console' => glsr( Console::class )->get(), |
|
88 | + 'notices' => glsr( Notice::class )->get(), |
|
89 | + ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @return void |
94 | 94 | */ |
95 | - public function routerSearchPosts(array $request) |
|
95 | + public function routerSearchPosts( array $request ) |
|
96 | 96 | { |
97 | - $results = glsr(Database::class)->searchPosts($request['search']); |
|
98 | - wp_send_json_success([ |
|
99 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
97 | + $results = glsr( Database::class )->searchPosts( $request['search'] ); |
|
98 | + wp_send_json_success( [ |
|
99 | + 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
|
100 | 100 | 'items' => $results, |
101 | - ]); |
|
101 | + ] ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @return void |
106 | 106 | */ |
107 | - public function routerSearchTranslations(array $request) |
|
107 | + public function routerSearchTranslations( array $request ) |
|
108 | 108 | { |
109 | - if (empty($request['exclude'])) { |
|
109 | + if( empty($request['exclude']) ) { |
|
110 | 110 | $request['exclude'] = []; |
111 | 111 | } |
112 | - $results = glsr(Translation::class) |
|
113 | - ->search($request['search']) |
|
112 | + $results = glsr( Translation::class ) |
|
113 | + ->search( $request['search'] ) |
|
114 | 114 | ->exclude() |
115 | - ->exclude($request['exclude']) |
|
115 | + ->exclude( $request['exclude'] ) |
|
116 | 116 | ->renderResults(); |
117 | - wp_send_json_success([ |
|
118 | - 'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>', |
|
117 | + wp_send_json_success( [ |
|
118 | + 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
|
119 | 119 | 'items' => $results, |
120 | - ]); |
|
120 | + ] ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return void |
125 | 125 | */ |
126 | - public function routerSubmitReview(array $request) |
|
126 | + public function routerSubmitReview( array $request ) |
|
127 | 127 | { |
128 | - $command = glsr(PublicController::class)->routerSubmitReview($request); |
|
129 | - $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true))); |
|
130 | - $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command); |
|
128 | + $command = glsr( PublicController::class )->routerSubmitReview( $request ); |
|
129 | + $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
130 | + $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command ); |
|
131 | 131 | $data = [ |
132 | - 'errors' => glsr()->sessionGet($command->form_id.'errors', false), |
|
133 | - 'message' => glsr()->sessionGet($command->form_id.'message', ''), |
|
134 | - 'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false), |
|
132 | + 'errors' => glsr()->sessionGet( $command->form_id.'errors', false ), |
|
133 | + 'message' => glsr()->sessionGet( $command->form_id.'message', '' ), |
|
134 | + 'recaptcha' => glsr()->sessionGet( $command->form_id.'recaptcha', false ), |
|
135 | 135 | 'redirect' => $redirect, |
136 | 136 | ]; |
137 | - if (false === $data['errors']) { |
|
137 | + if( false === $data['errors'] ) { |
|
138 | 138 | glsr()->sessionClear(); |
139 | - wp_send_json_success($data); |
|
139 | + wp_send_json_success( $data ); |
|
140 | 140 | } |
141 | - wp_send_json_error($data); |
|
141 | + wp_send_json_error( $data ); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * @return void |
146 | 146 | */ |
147 | - public function routerFetchPagedReviews(array $request) |
|
147 | + public function routerFetchPagedReviews( array $request ) |
|
148 | 148 | { |
149 | 149 | $urlQuery = []; |
150 | - parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery); |
|
150 | + parse_str( parse_url( Arr::get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery ); |
|
151 | 151 | $args = [ |
152 | - 'paged' => Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1), |
|
153 | - 'pagedUrl' => home_url(parse_url(Arr::get($request, 'url'), PHP_URL_PATH)), |
|
152 | + 'paged' => Arr::get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ), |
|
153 | + 'pagedUrl' => home_url( parse_url( Arr::get( $request, 'url' ), PHP_URL_PATH ) ), |
|
154 | 154 | 'pagination' => 'ajax', |
155 | 155 | 'schema' => false, |
156 | 156 | ]; |
157 | - $atts = (array) json_decode(Arr::get($request, 'atts')); |
|
158 | - $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts); |
|
159 | - $html = glsr(SiteReviews::class)->build(wp_parse_args($args, $atts)); |
|
160 | - return wp_send_json_success([ |
|
157 | + $atts = (array)json_decode( Arr::get( $request, 'atts' ) ); |
|
158 | + $atts = glsr( SiteReviewsShortcode::class )->normalizeAtts( $atts ); |
|
159 | + $html = glsr( SiteReviews::class )->build( wp_parse_args( $args, $atts ) ); |
|
160 | + return wp_send_json_success( [ |
|
161 | 161 | 'pagination' => $html->getPagination(), |
162 | 162 | 'reviews' => $html->getReviews(), |
163 | - ]); |
|
163 | + ] ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public function routerTogglePinned(array $request) |
|
169 | + public function routerTogglePinned( array $request ) |
|
170 | 170 | { |
171 | - $isPinned = $this->execute(new TogglePinned($request)); |
|
172 | - wp_send_json_success([ |
|
173 | - 'notices' => glsr(Notice::class)->get(), |
|
171 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
172 | + wp_send_json_success( [ |
|
173 | + 'notices' => glsr( Notice::class )->get(), |
|
174 | 174 | 'pinned' => $isPinned, |
175 | - ]); |
|
175 | + ] ); |
|
176 | 176 | } |
177 | 177 | } |
@@ -58,19 +58,19 @@ discard block |
||
58 | 58 | /** |
59 | 59 | * @return static |
60 | 60 | */ |
61 | - public function validate(array $request) |
|
61 | + public function validate( array $request ) |
|
62 | 62 | { |
63 | 63 | $this->form_id = $request['form_id']; |
64 | - $this->options = glsr(OptionManager::class)->all(); |
|
65 | - $this->request = $this->validateRequest($request); |
|
64 | + $this->options = glsr( OptionManager::class )->all(); |
|
65 | + $this->request = $this->validateRequest( $request ); |
|
66 | 66 | $this->validateCustom(); |
67 | 67 | $this->validateHoneyPot(); |
68 | 68 | $this->validateReviewLimits(); |
69 | 69 | $this->validateBlacklist(); |
70 | 70 | $this->validateAkismet(); |
71 | 71 | $this->validateRecaptcha(); |
72 | - if (!empty($this->error)) { |
|
73 | - $this->setSessionValues('message', $this->error); |
|
72 | + if( !empty($this->error) ) { |
|
73 | + $this->setSessionValues( 'message', $this->error ); |
|
74 | 74 | } |
75 | 75 | return $this; |
76 | 76 | } |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @param mixed $fallback |
81 | 81 | * @return mixed |
82 | 82 | */ |
83 | - protected function getOption($path, $fallback = '') |
|
83 | + protected function getOption( $path, $fallback = '' ) |
|
84 | 84 | { |
85 | - return Arr::get($this->options, $path, $fallback); |
|
85 | + return Arr::get( $this->options, $path, $fallback ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function getRecaptchaStatus() |
92 | 92 | { |
93 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
93 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
94 | 94 | return static::RECAPTCHA_DISABLED; |
95 | 95 | } |
96 | - if (empty($this->request['_recaptcha-token'])) { |
|
97 | - return $this->request['_counter'] < intval(apply_filters('site-reviews/recaptcha/timeout', 5)) |
|
96 | + if( empty($this->request['_recaptcha-token']) ) { |
|
97 | + return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) ) |
|
98 | 98 | ? static::RECAPTCHA_EMPTY |
99 | 99 | : static::RECAPTCHA_FAILED; |
100 | 100 | } |
@@ -106,23 +106,23 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function getRecaptchaTokenStatus() |
108 | 108 | { |
109 | - $endpoint = add_query_arg([ |
|
109 | + $endpoint = add_query_arg( [ |
|
110 | 110 | 'remoteip' => Helper::getIpAddress(), |
111 | 111 | 'response' => $this->request['_recaptcha-token'], |
112 | - 'secret' => $this->getOption('settings.submissions.recaptcha.secret'), |
|
113 | - ], static::RECAPTCHA_ENDPOINT); |
|
114 | - if (is_wp_error($response = wp_remote_get($endpoint))) { |
|
115 | - glsr_log()->error($response->get_error_message()); |
|
112 | + 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
|
113 | + ], static::RECAPTCHA_ENDPOINT ); |
|
114 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
115 | + glsr_log()->error( $response->get_error_message() ); |
|
116 | 116 | return static::RECAPTCHA_FAILED; |
117 | 117 | } |
118 | - $response = json_decode(wp_remote_retrieve_body($response)); |
|
119 | - if (!empty($response->success)) { |
|
120 | - return boolval($response->success) |
|
118 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
119 | + if( !empty($response->success) ) { |
|
120 | + return boolval( $response->success ) |
|
121 | 121 | ? static::RECAPTCHA_VALID |
122 | 122 | : static::RECAPTCHA_INVALID; |
123 | 123 | } |
124 | - foreach ($response->{'error-codes'} as $error) { |
|
125 | - glsr_log()->error('reCAPTCHA error: '.$error); |
|
124 | + foreach( $response->{'error-codes'} as $error ) { |
|
125 | + glsr_log()->error( 'reCAPTCHA error: '.$error ); |
|
126 | 126 | } |
127 | 127 | return static::RECAPTCHA_INVALID; |
128 | 128 | } |
@@ -130,35 +130,35 @@ discard block |
||
130 | 130 | /** |
131 | 131 | * @return array |
132 | 132 | */ |
133 | - protected function getValidationRules(array $request) |
|
133 | + protected function getValidationRules( array $request ) |
|
134 | 134 | { |
135 | 135 | $rules = array_intersect_key( |
136 | - apply_filters('site-reviews/validation/rules', static::VALIDATION_RULES, $request), |
|
137 | - array_flip($this->getOption('settings.submissions.required', [])) |
|
136 | + apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ), |
|
137 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
138 | 138 | ); |
139 | - $excluded = explode(',', Arr::get($request, 'excluded')); |
|
140 | - return array_diff_key($rules, array_flip($excluded)); |
|
139 | + $excluded = explode( ',', Arr::get( $request, 'excluded' ) ); |
|
140 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | 144 | * @return bool |
145 | 145 | */ |
146 | - protected function isRequestValid(array $request) |
|
146 | + protected function isRequestValid( array $request ) |
|
147 | 147 | { |
148 | - $rules = $this->getValidationRules($request); |
|
149 | - $errors = glsr(Validator::class)->validate($request, $rules); |
|
150 | - if (empty($errors)) { |
|
148 | + $rules = $this->getValidationRules( $request ); |
|
149 | + $errors = glsr( Validator::class )->validate( $request, $rules ); |
|
150 | + if( empty($errors) ) { |
|
151 | 151 | return true; |
152 | 152 | } |
153 | - $this->error = __('Please fix the submission errors.', 'site-reviews'); |
|
154 | - $this->setSessionValues('errors', $errors); |
|
155 | - $this->setSessionValues('values', $request); |
|
153 | + $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
|
154 | + $this->setSessionValues( 'errors', $errors ); |
|
155 | + $this->setSessionValues( 'values', $request ); |
|
156 | 156 | return false; |
157 | 157 | } |
158 | 158 | |
159 | - protected function setError($message, $loggedMessage = '') |
|
159 | + protected function setError( $message, $loggedMessage = '' ) |
|
160 | 160 | { |
161 | - $this->setSessionValues('errors', [], $loggedMessage); |
|
161 | + $this->setSessionValues( 'errors', [], $loggedMessage ); |
|
162 | 162 | $this->error = $message; |
163 | 163 | } |
164 | 164 | |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * @param string $loggedMessage |
169 | 169 | * @return void |
170 | 170 | */ |
171 | - protected function setSessionValues($type, $value, $loggedMessage = '') |
|
171 | + protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
|
172 | 172 | { |
173 | - glsr()->sessionSet($this->form_id.$type, $value); |
|
174 | - if (!empty($loggedMessage)) { |
|
175 | - glsr_log()->warning($loggedMessage)->debug($this->request); |
|
173 | + glsr()->sessionSet( $this->form_id.$type, $value ); |
|
174 | + if( !empty($loggedMessage) ) { |
|
175 | + glsr_log()->warning( $loggedMessage )->debug( $this->request ); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | */ |
182 | 182 | protected function validateAkismet() |
183 | 183 | { |
184 | - if (!empty($this->error)) { |
|
184 | + if( !empty($this->error) ) { |
|
185 | 185 | return; |
186 | 186 | } |
187 | - if (glsr(Akismet::class)->isSpam($this->request)) { |
|
188 | - $this->setError(__('This review has been flagged as possible spam and cannot be submitted.', 'site-reviews'), |
|
187 | + if( glsr( Akismet::class )->isSpam( $this->request ) ) { |
|
188 | + $this->setError( __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ), |
|
189 | 189 | 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' |
190 | 190 | ); |
191 | 191 | } |
@@ -196,18 +196,18 @@ discard block |
||
196 | 196 | */ |
197 | 197 | protected function validateBlacklist() |
198 | 198 | { |
199 | - if (!empty($this->error)) { |
|
199 | + if( !empty($this->error) ) { |
|
200 | 200 | return; |
201 | 201 | } |
202 | - if (!glsr(Blacklist::class)->isBlacklisted($this->request)) { |
|
202 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) ) { |
|
203 | 203 | return; |
204 | 204 | } |
205 | - $blacklistAction = $this->getOption('settings.submissions.blacklist.action'); |
|
206 | - if ('reject' != $blacklistAction) { |
|
205 | + $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
|
206 | + if( 'reject' != $blacklistAction ) { |
|
207 | 207 | $this->request['blacklisted'] = true; |
208 | 208 | return; |
209 | 209 | } |
210 | - $this->setError(__('Your review cannot be submitted at this time.', 'site-reviews'), |
|
210 | + $this->setError( __( 'Your review cannot be submitted at this time.', 'site-reviews' ), |
|
211 | 211 | 'Blacklisted submission detected:' |
212 | 212 | ); |
213 | 213 | } |
@@ -217,18 +217,18 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function validateCustom() |
219 | 219 | { |
220 | - if (!empty($this->error)) { |
|
220 | + if( !empty($this->error) ) { |
|
221 | 221 | return; |
222 | 222 | } |
223 | - $validated = apply_filters('site-reviews/validate/custom', true, $this->request); |
|
224 | - if (true === $validated) { |
|
223 | + $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
|
224 | + if( true === $validated ) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | - $errorMessage = is_string($validated) |
|
227 | + $errorMessage = is_string( $validated ) |
|
228 | 228 | ? $validated |
229 | - : __('The review submission failed. Please notify the site administrator.', 'site-reviews'); |
|
230 | - $this->setError($errorMessage); |
|
231 | - $this->setSessionValues('values', $this->request); |
|
229 | + : __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
|
230 | + $this->setError( $errorMessage ); |
|
231 | + $this->setSessionValues( 'values', $this->request ); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -236,11 +236,11 @@ discard block |
||
236 | 236 | */ |
237 | 237 | protected function validateHoneyPot() |
238 | 238 | { |
239 | - if (!empty($this->error)) { |
|
239 | + if( !empty($this->error) ) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | - if (!empty($this->request['gotcha'])) { |
|
243 | - $this->setError(__('The review submission failed. Please notify the site administrator.', 'site-reviews'), |
|
242 | + if( !empty($this->request['gotcha']) ) { |
|
243 | + $this->setError( __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ), |
|
244 | 244 | 'The Honeypot caught a bad submission:' |
245 | 245 | ); |
246 | 246 | } |
@@ -251,11 +251,11 @@ discard block |
||
251 | 251 | */ |
252 | 252 | protected function validateReviewLimits() |
253 | 253 | { |
254 | - if (!empty($this->error)) { |
|
254 | + if( !empty($this->error) ) { |
|
255 | 255 | return; |
256 | 256 | } |
257 | - if (glsr(ReviewLimits::class)->hasReachedLimit($this->request)) { |
|
258 | - $this->setError(__('You have already submitted a review.', 'site-reviews')); |
|
257 | + if( glsr( ReviewLimits::class )->hasReachedLimit( $this->request ) ) { |
|
258 | + $this->setError( __( 'You have already submitted a review.', 'site-reviews' ) ); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -264,33 +264,33 @@ discard block |
||
264 | 264 | */ |
265 | 265 | protected function validateRecaptcha() |
266 | 266 | { |
267 | - if (!empty($this->error)) { |
|
267 | + if( !empty($this->error) ) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | $status = $this->getRecaptchaStatus(); |
271 | - if (in_array($status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID])) { |
|
271 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) ) { |
|
272 | 272 | return; |
273 | 273 | } |
274 | - if (static::RECAPTCHA_EMPTY === $status) { |
|
275 | - $this->setSessionValues('recaptcha', 'unset'); |
|
274 | + if( static::RECAPTCHA_EMPTY === $status ) { |
|
275 | + $this->setSessionValues( 'recaptcha', 'unset' ); |
|
276 | 276 | $this->recaptchaIsUnset = true; |
277 | 277 | return; |
278 | 278 | } |
279 | - $this->setSessionValues('recaptcha', 'reset'); |
|
279 | + $this->setSessionValues( 'recaptcha', 'reset' ); |
|
280 | 280 | $errors = [ |
281 | - static::RECAPTCHA_FAILED => __('The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews'), |
|
282 | - static::RECAPTCHA_INVALID => __('The reCAPTCHA verification failed, please try again.', 'site-reviews'), |
|
281 | + static::RECAPTCHA_FAILED => __( 'The reCAPTCHA failed to load, please refresh the page and try again.', 'site-reviews' ), |
|
282 | + static::RECAPTCHA_INVALID => __( 'The reCAPTCHA verification failed, please try again.', 'site-reviews' ), |
|
283 | 283 | ]; |
284 | - $this->setError($errors[$status]); |
|
284 | + $this->setError( $errors[$status] ); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
288 | 288 | * @return array |
289 | 289 | */ |
290 | - protected function validateRequest(array $request) |
|
290 | + protected function validateRequest( array $request ) |
|
291 | 291 | { |
292 | - if ($this->isRequestValid($request)) { |
|
293 | - return array_merge(glsr(ValidateReviewDefaults::class)->defaults(), $request); |
|
292 | + if( $this->isRequestValid( $request ) ) { |
|
293 | + return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request ); |
|
294 | 294 | } |
295 | 295 | return $request; |
296 | 296 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p>This page shows all of the available shortcode options with examples of how to use them. You can use multiple options in the same shortcode.</p> |
4 | 4 | |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | <div class="glsr-card-header"> |
7 | 7 | <h3>[site_reviews]</h3> |
8 | 8 | <button type="button" class="handlediv" aria-expanded="true"> |
9 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
9 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
10 | 10 | <span class="toggle-indicator" aria-hidden="true"></span> |
11 | 11 | </button> |
12 | 12 | </div> |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | <div class="glsr-card-header"> |
81 | 81 | <h3>[site_reviews_form]</h3> |
82 | 82 | <button type="button" class="handlediv" aria-expanded="true"> |
83 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
83 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
84 | 84 | <span class="toggle-indicator" aria-hidden="true"></span> |
85 | 85 | </button> |
86 | 86 | </div> |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | <div class="glsr-card-header"> |
129 | 129 | <h3>[site_reviews_summary]</h3> |
130 | 130 | <button type="button" class="handlediv" aria-expanded="true"> |
131 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
131 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
132 | 132 | <span class="toggle-indicator" aria-hidden="true"></span> |
133 | 133 | </button> |
134 | 134 | </div> |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | <pre><code>[site_reviews_summary hide="bars,if_empty,rating,stars,summary"]</code></pre> |
159 | 159 | |
160 | 160 | <p class="glsr-heading">labels</p> |
161 | - <p>The "labels" attribute allows you to enter custom labels for the percentage bar levels (from high to low), each level should be separated with a comma. However, rather than using this attribute to change the labels it's recommended to instead create a custom translation for them in the <code><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!translations'); ?>">Settings → Translations</a></code> page.</p> |
|
161 | + <p>The "labels" attribute allows you to enter custom labels for the percentage bar levels (from high to low), each level should be separated with a comma. However, rather than using this attribute to change the labels it's recommended to instead create a custom translation for them in the <code><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!translations' ); ?>">Settings → Translations</a></code> page.</p> |
|
162 | 162 | <p>The default labels value is: <code>"Excellent,Very good,Average,Poor,Terrible"</code></p> |
163 | 163 | <pre><code>[site_reviews_summary labels="5 star,4 star,3 star,2 star,1 star"]</code></pre> |
164 | 164 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | <pre><code>[site_reviews_summary schema="true"]</code></pre> |
176 | 176 | |
177 | 177 | <p class="glsr-heading">text</p> |
178 | - <p>The "text" attribute allows you to change the summary text. Available template tags to use are, "{rating}" which represents the calculated average rating, "{max}" which represents the maximum star rating available, and "{num}" which represents the total number of reviews. However, rather than using this attribute to change the summary text it's recommended to instead create a custom translation for it in the <code><a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!translations'); ?>">Settings → Translations</a></code> page. That way, you will be able to customize both the singular (1 review) and plural (2 reviews) summary texts.</p> |
|
178 | + <p>The "text" attribute allows you to change the summary text. Available template tags to use are, "{rating}" which represents the calculated average rating, "{max}" which represents the maximum star rating available, and "{num}" which represents the total number of reviews. However, rather than using this attribute to change the summary text it's recommended to instead create a custom translation for it in the <code><a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!translations' ); ?>">Settings → Translations</a></code> page. That way, you will be able to customize both the singular (1 review) and plural (2 reviews) summary texts.</p> |
|
179 | 179 | <p>The default text value is: <code>"{rating} out of {max} stars (based on {num} reviews)"</code></p> |
180 | 180 | <pre><code>[site_reviews_summary text="{num} customer reviews"]</code></pre> |
181 | 181 |
@@ -1,3 +1,3 @@ |
||
1 | 1 | <div class="notice notice-info is-dismissible glsr-notice" data-dismiss="welcome"> |
2 | - <p><?= $text; ?> — <a class="button button-small" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=welcome#!whatsnew'); ?>">See what's new</a></p> |
|
2 | + <p><?= $text; ?> — <a class="button button-small" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=welcome#!whatsnew' ); ?>">See what's new</a></p> |
|
3 | 3 | </div> |
@@ -11,65 +11,65 @@ discard block |
||
11 | 11 | * @param array $instance |
12 | 12 | * @return void |
13 | 13 | */ |
14 | - public function form($instance) |
|
14 | + public function form( $instance ) |
|
15 | 15 | { |
16 | - $this->widgetArgs = glsr(SiteReviewsShortcode::class)->normalizeAtts($instance); |
|
17 | - $terms = glsr(Database::class)->getTerms(); |
|
18 | - $this->renderField('text', [ |
|
16 | + $this->widgetArgs = glsr( SiteReviewsShortcode::class )->normalizeAtts( $instance ); |
|
17 | + $terms = glsr( Database::class )->getTerms(); |
|
18 | + $this->renderField( 'text', [ |
|
19 | 19 | 'class' => 'widefat', |
20 | - 'label' => __('Title', 'site-reviews'), |
|
20 | + 'label' => __( 'Title', 'site-reviews' ), |
|
21 | 21 | 'name' => 'title', |
22 | - ]); |
|
23 | - $this->renderField('number', [ |
|
22 | + ] ); |
|
23 | + $this->renderField( 'number', [ |
|
24 | 24 | 'class' => 'small-text', |
25 | 25 | 'default' => 10, |
26 | - 'label' => __('How many reviews would you like to display?', 'site-reviews'), |
|
26 | + 'label' => __( 'How many reviews would you like to display?', 'site-reviews' ), |
|
27 | 27 | 'max' => 100, |
28 | 28 | 'name' => 'display', |
29 | - ]); |
|
30 | - $this->renderField('select', [ |
|
31 | - 'label' => __('What is the minimum rating to display?', 'site-reviews'), |
|
29 | + ] ); |
|
30 | + $this->renderField( 'select', [ |
|
31 | + 'label' => __( 'What is the minimum rating to display?', 'site-reviews' ), |
|
32 | 32 | 'name' => 'rating', |
33 | 33 | 'options' => [ |
34 | - '5' => sprintf(_n('%s star', '%s stars', 5, 'site-reviews'), 5), |
|
35 | - '4' => sprintf(_n('%s star', '%s stars', 4, 'site-reviews'), 4), |
|
36 | - '3' => sprintf(_n('%s star', '%s stars', 3, 'site-reviews'), 3), |
|
37 | - '2' => sprintf(_n('%s star', '%s stars', 2, 'site-reviews'), 2), |
|
38 | - '1' => sprintf(_n('%s star', '%s stars', 1, 'site-reviews'), 1), |
|
34 | + '5' => sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ), |
|
35 | + '4' => sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ), |
|
36 | + '3' => sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ), |
|
37 | + '2' => sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ), |
|
38 | + '1' => sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ), |
|
39 | 39 | ], |
40 | - ]); |
|
41 | - if (count(glsr()->reviewTypes) > 1) { |
|
42 | - $this->renderField('select', [ |
|
40 | + ] ); |
|
41 | + if( count( glsr()->reviewTypes ) > 1 ) { |
|
42 | + $this->renderField( 'select', [ |
|
43 | 43 | 'class' => 'widefat', |
44 | - 'label' => __('Which type of review would you like to display?', 'site-reviews'), |
|
44 | + 'label' => __( 'Which type of review would you like to display?', 'site-reviews' ), |
|
45 | 45 | 'name' => 'type', |
46 | - 'options' => ['' => __('All Reviews', 'site-reviews')] + glsr()->reviewTypes, |
|
47 | - ]); |
|
46 | + 'options' => ['' => __( 'All Reviews', 'site-reviews' )] + glsr()->reviewTypes, |
|
47 | + ] ); |
|
48 | 48 | } |
49 | - if (!empty($terms)) { |
|
50 | - $this->renderField('select', [ |
|
49 | + if( !empty($terms) ) { |
|
50 | + $this->renderField( 'select', [ |
|
51 | 51 | 'class' => 'widefat', |
52 | - 'label' => __('Limit reviews to this category', 'site-reviews'), |
|
52 | + 'label' => __( 'Limit reviews to this category', 'site-reviews' ), |
|
53 | 53 | 'name' => 'category', |
54 | - 'options' => ['' => __('All Categories', 'site-reviews')] + $terms, |
|
55 | - ]); |
|
54 | + 'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms, |
|
55 | + ] ); |
|
56 | 56 | } |
57 | - $this->renderField('text', [ |
|
57 | + $this->renderField( 'text', [ |
|
58 | 58 | 'class' => 'widefat', |
59 | 59 | 'default' => '', |
60 | - 'description' => sprintf(__("Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews'), '<code>post_id</code>'), |
|
61 | - 'label' => __('Limit reviews to those assigned to this page/post ID', 'site-reviews'), |
|
60 | + 'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ), |
|
61 | + 'label' => __( 'Limit reviews to those assigned to this page/post ID', 'site-reviews' ), |
|
62 | 62 | 'name' => 'assigned_to', |
63 | - ]); |
|
64 | - $this->renderField('text', [ |
|
63 | + ] ); |
|
64 | + $this->renderField( 'text', [ |
|
65 | 65 | 'class' => 'widefat', |
66 | - 'label' => __('Enter any custom CSS classes here', 'site-reviews'), |
|
66 | + 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
|
67 | 67 | 'name' => 'class', |
68 | - ]); |
|
69 | - $this->renderField('checkbox', [ |
|
68 | + ] ); |
|
69 | + $this->renderField( 'checkbox', [ |
|
70 | 70 | 'name' => 'hide', |
71 | - 'options' => glsr(SiteReviewsShortcode::class)->getHideOptions(), |
|
72 | - ]); |
|
71 | + 'options' => glsr( SiteReviewsShortcode::class )->getHideOptions(), |
|
72 | + ] ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | * @param array $oldInstance |
78 | 78 | * @return array |
79 | 79 | */ |
80 | - public function update($newInstance, $oldInstance) |
|
80 | + public function update( $newInstance, $oldInstance ) |
|
81 | 81 | { |
82 | - if (!is_numeric($newInstance['display'])) { |
|
82 | + if( !is_numeric( $newInstance['display'] ) ) { |
|
83 | 83 | $newInstance['display'] = 10; |
84 | 84 | } |
85 | - $newInstance['display'] = min(50, max(0, intval($newInstance['display']))); |
|
86 | - return parent::update($newInstance, $oldInstance); |
|
85 | + $newInstance['display'] = min( 50, max( 0, intval( $newInstance['display'] ) ) ); |
|
86 | + return parent::update( $newInstance, $oldInstance ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | * @param array $instance |
92 | 92 | * @return void |
93 | 93 | */ |
94 | - public function widget($args, $instance) |
|
94 | + public function widget( $args, $instance ) |
|
95 | 95 | { |
96 | - echo glsr(SiteReviewsShortcode::class)->build($instance, $args, 'widget'); |
|
96 | + echo glsr( SiteReviewsShortcode::class )->build( $instance, $args, 'widget' ); |
|
97 | 97 | } |
98 | 98 | } |