@@ -90,10 +90,14 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function registerMetaBoxes( $postType, $post ) |
| 92 | 92 | { |
| 93 | - if( $postType != Application::POST_TYPE )return; |
|
| 93 | + if( $postType != Application::POST_TYPE ) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 94 | 96 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
| 95 | 97 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
| 96 | - if( get_post_meta( $post->ID, 'review_type', true ) != 'local' )return; |
|
| 98 | + if( get_post_meta( $post->ID, 'review_type', true ) != 'local' ) { |
|
| 99 | + return; |
|
| 100 | + } |
|
| 97 | 101 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
| 98 | 102 | } |
| 99 | 103 | |
@@ -129,7 +133,9 @@ discard block |
||
| 129 | 133 | */ |
| 130 | 134 | public function renderAssignedToMetabox( WP_Post $post ) |
| 131 | 135 | { |
| 132 | - if( !$this->isReviewPostType( $post ))return; |
|
| 136 | + if( !$this->isReviewPostType( $post )) { |
|
| 137 | + return; |
|
| 138 | + } |
|
| 133 | 139 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 134 | 140 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 135 | 141 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -144,7 +150,9 @@ discard block |
||
| 144 | 150 | */ |
| 145 | 151 | public function renderDetailsMetaBox( WP_Post $post ) |
| 146 | 152 | { |
| 147 | - if( !$this->isReviewPostType( $post ))return; |
|
| 153 | + if( !$this->isReviewPostType( $post )) { |
|
| 154 | + return; |
|
| 155 | + } |
|
| 148 | 156 | $review = glsr( ReviewManager::class )->single( $post ); |
| 149 | 157 | glsr()->render( 'partials/editor/metabox-details', [ |
| 150 | 158 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -158,7 +166,9 @@ discard block |
||
| 158 | 166 | */ |
| 159 | 167 | public function renderPinnedInPublishMetaBox() |
| 160 | 168 | { |
| 161 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 169 | + if( !$this->isReviewPostType( get_post() )) { |
|
| 170 | + return; |
|
| 171 | + } |
|
| 162 | 172 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
| 163 | 173 | 'context' => [ |
| 164 | 174 | 'no' => __( 'No', 'site-reviews' ), |
@@ -174,7 +184,9 @@ discard block |
||
| 174 | 184 | */ |
| 175 | 185 | public function renderResponseMetaBox( WP_Post $post ) |
| 176 | 186 | { |
| 177 | - if( !$this->isReviewPostType( $post ))return; |
|
| 187 | + if( !$this->isReviewPostType( $post )) { |
|
| 188 | + return; |
|
| 189 | + } |
|
| 178 | 190 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 179 | 191 | glsr()->render( 'partials/editor/metabox-response', [ |
| 180 | 192 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -187,7 +199,9 @@ discard block |
||
| 187 | 199 | */ |
| 188 | 200 | public function renderReviewEditor( WP_Post $post ) |
| 189 | 201 | { |
| 190 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 202 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 203 | + return; |
|
| 204 | + } |
|
| 191 | 205 | glsr()->render( 'partials/editor/review', [ |
| 192 | 206 | 'post' => $post, |
| 193 | 207 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -201,7 +215,9 @@ discard block |
||
| 201 | 215 | public function renderReviewFields() |
| 202 | 216 | { |
| 203 | 217 | $screen = glsr_current_screen(); |
| 204 | - if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
|
| 218 | + if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE ) { |
|
| 219 | + return; |
|
| 220 | + } |
|
| 205 | 221 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
| 206 | 222 | add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
| 207 | 223 | } |
@@ -212,7 +228,9 @@ discard block |
||
| 212 | 228 | */ |
| 213 | 229 | public function renderReviewNotice( WP_Post $post ) |
| 214 | 230 | { |
| 215 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 231 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 232 | + return; |
|
| 233 | + } |
|
| 216 | 234 | glsr( Notice::class )->addWarning( sprintf( |
| 217 | 235 | __( '%s reviews are read-only.', 'site-reviews' ), |
| 218 | 236 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
@@ -231,7 +249,9 @@ discard block |
||
| 231 | 249 | */ |
| 232 | 250 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 233 | 251 | { |
| 234 | - if( !$this->isReviewPostType( $post ))return; |
|
| 252 | + if( !$this->isReviewPostType( $post )) { |
|
| 253 | + return; |
|
| 254 | + } |
|
| 235 | 255 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 236 | 256 | 'post' => $post, |
| 237 | 257 | 'tax_name' => Application::TAXONOMY, |
@@ -269,7 +289,9 @@ discard block |
||
| 269 | 289 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 270 | 290 | { |
| 271 | 291 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 272 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 292 | + if( !( $assignedPost instanceof WP_Post )) { |
|
| 293 | + return; |
|
| 294 | + } |
|
| 273 | 295 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
| 274 | 296 | 'context' => [ |
| 275 | 297 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -314,7 +336,9 @@ discard block |
||
| 314 | 336 | */ |
| 315 | 337 | protected function getReviewType( $review ) |
| 316 | 338 | { |
| 317 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 339 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 340 | + return; |
|
| 341 | + } |
|
| 318 | 342 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 319 | 343 | ? glsr()->reviewTypes[$review->review_type] |
| 320 | 344 | : __( 'Unknown', 'site-reviews' ); |
@@ -35,7 +35,9 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public function renderTaxonomyFilter() |
| 37 | 37 | { |
| 38 | - if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ))return; |
|
| 38 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY )) { |
|
| 39 | + return; |
|
| 40 | + } |
|
| 39 | 41 | echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
| 40 | 42 | 'class' => 'screen-reader-text', |
| 41 | 43 | 'for' => Application::TAXONOMY, |
@@ -115,7 +115,9 @@ discard block |
||
| 115 | 115 | $termId = intval( $termId ); |
| 116 | 116 | } |
| 117 | 117 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 118 | - if( !isset( $term['term_id'] ))continue; |
|
| 118 | + if( !isset( $term['term_id'] )) { |
|
| 119 | + continue; |
|
| 120 | + } |
|
| 119 | 121 | $terms[] = intval( $term['term_id'] ); |
| 120 | 122 | } |
| 121 | 123 | return $terms; |
@@ -127,7 +129,9 @@ discard block |
||
| 127 | 129 | */ |
| 128 | 130 | public function revert( $postId ) |
| 129 | 131 | { |
| 130 | - if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
|
| 132 | + if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE ) { |
|
| 133 | + return; |
|
| 134 | + } |
|
| 131 | 135 | delete_post_meta( $postId, '_edit_last' ); |
| 132 | 136 | $result = wp_update_post([ |
| 133 | 137 | 'ID' => $postId, |
@@ -145,7 +149,9 @@ discard block |
||
| 145 | 149 | */ |
| 146 | 150 | public function single( WP_Post $post ) |
| 147 | 151 | { |
| 148 | - if( $post->post_type != Application::POST_TYPE )return; |
|
| 152 | + if( $post->post_type != Application::POST_TYPE ) { |
|
| 153 | + return; |
|
| 154 | + } |
|
| 149 | 155 | $review = new Review( $post ); |
| 150 | 156 | return apply_filters( 'site-reviews/get/review', $review, $post ); |
| 151 | 157 | } |
@@ -170,7 +176,9 @@ discard block |
||
| 170 | 176 | protected function setTerms( $postId, $termIds ) |
| 171 | 177 | { |
| 172 | 178 | $terms = $this->normalizeTerms( $termIds ); |
| 173 | - if( empty( $terms ))return; |
|
| 179 | + if( empty( $terms )) { |
|
| 180 | + return; |
|
| 181 | + } |
|
| 174 | 182 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
| 175 | 183 | if( is_wp_error( $result )) { |
| 176 | 184 | glsr_log()->error( $result->get_error_message() ); |
@@ -74,7 +74,9 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function decreasePostCounts( Review $review ) |
| 76 | 76 | { |
| 77 | - if( empty( $counts = $this->getPostCounts( $review->assigned_to )))return; |
|
| 77 | + if( empty( $counts = $this->getPostCounts( $review->assigned_to ))) { |
|
| 78 | + return; |
|
| 79 | + } |
|
| 78 | 80 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
| 79 | 81 | $this->setPostCounts( $review->assigned_to, $counts ); |
| 80 | 82 | } |
@@ -85,7 +87,9 @@ discard block |
||
| 85 | 87 | public function decreaseTermCounts( Review $review ) |
| 86 | 88 | { |
| 87 | 89 | foreach( $review->term_ids as $termId ) { |
| 88 | - if( empty( $counts = $this->getTermCounts( $termId )))continue; |
|
| 90 | + if( empty( $counts = $this->getTermCounts( $termId ))) { |
|
| 91 | + continue; |
|
| 92 | + } |
|
| 89 | 93 | $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating ); |
| 90 | 94 | $this->setTermCounts( $termId, $counts ); |
| 91 | 95 | } |
@@ -107,7 +111,9 @@ discard block |
||
| 107 | 111 | 'min' => Rating::MIN_RATING, |
| 108 | 112 | ]); |
| 109 | 113 | foreach( $counts as $index => &$num ) { |
| 110 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
| 114 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] )) { |
|
| 115 | + continue; |
|
| 116 | + } |
|
| 111 | 117 | $num = 0; |
| 112 | 118 | } |
| 113 | 119 | return $counts; |
@@ -199,7 +205,9 @@ discard block |
||
| 199 | 205 | */ |
| 200 | 206 | public function increasePostCounts( Review $review ) |
| 201 | 207 | { |
| 202 | - if( !( get_post( $review->assigned_to ) instanceof WP_Post ))return; |
|
| 208 | + if( !( get_post( $review->assigned_to ) instanceof WP_Post )) { |
|
| 209 | + return; |
|
| 210 | + } |
|
| 203 | 211 | $counts = $this->getPostCounts( $review->assigned_to ); |
| 204 | 212 | $counts = empty( $counts ) |
| 205 | 213 | ? $this->buildPostCounts( $review->assigned_to ) |
@@ -248,7 +256,9 @@ discard block |
||
| 248 | 256 | */ |
| 249 | 257 | public function setTermCounts( $termId, array $reviewCounts ) |
| 250 | 258 | { |
| 251 | - if( !term_exists( $termId ))return; |
|
| 259 | + if( !term_exists( $termId )) { |
|
| 260 | + return; |
|
| 261 | + } |
|
| 252 | 262 | $ratingCounts = $this->flatten( $reviewCounts ); |
| 253 | 263 | update_term_meta( $termId, static::META_COUNT, $reviewCounts ); |
| 254 | 264 | update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts )); |
@@ -268,7 +278,9 @@ discard block |
||
| 268 | 278 | $types = array_unique( array_merge( ['local'], $types )); |
| 269 | 279 | foreach( $types as $type ) { |
| 270 | 280 | $type = $this->normalizeType( $type ); |
| 271 | - if( isset( $counts[$type] ))continue; |
|
| 281 | + if( isset( $counts[$type] )) { |
|
| 282 | + continue; |
|
| 283 | + } |
|
| 272 | 284 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
| 273 | 285 | } |
| 274 | 286 | foreach( $reviews as $review ) { |
@@ -321,7 +333,9 @@ discard block |
||
| 321 | 333 | } |
| 322 | 334 | foreach( $reviewCounts as &$counts ) { |
| 323 | 335 | foreach( range( 0, Rating::MAX_RATING ) as $index ) { |
| 324 | - if( isset( $counts[$index] ))continue; |
|
| 336 | + if( isset( $counts[$index] )) { |
|
| 337 | + continue; |
|
| 338 | + } |
|
| 325 | 339 | $counts[$index] = 0; |
| 326 | 340 | } |
| 327 | 341 | ksort( $counts ); |
@@ -108,12 +108,16 @@ |
||
| 108 | 108 | public function renderTinymceButton( $editorId ) |
| 109 | 109 | { |
| 110 | 110 | $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId ); |
| 111 | - if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return; |
|
| 111 | + if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors )) { |
|
| 112 | + return; |
|
| 113 | + } |
|
| 112 | 114 | $shortcodes = []; |
| 113 | 115 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
| 114 | 116 | $shortcodes[$shortcode] = $values; |
| 115 | 117 | } |
| 116 | - if( empty( $shortcodes ))return; |
|
| 118 | + if( empty( $shortcodes )) { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 117 | 121 | glsr()->render( 'partials/editor/tinymce', [ |
| 118 | 122 | 'shortcodes' => $shortcodes, |
| 119 | 123 | ]); |
@@ -25,7 +25,9 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | sort( $termIds ); |
| 27 | 27 | sort( $oldTermIds ); |
| 28 | - if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId ))return; |
|
| 28 | + if( $termIds === $oldTermIds || !$this->isReviewPostId( $postId )) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 29 | 31 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 30 | 32 | $ignoredTerms = array_intersect( $oldTermIds, $termIds ); |
| 31 | 33 | if( $review->term_ids = array_diff( $oldTermIds, $ignoredTerms )) { |
@@ -44,7 +46,9 @@ discard block |
||
| 44 | 46 | */ |
| 45 | 47 | public function onAfterChangeStatus( $newStatus, $oldStatus, WP_Post $post ) |
| 46 | 48 | { |
| 47 | - if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 49 | + if( $post->post_type != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 48 | 52 | $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
| 49 | 53 | if( $post->post_status == 'publish' ) { |
| 50 | 54 | glsr( CountsManager::class )->increase( $review ); |
@@ -60,7 +64,9 @@ discard block |
||
| 60 | 64 | */ |
| 61 | 65 | public function onAfterCreate( Review $review ) |
| 62 | 66 | { |
| 63 | - if( $review->status !== 'publish' )return; |
|
| 67 | + if( $review->status !== 'publish' ) { |
|
| 68 | + return; |
|
| 69 | + } |
|
| 64 | 70 | glsr( CountsManager::class )->increase( $review ); |
| 65 | 71 | } |
| 66 | 72 | |
@@ -71,7 +77,9 @@ discard block |
||
| 71 | 77 | */ |
| 72 | 78 | public function onBeforeDelete( $postId ) |
| 73 | 79 | { |
| 74 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 80 | + if( !$this->isReviewPostId( $postId )) { |
|
| 81 | + return; |
|
| 82 | + } |
|
| 75 | 83 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 76 | 84 | glsr( CountsManager::class )->decrease( $review ); |
| 77 | 85 | } |
@@ -88,9 +96,13 @@ discard block |
||
| 88 | 96 | { |
| 89 | 97 | if( !$this->isReviewPostId( $postId ) |
| 90 | 98 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 91 | - )return; |
|
| 99 | + ) { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 92 | 102 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 93 | - if( $review->$metaKey == $metaValue )return; |
|
| 103 | + if( $review->$metaKey == $metaValue ) { |
|
| 104 | + return; |
|
| 105 | + } |
|
| 94 | 106 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 95 | 107 | call_user_func( [$this, $method], $review, $metaValue ); |
| 96 | 108 | } |
@@ -65,7 +65,9 @@ |
||
| 65 | 65 | $avail_post_stati = get_available_post_statuses( Application::POST_TYPE ); |
| 66 | 66 | $table = new \WP_Posts_List_Table( ['screen' => $hookName] ); |
| 67 | 67 | $views = apply_filters( 'views_'.$hookName, $table->get_views() ); // uses compat get_views() |
| 68 | - if( empty( $views ))return; |
|
| 68 | + if( empty( $views )) { |
|
| 69 | + return; |
|
| 70 | + } |
|
| 69 | 71 | foreach( $views as $class => $view ) { |
| 70 | 72 | $views[$class] = "\t<li class='$class'>$view"; |
| 71 | 73 | } |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | * @see https://www.elegantthemes.com/gallery/divi/ |
| 9 | 9 | */ |
| 10 | 10 | add_action( 'site-reviews/customize/divi', function( $instance ) { |
| 11 | - if( $instance->tag != 'label' || $instance->args['type'] != 'checkbox' )return; |
|
| 11 | + if( $instance->tag != 'label' || $instance->args['type'] != 'checkbox' ) { |
|
| 12 | + return; |
|
| 13 | + } |
|
| 12 | 14 | $instance->args['text'] = '<i></i>'.$instance->args['text']; |
| 13 | 15 | }); |
| 14 | 16 | |
@@ -20,9 +22,13 @@ discard block |
||
| 20 | 22 | * @see https://wordpress.org/plugins/wp-super-cache/ |
| 21 | 23 | */ |
| 22 | 24 | add_action( 'site-reviews/review/created', function( $review, $request ) { |
| 23 | - if( !function_exists( 'wp_cache_post_change' ))return; |
|
| 25 | + if( !function_exists( 'wp_cache_post_change' )) { |
|
| 26 | + return; |
|
| 27 | + } |
|
| 24 | 28 | wp_cache_post_change( $request->post_id ); |
| 25 | - if( empty( $review->assigned_to ) || $review->assigned_to == $request->post_id )return; |
|
| 29 | + if( empty( $review->assigned_to ) || $review->assigned_to == $request->post_id ) { |
|
| 30 | + return; |
|
| 31 | + } |
|
| 26 | 32 | wp_cache_post_change( $review->assigned_to ); |
| 27 | 33 | }, 10, 2 ); |
| 28 | 34 | |
@@ -19,7 +19,9 @@ discard block |
||
| 19 | 19 | 'glsr_get_review', 'glsr_get_reviews', |
| 20 | 20 | 'glsr_log', |
| 21 | 21 | ); |
| 22 | - if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return; |
|
| 22 | + if( !in_array( $hook, $hooks ) || !function_exists( $hook )) { |
|
| 23 | + return; |
|
| 24 | + } |
|
| 23 | 25 | add_filter( $hook, function() use( $hook, $args ) { |
| 24 | 26 | array_shift( $args ); // remove the fallback value |
| 25 | 27 | return call_user_func_array( $hook, $args ); |
@@ -29,7 +31,8 @@ discard block |
||
| 29 | 31 | /** |
| 30 | 32 | * @return mixed |
| 31 | 33 | */ |
| 32 | -function glsr( $alias = null ) { |
|
| 34 | +function glsr( $alias = null ) |
|
| 35 | +{ |
|
| 33 | 36 | $app = \GeminiLabs\SiteReviews\Application::load(); |
| 34 | 37 | return !empty( $alias ) |
| 35 | 38 | ? $app->make( $alias ) |
@@ -39,7 +42,8 @@ discard block |
||
| 39 | 42 | /** |
| 40 | 43 | * @return void |
| 41 | 44 | */ |
| 42 | -function glsr_calculate_ratings() { |
|
| 45 | +function glsr_calculate_ratings() |
|
| 46 | +{ |
|
| 43 | 47 | glsr( 'Controllers\AdminController' )->routerCountReviews( false ); |
| 44 | 48 | glsr_log()->info( __( 'Recalculated rating counts.', 'site-reviews' )); |
| 45 | 49 | } |
@@ -47,7 +51,8 @@ discard block |
||
| 47 | 51 | /** |
| 48 | 52 | * @return null|\GeminiLabs\SiteReviews\Review |
| 49 | 53 | */ |
| 50 | -function glsr_create_review( $reviewValues = array() ) { |
|
| 54 | +function glsr_create_review( $reviewValues = array() ) |
|
| 55 | +{ |
|
| 51 | 56 | if( !is_array( $reviewValues )) { |
| 52 | 57 | $reviewValues = array(); |
| 53 | 58 | } |
@@ -61,7 +66,8 @@ discard block |
||
| 61 | 66 | /** |
| 62 | 67 | * @return \WP_Screen|object |
| 63 | 68 | */ |
| 64 | -function glsr_current_screen() { |
|
| 69 | +function glsr_current_screen() |
|
| 70 | +{ |
|
| 65 | 71 | if( function_exists( 'get_current_screen' )) { |
| 66 | 72 | $screen = get_current_screen(); |
| 67 | 73 | } |
@@ -74,7 +80,8 @@ discard block |
||
| 74 | 80 | * @param mixed ...$vars |
| 75 | 81 | * @return void |
| 76 | 82 | */ |
| 77 | -function glsr_debug( ...$vars ) { |
|
| 83 | +function glsr_debug( ...$vars ) |
|
| 84 | +{ |
|
| 78 | 85 | if( count( $vars ) == 1 ) { |
| 79 | 86 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
| 80 | 87 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -93,7 +100,8 @@ discard block |
||
| 93 | 100 | * @param mixed $fallback |
| 94 | 101 | * @return string|array |
| 95 | 102 | */ |
| 96 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
| 103 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
| 104 | +{ |
|
| 97 | 105 | return is_string( $path ) |
| 98 | 106 | ? glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ) |
| 99 | 107 | : $fallback; |
@@ -102,7 +110,8 @@ discard block |
||
| 102 | 110 | /** |
| 103 | 111 | * @return array |
| 104 | 112 | */ |
| 105 | -function glsr_get_options() { |
|
| 113 | +function glsr_get_options() |
|
| 114 | +{ |
|
| 106 | 115 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
| 107 | 116 | } |
| 108 | 117 | |
@@ -110,8 +119,11 @@ discard block |
||
| 110 | 119 | * @param int $post_id |
| 111 | 120 | * @return \GeminiLabs\SiteReviews\Review|void |
| 112 | 121 | */ |
| 113 | -function glsr_get_review( $post_id ) { |
|
| 114 | - if( !is_numeric( $post_id ))return; |
|
| 122 | +function glsr_get_review( $post_id ) |
|
| 123 | +{ |
|
| 124 | + if( !is_numeric( $post_id )) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 115 | 127 | $post = get_post( $post_id ); |
| 116 | 128 | if( $post instanceof WP_Post ) { |
| 117 | 129 | return glsr( 'Database\ReviewManager' )->single( $post ); |
@@ -122,7 +134,8 @@ discard block |
||
| 122 | 134 | * @return array |
| 123 | 135 | * @todo document change of $reviews->reviews to $reviews->results |
| 124 | 136 | */ |
| 125 | -function glsr_get_reviews( $args = array() ) { |
|
| 137 | +function glsr_get_reviews( $args = array() ) |
|
| 138 | +{ |
|
| 126 | 139 | if( !is_array( $args )) { |
| 127 | 140 | $args = []; |
| 128 | 141 | } |
@@ -132,7 +145,8 @@ discard block |
||
| 132 | 145 | /** |
| 133 | 146 | * @return \GeminiLabs\SiteReviews\Modules\Console |
| 134 | 147 | */ |
| 135 | -function glsr_log() { |
|
| 148 | +function glsr_log() |
|
| 149 | +{ |
|
| 136 | 150 | $args = func_get_args(); |
| 137 | 151 | $context = isset( $args[1] ) |
| 138 | 152 | ? $args[1] |