@@ -86,7 +86,9 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function renderFilters( $postType ) |
| 88 | 88 | { |
| 89 | - if( $postType !== Application::POST_TYPE )return; |
|
| 89 | + if( $postType !== Application::POST_TYPE ) { |
|
| 90 | + return; |
|
| 91 | + } |
|
| 90 | 92 | if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
| 91 | 93 | $status = 'publish'; |
| 92 | 94 | } |
@@ -103,7 +105,9 @@ discard block |
||
| 103 | 105 | */ |
| 104 | 106 | public function renderValues( $column, $postId ) |
| 105 | 107 | { |
| 106 | - if( glsr_current_screen()->post_type != Application::POST_TYPE )return; |
|
| 108 | + if( glsr_current_screen()->post_type != Application::POST_TYPE ) { |
|
| 109 | + return; |
|
| 110 | + } |
|
| 107 | 111 | $method = glsr( Helper::class )->buildMethodName( $column, 'buildColumn' ); |
| 108 | 112 | echo method_exists( $this, $method ) |
| 109 | 113 | ? call_user_func( [$this, $method], $postId ) |
@@ -116,7 +120,9 @@ discard block |
||
| 116 | 120 | */ |
| 117 | 121 | protected function renderFilterRatings( $ratings ) |
| 118 | 122 | { |
| 119 | - if( empty( $ratings ))return; |
|
| 123 | + if( empty( $ratings )) { |
|
| 124 | + return; |
|
| 125 | + } |
|
| 120 | 126 | $ratings = array_flip( array_reverse( $ratings )); |
| 121 | 127 | array_walk( $ratings, function( &$value, $key ) { |
| 122 | 128 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
@@ -139,7 +145,9 @@ discard block |
||
| 139 | 145 | */ |
| 140 | 146 | protected function renderFilterTypes( $types ) |
| 141 | 147 | { |
| 142 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 148 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 143 | 151 | echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
| 144 | 152 | 'class' => 'screen-reader-text', |
| 145 | 153 | 'for' => 'review_type', |
@@ -48,7 +48,9 @@ |
||
| 48 | 48 | public function filterUpdateMessages( array $messages ) |
| 49 | 49 | { |
| 50 | 50 | $post = get_post(); |
| 51 | - if( !( $post instanceof WP_Post ))return; |
|
| 51 | + if( !( $post instanceof WP_Post )) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 52 | 54 | $strings = $this->getReviewLabels(); |
| 53 | 55 | $restored = filter_input( INPUT_GET, 'revision' ); |
| 54 | 56 | if( $revisionTitle = wp_post_revision_title( intval( $restored ), false )) { |
@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function onCreateReview( $postData, $meta, $postId ) |
| 24 | 24 | { |
| 25 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
| 25 | + if( !$this->isReviewPostType( $review = get_post( $postId ))) { |
|
| 26 | + return; |
|
| 27 | + } |
|
| 26 | 28 | $this->updateAssignedToPost( $review ); |
| 27 | 29 | } |
| 28 | 30 | |
@@ -32,7 +34,9 @@ discard block |
||
| 32 | 34 | */ |
| 33 | 35 | public function onDeleteReview( $postId ) |
| 34 | 36 | { |
| 35 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
| 37 | + if( !$this->isReviewPostType( $review = get_post( $postId ))) { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 36 | 40 | $review->post_status = 'deleted'; // important to change the post_status here first! |
| 37 | 41 | $this->updateAssignedToPost( $review ); |
| 38 | 42 | } |
@@ -52,7 +56,9 @@ discard block |
||
| 52 | 56 | */ |
| 53 | 57 | public function saveAssignedToMetabox( $postId ) |
| 54 | 58 | { |
| 55 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 59 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) { |
|
| 60 | + return; |
|
| 61 | + } |
|
| 56 | 62 | $assignedTo = glsr( Helper::class )->filterInput( 'assigned_to' ); |
| 57 | 63 | $assignedTo || $assignedTo = ''; |
| 58 | 64 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -67,7 +73,9 @@ discard block |
||
| 67 | 73 | */ |
| 68 | 74 | public function saveResponseMetabox( $postId ) |
| 69 | 75 | { |
| 70 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
| 76 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 71 | 79 | $response = glsr( Helper::class )->filterInput( 'response' ); |
| 72 | 80 | $response || $response = ''; |
| 73 | 81 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
@@ -120,9 +128,13 @@ discard block |
||
| 120 | 128 | */ |
| 121 | 129 | protected function updateAssignedToPost( WP_Post $review ) |
| 122 | 130 | { |
| 123 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
| 131 | + if( !( $postId = $this->getAssignedToPostId( $review->ID ))) { |
|
| 132 | + return; |
|
| 133 | + } |
|
| 124 | 134 | $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 125 | - if( empty( $reviewIds ))return; |
|
| 135 | + if( empty( $reviewIds )) { |
|
| 136 | + return; |
|
| 137 | + } |
|
| 126 | 138 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
| 127 | 139 | $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
| 128 | 140 | if( empty( $updatedReviewIds )) { |
@@ -107,7 +107,9 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function renderReviewEditor( WP_Post $post ) |
| 109 | 109 | { |
| 110 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 110 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 111 | + return; |
|
| 112 | + } |
|
| 111 | 113 | glsr()->render( 'partials/editor/review', [ |
| 112 | 114 | 'post' => $post, |
| 113 | 115 | ]); |
@@ -119,7 +121,9 @@ discard block |
||
| 119 | 121 | */ |
| 120 | 122 | public function renderReviewNotice( WP_Post $post ) |
| 121 | 123 | { |
| 122 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 124 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 123 | 127 | glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' )); |
| 124 | 128 | glsr( Html::class )->renderTemplate( 'partials/editor/notice', [ |
| 125 | 129 | 'context' => [ |
@@ -134,13 +138,19 @@ discard block |
||
| 134 | 138 | */ |
| 135 | 139 | public function renderTinymceButton() |
| 136 | 140 | { |
| 137 | - if( glsr_current_screen()->base != 'post' )return; |
|
| 141 | + if( glsr_current_screen()->base != 'post' ) { |
|
| 142 | + return; |
|
| 143 | + } |
|
| 138 | 144 | $shortcodes = []; |
| 139 | 145 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
| 140 | - if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ))continue; |
|
| 146 | + if( !apply_filters( sanitize_title( $shortcode ).'_condition', true )) { |
|
| 147 | + continue; |
|
| 148 | + } |
|
| 141 | 149 | $shortcodes[$shortcode] = $values; |
| 142 | 150 | } |
| 143 | - if( empty( $shortcodes ))return; |
|
| 151 | + if( empty( $shortcodes )) { |
|
| 152 | + return; |
|
| 153 | + } |
|
| 144 | 154 | glsr()->render( 'partials/editor/tinymce', [ |
| 145 | 155 | 'shortcodes' => $shortcodes, |
| 146 | 156 | ]); |
@@ -72,7 +72,9 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function send() |
| 74 | 74 | { |
| 75 | - if( !$this->message || !$this->subject || !$this->to )return; |
|
| 75 | + if( !$this->message || !$this->subject || !$this->to ) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 76 | 78 | $sent = wp_mail( |
| 77 | 79 | $this->to, |
| 78 | 80 | $this->subject, |
@@ -90,8 +92,12 @@ discard block |
||
| 90 | 92 | */ |
| 91 | 93 | public function buildPlainTextMessage( PHPMailer $phpmailer ) |
| 92 | 94 | { |
| 93 | - if( empty( $this->email ))return; |
|
| 94 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 95 | + if( empty( $this->email )) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 98 | + if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody )) { |
|
| 99 | + return; |
|
| 100 | + } |
|
| 95 | 101 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 96 | 102 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 97 | 103 | } |
@@ -29,7 +29,8 @@ |
||
| 29 | 29 | protected $settings; |
| 30 | 30 | protected $taxonomy; |
| 31 | 31 | |
| 32 | - public function __construct( Application $app ) { |
|
| 32 | + public function __construct( Application $app ) |
|
| 33 | + { |
|
| 33 | 34 | $this->app = $app; |
| 34 | 35 | $this->admin = $app->make( AdminController::class ); |
| 35 | 36 | $this->editor = $app->make( EditorController::class ); |
@@ -4,7 +4,8 @@ discard block |
||
| 4 | 4 | /** |
| 5 | 5 | * @return mixed |
| 6 | 6 | */ |
| 7 | -function glsr( $alias = null ) { |
|
| 7 | +function glsr( $alias = null ) |
|
| 8 | +{ |
|
| 8 | 9 | $app = \GeminiLabs\SiteReviews\Application::load(); |
| 9 | 10 | return !empty( $alias ) |
| 10 | 11 | ? $app->make( $alias ) |
@@ -14,7 +15,8 @@ discard block |
||
| 14 | 15 | /** |
| 15 | 16 | * @return \WP_Screen|object |
| 16 | 17 | */ |
| 17 | -function glsr_current_screen() { |
|
| 18 | +function glsr_current_screen() |
|
| 19 | +{ |
|
| 18 | 20 | if( function_exists( 'get_current_screen' )) { |
| 19 | 21 | $screen = get_current_screen(); |
| 20 | 22 | } |
@@ -26,7 +28,8 @@ discard block |
||
| 26 | 28 | /** |
| 27 | 29 | * @return \GeminiLabs\SiteReviews\Database |
| 28 | 30 | */ |
| 29 | -function glsr_db() { |
|
| 31 | +function glsr_db() |
|
| 32 | +{ |
|
| 30 | 33 | return glsr( 'Database' ); |
| 31 | 34 | } |
| 32 | 35 | |
@@ -34,7 +37,8 @@ discard block |
||
| 34 | 37 | * @param mixed ...$vars |
| 35 | 38 | * @return void |
| 36 | 39 | */ |
| 37 | -function glsr_debug( ...$vars ) { |
|
| 40 | +function glsr_debug( ...$vars ) |
|
| 41 | +{ |
|
| 38 | 42 | if( count( $vars ) == 1 ) { |
| 39 | 43 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
| 40 | 44 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -51,7 +55,8 @@ discard block |
||
| 51 | 55 | /** |
| 52 | 56 | * @return \GeminiLabs\SiteReviews\Modules\Console |
| 53 | 57 | */ |
| 54 | -function glsr_log() { |
|
| 58 | +function glsr_log() |
|
| 59 | +{ |
|
| 55 | 60 | $args = func_get_args(); |
| 56 | 61 | $context = isset( $args[1] ) |
| 57 | 62 | ? $args[1] |
@@ -67,14 +72,16 @@ discard block |
||
| 67 | 72 | * @param mixed $fallback |
| 68 | 73 | * @return string|array |
| 69 | 74 | */ |
| 70 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
| 75 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
| 76 | +{ |
|
| 71 | 77 | return glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ); |
| 72 | 78 | } |
| 73 | 79 | |
| 74 | 80 | /** |
| 75 | 81 | * @return array |
| 76 | 82 | */ |
| 77 | -function glsr_get_options() { |
|
| 83 | +function glsr_get_options() |
|
| 84 | +{ |
|
| 78 | 85 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
| 79 | 86 | } |
| 80 | 87 | |
@@ -16,9 +16,13 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | $queries = []; |
| 18 | 18 | foreach( $keys as $key ) { |
| 19 | - if( !array_key_exists( $key, $values ))continue; |
|
| 19 | + if( !array_key_exists( $key, $values )) { |
|
| 20 | + continue; |
|
| 21 | + } |
|
| 20 | 22 | $methodName = glsr( Helper::class )->buildMethodName( $key, __FUNCTION__ ); |
| 21 | - if( !method_exists( $this, $methodName ))continue; |
|
| 23 | + if( !method_exists( $this, $methodName )) { |
|
| 24 | + continue; |
|
| 25 | + } |
|
| 22 | 26 | $query = call_user_func( [$this, $methodName], $values[$key] ); |
| 23 | 27 | if( is_array( $query )) { |
| 24 | 28 | $queries[] = $query; |
@@ -92,7 +96,9 @@ discard block |
||
| 92 | 96 | */ |
| 93 | 97 | protected function buildQueryAssignedTo( $value ) |
| 94 | 98 | { |
| 95 | - if( empty( $value ))return; |
|
| 99 | + if( empty( $value )) { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 96 | 102 | return [ |
| 97 | 103 | 'compare' => 'IN', |
| 98 | 104 | 'key' => 'assigned_to', |
@@ -106,7 +112,9 @@ discard block |
||
| 106 | 112 | */ |
| 107 | 113 | protected function buildQueryCategory( $value ) |
| 108 | 114 | { |
| 109 | - if( empty( $value ))return; |
|
| 115 | + if( empty( $value )) { |
|
| 116 | + return; |
|
| 117 | + } |
|
| 110 | 118 | return [ |
| 111 | 119 | 'field' => 'term_id', |
| 112 | 120 | 'taxonomy' => Application::TAXONOMY, |
@@ -120,7 +128,9 @@ discard block |
||
| 120 | 128 | */ |
| 121 | 129 | protected function buildQueryRating( $value ) |
| 122 | 130 | { |
| 123 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
| 131 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ))) { |
|
| 132 | + return; |
|
| 133 | + } |
|
| 124 | 134 | return [ |
| 125 | 135 | 'compare' => '>=', |
| 126 | 136 | 'key' => 'rating', |
@@ -134,7 +144,9 @@ discard block |
||
| 134 | 144 | */ |
| 135 | 145 | protected function buildQueryType( $value ) |
| 136 | 146 | { |
| 137 | - if( in_array( $value, ['','all'] ))return; |
|
| 147 | + if( in_array( $value, ['','all'] )) { |
|
| 148 | + return; |
|
| 149 | + } |
|
| 138 | 150 | return [ |
| 139 | 151 | 'key' => 'review_type', |
| 140 | 152 | 'value' => $value, |
@@ -212,7 +212,9 @@ discard block |
||
| 212 | 212 | $newParents = $parents; |
| 213 | 213 | foreach( $parents as $parent ) { |
| 214 | 214 | $parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ ); |
| 215 | - if( !class_exists( $parentClass ))continue; |
|
| 215 | + if( !class_exists( $parentClass )) { |
|
| 216 | + continue; |
|
| 217 | + } |
|
| 216 | 218 | $newParents = array_merge( $newParents, $this->getParents( (new $parentClass)->parents )); |
| 217 | 219 | } |
| 218 | 220 | return array_values( array_unique( $newParents )); |
@@ -226,7 +228,9 @@ discard block |
||
| 226 | 228 | $parents = $this->getParents(); |
| 227 | 229 | foreach( $parents as $parent ) { |
| 228 | 230 | $parentClass = glsr( Helper::class )->buildClassName( $parent, __NAMESPACE__ ); |
| 229 | - if( !class_exists( $parentClass ))continue; |
|
| 231 | + if( !class_exists( $parentClass )) { |
|
| 232 | + continue; |
|
| 233 | + } |
|
| 230 | 234 | $this->allowed = array_values( array_unique( array_merge( (new $parentClass)->allowed, $this->allowed ))); |
| 231 | 235 | } |
| 232 | 236 | } |