@@ -48,54 +48,54 @@ |
||
48 | 48 | */ |
49 | 49 | public function run() |
50 | 50 | { |
51 | - add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
52 | - add_action( 'admin_init', [$this->admin, 'registerShortcodeButtons'] ); |
|
53 | - add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] ); |
|
54 | - add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] ); |
|
55 | - add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
56 | - add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
57 | - add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
58 | - add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
59 | - add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
60 | - add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
61 | - add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
62 | - add_action( 'update_postmeta', [$this->editor, 'onBeforeUpdateReview'], 10, 4 ); |
|
63 | - add_action( 'site-reviews/create/review', [$this->editor, 'onCreateReview'], 10, 3 ); |
|
64 | - add_action( 'before_delete_post', [$this->editor, 'onDeleteReview'] ); |
|
65 | - add_action( 'transition_post_status', [$this->editor, 'onReviewStatusChange'], 10, 3 ); |
|
66 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'onSaveReview'], 20, 3 ); |
|
67 | - add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'] ); |
|
68 | - add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
69 | - add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
70 | - add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
71 | - add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
72 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
73 | - add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
74 | - add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
75 | - add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
76 | - add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
77 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
78 | - add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
79 | - add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
80 | - add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
81 | - add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
82 | - add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
83 | - add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
84 | - add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
85 | - add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
86 | - add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
87 | - add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
88 | - add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
89 | - add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
90 | - add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
51 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
52 | + add_action( 'admin_init', [$this->admin, 'registerShortcodeButtons'] ); |
|
53 | + add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] ); |
|
54 | + add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] ); |
|
55 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
56 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
57 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
58 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
59 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
60 | + add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
61 | + add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
62 | + add_action( 'update_postmeta', [$this->editor, 'onBeforeUpdateReview'], 10, 4 ); |
|
63 | + add_action( 'site-reviews/create/review', [$this->editor, 'onCreateReview'], 10, 3 ); |
|
64 | + add_action( 'before_delete_post', [$this->editor, 'onDeleteReview'] ); |
|
65 | + add_action( 'transition_post_status', [$this->editor, 'onReviewStatusChange'], 10, 3 ); |
|
66 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'onSaveReview'], 20, 3 ); |
|
67 | + add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'] ); |
|
68 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
69 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
70 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
71 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
72 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
73 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
74 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
75 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
76 | + add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
77 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
78 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
79 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
80 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
81 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
82 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
83 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
84 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
85 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
86 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
87 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
88 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
89 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
90 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
91 | 91 | add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
92 | - add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
93 | - add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
94 | - add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
95 | - add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
96 | - add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
97 | - add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
98 | - add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
99 | - add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
92 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
93 | + add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
94 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
95 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
96 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
97 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
98 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
99 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
100 | 100 | } |
101 | 101 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function __call( $method, array $arguments ) |
41 | 41 | { |
42 | - $value = isset( $arguments[0] ) |
|
42 | + $value = isset($arguments[0]) |
|
43 | 43 | ? $arguments[0] |
44 | 44 | : ''; |
45 | 45 | return $this->setProperty( $method, $value ); |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | * @param mixed $default |
97 | 97 | * @return mixed |
98 | 98 | */ |
99 | - public function getProperty( $property, $default = null) |
|
99 | + public function getProperty( $property, $default = null ) |
|
100 | 100 | { |
101 | - return isset( $this->properties[$property] ) |
|
101 | + return isset($this->properties[$property]) |
|
102 | 102 | ? $this->properties[$property] |
103 | 103 | : $default; |
104 | 104 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function offsetUnset( $offset ) |
168 | 168 | { |
169 | - unset( $this->properties[$offset] ); |
|
169 | + unset($this->properties[$offset]); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -212,16 +212,16 @@ discard block |
||
212 | 212 | */ |
213 | 213 | protected function getParents( $parents = null ) |
214 | 214 | { |
215 | - if( !isset( $parents )) { |
|
215 | + if( !isset($parents) ) { |
|
216 | 216 | $parents = $this->parents; |
217 | 217 | } |
218 | 218 | $newParents = $parents; |
219 | 219 | foreach( $parents as $parent ) { |
220 | 220 | $parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ ); |
221 | - if( !class_exists( $parentClass ))continue; |
|
222 | - $newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents )); |
|
221 | + if( !class_exists( $parentClass ) )continue; |
|
222 | + $newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents ) ); |
|
223 | 223 | } |
224 | - return array_values( array_unique( $newParents )); |
|
224 | + return array_values( array_unique( $newParents ) ); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | $parents = $this->getParents(); |
233 | 233 | foreach( $parents as $parent ) { |
234 | 234 | $parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ ); |
235 | - if( !class_exists( $parentClass ))continue; |
|
236 | - $this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed ))); |
|
235 | + if( !class_exists( $parentClass ) )continue; |
|
236 | + $this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed ) ) ); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | */ |
244 | 244 | protected function serializeProperty( $property ) |
245 | 245 | { |
246 | - if( is_array( $property )) { |
|
246 | + if( is_array( $property ) ) { |
|
247 | 247 | return array_map( [$this, 'serializeProperty'], $property ); |
248 | 248 | } |
249 | 249 | if( $property instanceof Type ) { |
250 | 250 | $property = $property->toArray(); |
251 | - unset( $property['@context'] ); |
|
251 | + unset($property['@context']); |
|
252 | 252 | } |
253 | 253 | if( $property instanceof DateTimeInterface ) { |
254 | 254 | $property = $property->format( DateTime::ATOM ); |
255 | 255 | } |
256 | - if( is_object( $property )) { |
|
256 | + if( is_object( $property ) ) { |
|
257 | 257 | throw new InvalidProperty(); |
258 | 258 | } |
259 | 259 | return $property; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function saveAssignedToMetabox( $postId ) |
87 | 87 | { |
88 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
88 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ) )return; |
|
89 | 89 | $assignedTo = glsr( Helper::class )->filterInput( 'assigned_to' ); |
90 | 90 | $assignedTo || $assignedTo = ''; |
91 | 91 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function saveResponseMetabox( $postId ) |
102 | 102 | { |
103 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
103 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ) )return; |
|
104 | 104 | $response = glsr( Helper::class )->filterInput( 'response' ); |
105 | 105 | $response || $response = ''; |
106 | 106 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
107 | 107 | 'a' => ['href' => [], 'title' => []], |
108 | 108 | 'em' => [], |
109 | 109 | 'strong' => [], |
110 | - ]))); |
|
110 | + ] ) ) ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function getAssignedToPostId( $postId ) |
118 | 118 | { |
119 | - $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true )); |
|
120 | - if(( $post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
119 | + $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true ) ); |
|
120 | + if( ($post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
121 | 121 | return $post->ID; |
122 | 122 | } |
123 | 123 | return false; |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | $meta = wp_parse_args( $meta, [ |
132 | 132 | 'rating' => get_post_meta( $review->ID, 'rating', true ), |
133 | 133 | 'review_type' => get_post_meta( $review->ID, 'review_type', true ), |
134 | - ]); |
|
134 | + ] ); |
|
135 | 135 | if( !in_array( $meta['review_type'], glsr()->reviewTypes ) |
136 | 136 | || intval( $meta['rating'] ) > Rating::MAX_RATING |
137 | 137 | )return; |
138 | 138 | $counts = glsr( OptionManager::class )->get( 'counts.'.$meta['review_type'], [] ); |
139 | 139 | foreach( range( 0, Rating::MAX_RATING ) as $rating ) { |
140 | - if( isset( $counts[$rating] ))continue; |
|
140 | + if( isset($counts[$rating]) )continue; |
|
141 | 141 | $counts[$rating] = 0; |
142 | 142 | } |
143 | 143 | ksort( $counts ); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | protected function setReviewCounts( WP_Post $review, array $counts ) |
151 | 151 | { |
152 | 152 | $type = get_post_meta( $review->ID, 'review_type', true ); |
153 | - if( !in_array( $type, glsr()->reviewTypes ))return; |
|
153 | + if( !in_array( $type, glsr()->reviewTypes ) )return; |
|
154 | 154 | glsr( OptionManager::class )->set( 'counts.'.$type, $counts ); |
155 | 155 | } |
156 | 156 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | protected function increaseReviewCount( WP_Post $review, array $meta = [] ) |
161 | 161 | { |
162 | - if( $counts = $this->getReviewCounts( $review, $meta )) { |
|
162 | + if( $counts = $this->getReviewCounts( $review, $meta ) ) { |
|
163 | 163 | $counts[$rating] -= 1; |
164 | 164 | $this->setReviewCounts( $review, $counts ); |
165 | 165 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | protected function decreaseReviewCount( WP_Post $review, array $meta = [] ) |
172 | 172 | { |
173 | - if( $counts = $this->getReviewCounts( $review, $meta )) { |
|
173 | + if( $counts = $this->getReviewCounts( $review, $meta ) ) { |
|
174 | 174 | $counts[$rating] += 1; |
175 | 175 | $this->setReviewCounts( $review, $counts ); |
176 | 176 | } |
@@ -197,22 +197,22 @@ discard block |
||
197 | 197 | */ |
198 | 198 | protected function updateAssignedToPost( WP_Post $review ) |
199 | 199 | { |
200 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
201 | - $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
202 | - if( empty( $reviewIds ))return; |
|
200 | + if( !($postId = $this->getAssignedToPostId( $review->ID )) )return; |
|
201 | + $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
202 | + if( empty($reviewIds) )return; |
|
203 | 203 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
204 | - $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
205 | - if( empty( $updatedReviewIds )) { |
|
204 | + $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
205 | + if( empty($updatedReviewIds) ) { |
|
206 | 206 | delete_post_meta( $postId, static::META_RANKING ); |
207 | 207 | delete_post_meta( $postId, static::META_REVIEW_ID ); |
208 | 208 | } |
209 | - else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds )) { |
|
210 | - $reviews = glsr( Database::class )->getReviews([ |
|
209 | + else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds ) ) { |
|
210 | + $reviews = glsr( Database::class )->getReviews( [ |
|
211 | 211 | 'count' => -1, |
212 | 212 | 'post__in' => $updatedReviewIds, |
213 | - ]); |
|
214 | - update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results )); |
|
215 | - update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results )); |
|
213 | + ] ); |
|
214 | + update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results ) ); |
|
215 | + update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results ) ); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | if( $review->post_status != 'publish' ) { |
226 | 226 | delete_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
227 | 227 | } |
228 | - else if( !in_array( $review->ID, $reviewIds )) { |
|
228 | + else if( !in_array( $review->ID, $reviewIds ) ) { |
|
229 | 229 | add_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
230 | 230 | } |
231 | 231 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | 'post_type' => Application::POST_TYPE, |
36 | 36 | ]; |
37 | 37 | $postId = wp_insert_post( $post, true ); |
38 | - if( is_wp_error( $postId )) { |
|
38 | + if( is_wp_error( $postId ) ) { |
|
39 | 39 | glsr_log()->error( $postId->get_error_message() ); |
40 | 40 | return false; |
41 | 41 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function deleteReview( $metaReviewId ) |
53 | 53 | { |
54 | - if( $postId = $this->getReviewPostId( $metaReviewId )) { |
|
54 | + if( $postId = $this->getReviewPostId( $metaReviewId ) ) { |
|
55 | 55 | wp_delete_post( $postId, true ); |
56 | 56 | } |
57 | 57 | } |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | public function getAssignedToPost( $post, $assignedTo = '' ) |
65 | 65 | { |
66 | 66 | $post = get_post( $post ); |
67 | - if( !( $post instanceof WP_Post ))return; |
|
68 | - if( empty( $assignedTo )) { |
|
67 | + if( !($post instanceof WP_Post) )return; |
|
68 | + if( empty($assignedTo) ) { |
|
69 | 69 | $assignedTo = get_post_meta( $post->ID, 'assigned_to', true ); |
70 | 70 | } |
71 | 71 | $assignedPost = get_post( $assignedTo ); |
72 | - if( !empty( $assignedTo ) |
|
72 | + if( !empty($assignedTo) |
|
73 | 73 | && $assignedPost instanceof WP_Post |
74 | 74 | && $assignedPost->ID != $post->ID ) { |
75 | 75 | return $assignedPost; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function getReview( $post ) |
84 | 84 | { |
85 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
85 | + if( !($post instanceof WP_Post) || $post->post_type != Application::POST_TYPE )return; |
|
86 | 86 | $review = $this->getReviewMeta( $post->ID ); |
87 | 87 | $modified = $this->isReviewModified( $post, $review ); |
88 | 88 | $review->content = $post->post_content; |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | { |
105 | 105 | $metaKey = $this->normalizeMetaKey( $metaKey ); |
106 | 106 | if( !$metaKey ) { |
107 | - return (array) wp_count_posts( Application::POST_TYPE ); |
|
107 | + return (array)wp_count_posts( Application::POST_TYPE ); |
|
108 | 108 | } |
109 | 109 | $counts = glsr( Cache::class )->getReviewCountsFor( $metaKey ); |
110 | 110 | if( !$metaValue ) { |
111 | 111 | return $counts; |
112 | 112 | } |
113 | - return isset( $counts[$metaValue] ) |
|
113 | + return isset($counts[$metaValue]) |
|
114 | 114 | ? $counts[$metaValue] |
115 | 115 | : 0; |
116 | 116 | } |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | public function getReviewMeta( $postId ) |
132 | 132 | { |
133 | 133 | $meta = get_post_type( $postId ) == Application::POST_TYPE |
134 | - ? array_map( 'array_shift', (array) get_post_meta( $postId )) |
|
134 | + ? array_map( 'array_shift', (array)get_post_meta( $postId ) ) |
|
135 | 135 | : []; |
136 | - return (object) $this->normalizeMeta( array_filter( $meta, 'strlen' )); |
|
136 | + return (object)$this->normalizeMeta( array_filter( $meta, 'strlen' ) ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $paged = glsr( QueryBuilder::class )->getPaged( |
163 | 163 | wp_validate_boolean( $args['pagination'] ) |
164 | 164 | ); |
165 | - $reviews = new WP_Query([ |
|
165 | + $reviews = new WP_Query( [ |
|
166 | 166 | 'meta_key' => 'pinned', |
167 | 167 | 'meta_query' => $metaQuery, |
168 | 168 | 'offset' => $args['offset'], |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | 'post_type' => Application::POST_TYPE, |
176 | 176 | 'posts_per_page' => $args['count'] ? $args['count'] : -1, |
177 | 177 | 'tax_query' => $taxQuery, |
178 | - ]); |
|
179 | - return (object) [ |
|
178 | + ] ); |
|
179 | + return (object)[ |
|
180 | 180 | 'results' => array_map( [$this, 'getReview'], $reviews->posts ), |
181 | 181 | 'max_num_pages' => $reviews->max_num_pages, |
182 | 182 | ]; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | public function getReviewsMeta( $keys, $status = 'publish' ) |
191 | 191 | { |
192 | 192 | $keys = array_map( [$this, 'normalizeMetaKey'], (array)$keys ); |
193 | - if( $status == 'all' || empty( $status )) { |
|
193 | + if( $status == 'all' || empty($status) ) { |
|
194 | 194 | $status = get_post_stati( ['exclude_from_search' => false] ); |
195 | 195 | } |
196 | 196 | return glsr( SqlQueries::class )->getReviewsMeta( $keys, $status ); |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | 'fields' => 'id=>name', |
207 | 207 | 'hide_empty' => false, |
208 | 208 | 'taxonomy' => Application::TAXONOMY, |
209 | - ]); |
|
210 | - unset( $args['count'] ); //we don't want a term count |
|
209 | + ] ); |
|
210 | + unset($args['count']); //we don't want a term count |
|
211 | 211 | $terms = get_terms( $args ); |
212 | - if( is_wp_error( $terms )) { |
|
212 | + if( is_wp_error( $terms ) ) { |
|
213 | 213 | glsr_log()->error( $terms->get_error_message() ); |
214 | 214 | return []; |
215 | 215 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public function normalizeMeta( array $meta ) |
223 | 223 | { |
224 | - if( empty( $meta )) { |
|
224 | + if( empty($meta) ) { |
|
225 | 225 | return []; |
226 | 226 | } |
227 | 227 | $defaults = wp_parse_args( $meta, [ |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | 'date' => '', |
230 | 230 | 'review_id' => '', |
231 | 231 | 'review_type' => '', |
232 | - ]); |
|
232 | + ] ); |
|
233 | 233 | return glsr( CreateReviewDefaults::class )->restrict( $defaults ); |
234 | 234 | } |
235 | 235 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | public function normalizeMetaKey( $metaKey ) |
241 | 241 | { |
242 | 242 | $metaKey = strtolower( $metaKey ); |
243 | - if( in_array( $metaKey, ['id', 'type'] )) { |
|
243 | + if( in_array( $metaKey, ['id', 'type'] ) ) { |
|
244 | 244 | $metaKey = 'review_'.$metaKey; |
245 | 245 | } |
246 | 246 | return $metaKey; |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | public function normalizeTerms( $termIds ) |
254 | 254 | { |
255 | 255 | $terms = []; |
256 | - $termIds = array_map( 'trim', explode( ',', $termIds )); |
|
256 | + $termIds = array_map( 'trim', explode( ',', $termIds ) ); |
|
257 | 257 | foreach( $termIds as $termId ) { |
258 | 258 | $term = term_exists( $termId, Application::TAXONOMY ); |
259 | - if( !isset( $term['term_id'] ))continue; |
|
259 | + if( !isset($term['term_id']) )continue; |
|
260 | 260 | $terms[] = intval( $term['term_id'] ); |
261 | 261 | } |
262 | 262 | return $terms; |
@@ -270,13 +270,13 @@ discard block |
||
270 | 270 | { |
271 | 271 | if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
272 | 272 | delete_post_meta( $postId, '_edit_last' ); |
273 | - $result = wp_update_post([ |
|
273 | + $result = wp_update_post( [ |
|
274 | 274 | 'ID' => $postId, |
275 | 275 | 'post_content' => get_post_meta( $postId, 'content', true ), |
276 | 276 | 'post_date' => get_post_meta( $postId, 'date', true ), |
277 | 277 | 'post_title' => get_post_meta( $postId, 'title', true ), |
278 | - ]); |
|
279 | - if( is_wp_error( $result )) { |
|
278 | + ] ); |
|
279 | + if( is_wp_error( $result ) ) { |
|
280 | 280 | glsr_log()->error( $result->get_error_message() ); |
281 | 281 | } |
282 | 282 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | 'post_status' => 'publish', |
292 | 292 | 'post_type' => 'any', |
293 | 293 | ]; |
294 | - if( is_numeric( $searchTerm )) { |
|
294 | + if( is_numeric( $searchTerm ) ) { |
|
295 | 295 | $args['post__in'] = [$searchTerm]; |
296 | 296 | } |
297 | 297 | else { |
@@ -310,9 +310,9 @@ discard block |
||
310 | 310 | ob_start(); |
311 | 311 | glsr()->render( 'partials/editor/search-result', [ |
312 | 312 | 'ID' => get_the_ID(), |
313 | - 'permalink' => esc_url( (string) get_permalink() ), |
|
313 | + 'permalink' => esc_url( (string)get_permalink() ), |
|
314 | 314 | 'title' => esc_attr( get_the_title() ), |
315 | - ]); |
|
315 | + ] ); |
|
316 | 316 | $results .= ob_get_clean(); |
317 | 317 | } |
318 | 318 | wp_reset_postdata(); |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | public function setReviewTerms( $postId, $termIds ) |
328 | 328 | { |
329 | 329 | $terms = $this->normalizeTerms( $termIds ); |
330 | - if( empty( $terms ))return; |
|
330 | + if( empty($terms) )return; |
|
331 | 331 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
332 | - if( is_wp_error( $result )) { |
|
332 | + if( is_wp_error( $result ) ) { |
|
333 | 333 | glsr_log()->error( $result->get_error_message() ); |
334 | 334 | } |
335 | 335 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | protected function getNewPostStatus( array $review, $isBlacklisted ) |
342 | 342 | { |
343 | 343 | $requireApprovalOption = glsr( OptionManager::class )->get( 'settings.general.require.approval' ); |
344 | - return $review['review_type'] == 'local' && ( $requireApprovalOption == 'yes' || $isBlacklisted ) |
|
344 | + return $review['review_type'] == 'local' && ($requireApprovalOption == 'yes' || $isBlacklisted) |
|
345 | 345 | ? 'pending' |
346 | 346 | : 'publish'; |
347 | 347 | } |