@@ -78,7 +78,9 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function renderFilters( $postType ) |
80 | 80 | { |
81 | - if( $postType !== Application::POST_TYPE )return; |
|
81 | + if( $postType !== Application::POST_TYPE ) { |
|
82 | + return; |
|
83 | + } |
|
82 | 84 | if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
83 | 85 | $status = 'publish'; |
84 | 86 | } |
@@ -107,7 +109,9 @@ discard block |
||
107 | 109 | */ |
108 | 110 | protected function renderFilterRatings( $ratings ) |
109 | 111 | { |
110 | - if( empty( $ratings ))return; |
|
112 | + if( empty( $ratings )) { |
|
113 | + return; |
|
114 | + } |
|
111 | 115 | $ratings = array_flip( array_reverse( $ratings )); |
112 | 116 | array_walk( $ratings, function( &$value, $key ) { |
113 | 117 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
@@ -130,7 +134,9 @@ discard block |
||
130 | 134 | */ |
131 | 135 | protected function renderFilterTypes( $types ) |
132 | 136 | { |
133 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
137 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
138 | + return; |
|
139 | + } |
|
134 | 140 | echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
135 | 141 | 'class' => 'screen-reader-text', |
136 | 142 | 'for' => 'review_type', |
@@ -22,7 +22,9 @@ |
||
22 | 22 | require_once __DIR__.'/activate.php'; |
23 | 23 | } |
24 | 24 | $check = new GL_Plugin_Check_v3( __FILE__ ); |
25 | -if( !$check->canProceed() )return; |
|
25 | +if( !$check->canProceed() ) { |
|
26 | + return; |
|
27 | +} |
|
26 | 28 | require_once __DIR__.'/autoload.php'; |
27 | 29 | require_once __DIR__.'/compatibility.php'; |
28 | 30 | require_once __DIR__.'/deprecated.php'; |
@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | 'glsr_log', |
21 | 21 | 'glsr_star_rating', |
22 | 22 | ); |
23 | - if( !in_array( $hook, $hooks ) || !function_exists( $hook ))return; |
|
23 | + if( !in_array( $hook, $hooks ) || !function_exists( $hook )) { |
|
24 | + return; |
|
25 | + } |
|
24 | 26 | add_filter( $hook, function() use( $hook, $args ) { |
25 | 27 | array_shift( $args ); // remove the fallback value |
26 | 28 | return call_user_func_array( $hook, $args ); |
@@ -30,7 +32,8 @@ discard block |
||
30 | 32 | /** |
31 | 33 | * @return mixed |
32 | 34 | */ |
33 | -function glsr( $alias = null ) { |
|
35 | +function glsr( $alias = null ) |
|
36 | +{ |
|
34 | 37 | $app = \GeminiLabs\SiteReviews\Application::load(); |
35 | 38 | return !empty( $alias ) |
36 | 39 | ? $app->make( $alias ) |
@@ -42,11 +45,14 @@ discard block |
||
42 | 45 | * @param $column string |
43 | 46 | * @return array |
44 | 47 | */ |
45 | -function glsr_array_column( array $array, $column ) { |
|
48 | +function glsr_array_column( array $array, $column ) |
|
49 | +{ |
|
46 | 50 | $result = array(); |
47 | 51 | foreach( $array as $subarray ) { |
48 | 52 | $subarray = (array)$subarray; |
49 | - if( !isset( $subarray[$column] ))continue; |
|
53 | + if( !isset( $subarray[$column] )) { |
|
54 | + continue; |
|
55 | + } |
|
50 | 56 | $result[] = $subarray[$column]; |
51 | 57 | } |
52 | 58 | return $result; |
@@ -55,7 +61,8 @@ discard block |
||
55 | 61 | /** |
56 | 62 | * @return void |
57 | 63 | */ |
58 | -function glsr_calculate_ratings() { |
|
64 | +function glsr_calculate_ratings() |
|
65 | +{ |
|
59 | 66 | glsr( 'Controllers\AdminController' )->routerCountReviews( false ); |
60 | 67 | glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' )); |
61 | 68 | } |
@@ -63,7 +70,8 @@ discard block |
||
63 | 70 | /** |
64 | 71 | * @return \GeminiLabs\SiteReviews\Review|false |
65 | 72 | */ |
66 | -function glsr_create_review( $reviewValues = array() ) { |
|
73 | +function glsr_create_review( $reviewValues = array() ) |
|
74 | +{ |
|
67 | 75 | $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
68 | 76 | glsr( 'Helper' )->consolidateArray( $reviewValues ) |
69 | 77 | ); |
@@ -73,7 +81,8 @@ discard block |
||
73 | 81 | /** |
74 | 82 | * @return \WP_Screen|object |
75 | 83 | */ |
76 | -function glsr_current_screen() { |
|
84 | +function glsr_current_screen() |
|
85 | +{ |
|
77 | 86 | if( function_exists( 'get_current_screen' )) { |
78 | 87 | $screen = get_current_screen(); |
79 | 88 | } |
@@ -86,7 +95,8 @@ discard block |
||
86 | 95 | * @param mixed ...$vars |
87 | 96 | * @return void |
88 | 97 | */ |
89 | -function glsr_debug( ...$vars ) { |
|
98 | +function glsr_debug( ...$vars ) |
|
99 | +{ |
|
90 | 100 | if( count( $vars ) == 1 ) { |
91 | 101 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
92 | 102 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -106,7 +116,8 @@ discard block |
||
106 | 116 | * @param mixed $fallback |
107 | 117 | * @return mixed |
108 | 118 | */ |
109 | -function glsr_get( $array, $path = '', $fallback = '' ) { |
|
119 | +function glsr_get( $array, $path = '', $fallback = '' ) |
|
120 | +{ |
|
110 | 121 | return glsr( 'Helper' )->dataGet( $array, $path, $fallback ); |
111 | 122 | } |
112 | 123 | |
@@ -115,7 +126,8 @@ discard block |
||
115 | 126 | * @param mixed $fallback |
116 | 127 | * @return string|array |
117 | 128 | */ |
118 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
129 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
130 | +{ |
|
119 | 131 | return is_string( $path ) |
120 | 132 | ? glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ) |
121 | 133 | : $fallback; |
@@ -124,7 +136,8 @@ discard block |
||
124 | 136 | /** |
125 | 137 | * @return array |
126 | 138 | */ |
127 | -function glsr_get_options() { |
|
139 | +function glsr_get_options() |
|
140 | +{ |
|
128 | 141 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
129 | 142 | } |
130 | 143 | |
@@ -132,7 +145,8 @@ discard block |
||
132 | 145 | * @param int $post_id |
133 | 146 | * @return \GeminiLabs\SiteReviews\Review |
134 | 147 | */ |
135 | -function glsr_get_review( $post_id ) { |
|
148 | +function glsr_get_review( $post_id ) |
|
149 | +{ |
|
136 | 150 | $post = null; |
137 | 151 | if( is_numeric( $post_id )) { |
138 | 152 | $post = get_post( $post_id ); |
@@ -146,14 +160,16 @@ discard block |
||
146 | 160 | /** |
147 | 161 | * @return array |
148 | 162 | */ |
149 | -function glsr_get_reviews( $args = array() ) { |
|
163 | +function glsr_get_reviews( $args = array() ) |
|
164 | +{ |
|
150 | 165 | return glsr( 'Database\ReviewManager' )->get( glsr( 'Helper' )->consolidateArray( $args )); |
151 | 166 | } |
152 | 167 | |
153 | 168 | /** |
154 | 169 | * @return \GeminiLabs\SiteReviews\Modules\Console |
155 | 170 | */ |
156 | -function glsr_log() { |
|
171 | +function glsr_log() |
|
172 | +{ |
|
157 | 173 | $args = func_get_args(); |
158 | 174 | $console = glsr( 'Modules\Console' ); |
159 | 175 | $value = glsr( 'Helper' )->dataGet( $args, '0' ); |
@@ -165,6 +181,7 @@ discard block |
||
165 | 181 | /** |
166 | 182 | * @return string |
167 | 183 | */ |
168 | -function glsr_star_rating( $rating ) { |
|
184 | +function glsr_star_rating( $rating ) |
|
185 | +{ |
|
169 | 186 | return glsr( 'Modules\Html\Partial' )->build( 'star-rating', ['rating' => $rating] ); |
170 | 187 | } |
@@ -185,7 +185,9 @@ discard block |
||
185 | 185 | $once = glsr( Helper::class )->consolidateArray( $once ); |
186 | 186 | $levels = $this->getLevels(); |
187 | 187 | foreach( $once as $entry ) { |
188 | - if( !in_array( glsr_get( $entry, 'level' ), $levels ))continue; |
|
188 | + if( !in_array( glsr_get( $entry, 'level' ), $levels )) { |
|
189 | + continue; |
|
190 | + } |
|
189 | 191 | $level = glsr_get( $entry, 'level' ); |
190 | 192 | $message = glsr_get( $entry, 'message' ); |
191 | 193 | $backtraceLine = glsr_get( $entry, 'backtrace' ); |
@@ -218,7 +220,9 @@ discard block |
||
218 | 220 | return glsr_get( $entry, 'level' ) == $level |
219 | 221 | && glsr_get( $entry, 'handle' ) == $handle; |
220 | 222 | }); |
221 | - if( !empty( $filtered ))return; |
|
223 | + if( !empty( $filtered )) { |
|
224 | + return; |
|
225 | + } |
|
222 | 226 | $once[] = [ |
223 | 227 | 'backtrace' => $this->getBacktraceLineFromData( $data ), |
224 | 228 | 'handle' => $handle, |
@@ -411,7 +415,9 @@ discard block |
||
411 | 415 | */ |
412 | 416 | protected function reset() |
413 | 417 | { |
414 | - if( $this->size() <= pow( 1024, 2 ) / 8 )return; |
|
418 | + if( $this->size() <= pow( 1024, 2 ) / 8 ) { |
|
419 | + return; |
|
420 | + } |
|
415 | 421 | $this->clear(); |
416 | 422 | file_put_contents( |
417 | 423 | $this->file, |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | { |
35 | 35 | $this->args = $args; |
36 | 36 | $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $args ); |
37 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
37 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' )) { |
|
38 | + return; |
|
39 | + } |
|
38 | 40 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
39 | 41 | $this->generateSchema(); |
40 | 42 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -55,7 +57,9 @@ discard block |
||
55 | 57 | */ |
56 | 58 | protected function buildPercentage() |
57 | 59 | { |
58 | - if( $this->isHidden( 'bars' ))return; |
|
60 | + if( $this->isHidden( 'bars' )) { |
|
61 | + return; |
|
62 | + } |
|
59 | 63 | $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
60 | 64 | $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) { |
61 | 65 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
@@ -108,7 +112,9 @@ discard block |
||
108 | 112 | */ |
109 | 113 | protected function buildRating() |
110 | 114 | { |
111 | - if( $this->isHidden( 'rating' ))return; |
|
115 | + if( $this->isHidden( 'rating' )) { |
|
116 | + return; |
|
117 | + } |
|
112 | 118 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
113 | 119 | } |
114 | 120 | |
@@ -117,7 +123,9 @@ discard block |
||
117 | 123 | */ |
118 | 124 | protected function buildStars() |
119 | 125 | { |
120 | - if( $this->isHidden( 'stars' ))return; |
|
126 | + if( $this->isHidden( 'stars' )) { |
|
127 | + return; |
|
128 | + } |
|
121 | 129 | $stars = glsr_star_rating( $this->averageRating ); |
122 | 130 | return $this->wrap( 'stars', $stars ); |
123 | 131 | } |
@@ -127,7 +135,9 @@ discard block |
||
127 | 135 | */ |
128 | 136 | protected function buildText() |
129 | 137 | { |
130 | - if( $this->isHidden( 'summary' ))return; |
|
138 | + if( $this->isHidden( 'summary' )) { |
|
139 | + return; |
|
140 | + } |
|
131 | 141 | $count = intval( array_sum( $this->ratingCounts )); |
132 | 142 | if( empty( $this->args['text'] )) { |
133 | 143 | // @todo document this change |
@@ -152,7 +162,9 @@ discard block |
||
152 | 162 | */ |
153 | 163 | protected function generateSchema() |
154 | 164 | { |
155 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
165 | + if( !wp_validate_boolean( $this->args['schema'] )) { |
|
166 | + return; |
|
167 | + } |
|
156 | 168 | glsr( Schema::class )->store( |
157 | 169 | glsr( Schema::class )->buildSummary( $this->args ) |
158 | 170 | ); |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function saveAssignedToMetabox( $postId ) |
14 | 14 | { |
15 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
15 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' )) { |
|
16 | + return; |
|
17 | + } |
|
16 | 18 | $assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' )); |
17 | 19 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
18 | 20 | } |
@@ -23,7 +25,9 @@ discard block |
||
23 | 25 | */ |
24 | 26 | public function saveResponseMetabox( $postId ) |
25 | 27 | { |
26 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
28 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' )) { |
|
29 | + return; |
|
30 | + } |
|
27 | 31 | $response = strval( glsr( Helper::class )->filterInput( 'response' )); |
28 | 32 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
29 | 33 | 'a' => ['href' => [], 'title' => []], |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | { |
23 | 23 | global $menu, $typenow; |
24 | 24 | foreach( $menu as $key => $value ) { |
25 | - if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
25 | + if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE ) { |
|
26 | + continue; |
|
27 | + } |
|
26 | 28 | $postCount = wp_count_posts( Application::POST_TYPE ); |
27 | 29 | $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
28 | 30 | 'class' => 'pending-count', |
@@ -53,7 +55,9 @@ discard block |
||
53 | 55 | foreach( $pages as $slug => $title ) { |
54 | 56 | $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' ); |
55 | 57 | $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
56 | - if( !is_callable( $callback ))continue; |
|
58 | + if( !is_callable( $callback )) { |
|
59 | + continue; |
|
60 | + } |
|
57 | 61 | add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission( $slug ), $slug, $callback ); |
58 | 62 | } |
59 | 63 | } |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function enqueuePolyfillService() |
57 | 57 | { |
58 | - if( !apply_filters( 'site-reviews/assets/polyfill', true ))return; |
|
58 | + if( !apply_filters( 'site-reviews/assets/polyfill', true )) { |
|
59 | + return; |
|
60 | + } |
|
59 | 61 | wp_enqueue_script( Application::ID.'/polyfill', add_query_arg([ |
60 | 62 | 'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
61 | 63 | 'flags' => 'gated', |
@@ -70,7 +72,9 @@ discard block |
||
70 | 72 | // wpforms-recaptcha |
71 | 73 | // google-recaptcha |
72 | 74 | // nf-google-recaptcha |
73 | - if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
|
75 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
76 | + return; |
|
77 | + } |
|
74 | 78 | $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
75 | 79 | wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
76 | 80 | 'hl' => $language, |
@@ -84,7 +88,9 @@ discard block |
||
84 | 88 | public function inlineStyles() |
85 | 89 | { |
86 | 90 | $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
87 | - if( !apply_filters( 'site-reviews/assets/css', true ))return; |
|
91 | + if( !apply_filters( 'site-reviews/assets/css', true )) { |
|
92 | + return; |
|
93 | + } |
|
88 | 94 | if( !file_exists( $inlineStylesheetPath )) { |
89 | 95 | glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
90 | 96 | return; |
@@ -26,7 +26,9 @@ discard block |
||
26 | 26 | { |
27 | 27 | sort( $termTaxonomyIds ); |
28 | 28 | sort( $oldTermTaxonomyIds ); |
29 | - if( $termTaxonomyIds === $oldTermTaxonomyIds || !$this->isReviewPostId( $postId ))return; |
|
29 | + if( $termTaxonomyIds === $oldTermTaxonomyIds || !$this->isReviewPostId( $postId )) { |
|
30 | + return; |
|
31 | + } |
|
30 | 32 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
31 | 33 | $ignoredIds = array_intersect( $oldTermTaxonomyIds, $termTaxonomyIds ); |
32 | 34 | $decreasedIds = array_diff( $oldTermTaxonomyIds, $ignoredIds ); |
@@ -48,7 +50,9 @@ discard block |
||
48 | 50 | */ |
49 | 51 | public function onAfterChangeStatus( $newStatus, $oldStatus, $post ) |
50 | 52 | { |
51 | - if( glsr_get( $post, 'post_type') != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
53 | + if( glsr_get( $post, 'post_type') != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
54 | + return; |
|
55 | + } |
|
52 | 56 | $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
53 | 57 | if( $post->post_status == 'publish' ) { |
54 | 58 | glsr( CountsManager::class )->increase( $review ); |
@@ -64,7 +68,9 @@ discard block |
||
64 | 68 | */ |
65 | 69 | public function onAfterCreate( Review $review ) |
66 | 70 | { |
67 | - if( $review->status !== 'publish' )return; |
|
71 | + if( $review->status !== 'publish' ) { |
|
72 | + return; |
|
73 | + } |
|
68 | 74 | glsr( CountsManager::class )->increase( $review ); |
69 | 75 | } |
70 | 76 | |
@@ -75,7 +81,9 @@ discard block |
||
75 | 81 | */ |
76 | 82 | public function onBeforeDelete( $postId ) |
77 | 83 | { |
78 | - if( !$this->isReviewPostId( $postId ))return; |
|
84 | + if( !$this->isReviewPostId( $postId )) { |
|
85 | + return; |
|
86 | + } |
|
79 | 87 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
80 | 88 | glsr( CountsManager::class )->decrease( $review ); |
81 | 89 | } |
@@ -92,9 +100,13 @@ discard block |
||
92 | 100 | { |
93 | 101 | if( !$this->isReviewPostId( $postId ) |
94 | 102 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
95 | - )return; |
|
103 | + ) { |
|
104 | + return; |
|
105 | + } |
|
96 | 106 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
97 | - if( $review->$metaKey == $metaValue )return; |
|
107 | + if( $review->$metaKey == $metaValue ) { |
|
108 | + return; |
|
109 | + } |
|
98 | 110 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
99 | 111 | call_user_func( [$this, $method], $review, $metaValue ); |
100 | 112 | } |