@@ -34,7 +34,7 @@ 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' ) )return; |
|
38 | 38 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
39 | 39 | $this->generateSchema(); |
40 | 40 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'stars' => $this->buildStars(), |
48 | 48 | 'text' => $this->buildText(), |
49 | 49 | ], |
50 | - ]); |
|
50 | + ] ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | */ |
56 | 56 | protected function buildPercentage() |
57 | 57 | { |
58 | - if( $this->isHidden( 'bars' ))return; |
|
59 | - $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
|
60 | - $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) { |
|
58 | + if( $this->isHidden( 'bars' ) )return; |
|
59 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) ); |
|
60 | + $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use($percentages) { |
|
61 | 61 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
62 | 62 | $background = $this->buildPercentageBackground( $percentages[$level] ); |
63 | 63 | $count = apply_filters( 'site-reviews/summary/counts', |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $percent = $this->buildPercentageCount( $count ); |
68 | 68 | return $carry.glsr( Builder::class )->div( $label.$background.$percent, [ |
69 | 69 | 'class' => 'glsr-bar', |
70 | - ]); |
|
70 | + ] ); |
|
71 | 71 | }); |
72 | 72 | return $this->wrap( 'percentage', $bars ); |
73 | 73 | } |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | */ |
79 | 79 | protected function buildPercentageBackground( $percent ) |
80 | 80 | { |
81 | - $backgroundPercent = glsr( Builder::class )->span([ |
|
81 | + $backgroundPercent = glsr( Builder::class )->span( [ |
|
82 | 82 | 'class' => 'glsr-bar-background-percent', |
83 | 83 | 'style' => 'width:'.$percent, |
84 | - ]); |
|
84 | + ] ); |
|
85 | 85 | return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
86 | 86 | } |
87 | 87 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | protected function buildRating() |
110 | 110 | { |
111 | - if( $this->isHidden( 'rating' ))return; |
|
111 | + if( $this->isHidden( 'rating' ) )return; |
|
112 | 112 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
113 | 113 | } |
114 | 114 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function buildStars() |
119 | 119 | { |
120 | - if( $this->isHidden( 'stars' ))return; |
|
120 | + if( $this->isHidden( 'stars' ) )return; |
|
121 | 121 | $stars = glsr_star_rating( $this->averageRating ); |
122 | 122 | return $this->wrap( 'stars', $stars ); |
123 | 123 | } |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildText() |
129 | 129 | { |
130 | - if( $this->isHidden( 'summary' ))return; |
|
131 | - $count = intval( array_sum( $this->ratingCounts )); |
|
132 | - if( empty( $this->args['text'] )) { |
|
130 | + if( $this->isHidden( 'summary' ) )return; |
|
131 | + $count = intval( array_sum( $this->ratingCounts ) ); |
|
132 | + if( empty($this->args['text']) ) { |
|
133 | 133 | // @todo document this change |
134 | 134 | $this->args['text'] = _nx( |
135 | 135 | '{rating} out of {max} stars (based on {num} review)', |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | ); |
141 | 141 | } |
142 | 142 | $summary = str_replace( |
143 | - ['{rating}','{max}', '{num}'], |
|
143 | + ['{rating}', '{max}', '{num}'], |
|
144 | 144 | [$this->averageRating, Rating::MAX_RATING, $count], |
145 | 145 | $this->args['text'] |
146 | 146 | ); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function generateSchema() |
154 | 154 | { |
155 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
155 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
156 | 156 | glsr( Schema::class )->store( |
157 | 157 | glsr( Schema::class )->buildSummary( $this->args ) |
158 | 158 | ); |
@@ -184,6 +184,6 @@ discard block |
||
184 | 184 | { |
185 | 185 | return glsr( Builder::class )->div( $value, [ |
186 | 186 | 'class' => 'glsr-summary-'.$key, |
187 | - ]); |
|
187 | + ] ); |
|
188 | 188 | } |
189 | 189 | } |
@@ -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,8 +12,8 @@ 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; |
|
16 | - $assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' )); |
|
15 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ) )return; |
|
16 | + $assignedTo = strval( glsr( Helper::class )->filterInput( 'assigned_to' ) ); |
|
17 | 17 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
18 | 18 | } |
19 | 19 | |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function saveResponseMetabox( $postId ) |
25 | 25 | { |
26 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
27 | - $response = strval( glsr( Helper::class )->filterInput( 'response' )); |
|
26 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ) )return; |
|
27 | + $response = strval( glsr( Helper::class )->filterInput( 'response' ) ); |
|
28 | 28 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
29 | 29 | 'a' => ['href' => [], 'title' => []], |
30 | 30 | 'em' => [], |
31 | 31 | 'strong' => [], |
32 | - ]))); |
|
32 | + ] ) ) ); |
|
33 | 33 | } |
34 | 34 | } |
@@ -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,17 +22,17 @@ 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 )continue; |
|
26 | 26 | $postCount = wp_count_posts( Application::POST_TYPE ); |
27 | 27 | $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
28 | 28 | 'class' => 'pending-count', |
29 | - ]); |
|
29 | + ] ); |
|
30 | 30 | $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [ |
31 | 31 | 'class' => 'awaiting-mod count-'.$postCount->pending, |
32 | - ]); |
|
32 | + ] ); |
|
33 | 33 | $menu[$key][0] .= ' '.$awaitingModeration; |
34 | 34 | if( $typenow === Application::POST_TYPE ) { |
35 | - $menu[$key][4].= ' current'; |
|
35 | + $menu[$key][4] .= ' current'; |
|
36 | 36 | } |
37 | 37 | break; |
38 | 38 | } |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | 'tools' => __( 'Tools', 'site-reviews' ), |
50 | 50 | 'addons' => __( 'Add-ons', 'site-reviews' ), |
51 | 51 | 'documentation' => __( 'Documentation', 'site-reviews' ), |
52 | - ]); |
|
52 | + ] ); |
|
53 | 53 | foreach( $pages as $slug => $title ) { |
54 | 54 | $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' ); |
55 | 55 | $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
56 | - if( !is_callable( $callback ))continue; |
|
56 | + if( !is_callable( $callback ) )continue; |
|
57 | 57 | add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission( $slug ), $slug, $callback ); |
58 | 58 | } |
59 | 59 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $this->renderPage( 'addons', [ |
69 | 69 | 'template' => glsr( Template::class ), |
70 | - ]); |
|
70 | + ] ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | 'hooks' => __( 'Hooks', 'site-reviews' ), |
85 | 85 | 'functions' => __( 'Functions', 'site-reviews' ), |
86 | 86 | 'addons' => __( 'Addons', 'site-reviews' ), |
87 | - ]); |
|
87 | + ] ); |
|
88 | 88 | $addons = apply_filters( 'site-reviews/addon/documentation', [] ); |
89 | 89 | ksort( $addons ); |
90 | - if( empty( $addons )) { |
|
91 | - unset( $tabs['addons'] ); |
|
90 | + if( empty($addons) ) { |
|
91 | + unset($tabs['addons']); |
|
92 | 92 | } |
93 | 93 | $this->renderPage( 'documentation', [ |
94 | 94 | 'addons' => $addons, |
95 | 95 | 'tabs' => $tabs, |
96 | - ]); |
|
96 | + ] ); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | 'translations' => __( 'Translations', 'site-reviews' ), |
112 | 112 | 'addons' => __( 'Addons', 'site-reviews' ), |
113 | 113 | 'licenses' => __( 'Licenses', 'site-reviews' ), |
114 | - ]); |
|
115 | - if( empty( glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.addons' ))) { |
|
116 | - unset( $tabs['addons'] ); |
|
114 | + ] ); |
|
115 | + if( empty(glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.addons' )) ) { |
|
116 | + unset($tabs['addons']); |
|
117 | 117 | } |
118 | - if( empty( glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.licenses' ))) { |
|
119 | - unset( $tabs['licenses'] ); |
|
118 | + if( empty(glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.licenses' )) ) { |
|
119 | + unset($tabs['licenses']); |
|
120 | 120 | } |
121 | 121 | $this->renderPage( 'settings', [ |
122 | 122 | 'notices' => $this->getNotices(), |
123 | 123 | 'settings' => glsr( Settings::class ), |
124 | 124 | 'tabs' => $tabs, |
125 | - ]); |
|
125 | + ] ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | 'sync' => __( 'Sync Reviews', 'site-reviews' ), |
138 | 138 | 'console' => __( 'Console', 'site-reviews' ), |
139 | 139 | 'system-info' => __( 'System Info', 'site-reviews' ), |
140 | - ]); |
|
141 | - if( !apply_filters( 'site-reviews/addon/sync/enable', false )) { |
|
142 | - unset( $tabs['sync'] ); |
|
140 | + ] ); |
|
141 | + if( !apply_filters( 'site-reviews/addon/sync/enable', false ) ) { |
|
142 | + unset($tabs['sync']); |
|
143 | 143 | } |
144 | 144 | $this->renderPage( 'tools', [ |
145 | 145 | 'data' => [ |
146 | 146 | 'context' => [ |
147 | 147 | 'base_url' => admin_url( 'edit.php?post_type='.Application::POST_TYPE ), |
148 | - 'console' => strval( glsr( Console::class )), |
|
148 | + 'console' => strval( glsr( Console::class ) ), |
|
149 | 149 | 'id' => Application::ID, |
150 | - 'system' => strval( glsr( System::class )), |
|
150 | + 'system' => strval( glsr( System::class ) ), |
|
151 | 151 | ], |
152 | 152 | 'services' => apply_filters( 'site-reviews/addon/sync/services', [] ), |
153 | 153 | ], |
154 | 154 | 'notices' => $this->getNotices(), |
155 | 155 | 'tabs' => $tabs, |
156 | 156 | 'template' => glsr( Template::class ), |
157 | - ]); |
|
157 | + ] ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | { |
176 | 176 | return glsr( Builder::class )->div( glsr( Notice::class )->get(), [ |
177 | 177 | 'id' => 'glsr-notices', |
178 | - ]); |
|
178 | + ] ); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -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 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php defined( 'WPINC' ) || die; ?> |
2 | 2 | |
3 | -<?php if( glsr()->hasPermission( 'settings' )) : ?> |
|
3 | +<?php if( glsr()->hasPermission( 'settings' ) ) : ?> |
|
4 | 4 | <div class="glsr-card card"> |
5 | 5 | <h3>Export Settings</h3> |
6 | 6 | <p>Export the Site Reviews settings for this site to a <code>*.json</code> file. This allows you to easily import the plugin settings into another site.</p> |
@@ -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; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function enqueueAssets() |
29 | 29 | { |
30 | - if( apply_filters( 'site-reviews/assets/css', true )) { |
|
30 | + if( apply_filters( 'site-reviews/assets/css', true ) ) { |
|
31 | 31 | wp_enqueue_style( |
32 | 32 | Application::ID, |
33 | 33 | $this->getStylesheet(), |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | glsr()->version |
36 | 36 | ); |
37 | 37 | } |
38 | - if( apply_filters( 'site-reviews/assets/js', true )) { |
|
38 | + if( apply_filters( 'site-reviews/assets/js', true ) ) { |
|
39 | 39 | $dependencies = apply_filters( 'site-reviews/assets/polyfill', true ) |
40 | 40 | ? [Application::ID.'/polyfill'] |
41 | 41 | : []; |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function enqueuePolyfillService() |
57 | 57 | { |
58 | - if( !apply_filters( 'site-reviews/assets/polyfill', true ))return; |
|
59 | - wp_enqueue_script( Application::ID.'/polyfill', add_query_arg([ |
|
58 | + if( !apply_filters( 'site-reviews/assets/polyfill', true ) )return; |
|
59 | + wp_enqueue_script( Application::ID.'/polyfill', add_query_arg( [ |
|
60 | 60 | 'features' => 'CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver', |
61 | 61 | 'flags' => 'gated', |
62 | - ], 'https://polyfill.io/v3/polyfill.min.js' )); |
|
62 | + ], 'https://polyfill.io/v3/polyfill.min.js' ) ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | // nf-google-recaptcha |
73 | 73 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
74 | 74 | $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
75 | - wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
|
75 | + wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [ |
|
76 | 76 | 'hl' => $language, |
77 | 77 | 'render' => 'explicit', |
78 | - ], 'https://www.google.com/recaptcha/api.js' )); |
|
78 | + ], 'https://www.google.com/recaptcha/api.js' ) ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | public function inlineStyles() |
102 | 102 | { |
103 | 103 | $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
104 | - if( !apply_filters( 'site-reviews/assets/css', true ))return; |
|
105 | - if( !file_exists( $inlineStylesheetPath )) { |
|
104 | + if( !apply_filters( 'site-reviews/assets/css', true ) )return; |
|
105 | + if( !file_exists( $inlineStylesheetPath ) ) { |
|
106 | 106 | glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
107 | 107 | return; |
108 | 108 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | { |
123 | 123 | $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});'; |
124 | 124 | foreach( $variables as $key => $value ) { |
125 | - $script.= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE )); |
|
125 | + $script .= sprintf( 'GLSR.%s=%s;', $key, json_encode( $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ); |
|
126 | 126 | } |
127 | 127 | $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys |
128 | 128 | $optimizedScript = preg_replace( $pattern, '$1$2', $script ); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function getFixedSelectorsForPagination() |
136 | 136 | { |
137 | - $selectors = ['#wpadminbar','.site-navigation-fixed']; |
|
137 | + $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
138 | 138 | return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors ); |
139 | 139 | } |
140 | 140 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | protected function getStylesheet() |
145 | 145 | { |
146 | 146 | $currentStyle = glsr( Style::class )->style; |
147 | - return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' )) |
|
147 | + return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) ) |
|
148 | 148 | ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' ) |
149 | 149 | : glsr()->url( 'assets/styles/'.Application::ID.'.css' ); |
150 | 150 | } |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | public function approve() |
23 | 23 | { |
24 | 24 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
25 | - check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
|
26 | - wp_update_post([ |
|
25 | + check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) ); |
|
26 | + wp_update_post( [ |
|
27 | 27 | 'ID' => $postId, |
28 | 28 | 'post_status' => 'publish', |
29 | - ]); |
|
29 | + ] ); |
|
30 | 30 | wp_safe_redirect( wp_get_referer() ); |
31 | 31 | exit; |
32 | 32 | } |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
60 | 60 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
61 | 61 | foreach( $postTypeColumns as $key => &$value ) { |
62 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
62 | + if( !array_key_exists( $key, $columns ) || !empty($value) )continue; |
|
63 | 63 | $value = $columns[$key]; |
64 | 64 | } |
65 | - if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
|
66 | - unset( $postTypeColumns['review_type'] ); |
|
65 | + if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) { |
|
66 | + unset($postTypeColumns['review_type']); |
|
67 | 67 | } |
68 | 68 | return array_filter( $postTypeColumns, 'strlen' ); |
69 | 69 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function filterPostStates( $postStates, $post ) { |
107 | 107 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
108 | - if( glsr_get( $post, 'post_type' ) == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
|
108 | + if( glsr_get( $post, 'post_type' ) == Application::POST_TYPE && array_key_exists( 'pending', $postStates ) ) { |
|
109 | 109 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
110 | 110 | } |
111 | 111 | return $postStates; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | if( glsr_get( $post, 'post_type' ) != Application::POST_TYPE || $post->post_status == 'trash' ) { |
123 | 123 | return $actions; |
124 | 124 | } |
125 | - unset( $actions['inline hide-if-no-js'] ); //Remove Quick-edit |
|
125 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
126 | 126 | $rowActions = [ |
127 | 127 | 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
128 | 128 | 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ), |
137 | 137 | $key.'-review_'.$post->ID |
138 | 138 | ), |
139 | - ]); |
|
139 | + ] ); |
|
140 | 140 | } |
141 | 141 | return $newActions + glsr( Helper::class )->consolidateArray( $actions ); |
142 | 142 | } |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | { |
151 | 151 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
152 | 152 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
153 | - unset( $postTypeColumns['cb'] ); |
|
153 | + unset($postTypeColumns['cb']); |
|
154 | 154 | foreach( $postTypeColumns as $key => $value ) { |
155 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
155 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) )continue; |
|
156 | 156 | $columns[$key] = $key; |
157 | 157 | } |
158 | 158 | return $columns; |
@@ -170,18 +170,18 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function filterStatusText( $translation, $single, $plural, $number, $domain ) |
172 | 172 | { |
173 | - if( $this->canModifyTranslation( $domain )) { |
|
173 | + if( $this->canModifyTranslation( $domain ) ) { |
|
174 | 174 | $strings = [ |
175 | 175 | 'Published' => __( 'Approved', 'site-reviews' ), |
176 | 176 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
177 | 177 | ]; |
178 | 178 | foreach( $strings as $search => $replace ) { |
179 | 179 | if( strpos( $single, $search ) === false )continue; |
180 | - $translation = $this->getTranslation([ |
|
180 | + $translation = $this->getTranslation( [ |
|
181 | 181 | 'number' => $number, |
182 | 182 | 'plural' => str_replace( $search, $replace, $plural ), |
183 | 183 | 'single' => str_replace( $search, $replace, $single ), |
184 | - ]); |
|
184 | + ] ); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | return $translation; |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function saveBulkEditFields( $postId ) |
230 | 230 | { |
231 | - if( !current_user_can( 'edit_posts' ))return; |
|
231 | + if( !current_user_can( 'edit_posts' ) )return; |
|
232 | 232 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
233 | - if( $assignedTo && get_post( $assignedTo )) { |
|
233 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
234 | 234 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
235 | 235 | } |
236 | 236 | } |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function setQueryForColumn( WP_Query $query ) |
243 | 243 | { |
244 | - if( !$this->hasPermission( $query ))return; |
|
244 | + if( !$this->hasPermission( $query ) )return; |
|
245 | 245 | $this->setMetaQuery( $query, [ |
246 | 246 | 'rating', 'review_type', |
247 | - ]); |
|
247 | + ] ); |
|
248 | 248 | $this->setOrderby( $query ); |
249 | 249 | } |
250 | 250 | |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | public function unapprove() |
256 | 256 | { |
257 | 257 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
258 | - check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
|
259 | - wp_update_post([ |
|
258 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
259 | + wp_update_post( [ |
|
260 | 260 | 'ID' => $postId, |
261 | 261 | 'post_status' => 'pending', |
262 | - ]); |
|
262 | + ] ); |
|
263 | 263 | wp_safe_redirect( wp_get_referer() ); |
264 | 264 | exit; |
265 | 265 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | 'single' => '', |
290 | 290 | 'text' => '', |
291 | 291 | ]; |
292 | - $args = (object) wp_parse_args( $args, $defaults ); |
|
292 | + $args = (object)wp_parse_args( $args, $defaults ); |
|
293 | 293 | $translations = get_translations_for_domain( Application::ID ); |
294 | 294 | return $args->text |
295 | 295 | ? $translations->translate( $args->text ) |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
315 | 315 | { |
316 | 316 | foreach( $metaKeys as $key ) { |
317 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
317 | + if( !($value = filter_input( INPUT_GET, $key )) )continue; |
|
318 | 318 | $metaQuery = (array)$query->get( 'meta_query' ); |
319 | 319 | $metaQuery[] = [ |
320 | 320 | 'key' => $key, |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | { |
332 | 332 | $orderby = $query->get( 'orderby' ); |
333 | 333 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
334 | - unset( $columns['cb'], $columns['title'], $columns['date'] ); |
|
335 | - if( in_array( $orderby, array_keys( $columns ))) { |
|
334 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
335 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
336 | 336 | if( $orderby == 'reviewer' ) { |
337 | 337 | $orderby = 'author'; |
338 | 338 | } |
@@ -21,7 +21,9 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function approve() |
23 | 23 | { |
24 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
24 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
25 | + return; |
|
26 | + } |
|
25 | 27 | check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
26 | 28 | wp_update_post([ |
27 | 29 | 'ID' => $postId, |
@@ -59,7 +61,9 @@ discard block |
||
59 | 61 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
60 | 62 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
61 | 63 | foreach( $postTypeColumns as $key => &$value ) { |
62 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
64 | + if( !array_key_exists( $key, $columns ) || !empty( $value )) { |
|
65 | + continue; |
|
66 | + } |
|
63 | 67 | $value = $columns[$key]; |
64 | 68 | } |
65 | 69 | if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
@@ -103,7 +107,8 @@ discard block |
||
103 | 107 | * @return array |
104 | 108 | * @filter display_post_states |
105 | 109 | */ |
106 | - public function filterPostStates( $postStates, $post ) { |
|
110 | + public function filterPostStates( $postStates, $post ) |
|
111 | + { |
|
107 | 112 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
108 | 113 | if( glsr_get( $post, 'post_type' ) == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
109 | 114 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
@@ -152,7 +157,9 @@ discard block |
||
152 | 157 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
153 | 158 | unset( $postTypeColumns['cb'] ); |
154 | 159 | foreach( $postTypeColumns as $key => $value ) { |
155 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
160 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
161 | + continue; |
|
162 | + } |
|
156 | 163 | $columns[$key] = $key; |
157 | 164 | } |
158 | 165 | return $columns; |
@@ -176,7 +183,9 @@ discard block |
||
176 | 183 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
177 | 184 | ]; |
178 | 185 | foreach( $strings as $search => $replace ) { |
179 | - if( strpos( $single, $search ) === false )continue; |
|
186 | + if( strpos( $single, $search ) === false ) { |
|
187 | + continue; |
|
188 | + } |
|
180 | 189 | $translation = $this->getTranslation([ |
181 | 190 | 'number' => $number, |
182 | 191 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -228,7 +237,9 @@ discard block |
||
228 | 237 | */ |
229 | 238 | public function saveBulkEditFields( $postId ) |
230 | 239 | { |
231 | - if( !current_user_can( 'edit_posts' ))return; |
|
240 | + if( !current_user_can( 'edit_posts' )) { |
|
241 | + return; |
|
242 | + } |
|
232 | 243 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
233 | 244 | if( $assignedTo && get_post( $assignedTo )) { |
234 | 245 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -241,7 +252,9 @@ discard block |
||
241 | 252 | */ |
242 | 253 | public function setQueryForColumn( WP_Query $query ) |
243 | 254 | { |
244 | - if( !$this->hasPermission( $query ))return; |
|
255 | + if( !$this->hasPermission( $query )) { |
|
256 | + return; |
|
257 | + } |
|
245 | 258 | $this->setMetaQuery( $query, [ |
246 | 259 | 'rating', 'review_type', |
247 | 260 | ]); |
@@ -254,7 +267,9 @@ discard block |
||
254 | 267 | */ |
255 | 268 | public function unapprove() |
256 | 269 | { |
257 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
270 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
271 | + return; |
|
272 | + } |
|
258 | 273 | check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
259 | 274 | wp_update_post([ |
260 | 275 | 'ID' => $postId, |
@@ -314,7 +329,9 @@ discard block |
||
314 | 329 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
315 | 330 | { |
316 | 331 | foreach( $metaKeys as $key ) { |
317 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
332 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
333 | + continue; |
|
334 | + } |
|
318 | 335 | $metaQuery = (array)$query->get( 'meta_query' ); |
319 | 336 | $metaQuery[] = [ |
320 | 337 | 'key' => $key, |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function renderAssignedToMetabox( $post ) |
135 | 135 | { |
136 | - if( !$this->isReviewPostType( $post ))return; |
|
136 | + if( !$this->isReviewPostType( $post ) )return; |
|
137 | 137 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
138 | 138 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
139 | 139 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
140 | 140 | 'id' => $assignedTo, |
141 | 141 | 'template' => $this->buildAssignedToTemplate( $assignedTo, $post ), |
142 | - ]); |
|
142 | + ] ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function renderDetailsMetaBox( $post ) |
151 | 151 | { |
152 | - if( !$this->isReviewPostType( $post ))return; |
|
152 | + if( !$this->isReviewPostType( $post ) )return; |
|
153 | 153 | $review = glsr( ReviewManager::class )->single( $post ); |
154 | 154 | glsr()->render( 'partials/editor/metabox-details', [ |
155 | 155 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
156 | 156 | 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
157 | - ]); |
|
157 | + ] ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function renderPinnedInPublishMetaBox() |
165 | 165 | { |
166 | - if( !$this->isReviewPostType( get_post() ))return; |
|
166 | + if( !$this->isReviewPostType( get_post() ) )return; |
|
167 | 167 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
168 | 168 | 'context' => [ |
169 | 169 | 'no' => __( 'No', 'site-reviews' ), |
170 | 170 | 'yes' => __( 'Yes', 'site-reviews' ), |
171 | 171 | ], |
172 | - 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true )), |
|
173 | - ]); |
|
172 | + 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true ) ), |
|
173 | + ] ); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function renderResponseMetaBox( $post ) |
182 | 182 | { |
183 | - if( !$this->isReviewPostType( $post ))return; |
|
183 | + if( !$this->isReviewPostType( $post ) )return; |
|
184 | 184 | wp_nonce_field( 'response', '_nonce-response', false ); |
185 | 185 | glsr()->render( 'partials/editor/metabox-response', [ |
186 | 186 | 'response' => get_post_meta( $post->ID, 'response', true ), |
187 | - ]); |
|
187 | + ] ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function renderReviewEditor( $post ) |
196 | 196 | { |
197 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
197 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
198 | 198 | glsr()->render( 'partials/editor/review', [ |
199 | 199 | 'post' => $post, |
200 | 200 | 'response' => get_post_meta( $post->ID, 'response', true ), |
201 | - ]); |
|
201 | + ] ); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $screen = glsr_current_screen(); |
211 | 211 | if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
212 | 212 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
213 | - add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
213 | + add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -220,16 +220,16 @@ discard block |
||
220 | 220 | */ |
221 | 221 | public function renderReviewNotice( $post ) |
222 | 222 | { |
223 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
223 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
224 | 224 | glsr( Notice::class )->addWarning( sprintf( |
225 | 225 | __( '%s reviews are read-only.', 'site-reviews' ), |
226 | 226 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
227 | - )); |
|
227 | + ) ); |
|
228 | 228 | glsr( Template::class )->render( 'partials/editor/notice', [ |
229 | 229 | 'context' => [ |
230 | 230 | 'notices' => glsr( Notice::class )->get(), |
231 | 231 | ], |
232 | - ]); |
|
232 | + ] ); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function renderTaxonomyMetabox( $post ) |
242 | 242 | { |
243 | - if( !$this->isReviewPostType( $post ))return; |
|
243 | + if( !$this->isReviewPostType( $post ) )return; |
|
244 | 244 | glsr()->render( 'partials/editor/metabox-categories', [ |
245 | 245 | 'post' => $post, |
246 | 246 | 'tax_name' => Application::TAXONOMY, |
247 | 247 | 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
248 | - ]); |
|
248 | + ] ); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | public function revertReview() |
257 | 257 | { |
258 | 258 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
259 | - check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
|
259 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
260 | 260 | glsr( ReviewManager::class )->revert( $postId ); |
261 | 261 | $this->redirect( $postId, 52 ); |
262 | 262 | } |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
280 | 280 | { |
281 | 281 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
282 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
282 | + if( !($assignedPost instanceof WP_Post) )return; |
|
283 | 283 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
284 | 284 | 'context' => [ |
285 | 285 | 'data.url' => (string)get_permalink( $assignedPost ), |
286 | 286 | 'data.title' => get_the_title( $assignedPost ), |
287 | 287 | ], |
288 | - ]); |
|
288 | + ] ); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | 'class' => 'button button-large', |
311 | 311 | 'href' => $revertUrl, |
312 | 312 | 'id' => 'revert', |
313 | - ]); |
|
313 | + ] ); |
|
314 | 314 | } |
315 | 315 | return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
316 | 316 | 'class' => 'button button-large', |
317 | 317 | 'disabled' => true, |
318 | 318 | 'id' => 'revert', |
319 | - ]); |
|
319 | + ] ); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
330 | 330 | ? glsr()->reviewTypes[$review->review_type] |
331 | 331 | : __( 'Unknown', 'site-reviews' ); |
332 | - if( !empty( $review->url )) { |
|
332 | + if( !empty($review->url) ) { |
|
333 | 333 | $reviewType = glsr( Builder::class )->a( $reviewType, [ |
334 | 334 | 'href' => $review->url, |
335 | 335 | 'target' => '_blank', |
336 | - ]); |
|
336 | + ] ); |
|
337 | 337 | } |
338 | 338 | return $reviewType; |
339 | 339 | } |
@@ -362,16 +362,16 @@ discard block |
||
362 | 362 | */ |
363 | 363 | protected function normalizeDetailsMetaBox( Review $review ) |
364 | 364 | { |
365 | - $user = empty( $review->user_id ) |
|
365 | + $user = empty($review->user_id) |
|
366 | 366 | ? __( 'Unregistered user', 'site-reviews' ) |
367 | 367 | : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
368 | 368 | 'href' => get_author_posts_url( $review->user_id ), |
369 | - ]); |
|
370 | - $email = empty( $review->email ) |
|
369 | + ] ); |
|
370 | + $email = empty($review->email) |
|
371 | 371 | ? '—' |
372 | 372 | : glsr( Builder::class )->a( $review->email, [ |
373 | 373 | 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
374 | - ]); |
|
374 | + ] ); |
|
375 | 375 | $metabox = [ |
376 | 376 | __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ), |
377 | 377 | __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | __( 'IP Address', 'site-reviews' ) => $review->ip_address, |
383 | 383 | __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ), |
384 | 384 | ]; |
385 | - return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review )); |
|
385 | + return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) ); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $redirectUri = $hasReferer |
400 | 400 | ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
401 | 401 | : get_edit_post_link( $postId ); |
402 | - wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri )); |
|
402 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
403 | 403 | exit; |
404 | 404 | } |
405 | 405 | } |
@@ -96,7 +96,9 @@ discard block |
||
96 | 96 | { |
97 | 97 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
98 | 98 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
99 | - if( get_post_meta( $post->ID, 'review_type', true ) != 'local' )return; |
|
99 | + if( get_post_meta( $post->ID, 'review_type', true ) != 'local' ) { |
|
100 | + return; |
|
101 | + } |
|
100 | 102 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
101 | 103 | } |
102 | 104 | |
@@ -133,7 +135,9 @@ discard block |
||
133 | 135 | */ |
134 | 136 | public function renderAssignedToMetabox( $post ) |
135 | 137 | { |
136 | - if( !$this->isReviewPostType( $post ))return; |
|
138 | + if( !$this->isReviewPostType( $post )) { |
|
139 | + return; |
|
140 | + } |
|
137 | 141 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
138 | 142 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
139 | 143 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -149,7 +153,9 @@ discard block |
||
149 | 153 | */ |
150 | 154 | public function renderDetailsMetaBox( $post ) |
151 | 155 | { |
152 | - if( !$this->isReviewPostType( $post ))return; |
|
156 | + if( !$this->isReviewPostType( $post )) { |
|
157 | + return; |
|
158 | + } |
|
153 | 159 | $review = glsr( ReviewManager::class )->single( $post ); |
154 | 160 | glsr()->render( 'partials/editor/metabox-details', [ |
155 | 161 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -163,7 +169,9 @@ discard block |
||
163 | 169 | */ |
164 | 170 | public function renderPinnedInPublishMetaBox() |
165 | 171 | { |
166 | - if( !$this->isReviewPostType( get_post() ))return; |
|
172 | + if( !$this->isReviewPostType( get_post() )) { |
|
173 | + return; |
|
174 | + } |
|
167 | 175 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
168 | 176 | 'context' => [ |
169 | 177 | 'no' => __( 'No', 'site-reviews' ), |
@@ -180,7 +188,9 @@ discard block |
||
180 | 188 | */ |
181 | 189 | public function renderResponseMetaBox( $post ) |
182 | 190 | { |
183 | - if( !$this->isReviewPostType( $post ))return; |
|
191 | + if( !$this->isReviewPostType( $post )) { |
|
192 | + return; |
|
193 | + } |
|
184 | 194 | wp_nonce_field( 'response', '_nonce-response', false ); |
185 | 195 | glsr()->render( 'partials/editor/metabox-response', [ |
186 | 196 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -194,7 +204,9 @@ discard block |
||
194 | 204 | */ |
195 | 205 | public function renderReviewEditor( $post ) |
196 | 206 | { |
197 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
207 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
208 | + return; |
|
209 | + } |
|
198 | 210 | glsr()->render( 'partials/editor/review', [ |
199 | 211 | 'post' => $post, |
200 | 212 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -208,7 +220,9 @@ discard block |
||
208 | 220 | public function renderReviewFields() |
209 | 221 | { |
210 | 222 | $screen = glsr_current_screen(); |
211 | - if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
|
223 | + if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE ) { |
|
224 | + return; |
|
225 | + } |
|
212 | 226 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
213 | 227 | add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
214 | 228 | } |
@@ -220,7 +234,9 @@ discard block |
||
220 | 234 | */ |
221 | 235 | public function renderReviewNotice( $post ) |
222 | 236 | { |
223 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
237 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
238 | + return; |
|
239 | + } |
|
224 | 240 | glsr( Notice::class )->addWarning( sprintf( |
225 | 241 | __( '%s reviews are read-only.', 'site-reviews' ), |
226 | 242 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
@@ -240,7 +256,9 @@ discard block |
||
240 | 256 | */ |
241 | 257 | public function renderTaxonomyMetabox( $post ) |
242 | 258 | { |
243 | - if( !$this->isReviewPostType( $post ))return; |
|
259 | + if( !$this->isReviewPostType( $post )) { |
|
260 | + return; |
|
261 | + } |
|
244 | 262 | glsr()->render( 'partials/editor/metabox-categories', [ |
245 | 263 | 'post' => $post, |
246 | 264 | 'tax_name' => Application::TAXONOMY, |
@@ -255,7 +273,9 @@ discard block |
||
255 | 273 | */ |
256 | 274 | public function revertReview() |
257 | 275 | { |
258 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
276 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
277 | + return; |
|
278 | + } |
|
259 | 279 | check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
260 | 280 | glsr( ReviewManager::class )->revert( $postId ); |
261 | 281 | $this->redirect( $postId, 52 ); |
@@ -279,7 +299,9 @@ discard block |
||
279 | 299 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
280 | 300 | { |
281 | 301 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
282 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
302 | + if( !( $assignedPost instanceof WP_Post )) { |
|
303 | + return; |
|
304 | + } |
|
283 | 305 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
284 | 306 | 'context' => [ |
285 | 307 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -325,7 +347,9 @@ discard block |
||
325 | 347 | */ |
326 | 348 | protected function getReviewType( $review ) |
327 | 349 | { |
328 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
350 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
351 | + return; |
|
352 | + } |
|
329 | 353 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
330 | 354 | ? glsr()->reviewTypes[$review->review_type] |
331 | 355 | : __( 'Unknown', 'site-reviews' ); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function build() |
23 | 23 | { |
24 | - glsr_log()->error( 'Build method is not implemented for '.get_class( $this )); |
|
24 | + glsr_log()->error( 'Build method is not implemented for '.get_class( $this ) ); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | wp_parse_args( $args, static::defaults() ), |
42 | 42 | static::required() |
43 | 43 | ); |
44 | - $merged['class'] = implode( ' ', static::mergedAttribute( 'class', ' ', $args )); |
|
45 | - $merged['style'] = implode( ';', static::mergedAttribute( 'style', ';', $args )); |
|
44 | + $merged['class'] = implode( ' ', static::mergedAttribute( 'class', ' ', $args ) ); |
|
45 | + $merged['style'] = implode( ';', static::mergedAttribute( 'style', ';', $args ) ); |
|
46 | 46 | return $merged; |
47 | 47 | } |
48 | 48 | |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | public static function mergedAttribute( $key, $delimiter, array $args ) |
55 | 55 | { |
56 | 56 | return array_filter( array_merge( |
57 | - explode( $delimiter, glsr_get( $args, $key )), |
|
58 | - explode( $delimiter, glsr_get( static::defaults(), $key )), |
|
59 | - explode( $delimiter, glsr_get( static::required(), $key )) |
|
60 | - )); |
|
57 | + explode( $delimiter, glsr_get( $args, $key ) ), |
|
58 | + explode( $delimiter, glsr_get( static::defaults(), $key ) ), |
|
59 | + explode( $delimiter, glsr_get( static::required(), $key ) ) |
|
60 | + ) ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | 'templates/form/submit-button', |
51 | 51 | 'templates/reviews-form', |
52 | 52 | ]; |
53 | - if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) { |
|
53 | + if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) { |
|
54 | 54 | return $view; |
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
58 | + if( !file_exists( glsr()->file( $possibleView ) ) )continue; |
|
59 | 59 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
60 | 60 | } |
61 | 61 | return $view; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function modifyField( Builder $instance ) |
90 | 90 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
91 | + if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return; |
|
92 | 92 | call_user_func_array( [$this, 'customize'], [$instance] ); |
93 | 93 | } |
94 | 94 | |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function customize( Builder $instance ) |
107 | 107 | { |
108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
109 | - $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
|
108 | + if( !array_key_exists( $instance->tag, $this->fields ) )return; |
|
109 | + $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) ); |
|
110 | 110 | $key = $instance->tag.'_'.$args['type']; |
111 | - $classes = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag )); |
|
111 | + $classes = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag ) ); |
|
112 | 112 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
113 | 113 | do_action_ref_array( 'site-reviews/customize/'.$this->style, [$instance] ); |
114 | 114 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $args = wp_parse_args( $instance->args, [ |
141 | 141 | 'is_public' => false, |
142 | 142 | 'is_raw' => false, |
143 | - ]); |
|
143 | + ] ); |
|
144 | 144 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
145 | 145 | return false; |
146 | 146 | } |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | $views = $this->generatePossibleViews( $view ); |
57 | 57 | foreach( $views as $possibleView ) { |
58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
58 | + if( !file_exists( glsr()->file( $possibleView ))) { |
|
59 | + continue; |
|
60 | + } |
|
59 | 61 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
60 | 62 | } |
61 | 63 | return $view; |
@@ -88,7 +90,9 @@ discard block |
||
88 | 90 | */ |
89 | 91 | public function modifyField( Builder $instance ) |
90 | 92 | { |
91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
93 | + if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) { |
|
94 | + return; |
|
95 | + } |
|
92 | 96 | call_user_func_array( [$this, 'customize'], [$instance] ); |
93 | 97 | } |
94 | 98 | |
@@ -105,7 +109,9 @@ discard block |
||
105 | 109 | */ |
106 | 110 | protected function customize( Builder $instance ) |
107 | 111 | { |
108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
112 | + if( !array_key_exists( $instance->tag, $this->fields )) { |
|
113 | + return; |
|
114 | + } |
|
109 | 115 | $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
110 | 116 | $key = $instance->tag.'_'.$args['type']; |
111 | 117 | $classes = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag )); |