@@ -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,20 +37,20 @@ discard block |
||
37 | 37 | * @return array |
38 | 38 | * @filter manage_.Application::POST_TYPE._posts_columns |
39 | 39 | */ |
40 | - public function filterColumnsForPostType($columns) |
|
40 | + public function filterColumnsForPostType( $columns ) |
|
41 | 41 | { |
42 | - $columns = Arr::consolidateArray($columns); |
|
42 | + $columns = Arr::consolidateArray( $columns ); |
|
43 | 43 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
44 | - foreach ($postTypeColumns as $key => &$value) { |
|
45 | - if (!array_key_exists($key, $columns) || !empty($value)) { |
|
44 | + foreach( $postTypeColumns as $key => &$value ) { |
|
45 | + if( !array_key_exists( $key, $columns ) || !empty($value) ) { |
|
46 | 46 | continue; |
47 | 47 | } |
48 | 48 | $value = $columns[$key]; |
49 | 49 | } |
50 | - if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) { |
|
50 | + if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) { |
|
51 | 51 | unset($postTypeColumns['review_type']); |
52 | 52 | } |
53 | - return array_filter($postTypeColumns, 'strlen'); |
|
53 | + return array_filter( $postTypeColumns, 'strlen' ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * @return string |
60 | 60 | * @filter post_date_column_status |
61 | 61 | */ |
62 | - public function filterDateColumnStatus($status, $post) |
|
62 | + public function filterDateColumnStatus( $status, $post ) |
|
63 | 63 | { |
64 | - if (Application::POST_TYPE == Arr::get($post, 'post_type')) { |
|
65 | - $status = __('Submitted', 'site-reviews'); |
|
64 | + if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) ) { |
|
65 | + $status = __( 'Submitted', 'site-reviews' ); |
|
66 | 66 | } |
67 | 67 | return $status; |
68 | 68 | } |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | * @return array |
74 | 74 | * @filter default_hidden_columns |
75 | 75 | */ |
76 | - public function filterDefaultHiddenColumns($hidden, $screen) |
|
76 | + public function filterDefaultHiddenColumns( $hidden, $screen ) |
|
77 | 77 | { |
78 | - if (Arr::get($screen, 'id') == 'edit-'.Application::POST_TYPE) { |
|
79 | - $hidden = Arr::consolidateArray($hidden); |
|
80 | - $hidden = array_unique(array_merge($hidden, [ |
|
78 | + if( Arr::get( $screen, 'id' ) == 'edit-'.Application::POST_TYPE ) { |
|
79 | + $hidden = Arr::consolidateArray( $hidden ); |
|
80 | + $hidden = array_unique( array_merge( $hidden, [ |
|
81 | 81 | 'email', 'ip_address', 'response', 'reviewer', |
82 | - ])); |
|
82 | + ] ) ); |
|
83 | 83 | } |
84 | 84 | return $hidden; |
85 | 85 | } |
@@ -90,28 +90,28 @@ discard block |
||
90 | 90 | * @return array |
91 | 91 | * @filter post_row_actions |
92 | 92 | */ |
93 | - public function filterRowActions($actions, $post) |
|
93 | + public function filterRowActions( $actions, $post ) |
|
94 | 94 | { |
95 | - if (Application::POST_TYPE != Arr::get($post, 'post_type') || 'trash' == $post->post_status) { |
|
95 | + if( Application::POST_TYPE != Arr::get( $post, 'post_type' ) || 'trash' == $post->post_status ) { |
|
96 | 96 | return $actions; |
97 | 97 | } |
98 | 98 | unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
99 | 99 | $rowActions = [ |
100 | - 'approve' => esc_attr__('Approve', 'site-reviews'), |
|
101 | - 'unapprove' => esc_attr__('Unapprove', 'site-reviews'), |
|
100 | + 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
|
101 | + 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
|
102 | 102 | ]; |
103 | 103 | $newActions = []; |
104 | - foreach ($rowActions as $key => $text) { |
|
105 | - $newActions[$key] = glsr(Builder::class)->a($text, [ |
|
106 | - 'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text), |
|
104 | + foreach( $rowActions as $key => $text ) { |
|
105 | + $newActions[$key] = glsr( Builder::class )->a( $text, [ |
|
106 | + 'aria-label' => sprintf( esc_attr_x( '%s this review', 'Approve the review', 'site-reviews' ), $text ), |
|
107 | 107 | 'class' => 'glsr-change-status', |
108 | 108 | 'href' => wp_nonce_url( |
109 | - admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID), |
|
109 | + admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ), |
|
110 | 110 | $key.'-review_'.$post->ID |
111 | 111 | ), |
112 | - ]); |
|
112 | + ] ); |
|
113 | 113 | } |
114 | - return $newActions + Arr::consolidateArray($actions); |
|
114 | + return $newActions + Arr::consolidateArray( $actions ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | * @return array |
120 | 120 | * @filter manage_edit-.Application::POST_TYPE._sortable_columns |
121 | 121 | */ |
122 | - public function filterSortableColumns($columns) |
|
122 | + public function filterSortableColumns( $columns ) |
|
123 | 123 | { |
124 | - $columns = Arr::consolidateArray($columns); |
|
124 | + $columns = Arr::consolidateArray( $columns ); |
|
125 | 125 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
126 | 126 | unset($postTypeColumns['cb']); |
127 | - foreach ($postTypeColumns as $key => $value) { |
|
128 | - if (Str::startsWith('taxonomy', $key)) { |
|
127 | + foreach( $postTypeColumns as $key => $value ) { |
|
128 | + if( Str::startsWith( 'taxonomy', $key ) ) { |
|
129 | 129 | continue; |
130 | 130 | } |
131 | 131 | $columns[$key] = $key; |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | * @return void |
140 | 140 | * @action bulk_edit_custom_box |
141 | 141 | */ |
142 | - public function renderBulkEditFields($columnName, $postType) |
|
142 | + public function renderBulkEditFields( $columnName, $postType ) |
|
143 | 143 | { |
144 | - if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) { |
|
145 | - glsr()->render('partials/editor/bulk-edit-assigned-to'); |
|
144 | + if( 'assigned_to' == $columnName && Application::POST_TYPE == $postType ) { |
|
145 | + glsr()->render( 'partials/editor/bulk-edit-assigned-to' ); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | * @return void |
152 | 152 | * @action restrict_manage_posts |
153 | 153 | */ |
154 | - public function renderColumnFilters($postType) |
|
154 | + public function renderColumnFilters( $postType ) |
|
155 | 155 | { |
156 | - glsr(Columns::class)->renderFilters($postType); |
|
156 | + glsr( Columns::class )->renderFilters( $postType ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | * @return void |
163 | 163 | * @action manage_posts_custom_column |
164 | 164 | */ |
165 | - public function renderColumnValues($column, $postId) |
|
165 | + public function renderColumnValues( $column, $postId ) |
|
166 | 166 | { |
167 | - glsr(Columns::class)->renderValues($column, $postId); |
|
167 | + glsr( Columns::class )->renderValues( $column, $postId ); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | * @return void |
173 | 173 | * @action save_post_.Application::POST_TYPE |
174 | 174 | */ |
175 | - public function saveBulkEditFields($postId) |
|
175 | + public function saveBulkEditFields( $postId ) |
|
176 | 176 | { |
177 | - if (!current_user_can('edit_posts')) { |
|
177 | + if( !current_user_can( 'edit_posts' ) ) { |
|
178 | 178 | return; |
179 | 179 | } |
180 | - $assignedTo = filter_input(INPUT_GET, 'assigned_to'); |
|
181 | - if ($assignedTo && get_post($assignedTo)) { |
|
182 | - glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
180 | + $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
|
181 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
182 | + glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo ); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | * @return void |
188 | 188 | * @action pre_get_posts |
189 | 189 | */ |
190 | - public function setQueryForColumn(WP_Query $query) |
|
190 | + public function setQueryForColumn( WP_Query $query ) |
|
191 | 191 | { |
192 | - if (!$this->hasPermission($query)) { |
|
192 | + if( !$this->hasPermission( $query ) ) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | - $this->setMetaQuery($query, [ |
|
195 | + $this->setMetaQuery( $query, [ |
|
196 | 196 | 'rating', 'review_type', |
197 | - ]); |
|
198 | - $this->setOrderby($query); |
|
197 | + ] ); |
|
198 | + $this->setOrderby( $query ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -204,15 +204,15 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function unapprove() |
206 | 206 | { |
207 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
207 | + if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) { |
|
208 | 208 | return; |
209 | 209 | } |
210 | - check_admin_referer('unapprove-review_'.($postId = $this->getPostId())); |
|
211 | - wp_update_post([ |
|
210 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
211 | + wp_update_post( [ |
|
212 | 212 | 'ID' => $postId, |
213 | 213 | 'post_status' => 'pending', |
214 | - ]); |
|
215 | - wp_safe_redirect(wp_get_referer()); |
|
214 | + ] ); |
|
215 | + wp_safe_redirect( wp_get_referer() ); |
|
216 | 216 | exit; |
217 | 217 | } |
218 | 218 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @param string $domain |
222 | 222 | * @return bool |
223 | 223 | */ |
224 | - protected function canModifyTranslation($domain = 'default') |
|
224 | + protected function canModifyTranslation( $domain = 'default' ) |
|
225 | 225 | { |
226 | 226 | $screen = glsr_current_screen(); |
227 | 227 | return 'default' == $domain |
@@ -232,48 +232,48 @@ discard block |
||
232 | 232 | /** |
233 | 233 | * @return bool |
234 | 234 | */ |
235 | - protected function hasPermission(WP_Query $query) |
|
235 | + protected function hasPermission( WP_Query $query ) |
|
236 | 236 | { |
237 | 237 | global $pagenow; |
238 | 238 | return is_admin() |
239 | 239 | && $query->is_main_query() |
240 | - && Application::POST_TYPE == $query->get('post_type') |
|
240 | + && Application::POST_TYPE == $query->get( 'post_type' ) |
|
241 | 241 | && 'edit.php' == $pagenow; |
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
245 | 245 | * @return void |
246 | 246 | */ |
247 | - protected function setMetaQuery(WP_Query $query, array $metaKeys) |
|
247 | + protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
|
248 | 248 | { |
249 | - foreach ($metaKeys as $key) { |
|
250 | - $value = (string) filter_input(INPUT_GET, $key); |
|
251 | - if ('' === $value) { |
|
249 | + foreach( $metaKeys as $key ) { |
|
250 | + $value = (string)filter_input( INPUT_GET, $key ); |
|
251 | + if( '' === $value ) { |
|
252 | 252 | continue; |
253 | 253 | } |
254 | - $metaQuery = (array) $query->get('meta_query'); |
|
254 | + $metaQuery = (array)$query->get( 'meta_query' ); |
|
255 | 255 | $metaQuery[] = [ |
256 | - 'key' => Str::prefix('_', $key, '_'), |
|
256 | + 'key' => Str::prefix( '_', $key, '_' ), |
|
257 | 257 | 'value' => $value, |
258 | 258 | ]; |
259 | - $query->set('meta_query', array_filter($metaQuery)); |
|
259 | + $query->set( 'meta_query', array_filter( $metaQuery ) ); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | 264 | * @return void |
265 | 265 | */ |
266 | - protected function setOrderby(WP_Query $query) |
|
266 | + protected function setOrderby( WP_Query $query ) |
|
267 | 267 | { |
268 | - $orderby = $query->get('orderby'); |
|
268 | + $orderby = $query->get( 'orderby' ); |
|
269 | 269 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
270 | 270 | unset($columns['cb'], $columns['title'], $columns['date']); |
271 | - if (in_array($orderby, array_keys($columns))) { |
|
272 | - if ('reviewer' == $orderby) { |
|
271 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
272 | + if( 'reviewer' == $orderby ) { |
|
273 | 273 | $orderby = 'author'; |
274 | 274 | } |
275 | - $query->set('meta_key', Str::prefix('_', $orderby, '_')); |
|
276 | - $query->set('orderby', 'meta_value'); |
|
275 | + $query->set( 'meta_key', Str::prefix( '_', $orderby, '_' ) ); |
|
276 | + $query->set( 'orderby', 'meta_value' ); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | * @param bool $single |
19 | 19 | * @return mixed |
20 | 20 | */ |
21 | - public function get($postId, $key, $single = true) |
|
21 | + public function get( $postId, $key, $single = true ) |
|
22 | 22 | { |
23 | - $key = Str::prefix('_', $key); |
|
24 | - return get_post_meta(intval($postId), $key, $single); |
|
23 | + $key = Str::prefix( '_', $key ); |
|
24 | + return get_post_meta( intval( $postId ), $key, $single ); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * @param string $assignedTo |
30 | 30 | * @return void|WP_Post |
31 | 31 | */ |
32 | - public function getAssignedToPost($postId, $assignedTo = '') |
|
32 | + public function getAssignedToPost( $postId, $assignedTo = '' ) |
|
33 | 33 | { |
34 | - if (empty($assignedTo)) { |
|
35 | - $assignedTo = $this->get($postId, 'assigned_to'); |
|
34 | + if( empty($assignedTo) ) { |
|
35 | + $assignedTo = $this->get( $postId, 'assigned_to' ); |
|
36 | 36 | } |
37 | - if (empty($assignedTo)) { |
|
37 | + if( empty($assignedTo) ) { |
|
38 | 38 | return; |
39 | 39 | } |
40 | - $assignedPost = get_post($assignedTo); |
|
41 | - if ($assignedPost instanceof WP_Post && $assignedPost->ID != $postId) { |
|
40 | + $assignedPost = get_post( $assignedTo ); |
|
41 | + if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
|
42 | 42 | return $assignedPost; |
43 | 43 | } |
44 | 44 | } |
@@ -48,25 +48,25 @@ discard block |
||
48 | 48 | * @param string $metaValue |
49 | 49 | * @return array|int |
50 | 50 | */ |
51 | - public function getReviewCount($metaKey = '', $metaValue = '') |
|
51 | + public function getReviewCount( $metaKey = '', $metaValue = '' ) |
|
52 | 52 | { |
53 | - if (!$metaKey) { |
|
54 | - return (array) wp_count_posts(Application::POST_TYPE); |
|
53 | + if( !$metaKey ) { |
|
54 | + return (array)wp_count_posts( Application::POST_TYPE ); |
|
55 | 55 | } |
56 | - $counts = glsr(Cache::class)->getReviewCountsFor($metaKey); |
|
57 | - if (!$metaValue) { |
|
56 | + $counts = glsr( Cache::class )->getReviewCountsFor( $metaKey ); |
|
57 | + if( !$metaValue ) { |
|
58 | 58 | return $counts; |
59 | 59 | } |
60 | - return Arr::get($counts, $metaValue, 0); |
|
60 | + return Arr::get( $counts, $metaValue, 0 ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param string $metaReviewType |
65 | 65 | * @return array |
66 | 66 | */ |
67 | - public function getReviewIdsByType($metaReviewType) |
|
67 | + public function getReviewIdsByType( $metaReviewType ) |
|
68 | 68 | { |
69 | - return glsr(SqlQueries::class)->getReviewIdsByType($metaReviewType); |
|
69 | + return glsr( SqlQueries::class )->getReviewIdsByType( $metaReviewType ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,21 +74,21 @@ discard block |
||
74 | 74 | * @param string $status |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function getReviewsMeta($key, $status = 'publish') |
|
77 | + public function getReviewsMeta( $key, $status = 'publish' ) |
|
78 | 78 | { |
79 | - return glsr(SqlQueries::class)->getReviewsMeta($key, $status); |
|
79 | + return glsr( SqlQueries::class )->getReviewsMeta( $key, $status ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * @param string $field |
84 | 84 | * @return array |
85 | 85 | */ |
86 | - public function getTermIds(array $values, $field) |
|
86 | + public function getTermIds( array $values, $field ) |
|
87 | 87 | { |
88 | 88 | $termIds = []; |
89 | - foreach ($values as $value) { |
|
90 | - $term = get_term_by($field, $value, Application::TAXONOMY); |
|
91 | - if (!isset($term->term_id)) { |
|
89 | + foreach( $values as $value ) { |
|
90 | + $term = get_term_by( $field, $value, Application::TAXONOMY ); |
|
91 | + if( !isset($term->term_id) ) { |
|
92 | 92 | continue; |
93 | 93 | } |
94 | 94 | $termIds[] = $term->term_id; |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * @return array |
101 | 101 | */ |
102 | - public function getTerms(array $args = []) |
|
102 | + public function getTerms( array $args = [] ) |
|
103 | 103 | { |
104 | - $args = wp_parse_args($args, [ |
|
104 | + $args = wp_parse_args( $args, [ |
|
105 | 105 | 'count' => false, |
106 | 106 | 'fields' => 'id=>name', |
107 | 107 | 'hide_empty' => false, |
108 | 108 | 'taxonomy' => Application::TAXONOMY, |
109 | - ]); |
|
110 | - $terms = get_terms($args); |
|
111 | - if (is_wp_error($terms)) { |
|
112 | - glsr_log()->error($terms->get_error_message()); |
|
109 | + ] ); |
|
110 | + $terms = get_terms( $args ); |
|
111 | + if( is_wp_error( $terms ) ) { |
|
112 | + glsr_log()->error( $terms->get_error_message() ); |
|
113 | 113 | return []; |
114 | 114 | } |
115 | 115 | return $terms; |
@@ -119,36 +119,36 @@ discard block |
||
119 | 119 | * @param string $searchTerm |
120 | 120 | * @return void|string |
121 | 121 | */ |
122 | - public function searchPosts($searchTerm) |
|
122 | + public function searchPosts( $searchTerm ) |
|
123 | 123 | { |
124 | 124 | $args = [ |
125 | 125 | 'post_status' => 'publish', |
126 | 126 | 'post_type' => 'any', |
127 | 127 | ]; |
128 | - if (is_numeric($searchTerm)) { |
|
128 | + if( is_numeric( $searchTerm ) ) { |
|
129 | 129 | $args['post__in'] = [$searchTerm]; |
130 | 130 | } else { |
131 | 131 | $args['orderby'] = 'relevance'; |
132 | 132 | $args['posts_per_page'] = 10; |
133 | 133 | $args['s'] = $searchTerm; |
134 | 134 | } |
135 | - $queryBuilder = glsr(QueryBuilder::class); |
|
136 | - add_filter('posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2); |
|
137 | - $search = new WP_Query($args); |
|
138 | - remove_filter('posts_search', [$queryBuilder, 'filterSearchByTitle'], 500); |
|
139 | - if (!$search->have_posts()) { |
|
135 | + $queryBuilder = glsr( QueryBuilder::class ); |
|
136 | + add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
|
137 | + $search = new WP_Query( $args ); |
|
138 | + remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
|
139 | + if( !$search->have_posts() ) { |
|
140 | 140 | return; |
141 | 141 | } |
142 | 142 | $results = ''; |
143 | - while ($search->have_posts()) { |
|
143 | + while( $search->have_posts() ) { |
|
144 | 144 | $search->the_post(); |
145 | 145 | ob_start(); |
146 | - glsr()->render('partials/editor/search-result', [ |
|
146 | + glsr()->render( 'partials/editor/search-result', [ |
|
147 | 147 | 'ID' => get_the_ID(), |
148 | - 'permalink' => esc_url((string) get_permalink()), |
|
149 | - 'title' => esc_attr(get_the_title()), |
|
150 | - ]); |
|
151 | - $results.= ob_get_clean(); |
|
148 | + 'permalink' => esc_url( (string)get_permalink() ), |
|
149 | + 'title' => esc_attr( get_the_title() ), |
|
150 | + ] ); |
|
151 | + $results .= ob_get_clean(); |
|
152 | 152 | } |
153 | 153 | wp_reset_postdata(); |
154 | 154 | return $results; |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | * @param mixed $value |
161 | 161 | * @return int|bool |
162 | 162 | */ |
163 | - public function set($postId, $key, $value) |
|
163 | + public function set( $postId, $key, $value ) |
|
164 | 164 | { |
165 | - $key = Str::prefix('_', $key); |
|
166 | - return update_post_meta($postId, $key, $value); |
|
165 | + $key = Str::prefix( '_', $key ); |
|
166 | + return update_post_meta( $postId, $key, $value ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @param mixed $value |
173 | 173 | * @return int|bool |
174 | 174 | */ |
175 | - public function update($postId, $key, $value) |
|
175 | + public function update( $postId, $key, $value ) |
|
176 | 176 | { |
177 | - return $this->set($postId, $key, $value); |
|
177 | + return $this->set( $postId, $key, $value ); |
|
178 | 178 | } |
179 | 179 | } |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | protected function hideOptions() |
10 | 10 | { |
11 | 11 | return [ |
12 | - 'rating' => __('Hide the rating field', 'site-reviews'), |
|
13 | - 'title' => __('Hide the title field', 'site-reviews'), |
|
14 | - 'content' => __('Hide the review field', 'site-reviews'), |
|
15 | - 'name' => __('Hide the name field', 'site-reviews'), |
|
16 | - 'email' => __('Hide the email field', 'site-reviews'), |
|
17 | - 'terms' => __('Hide the terms field', 'site-reviews'), |
|
12 | + 'rating' => __( 'Hide the rating field', 'site-reviews' ), |
|
13 | + 'title' => __( 'Hide the title field', 'site-reviews' ), |
|
14 | + 'content' => __( 'Hide the review field', 'site-reviews' ), |
|
15 | + 'name' => __( 'Hide the name field', 'site-reviews' ), |
|
16 | + 'email' => __( 'Hide the email field', 'site-reviews' ), |
|
17 | + 'terms' => __( 'Hide the terms field', 'site-reviews' ), |
|
18 | 18 | ]; |
19 | 19 | } |
20 | 20 | |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | * @param string $type |
24 | 24 | * @return array |
25 | 25 | */ |
26 | - public function normalizeAtts($atts, $type = 'shortcode') |
|
26 | + public function normalizeAtts( $atts, $type = 'shortcode' ) |
|
27 | 27 | { |
28 | - $atts = parent::normalizeAtts($atts, $type); |
|
29 | - if (empty($atts['id'])) { |
|
30 | - $atts['id'] = Application::PREFIX.substr(md5(serialize($atts)), 0, 8); |
|
28 | + $atts = parent::normalizeAtts( $atts, $type ); |
|
29 | + if( empty($atts['id']) ) { |
|
30 | + $atts['id'] = Application::PREFIX.substr( md5( serialize( $atts ) ), 0, 8 ); |
|
31 | 31 | } |
32 | 32 | return $atts; |
33 | 33 | } |
@@ -16,19 +16,19 @@ discard block |
||
16 | 16 | * Build a WP_Query meta_query/tax_query. |
17 | 17 | * @return array |
18 | 18 | */ |
19 | - public function buildQuery(array $keys = [], array $values = []) |
|
19 | + public function buildQuery( array $keys = [], array $values = [] ) |
|
20 | 20 | { |
21 | 21 | $queries = []; |
22 | - foreach ($keys as $key) { |
|
23 | - if (!array_key_exists($key, $values)) { |
|
22 | + foreach( $keys as $key ) { |
|
23 | + if( !array_key_exists( $key, $values ) ) { |
|
24 | 24 | continue; |
25 | 25 | } |
26 | - $methodName = Helper::buildMethodName($key, __FUNCTION__); |
|
27 | - if (!method_exists($this, $methodName)) { |
|
26 | + $methodName = Helper::buildMethodName( $key, __FUNCTION__ ); |
|
27 | + if( !method_exists( $this, $methodName ) ) { |
|
28 | 28 | continue; |
29 | 29 | } |
30 | - $query = call_user_func([$this, $methodName], $values[$key]); |
|
31 | - if (is_array($query)) { |
|
30 | + $query = call_user_func( [$this, $methodName], $values[$key] ); |
|
31 | + if( is_array( $query ) ) { |
|
32 | 32 | $queries[] = $query; |
33 | 33 | } |
34 | 34 | } |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - public function buildSqlLines(array $values, array $conditions) |
|
41 | + public function buildSqlLines( array $values, array $conditions ) |
|
42 | 42 | { |
43 | 43 | $string = ''; |
44 | - $values = array_filter($values); |
|
45 | - foreach ($conditions as $key => $value) { |
|
46 | - if (!isset($values[$key])) { |
|
44 | + $values = array_filter( $values ); |
|
45 | + foreach( $conditions as $key => $value ) { |
|
46 | + if( !isset($values[$key]) ) { |
|
47 | 47 | continue; |
48 | 48 | } |
49 | - $values[$key] = implode(',', (array) $values[$key]); |
|
50 | - $string.= Str::contains($value, '%s') |
|
51 | - ? sprintf($value, strval($values[$key])) |
|
49 | + $values[$key] = implode( ',', (array)$values[$key] ); |
|
50 | + $string .= Str::contains( $value, '%s' ) |
|
51 | + ? sprintf( $value, strval( $values[$key] ) ) |
|
52 | 52 | : $value; |
53 | 53 | } |
54 | 54 | return $string; |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | * @param string $sprintfFormat |
61 | 61 | * @return string |
62 | 62 | */ |
63 | - public function buildSqlOr($values, $sprintfFormat) |
|
63 | + public function buildSqlOr( $values, $sprintfFormat ) |
|
64 | 64 | { |
65 | - if (!is_array($values)) { |
|
66 | - $values = explode(',', $values); |
|
65 | + if( !is_array( $values ) ) { |
|
66 | + $values = explode( ',', $values ); |
|
67 | 67 | } |
68 | - $values = array_filter(array_map('trim', (array) $values)); |
|
69 | - $values = array_map(function ($value) use ($sprintfFormat) { |
|
70 | - return sprintf($sprintfFormat, $value); |
|
71 | - }, $values); |
|
72 | - return implode(' OR ', $values); |
|
68 | + $values = array_filter( array_map( 'trim', (array)$values ) ); |
|
69 | + $values = array_map( function( $value ) use ($sprintfFormat) { |
|
70 | + return sprintf( $sprintfFormat, $value ); |
|
71 | + }, $values ); |
|
72 | + return implode( ' OR ', $values ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -79,23 +79,23 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | * @filter posts_search |
81 | 81 | */ |
82 | - public function filterSearchByTitle($search, WP_Query $query) |
|
82 | + public function filterSearchByTitle( $search, WP_Query $query ) |
|
83 | 83 | { |
84 | - if (empty($search) || empty($query->get('search_terms'))) { |
|
84 | + if( empty($search) || empty($query->get( 'search_terms' )) ) { |
|
85 | 85 | return $search; |
86 | 86 | } |
87 | 87 | global $wpdb; |
88 | - $n = empty($query->get('exact')) |
|
88 | + $n = empty($query->get( 'exact' )) |
|
89 | 89 | ? '%' |
90 | 90 | : ''; |
91 | 91 | $search = []; |
92 | - foreach ((array) $query->get('search_terms') as $term) { |
|
93 | - $search[] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like($term).$n); |
|
92 | + foreach( (array)$query->get( 'search_terms' ) as $term ) { |
|
93 | + $search[] = $wpdb->prepare( "{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like( $term ).$n ); |
|
94 | 94 | } |
95 | - if (!is_user_logged_in()) { |
|
95 | + if( !is_user_logged_in() ) { |
|
96 | 96 | $search[] = "{$wpdb->posts}.post_password = ''"; |
97 | 97 | } |
98 | - return ' AND '.implode(' AND ', $search); |
|
98 | + return ' AND '.implode( ' AND ', $search ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * @param bool $isEnabled |
104 | 104 | * @return int |
105 | 105 | */ |
106 | - public function getPaged($isEnabled = true) |
|
106 | + public function getPaged( $isEnabled = true ) |
|
107 | 107 | { |
108 | 108 | return $isEnabled |
109 | - ? max(1, intval(filter_input(INPUT_GET, glsr()->constant('PAGED_QUERY_VAR')))) |
|
109 | + ? max( 1, intval( filter_input( INPUT_GET, glsr()->constant( 'PAGED_QUERY_VAR' ) ) ) ) |
|
110 | 110 | : 1; |
111 | 111 | } |
112 | 112 | |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * @param string $value |
115 | 115 | * @return void|array |
116 | 116 | */ |
117 | - protected function buildQueryAssignedTo($value) |
|
117 | + protected function buildQueryAssignedTo( $value ) |
|
118 | 118 | { |
119 | - if (!empty($value)) { |
|
120 | - $postIds = Arr::convertStringToArray($value, 'is_numeric'); |
|
119 | + if( !empty($value) ) { |
|
120 | + $postIds = Arr::convertStringToArray( $value, 'is_numeric' ); |
|
121 | 121 | return [ |
122 | 122 | 'compare' => 'IN', |
123 | 123 | 'key' => '_assigned_to', |
124 | - 'value' => glsr(Multilingual::class)->getPostIds($postIds), |
|
124 | + 'value' => glsr( Multilingual::class )->getPostIds( $postIds ), |
|
125 | 125 | ]; |
126 | 126 | } |
127 | 127 | } |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | * @param array $value |
131 | 131 | * @return void|array |
132 | 132 | */ |
133 | - protected function buildQueryCategory($value) |
|
133 | + protected function buildQueryCategory( $value ) |
|
134 | 134 | { |
135 | - if (!empty($value)) { |
|
135 | + if( !empty($value) ) { |
|
136 | 136 | return [ |
137 | 137 | 'field' => 'term_id', |
138 | 138 | 'taxonomy' => Application::TAXONOMY, |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * @param string $value |
146 | 146 | * @return void|array |
147 | 147 | */ |
148 | - protected function buildQueryEmail($value) |
|
148 | + protected function buildQueryEmail( $value ) |
|
149 | 149 | { |
150 | - if (!empty($value)) { |
|
150 | + if( !empty($value) ) { |
|
151 | 151 | return [ |
152 | 152 | 'key' => '_email', |
153 | 153 | 'value' => $value, |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | * @param string $value |
160 | 160 | * @return void|array |
161 | 161 | */ |
162 | - protected function buildQueryIpAddress($value) |
|
162 | + protected function buildQueryIpAddress( $value ) |
|
163 | 163 | { |
164 | - if (!empty($value)) { |
|
164 | + if( !empty($value) ) { |
|
165 | 165 | return [ |
166 | 166 | 'key' => '_ip_address', |
167 | 167 | 'value' => $value, |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | * @param string $value |
174 | 174 | * @return void|array |
175 | 175 | */ |
176 | - protected function buildQueryRating($value) |
|
176 | + protected function buildQueryRating( $value ) |
|
177 | 177 | { |
178 | - if (is_numeric($value) |
|
179 | - && in_array(intval($value), range(1, glsr()->constant('MAX_RATING', Rating::class)))) { |
|
178 | + if( is_numeric( $value ) |
|
179 | + && in_array( intval( $value ), range( 1, glsr()->constant( 'MAX_RATING', Rating::class ) ) ) ) { |
|
180 | 180 | return [ |
181 | 181 | 'compare' => '>=', |
182 | 182 | 'key' => '_rating', |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * @param string $value |
190 | 190 | * @return void|array |
191 | 191 | */ |
192 | - protected function buildQueryType($value) |
|
192 | + protected function buildQueryType( $value ) |
|
193 | 193 | { |
194 | - if (!in_array($value, ['', 'all'])) { |
|
194 | + if( !in_array( $value, ['', 'all'] ) ) { |
|
195 | 195 | return [ |
196 | 196 | 'key' => '_review_type', |
197 | 197 | 'value' => $value, |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @return bool |
9 | 9 | */ |
10 | - public static function compareArrays(array $arr1, array $arr2) |
|
10 | + public static function compareArrays( array $arr1, array $arr2 ) |
|
11 | 11 | { |
12 | - sort($arr1); |
|
13 | - sort($arr2); |
|
12 | + sort( $arr1 ); |
|
13 | + sort( $arr2 ); |
|
14 | 14 | return $arr1 == $arr2; |
15 | 15 | } |
16 | 16 | |
@@ -18,21 +18,21 @@ discard block |
||
18 | 18 | * @param mixed $array |
19 | 19 | * @return array |
20 | 20 | */ |
21 | - public static function consolidateArray($array) |
|
21 | + public static function consolidateArray( $array ) |
|
22 | 22 | { |
23 | - return is_array($array) || is_object($array) |
|
24 | - ? (array) $array |
|
23 | + return is_array( $array ) || is_object( $array ) |
|
24 | + ? (array)$array |
|
25 | 25 | : []; |
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @return array |
30 | 30 | */ |
31 | - public static function convertDotNotationArray(array $array) |
|
31 | + public static function convertDotNotationArray( array $array ) |
|
32 | 32 | { |
33 | 33 | $results = []; |
34 | - foreach ($array as $path => $value) { |
|
35 | - $results = static::set($results, $path, $value); |
|
34 | + foreach( $array as $path => $value ) { |
|
35 | + $results = static::set( $results, $path, $value ); |
|
36 | 36 | } |
37 | 37 | return $results; |
38 | 38 | } |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @param mixed $callback |
43 | 43 | * @return array |
44 | 44 | */ |
45 | - public static function convertStringToArray($string, $callback = null) |
|
45 | + public static function convertStringToArray( $string, $callback = null ) |
|
46 | 46 | { |
47 | - $array = array_map('trim', explode(',', $string)); |
|
47 | + $array = array_map( 'trim', explode( ',', $string ) ); |
|
48 | 48 | return $callback |
49 | - ? array_filter($array, $callback) |
|
50 | - : array_filter($array); |
|
49 | + ? array_filter( $array, $callback ) |
|
50 | + : array_filter( $array ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | * @param string $prefix |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public static function flattenArray(array $array, $flattenValue = false, $prefix = '') |
|
58 | + public static function flattenArray( array $array, $flattenValue = false, $prefix = '' ) |
|
59 | 59 | { |
60 | 60 | $result = []; |
61 | - foreach ($array as $key => $value) { |
|
62 | - $newKey = ltrim($prefix.'.'.$key, '.'); |
|
63 | - if (static::isIndexedFlatArray($value)) { |
|
64 | - if ($flattenValue) { |
|
65 | - $value = '['.implode(', ', $value).']'; |
|
61 | + foreach( $array as $key => $value ) { |
|
62 | + $newKey = ltrim( $prefix.'.'.$key, '.' ); |
|
63 | + if( static::isIndexedFlatArray( $value ) ) { |
|
64 | + if( $flattenValue ) { |
|
65 | + $value = '['.implode( ', ', $value ).']'; |
|
66 | 66 | } |
67 | - } elseif (is_array($value)) { |
|
68 | - $result = array_merge($result, static::flattenArray($value, $flattenValue, $newKey)); |
|
67 | + } elseif( is_array( $value ) ) { |
|
68 | + $result = array_merge( $result, static::flattenArray( $value, $flattenValue, $newKey ) ); |
|
69 | 69 | continue; |
70 | 70 | } |
71 | 71 | $result[$newKey] = $value; |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | * @param mixed $fallback |
81 | 81 | * @return mixed |
82 | 82 | */ |
83 | - public static function get($data, $path = '', $fallback = '') |
|
83 | + public static function get( $data, $path = '', $fallback = '' ) |
|
84 | 84 | { |
85 | - $data = static::consolidateArray($data); |
|
86 | - $keys = explode('.', $path); |
|
87 | - foreach ($keys as $key) { |
|
88 | - if (!isset($data[$key])) { |
|
85 | + $data = static::consolidateArray( $data ); |
|
86 | + $keys = explode( '.', $path ); |
|
87 | + foreach( $keys as $key ) { |
|
88 | + if( !isset($data[$key]) ) { |
|
89 | 89 | return $fallback; |
90 | 90 | } |
91 | 91 | $data = $data[$key]; |
@@ -98,47 +98,47 @@ discard block |
||
98 | 98 | * @param string $position |
99 | 99 | * @return array |
100 | 100 | */ |
101 | - public static function insertInArray(array $array, array $insert, $key, $position = 'before') |
|
101 | + public static function insertInArray( array $array, array $insert, $key, $position = 'before' ) |
|
102 | 102 | { |
103 | - $keyPosition = intval(array_search($key, array_keys($array))); |
|
104 | - if ('after' == $position) { |
|
103 | + $keyPosition = intval( array_search( $key, array_keys( $array ) ) ); |
|
104 | + if( 'after' == $position ) { |
|
105 | 105 | ++$keyPosition; |
106 | 106 | } |
107 | - if (false !== $keyPosition) { |
|
108 | - $result = array_slice($array, 0, $keyPosition); |
|
109 | - $result = array_merge($result, $insert); |
|
110 | - return array_merge($result, array_slice($array, $keyPosition)); |
|
107 | + if( false !== $keyPosition ) { |
|
108 | + $result = array_slice( $array, 0, $keyPosition ); |
|
109 | + $result = array_merge( $result, $insert ); |
|
110 | + return array_merge( $result, array_slice( $array, $keyPosition ) ); |
|
111 | 111 | } |
112 | - return array_merge($array, $insert); |
|
112 | + return array_merge( $array, $insert ); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | 116 | * @param mixed $array |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | - public static function isIndexedFlatArray($array) |
|
119 | + public static function isIndexedFlatArray( $array ) |
|
120 | 120 | { |
121 | - if (!is_array($array) || array_filter($array, 'is_array')) { |
|
121 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | - return wp_is_numeric_array($array); |
|
124 | + return wp_is_numeric_array( $array ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * @param bool $prefixed |
129 | 129 | * @return array |
130 | 130 | */ |
131 | - public static function prefixArrayKeys(array $values, $prefixed = true) |
|
131 | + public static function prefixArrayKeys( array $values, $prefixed = true ) |
|
132 | 132 | { |
133 | 133 | $trim = '_'; |
134 | 134 | $prefix = $prefixed |
135 | 135 | ? $trim |
136 | 136 | : ''; |
137 | 137 | $prefixed = []; |
138 | - foreach ($values as $key => $value) { |
|
139 | - $key = trim($key); |
|
140 | - if (0 === strpos($key, $trim)) { |
|
141 | - $key = substr($key, strlen($trim)); |
|
138 | + foreach( $values as $key => $value ) { |
|
139 | + $key = trim( $key ); |
|
140 | + if( 0 === strpos( $key, $trim ) ) { |
|
141 | + $key = substr( $key, strlen( $trim ) ); |
|
142 | 142 | } |
143 | 143 | $prefixed[$prefix.$key] = $value; |
144 | 144 | } |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | /** |
149 | 149 | * @return array |
150 | 150 | */ |
151 | - public static function removeEmptyArrayValues(array $array) |
|
151 | + public static function removeEmptyArrayValues( array $array ) |
|
152 | 152 | { |
153 | 153 | $result = []; |
154 | - foreach ($array as $key => $value) { |
|
155 | - if (!$value) { |
|
154 | + foreach( $array as $key => $value ) { |
|
155 | + if( !$value ) { |
|
156 | 156 | continue; |
157 | 157 | } |
158 | - $result[$key] = is_array($value) |
|
159 | - ? static::removeEmptyArrayValues($value) |
|
158 | + $result[$key] = is_array( $value ) |
|
159 | + ? static::removeEmptyArrayValues( $value ) |
|
160 | 160 | : $value; |
161 | 161 | } |
162 | 162 | return $result; |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | * @param mixed $value |
170 | 170 | * @return array |
171 | 171 | */ |
172 | - public static function set(array $data, $path, $value) |
|
172 | + public static function set( array $data, $path, $value ) |
|
173 | 173 | { |
174 | - $token = strtok($path, '.'); |
|
174 | + $token = strtok( $path, '.' ); |
|
175 | 175 | $ref = &$data; |
176 | - while (false !== $token) { |
|
177 | - $ref = static::consolidateArray($ref); |
|
176 | + while( false !== $token ) { |
|
177 | + $ref = static::consolidateArray( $ref ); |
|
178 | 178 | $ref = &$ref[$token]; |
179 | - $token = strtok('.'); |
|
179 | + $token = strtok( '.' ); |
|
180 | 180 | } |
181 | 181 | $ref = $value; |
182 | 182 | return $data; |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | /** |
186 | 186 | * @return array |
187 | 187 | */ |
188 | - public static function unique(array $values) |
|
188 | + public static function unique( array $values ) |
|
189 | 189 | { |
190 | - return array_filter(array_unique($values)); |
|
190 | + return array_filter( array_unique( $values ) ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @return array |
195 | 195 | */ |
196 | - public static function unprefixArrayKeys(array $values) |
|
196 | + public static function unprefixArrayKeys( array $values ) |
|
197 | 197 | { |
198 | - return static::prefixArrayKeys($values, false); |
|
198 | + return static::prefixArrayKeys( $values, false ); |
|
199 | 199 | } |
200 | 200 | } |
@@ -21,29 +21,29 @@ discard block |
||
21 | 21 | * @param array $args |
22 | 22 | * @return |
23 | 23 | */ |
24 | - public function __call($method, $args = []) |
|
24 | + public function __call( $method, $args = [] ) |
|
25 | 25 | { |
26 | - if ($this->isIntegrated() && method_exists($this->integration, $method)) { |
|
27 | - return call_user_func_array([$this->integration, $method], $args); |
|
26 | + if( $this->isIntegrated() && method_exists( $this->integration, $method ) ) { |
|
27 | + return call_user_func_array( [$this->integration, $method], $args ); |
|
28 | 28 | } |
29 | - return Arr::get($args, 0, false); |
|
29 | + return Arr::get( $args, 0, false ); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @param string $integration |
34 | 34 | * @return false|\GeminiLabs\SiteReviews\Modules\Multilingual\Polylang|\GeminiLabs\SiteReviews\Modules\Multilingual\Wpml |
35 | 35 | */ |
36 | - public function getIntegration($integration = '') |
|
36 | + public function getIntegration( $integration = '' ) |
|
37 | 37 | { |
38 | - if (empty($integration)) { |
|
39 | - $integration = glsr(OptionManager::class)->get('settings.general.multilingual'); |
|
38 | + if( empty($integration) ) { |
|
39 | + $integration = glsr( OptionManager::class )->get( 'settings.general.multilingual' ); |
|
40 | 40 | } |
41 | - if (!empty($integration)) { |
|
42 | - $integrationClass = 'GeminiLabs\SiteReviews\Modules\Multilingual\\'.ucfirst($integration); |
|
43 | - if (class_exists($integrationClass)) { |
|
44 | - return glsr($integrationClass); |
|
41 | + if( !empty($integration) ) { |
|
42 | + $integrationClass = 'GeminiLabs\SiteReviews\Modules\Multilingual\\'.ucfirst( $integration ); |
|
43 | + if( class_exists( $integrationClass ) ) { |
|
44 | + return glsr( $integrationClass ); |
|
45 | 45 | } |
46 | - glsr_log()->error($integrationClass.' does not exist'); |
|
46 | + glsr_log()->error( $integrationClass.' does not exist' ); |
|
47 | 47 | } |
48 | 48 | return false; |
49 | 49 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function isIntegrated() |
55 | 55 | { |
56 | - if (!empty($this->integration)) { |
|
56 | + if( !empty($this->integration) ) { |
|
57 | 57 | return true; |
58 | 58 | } |
59 | - if ($integration = $this->getIntegration()) { |
|
59 | + if( $integration = $this->getIntegration() ) { |
|
60 | 60 | $this->integration = $integration; |
61 | 61 | return true; |
62 | 62 | } |
@@ -1,22 +1,22 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<p><?= sprintf(__('Here you can customise any text of the plugin, including the submission form labels and placeholders. However, if you have a multilingual website you should use the %s plugin instead.', 'site-reviews'), '<a href="https://wordpress.org/plugins/loco-translate/">Loco Translate</a>'); ?></p> |
|
3 | +<p><?= sprintf( __( 'Here you can customise any text of the plugin, including the submission form labels and placeholders. However, if you have a multilingual website you should use the %s plugin instead.', 'site-reviews' ), '<a href="https://wordpress.org/plugins/loco-translate/">Loco Translate</a>' ); ?></p> |
|
4 | 4 | |
5 | 5 | <div class="glsr-strings-form"> |
6 | 6 | <div class="glsr-search-box" id="glsr-search-translations"> |
7 | - <span class="screen-reader-text"><?= __('Search for translatable text', 'site-reviews'); ?></span> |
|
7 | + <span class="screen-reader-text"><?= __( 'Search for translatable text', 'site-reviews' ); ?></span> |
|
8 | 8 | <div class="glsr-spinner"> |
9 | 9 | <span class="spinner"></span> |
10 | 10 | </div> |
11 | - <input type="search" class="glsr-search-input" autocomplete="off" placeholder="<?= __('Search here for text to translate...', 'site-reviews'); ?>"> |
|
12 | - <?php wp_nonce_field('search-translations', '_search_nonce', false); ?> |
|
11 | + <input type="search" class="glsr-search-input" autocomplete="off" placeholder="<?= __( 'Search here for text to translate...', 'site-reviews' ); ?>"> |
|
12 | + <?php wp_nonce_field( 'search-translations', '_search_nonce', false ); ?> |
|
13 | 13 | <div class="glsr-search-results" data-prefix="{{ database_key }}"></div> |
14 | 14 | </div> |
15 | 15 | <table class="glsr-strings-table wp-list-table widefat striped {{ class }}"> |
16 | 16 | <thead> |
17 | 17 | <tr> |
18 | - <th scope="col" class="manage-column column-primary"><?= __('Original Text', 'site-reviews'); ?></th> |
|
19 | - <th scope="col" class="manage-column"><?= __('Custom Translation', 'site-reviews'); ?></th> |
|
18 | + <th scope="col" class="manage-column column-primary"><?= __( 'Original Text', 'site-reviews' ); ?></th> |
|
19 | + <th scope="col" class="manage-column"><?= __( 'Custom Translation', 'site-reviews' ); ?></th> |
|
20 | 20 | </tr> |
21 | 21 | </thead> |
22 | 22 | <tbody>{{ translations }}</tbody> |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | </div> |
26 | 26 | |
27 | 27 | <script type="text/html" id="tmpl-glsr-string-plural"> |
28 | -<?php include glsr()->path('views/partials/translations/plural.php'); ?> |
|
28 | +<?php include glsr()->path( 'views/partials/translations/plural.php' ); ?> |
|
29 | 29 | </script> |
30 | 30 | <script type="text/html" id="tmpl-glsr-string-single"> |
31 | -<?php include glsr()->path('views/partials/translations/single.php'); ?> |
|
31 | +<?php include glsr()->path( 'views/partials/translations/single.php' ); ?> |
|
32 | 32 | </script> |
@@ -14,26 +14,26 @@ discard block |
||
14 | 14 | * @return array |
15 | 15 | * @filter site-reviews/get/reviews/query |
16 | 16 | */ |
17 | - public function filterReviewsQuery(array $parameters, array $args) |
|
17 | + public function filterReviewsQuery( array $parameters, array $args ) |
|
18 | 18 | { |
19 | - if ($authorId = get_current_user_id()) { |
|
19 | + if( $authorId = get_current_user_id() ) { |
|
20 | 20 | $parameters['author'] = $authorId; |
21 | 21 | } |
22 | 22 | $parameters['post_status'] = ['pending', 'publish']; |
23 | - return apply_filters('site-reviews/review-limits/query', $parameters, $args); |
|
23 | + return apply_filters( 'site-reviews/review-limits/query', $parameters, $args ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @return bool |
28 | 28 | */ |
29 | - public function hasReachedLimit(array $request = []) |
|
29 | + public function hasReachedLimit( array $request = [] ) |
|
30 | 30 | { |
31 | 31 | $this->request = $request; |
32 | 32 | $method = Helper::buildMethodName( |
33 | - glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy' |
|
33 | + glsr( OptionManager::class )->get( 'settings.submissions.limit' ), 'validateBy' |
|
34 | 34 | ); |
35 | - return method_exists($this, $method) |
|
36 | - ? !call_user_func([$this, $method]) |
|
35 | + return method_exists( $this, $method ) |
|
36 | + ? !call_user_func( [$this, $method] ) |
|
37 | 37 | : false; |
38 | 38 | } |
39 | 39 | |
@@ -42,41 +42,41 @@ discard block |
||
42 | 42 | * @param string $whitelist |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function isWhitelisted($value, $whitelist) |
|
45 | + public function isWhitelisted( $value, $whitelist ) |
|
46 | 46 | { |
47 | - if (empty($whitelist)) { |
|
47 | + if( empty($whitelist) ) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | - return in_array($value, array_filter(explode("\n", $whitelist), 'trim')); |
|
50 | + return in_array( $value, array_filter( explode( "\n", $whitelist ), 'trim' ) ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param string $whitelistName |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - protected function getWhitelist($whitelistName) |
|
57 | + protected function getWhitelist( $whitelistName ) |
|
58 | 58 | { |
59 | - return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName); |
|
59 | + return glsr( OptionManager::class )->get( 'settings.submissions.limit_whitelist.'.$whitelistName ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @return bool |
64 | 64 | */ |
65 | - protected function validate($key, $value, $addMetaQuery = true) |
|
65 | + protected function validate( $key, $value, $addMetaQuery = true ) |
|
66 | 66 | { |
67 | - if ($this->isWhitelisted($value, $this->getWhitelist($key))) { |
|
67 | + if( $this->isWhitelisted( $value, $this->getWhitelist( $key ) ) ) { |
|
68 | 68 | return true; |
69 | 69 | } |
70 | - add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2); |
|
71 | - $args = ['assigned_to' => Arr::get($this->request, 'assign_to')]; |
|
72 | - if ($addMetaQuery) { |
|
70 | + add_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2 ); |
|
71 | + $args = ['assigned_to' => Arr::get( $this->request, 'assign_to' )]; |
|
72 | + if( $addMetaQuery ) { |
|
73 | 73 | $args[$key] = $value; |
74 | 74 | } |
75 | - $reviews = glsr_get_reviews($args); |
|
76 | - remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5); |
|
77 | - $result = 0 === count($reviews); |
|
78 | - $result = apply_filters('site-reviews/review-limits/validate', $result, $reviews, $this->request, $key); |
|
79 | - return wp_validate_boolean($result); |
|
75 | + $reviews = glsr_get_reviews( $args ); |
|
76 | + remove_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5 ); |
|
77 | + $result = 0 === count( $reviews ); |
|
78 | + $result = apply_filters( 'site-reviews/review-limits/validate', $result, $reviews, $this->request, $key ); |
|
79 | + return wp_validate_boolean( $result ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function validateByEmail() |
86 | 86 | { |
87 | - glsr_log()->debug('Email is: '.Arr::get($this->request, 'email')); |
|
88 | - return $this->validate('email', Arr::get($this->request, 'email')); |
|
87 | + glsr_log()->debug( 'Email is: '.Arr::get( $this->request, 'email' ) ); |
|
88 | + return $this->validate( 'email', Arr::get( $this->request, 'email' ) ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | */ |
94 | 94 | protected function validateByIpAddress() |
95 | 95 | { |
96 | - glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address')); |
|
97 | - return $this->validate('ip_address', Arr::get($this->request, 'ip_address')); |
|
96 | + glsr_log()->debug( 'IP Address is: '.Arr::get( $this->request, 'ip_address' ) ); |
|
97 | + return $this->validate( 'ip_address', Arr::get( $this->request, 'ip_address' ) ); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | protected function validateByUsername() |
104 | 104 | { |
105 | 105 | $user = wp_get_current_user(); |
106 | - if (!$user->exists()) { |
|
106 | + if( !$user->exists() ) { |
|
107 | 107 | return true; |
108 | 108 | } |
109 | - glsr_log()->debug('Username is: '.$user->user_login); |
|
110 | - return $this->validate('username', $user->user_login, false); |
|
109 | + glsr_log()->debug( 'Username is: '.$user->user_login ); |
|
110 | + return $this->validate( 'username', $user->user_login, false ); |
|
111 | 111 | } |
112 | 112 | } |
@@ -14,44 +14,44 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * {@inheritdoc} |
16 | 16 | */ |
17 | - public function getPostId($postId) |
|
17 | + public function getPostId( $postId ) |
|
18 | 18 | { |
19 | - $postId = trim($postId); |
|
20 | - if (!is_numeric($postId)) { |
|
19 | + $postId = trim( $postId ); |
|
20 | + if( !is_numeric( $postId ) ) { |
|
21 | 21 | return 0; |
22 | 22 | } |
23 | - if ($this->isEnabled()) { |
|
24 | - $postId = apply_filters('wpml_object_id', $postId, 'any', true); |
|
23 | + if( $this->isEnabled() ) { |
|
24 | + $postId = apply_filters( 'wpml_object_id', $postId, 'any', true ); |
|
25 | 25 | } |
26 | - return intval($postId); |
|
26 | + return intval( $postId ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * {@inheritdoc} |
31 | 31 | */ |
32 | - public function getPostIds(array $postIds) |
|
32 | + public function getPostIds( array $postIds ) |
|
33 | 33 | { |
34 | - if (!$this->isEnabled()) { |
|
34 | + if( !$this->isEnabled() ) { |
|
35 | 35 | return $postIds; |
36 | 36 | } |
37 | 37 | $newPostIds = []; |
38 | - foreach (Arr::unique($postIds) as $postId) { |
|
39 | - $postType = get_post_type($postId); |
|
40 | - if (!$postType) { |
|
38 | + foreach( Arr::unique( $postIds ) as $postId ) { |
|
39 | + $postType = get_post_type( $postId ); |
|
40 | + if( !$postType ) { |
|
41 | 41 | continue; |
42 | 42 | } |
43 | 43 | $elementType = 'post_'.$postType; |
44 | - $trid = apply_filters('wpml_element_trid', null, $postId, $elementType); |
|
45 | - $translations = apply_filters('wpml_get_element_translations', null, $trid, $elementType); |
|
46 | - if (!is_array($translations)) { |
|
44 | + $trid = apply_filters( 'wpml_element_trid', null, $postId, $elementType ); |
|
45 | + $translations = apply_filters( 'wpml_get_element_translations', null, $trid, $elementType ); |
|
46 | + if( !is_array( $translations ) ) { |
|
47 | 47 | $translations = []; |
48 | 48 | } |
49 | 49 | $newPostIds = array_merge( |
50 | 50 | $newPostIds, |
51 | - array_column($translations, 'element_id') |
|
51 | + array_column( $translations, 'element_id' ) |
|
52 | 52 | ); |
53 | 53 | } |
54 | - return Arr::unique($newPostIds); |
|
54 | + return Arr::unique( $newPostIds ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function isActive() |
61 | 61 | { |
62 | - return defined('ICL_SITEPRESS_VERSION'); |
|
62 | + return defined( 'ICL_SITEPRESS_VERSION' ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function isEnabled() |
69 | 69 | { |
70 | 70 | return $this->isActive() |
71 | - && 'wpml' == glsr(OptionManager::class)->get('settings.general.multilingual'); |
|
71 | + && 'wpml' == glsr( OptionManager::class )->get( 'settings.general.multilingual' ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,6 +77,6 @@ discard block |
||
77 | 77 | public function isSupported() |
78 | 78 | { |
79 | 79 | return $this->isActive() |
80 | - && version_compare(ICL_SITEPRESS_VERSION, $this->supportedVersion, '>='); |
|
80 | + && version_compare( ICL_SITEPRESS_VERSION, $this->supportedVersion, '>=' ); |
|
81 | 81 | } |
82 | 82 | } |