@@ -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 | } |
@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | public function onBeforeUpdateReview( WP_Post $review, $metaKey, $metaValue ) |
| 24 | 24 | { |
| 25 | 25 | $previousValue = get_post_meta( $review->ID, $metaKey, true ); |
| 26 | - if( $previousValue == $metaValue )return; |
|
| 26 | + if( $previousValue == $metaValue ) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 27 | 29 | $this->decreaseReviewCount( $review ); |
| 28 | 30 | $this->increaseReviewCount( $review, [$metaKey => $metaValue] ); |
| 29 | 31 | } |
@@ -36,7 +38,9 @@ discard block |
||
| 36 | 38 | */ |
| 37 | 39 | public function onCreateReview( $postData, $meta, $postId ) |
| 38 | 40 | { |
| 39 | - if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE )return; |
|
| 41 | + if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE ) { |
|
| 42 | + return; |
|
| 43 | + } |
|
| 40 | 44 | $review = get_post( $postId ) |
| 41 | 45 | $this->updateAssignedToPost( $review ); |
| 42 | 46 | $this->increaseReviewCount( $review ); |
@@ -48,7 +52,9 @@ discard block |
||
| 48 | 52 | */ |
| 49 | 53 | public function onDeleteReview( $postId ) |
| 50 | 54 | { |
| 51 | - if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE )return; |
|
| 55 | + if( get_post_field( 'post_type', $postId ) !== Application::POST_TYPE ) { |
|
| 56 | + return; |
|
| 57 | + } |
|
| 52 | 58 | $review = get_post( $postId ) |
| 53 | 59 | $review->post_status = 'deleted'; // important to change the post_status here first! |
| 54 | 60 | $this->updateAssignedToPost( $review ); |
@@ -85,7 +91,9 @@ discard block |
||
| 85 | 91 | */ |
| 86 | 92 | public function saveAssignedToMetabox( $postId ) |
| 87 | 93 | { |
| 88 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 94 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 89 | 97 | $assignedTo = glsr( Helper::class )->filterInput( 'assigned_to' ); |
| 90 | 98 | $assignedTo || $assignedTo = ''; |
| 91 | 99 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -100,7 +108,9 @@ discard block |
||
| 100 | 108 | */ |
| 101 | 109 | public function saveResponseMetabox( $postId ) |
| 102 | 110 | { |
| 103 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
| 111 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) { |
|
| 112 | + return; |
|
| 113 | + } |
|
| 104 | 114 | $response = glsr( Helper::class )->filterInput( 'response' ); |
| 105 | 115 | $response || $response = ''; |
| 106 | 116 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
@@ -134,10 +144,14 @@ discard block |
||
| 134 | 144 | ]); |
| 135 | 145 | if( !in_array( $meta['review_type'], glsr()->reviewTypes ) |
| 136 | 146 | || intval( $meta['rating'] ) > Rating::MAX_RATING |
| 137 | - )return; |
|
| 147 | + ) { |
|
| 148 | + return; |
|
| 149 | + } |
|
| 138 | 150 | $counts = glsr( OptionManager::class )->get( 'counts.'.$meta['review_type'], [] ); |
| 139 | 151 | foreach( range( 0, Rating::MAX_RATING ) as $rating ) { |
| 140 | - if( isset( $counts[$rating] ))continue; |
|
| 152 | + if( isset( $counts[$rating] )) { |
|
| 153 | + continue; |
|
| 154 | + } |
|
| 141 | 155 | $counts[$rating] = 0; |
| 142 | 156 | } |
| 143 | 157 | ksort( $counts ); |
@@ -150,7 +164,9 @@ discard block |
||
| 150 | 164 | protected function setReviewCounts( WP_Post $review, array $counts ) |
| 151 | 165 | { |
| 152 | 166 | $type = get_post_meta( $review->ID, 'review_type', true ); |
| 153 | - if( !in_array( $type, glsr()->reviewTypes ))return; |
|
| 167 | + if( !in_array( $type, glsr()->reviewTypes )) { |
|
| 168 | + return; |
|
| 169 | + } |
|
| 154 | 170 | glsr( OptionManager::class )->set( 'counts.'.$type, $counts ); |
| 155 | 171 | } |
| 156 | 172 | |
@@ -197,9 +213,13 @@ discard block |
||
| 197 | 213 | */ |
| 198 | 214 | protected function updateAssignedToPost( WP_Post $review ) |
| 199 | 215 | { |
| 200 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
| 216 | + if( !( $postId = $this->getAssignedToPostId( $review->ID ))) { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 201 | 219 | $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 202 | - if( empty( $reviewIds ))return; |
|
| 220 | + if( empty( $reviewIds )) { |
|
| 221 | + return; |
|
| 222 | + } |
|
| 203 | 223 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
| 204 | 224 | $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 205 | 225 | if( empty( $updatedReviewIds )) { |
@@ -92,7 +92,9 @@ discard block |
||
| 92 | 92 | if( !in_array( $metaKey, ['rating', 'review_type'] ) |
| 93 | 93 | || get_post_field( 'post_type', $postId ) != Application::POST_TYPE |
| 94 | 94 | || get_post_field( 'post_status', $postId ) != 'publish' // only fire on an existing published post |
| 95 | - )return; |
|
| 95 | + ) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 96 | 98 | glsr( Metaboxes::class )->onBeforeUpdateReview( get_post( $postId ), $metaKey, $metaValue ); |
| 97 | 99 | } |
| 98 | 100 | |
@@ -127,7 +129,9 @@ discard block |
||
| 127 | 129 | { |
| 128 | 130 | if( in_array( $oldStatus, ['new', $newStatus] ) |
| 129 | 131 | || $post->post_type != Application::POST_TYPE |
| 130 | - )return; |
|
| 132 | + ) { |
|
| 133 | + return; |
|
| 134 | + } |
|
| 131 | 135 | glsr( Metaboxes::class )->onReviewStatusChange( $newStatus, $post ); |
| 132 | 136 | } |
| 133 | 137 | |
@@ -148,7 +152,9 @@ discard block |
||
| 148 | 152 | */ |
| 149 | 153 | public function registerMetaBoxes( $postType ) |
| 150 | 154 | { |
| 151 | - if( $postType != Application::POST_TYPE )return; |
|
| 155 | + if( $postType != Application::POST_TYPE ) { |
|
| 156 | + return; |
|
| 157 | + } |
|
| 152 | 158 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
| 153 | 159 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
| 154 | 160 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
@@ -178,7 +184,9 @@ discard block |
||
| 178 | 184 | */ |
| 179 | 185 | public function renderAssignedToMetabox( WP_Post $post ) |
| 180 | 186 | { |
| 181 | - if( !$this->isReviewPostType( $post ))return; |
|
| 187 | + if( !$this->isReviewPostType( $post )) { |
|
| 188 | + return; |
|
| 189 | + } |
|
| 182 | 190 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 183 | 191 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 184 | 192 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -193,7 +201,9 @@ discard block |
||
| 193 | 201 | */ |
| 194 | 202 | public function renderDetailsMetaBox( WP_Post $post ) |
| 195 | 203 | { |
| 196 | - if( !$this->isReviewPostType( $post ))return; |
|
| 204 | + if( !$this->isReviewPostType( $post )) { |
|
| 205 | + return; |
|
| 206 | + } |
|
| 197 | 207 | $review = glsr( Database::class )->getReview( $post ); |
| 198 | 208 | glsr()->render( 'partials/editor/metabox-details', [ |
| 199 | 209 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -207,7 +217,9 @@ discard block |
||
| 207 | 217 | */ |
| 208 | 218 | public function renderPinnedInPublishMetaBox() |
| 209 | 219 | { |
| 210 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 220 | + if( !$this->isReviewPostType( get_post() )) { |
|
| 221 | + return; |
|
| 222 | + } |
|
| 211 | 223 | glsr( Html::class )->renderTemplate( 'partials/editor/pinned', [ |
| 212 | 224 | 'context' => [ |
| 213 | 225 | 'no' => __( 'No', 'site-reviews' ), |
@@ -223,7 +235,9 @@ discard block |
||
| 223 | 235 | */ |
| 224 | 236 | public function renderResponseMetaBox( WP_Post $post ) |
| 225 | 237 | { |
| 226 | - if( !$this->isReviewPostType( $post ))return; |
|
| 238 | + if( !$this->isReviewPostType( $post )) { |
|
| 239 | + return; |
|
| 240 | + } |
|
| 227 | 241 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 228 | 242 | glsr()->render( 'partials/editor/metabox-response', [ |
| 229 | 243 | 'response' => glsr( Database::class )->getReview( $post )->response, |
@@ -237,7 +251,9 @@ discard block |
||
| 237 | 251 | */ |
| 238 | 252 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 239 | 253 | { |
| 240 | - if( !$this->isReviewPostType( $post ))return; |
|
| 254 | + if( !$this->isReviewPostType( $post )) { |
|
| 255 | + return; |
|
| 256 | + } |
|
| 241 | 257 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 242 | 258 | 'post' => $post, |
| 243 | 259 | 'tax_name' => Application::TAXONOMY, |
@@ -275,7 +291,9 @@ discard block |
||
| 275 | 291 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 276 | 292 | { |
| 277 | 293 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post, $assignedTo ); |
| 278 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 294 | + if( !( $assignedPost instanceof WP_Post )) { |
|
| 295 | + return; |
|
| 296 | + } |
|
| 279 | 297 | return glsr( Html::class )->buildTemplate( 'partials/editor/assigned-post', [ |
| 280 | 298 | 'context' => [ |
| 281 | 299 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -317,7 +335,9 @@ discard block |
||
| 317 | 335 | */ |
| 318 | 336 | protected function getReviewType( $review ) |
| 319 | 337 | { |
| 320 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 338 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 339 | + return; |
|
| 340 | + } |
|
| 321 | 341 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 322 | 342 | ? glsr()->reviewTypes[$review->review_type] |
| 323 | 343 | : __( 'Unknown', 'site-reviews' ); |
@@ -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 | } |
@@ -64,7 +64,9 @@ discard block |
||
| 64 | 64 | public function getAssignedToPost( $post, $assignedTo = '' ) |
| 65 | 65 | { |
| 66 | 66 | $post = get_post( $post ); |
| 67 | - if( !( $post instanceof WP_Post ))return; |
|
| 67 | + if( !( $post instanceof WP_Post )) { |
|
| 68 | + return; |
|
| 69 | + } |
|
| 68 | 70 | if( empty( $assignedTo )) { |
| 69 | 71 | $assignedTo = get_post_meta( $post->ID, 'assigned_to', true ); |
| 70 | 72 | } |
@@ -82,7 +84,9 @@ discard block |
||
| 82 | 84 | */ |
| 83 | 85 | public function getReview( $post ) |
| 84 | 86 | { |
| 85 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 87 | + if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) { |
|
| 88 | + return; |
|
| 89 | + } |
|
| 86 | 90 | $review = $this->getReviewMeta( $post->ID ); |
| 87 | 91 | $modified = $this->isReviewModified( $post, $review ); |
| 88 | 92 | $review->content = $post->post_content; |
@@ -256,7 +260,9 @@ discard block |
||
| 256 | 260 | $termIds = array_map( 'trim', explode( ',', $termIds )); |
| 257 | 261 | foreach( $termIds as $termId ) { |
| 258 | 262 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 259 | - if( !isset( $term['term_id'] ))continue; |
|
| 263 | + if( !isset( $term['term_id'] )) { |
|
| 264 | + continue; |
|
| 265 | + } |
|
| 260 | 266 | $terms[] = intval( $term['term_id'] ); |
| 261 | 267 | } |
| 262 | 268 | return $terms; |
@@ -268,7 +274,9 @@ discard block |
||
| 268 | 274 | */ |
| 269 | 275 | public function revertReview( $postId ) |
| 270 | 276 | { |
| 271 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
| 277 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
| 278 | + return; |
|
| 279 | + } |
|
| 272 | 280 | delete_post_meta( $postId, '_edit_last' ); |
| 273 | 281 | $result = wp_update_post([ |
| 274 | 282 | 'ID' => $postId, |
@@ -303,7 +311,9 @@ discard block |
||
| 303 | 311 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
| 304 | 312 | $search = new WP_Query( $args ); |
| 305 | 313 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
| 306 | - if( !$search->have_posts() )return; |
|
| 314 | + if( !$search->have_posts() ) { |
|
| 315 | + return; |
|
| 316 | + } |
|
| 307 | 317 | $results = ''; |
| 308 | 318 | while( $search->have_posts() ) { |
| 309 | 319 | $search->the_post(); |
@@ -327,7 +337,9 @@ discard block |
||
| 327 | 337 | public function setReviewTerms( $postId, $termIds ) |
| 328 | 338 | { |
| 329 | 339 | $terms = $this->normalizeTerms( $termIds ); |
| 330 | - if( empty( $terms ))return; |
|
| 340 | + if( empty( $terms )) { |
|
| 341 | + return; |
|
| 342 | + } |
|
| 331 | 343 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
| 332 | 344 | if( is_wp_error( $result )) { |
| 333 | 345 | glsr_log()->error( $result->get_error_message() ); |