@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | $counts = array_fill_keys( [5,4,3,2,1], [] ); |
64 | 64 | array_walk( $counts, function( &$count, $key ) use( $reviews ) { |
65 | 65 | $count = count( array_filter( $reviews, function( $review ) use( $key ) { |
66 | - if( !isset( $review->rating ))return; |
|
66 | + if( !isset( $review->rating )) { |
|
67 | + return; |
|
68 | + } |
|
67 | 69 | return $review->rating == $key; |
68 | 70 | })); |
69 | 71 | }); |
@@ -83,7 +85,9 @@ discard block |
||
83 | 85 | public function getLowerBound( array $upDownRatings, $confidencePercentage = 95 ) |
84 | 86 | { |
85 | 87 | $numRatings = count( $upDownRatings ); |
86 | - if( !$numRatings )return 0; |
|
88 | + if( !$numRatings ) { |
|
89 | + return 0; |
|
90 | + } |
|
87 | 91 | $positiveRatings = count( array_filter( $upDownRatings, function( $value ) { |
88 | 92 | return $value > 0; |
89 | 93 | })); |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | { |
51 | 51 | $average = count( $reviews ); |
52 | 52 | if( $average > 0 ) { |
53 | - $average = round( $this->getTotal( $reviews ) / $average, intval( $roundBy )); |
|
53 | + $average = round( $this->getTotal( $reviews ) / $average, intval( $roundBy ) ); |
|
54 | 54 | } |
55 | - return floatval( apply_filters( 'site-reviews/rating/average', $average, $reviews )); |
|
55 | + return floatval( apply_filters( 'site-reviews/rating/average', $average, $reviews ) ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function getCounts( array $reviews ) |
62 | 62 | { |
63 | - $counts = array_fill_keys( [5,4,3,2,1], [] ); |
|
64 | - array_walk( $counts, function( &$count, $key ) use( $reviews ) { |
|
65 | - $count = count( array_filter( $reviews, function( $review ) use( $key ) { |
|
66 | - if( !isset( $review->rating ))return; |
|
63 | + $counts = array_fill_keys( [5, 4, 3, 2, 1], [] ); |
|
64 | + array_walk( $counts, function( &$count, $key ) use($reviews) { |
|
65 | + $count = count( array_filter( $reviews, function( $review ) use($key) { |
|
66 | + if( !isset($review->rating) )return; |
|
67 | 67 | return $review->rating == $key; |
68 | - })); |
|
68 | + }) ); |
|
69 | 69 | }); |
70 | 70 | return $counts; |
71 | 71 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | if( !$numRatings )return 0; |
87 | 87 | $positiveRatings = count( array_filter( $upDownRatings, function( $value ) { |
88 | 88 | return $value > 0; |
89 | - })); |
|
89 | + }) ); |
|
90 | 90 | $z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
91 | 91 | $phat = 1 * $positiveRatings / $numRatings; |
92 | - return ( $phat + $z * $z / ( 2 * $numRatings ) - $z * sqrt(( $phat * ( 1 - $phat ) + $z * $z / ( 4 * $numRatings )) / $numRatings )) / ( 1 + $z * $z / $numRatings ); |
|
92 | + return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | public function getPercentages( array $reviews ) |
109 | 109 | { |
110 | 110 | $counts = $this->getCounts( $reviews ); |
111 | - array_walk( $counts, function( &$count, $rating ) use( $counts ) { |
|
111 | + array_walk( $counts, function( &$count, $rating ) use($counts) { |
|
112 | 112 | $total = array_sum( $counts ); |
113 | - $count = !empty( $total ) && !empty( $counts[$rating] ) |
|
113 | + $count = !empty($total) && !empty($counts[$rating]) |
|
114 | 114 | ? $counts[$rating] / array_sum( $counts ) * 100 |
115 | 115 | : 0; |
116 | 116 | }); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $this->getRankingUsingImdb( $reviews ), |
128 | 128 | $reviews, |
129 | 129 | $this |
130 | - )); |
|
130 | + ) ); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | $bayesMinimal = 10; // confidence |
158 | 158 | // Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error. |
159 | 159 | // This could also be the average score of all items instead of a fixed value. |
160 | - $bayesMean = ( $confidencePercentage / 100 ) * static::MAX_RATING; // prior, 70% = 3.5 |
|
160 | + $bayesMean = ($confidencePercentage / 100) * static::MAX_RATING; // prior, 70% = 3.5 |
|
161 | 161 | $numOfReviews = count( $reviews ); |
162 | 162 | $avgRating = $this->getAverage( $reviews ); |
163 | 163 | return $avgRating > 0 |
164 | - ? (( $bayesMinimal * $bayesMean ) + ( $avgRating * $numOfReviews )) / ( $bayesMinimal + $numOfReviews ) |
|
164 | + ? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews) |
|
165 | 165 | : 0; |
166 | 166 | } |
167 | 167 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $weight = $this->getWeight( $ratingCounts, $ratingCountsSum ); |
183 | 183 | $weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true ); |
184 | 184 | $zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage]; |
185 | - return $weight - $zScore * sqrt(( $weightPow2 - pow( $weight, 2 )) / ( $ratingCountsSum + 1 )); |
|
185 | + return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | $remainders = array_column( $percentages, 'remainder' ); |
203 | 203 | array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages ); |
204 | 204 | $i = 0; |
205 | - if( array_sum( array_column( $percentages, 'percent' )) > 0 ) { |
|
206 | - while( array_sum( array_column( $percentages, 'percent' )) < $target ) { |
|
205 | + if( array_sum( array_column( $percentages, 'percent' ) ) > 0 ) { |
|
206 | + while( array_sum( array_column( $percentages, 'percent' ) ) < $target ) { |
|
207 | 207 | $percentages[$i]['percent']++; |
208 | 208 | $i++; |
209 | 209 | } |
210 | 210 | } |
211 | 211 | array_multisort( $indexes, SORT_DESC, $percentages ); |
212 | - return array_combine( $indexes, array_column( $percentages, 'percent' )); |
|
212 | + return array_combine( $indexes, array_column( $percentages, 'percent' ) ); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false ) |
221 | 221 | { |
222 | 222 | return array_reduce( array_keys( $ratingCounts ), |
223 | - function( $count, $rating ) use( $ratingCounts, $ratingCountsSum, $powerOf2 ) { |
|
223 | + function( $count, $rating ) use($ratingCounts, $ratingCountsSum, $powerOf2) { |
|
224 | 224 | $ratingLevel = $powerOf2 ? pow( $rating, 2 ) : $rating; |
225 | - return $count + ( $ratingLevel * ( $ratingCounts[$rating] + 1 )) / $ratingCountsSum; |
|
225 | + return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum; |
|
226 | 226 | } |
227 | 227 | ); |
228 | 228 | } |
@@ -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, $prefix = __METHOD__ ); |
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; |
@@ -90,7 +94,9 @@ discard block |
||
90 | 94 | */ |
91 | 95 | protected function buildQueryAssignedTo( $value ) |
92 | 96 | { |
93 | - if( empty( $value ))return; |
|
97 | + if( empty( $value )) { |
|
98 | + return; |
|
99 | + } |
|
94 | 100 | return [ |
95 | 101 | 'compare' => 'IN', |
96 | 102 | 'key' => 'assigned_to', |
@@ -104,7 +110,9 @@ discard block |
||
104 | 110 | */ |
105 | 111 | protected function buildQueryCategory( $value ) |
106 | 112 | { |
107 | - if( empty( $value ))return; |
|
113 | + if( empty( $value )) { |
|
114 | + return; |
|
115 | + } |
|
108 | 116 | return [ |
109 | 117 | 'field' => 'term_id', |
110 | 118 | 'taxonomy' => Application::TAXONOMY, |
@@ -118,7 +126,9 @@ discard block |
||
118 | 126 | */ |
119 | 127 | protected function buildQueryRating( $value ) |
120 | 128 | { |
121 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
129 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ))) { |
|
130 | + return; |
|
131 | + } |
|
122 | 132 | return [ |
123 | 133 | 'compare' => '>=', |
124 | 134 | 'key' => 'rating', |
@@ -132,7 +142,9 @@ discard block |
||
132 | 142 | */ |
133 | 143 | protected function buildQueryType( $value ) |
134 | 144 | { |
135 | - if( in_array( $value, ['','all'] ))return; |
|
145 | + if( in_array( $value, ['','all'] )) { |
|
146 | + return; |
|
147 | + } |
|
136 | 148 | return [ |
137 | 149 | 'key' => 'review_type', |
138 | 150 | 'value' => $value, |
@@ -16,11 +16,11 @@ 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 ) )continue; |
|
20 | 20 | $methodName = glsr( Helper::class )->buildMethodName( $key, $prefix = __METHOD__ ); |
21 | - if( !method_exists( $this, $methodName ))continue; |
|
21 | + if( !method_exists( $this, $methodName ) )continue; |
|
22 | 22 | $query = call_user_func( [$this, $methodName], $values[$key] ); |
23 | - if( is_array( $query )) { |
|
23 | + if( is_array( $query ) ) { |
|
24 | 24 | $queries[] = $query; |
25 | 25 | } |
26 | 26 | } |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function buildSqlOr( $values, $sprintfFormat ) |
37 | 37 | { |
38 | - if( !is_array( $values )) { |
|
38 | + if( !is_array( $values ) ) { |
|
39 | 39 | $values = explode( ',', $values ); |
40 | 40 | } |
41 | - $values = array_filter( array_map( 'trim', (array)$values )); |
|
42 | - $values = array_map( function( $value ) use( $sprintfFormat ) { |
|
41 | + $values = array_filter( array_map( 'trim', (array)$values ) ); |
|
42 | + $values = array_map( function( $value ) use($sprintfFormat) { |
|
43 | 43 | return sprintf( $sprintfFormat, $value ); |
44 | 44 | }, $values ); |
45 | 45 | return implode( ' OR ', $values ); |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function filterSearchByTitle( $search, WP_Query $query ) |
56 | 56 | { |
57 | - if( empty( $search ) || empty( $query->get( 'search_terms' ))) { |
|
57 | + if( empty($search) || empty($query->get( 'search_terms' )) ) { |
|
58 | 58 | return $search; |
59 | 59 | } |
60 | 60 | global $wpdb; |
61 | - $n = empty( $query->get( 'exact' )) |
|
61 | + $n = empty($query->get( 'exact' )) |
|
62 | 62 | ? '%' |
63 | 63 | : ''; |
64 | 64 | $search = []; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function getPaged( $isEnabled = true ) |
80 | 80 | { |
81 | 81 | $paged = $isEnabled |
82 | - ? intval( get_query_var( is_front_page() ? 'page' : Application::PAGED_QUERY_VAR )) |
|
82 | + ? intval( get_query_var( is_front_page() ? 'page' : Application::PAGED_QUERY_VAR ) ) |
|
83 | 83 | : 1; |
84 | 84 | return max( 1, $paged ); |
85 | 85 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function buildQueryAssignedTo( $value ) |
92 | 92 | { |
93 | - if( empty( $value ))return; |
|
93 | + if( empty($value) )return; |
|
94 | 94 | return [ |
95 | 95 | 'compare' => 'IN', |
96 | 96 | 'key' => 'assigned_to', |
97 | - 'value' => array_filter( array_map( 'trim', explode( ',', $value )), 'is_numeric' ), |
|
97 | + 'value' => array_filter( array_map( 'trim', explode( ',', $value ) ), 'is_numeric' ), |
|
98 | 98 | ]; |
99 | 99 | } |
100 | 100 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function buildQueryCategory( $value ) |
106 | 106 | { |
107 | - if( empty( $value ))return; |
|
107 | + if( empty($value) )return; |
|
108 | 108 | return [ |
109 | 109 | 'field' => 'term_id', |
110 | 110 | 'taxonomy' => Application::TAXONOMY, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function buildQueryRating( $value ) |
120 | 120 | { |
121 | - if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return; |
|
121 | + if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ) ) )return; |
|
122 | 122 | return [ |
123 | 123 | 'compare' => '>=', |
124 | 124 | 'key' => 'rating', |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | protected function buildQueryType( $value ) |
134 | 134 | { |
135 | - if( in_array( $value, ['','all'] ))return; |
|
135 | + if( in_array( $value, ['', 'all'] ) )return; |
|
136 | 136 | return [ |
137 | 137 | 'key' => 'review_type', |
138 | 138 | 'value' => $value, |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | function glsr( $alias = null ) { |
8 | 8 | $app = \GeminiLabs\SiteReviews\Application::load(); |
9 | - return empty( $alias ) |
|
9 | + return empty($alias) |
|
10 | 10 | ? $app |
11 | 11 | : $app->make( $alias ); |
12 | 12 | } |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | * @return \WP_Screen|object |
17 | 17 | */ |
18 | 18 | function glsr_current_screen() { |
19 | - if( function_exists( 'get_current_screen' )) { |
|
19 | + if( function_exists( 'get_current_screen' ) ) { |
|
20 | 20 | $screen = get_current_screen(); |
21 | 21 | } |
22 | - return empty( $screen ) |
|
22 | + return empty($screen) |
|
23 | 23 | ? (object)array_fill_keys( ['base', 'id', 'post_type'], null ) |
24 | 24 | : $screen; |
25 | 25 | } |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | */ |
55 | 55 | function glsr_log() { |
56 | 56 | $args = func_get_args(); |
57 | - $context = isset( $args[1] ) |
|
57 | + $context = isset($args[1]) |
|
58 | 58 | ? $args[1] |
59 | 59 | : []; |
60 | 60 | $logger = glsr( 'Modules\Logger' ); |
61 | - return empty( $args ) |
|
61 | + return empty($args) |
|
62 | 62 | ? $logger |
63 | 63 | : $logger->log( 'debug', $args[0], $context ); |
64 | 64 | } |
@@ -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 |
@@ -15,7 +16,8 @@ discard block |
||
15 | 16 | * get_current_screen() is unreliable because it is not defined on all admin pages |
16 | 17 | * @return \WP_Screen|object |
17 | 18 | */ |
18 | -function glsr_current_screen() { |
|
19 | +function glsr_current_screen() |
|
20 | +{ |
|
19 | 21 | if( function_exists( 'get_current_screen' )) { |
20 | 22 | $screen = get_current_screen(); |
21 | 23 | } |
@@ -27,7 +29,8 @@ discard block |
||
27 | 29 | /** |
28 | 30 | * @return \GeminiLabs\SiteReviews\Database |
29 | 31 | */ |
30 | -function glsr_db() { |
|
32 | +function glsr_db() |
|
33 | +{ |
|
31 | 34 | return glsr( 'Database' ); |
32 | 35 | } |
33 | 36 | |
@@ -35,7 +38,8 @@ discard block |
||
35 | 38 | * @param mixed ...$vars |
36 | 39 | * @return void |
37 | 40 | */ |
38 | -function glsr_debug( ...$vars ) { |
|
41 | +function glsr_debug( ...$vars ) |
|
42 | +{ |
|
39 | 43 | if( count( $vars ) == 1 ) { |
40 | 44 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
41 | 45 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -52,7 +56,8 @@ discard block |
||
52 | 56 | /** |
53 | 57 | * @return \GeminiLabs\SiteReviews\Modules\Logger |
54 | 58 | */ |
55 | -function glsr_log() { |
|
59 | +function glsr_log() |
|
60 | +{ |
|
56 | 61 | $args = func_get_args(); |
57 | 62 | $context = isset( $args[1] ) |
58 | 63 | ? $args[1] |
@@ -68,7 +73,8 @@ discard block |
||
68 | 73 | * @return void |
69 | 74 | * @callback register_taxonomy() "meta_box_cb" |
70 | 75 | */ |
71 | -function glsr_categories_meta_box( $post, $box ) { |
|
76 | +function glsr_categories_meta_box( $post, $box ) |
|
77 | +{ |
|
72 | 78 | glsr( 'Controllers\EditorController' )->renderTaxonomyMetabox( $post, $box ); |
73 | 79 | } |
74 | 80 | |
@@ -77,14 +83,16 @@ discard block |
||
77 | 83 | * @param mixed $fallback |
78 | 84 | * @return string|array |
79 | 85 | */ |
80 | -function glsr_get_option( $option_path = '', $fallback = '' ) { |
|
86 | +function glsr_get_option( $option_path = '', $fallback = '' ) |
|
87 | +{ |
|
81 | 88 | return glsr( 'Database\OptionManager' )->get( 'settings.'.$option_path, $fallback ); |
82 | 89 | } |
83 | 90 | |
84 | 91 | /** |
85 | 92 | * @return array |
86 | 93 | */ |
87 | -function glsr_get_options() { |
|
94 | +function glsr_get_options() |
|
95 | +{ |
|
88 | 96 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
89 | 97 | } |
90 | 98 |
@@ -2,31 +2,31 @@ |
||
2 | 2 | |
3 | 3 | $render->rating( 'rating', [ |
4 | 4 | 'label' => __( 'Your overall rating', 'site-reviews' ), |
5 | -]); |
|
5 | +] ); |
|
6 | 6 | $render->text( 'title', [ |
7 | 7 | 'label' => __( 'Title of your review', 'site-reviews' ), |
8 | 8 | 'placeholder' => __( 'Summarize your review or highlight an interesting detail', 'site-reviews' ), |
9 | -]); |
|
9 | +] ); |
|
10 | 10 | $render->textarea( 'content', [ |
11 | 11 | 'label' => __( 'Your review', 'site-reviews' ), |
12 | 12 | 'placeholder' => __( 'Tell people your review', 'site-reviews' ), |
13 | -]); |
|
13 | +] ); |
|
14 | 14 | $render->text( 'name', [ |
15 | 15 | 'label' => __( 'Your name', 'site-reviews' ), |
16 | 16 | 'placeholder' => __( 'Tell us your name', 'site-reviews' ), |
17 | -]); |
|
17 | +] ); |
|
18 | 18 | $render->email( 'email', [ |
19 | 19 | 'label' => __( 'Your email', 'site-reviews' ), |
20 | 20 | 'placeholder' => __( 'Tell us your email', 'site-reviews' ), |
21 | -]); |
|
21 | +] ); |
|
22 | 22 | $render->checkbox( 'terms', [ |
23 | 23 | 'label' => __( 'This review is based on my own experience and is my genuine opinion.', 'site-reviews' ), |
24 | -]); |
|
24 | +] ); |
|
25 | 25 | $render->honeypot( 'gotcha' ); |
26 | 26 | $render->hidden( 'assign_to' ); |
27 | 27 | $render->hidden( 'category' ); |
28 | 28 | $render->hidden( 'excluded' ); |
29 | 29 | $render->hidden( 'id' ); |
30 | 30 | wp_nonce_field( 'post-review' ); |
31 | -$render->submit( __( 'Submit your review', 'site-reviews' )); |
|
31 | +$render->submit( __( 'Submit your review', 'site-reviews' ) ); |
|
32 | 32 | $render->result(); |
@@ -197,7 +197,7 @@ |
||
197 | 197 | 'type' => 'text', |
198 | 198 | ], |
199 | 199 | 'settings.submissions.required' => [ |
200 | - 'default' => ['title','content','name','email'], |
|
200 | + 'default' => ['title', 'content', 'name', 'email'], |
|
201 | 201 | 'label' => __( 'Required Fields', 'site-reviews' ), |
202 | 202 | 'options' => [ |
203 | 203 | 'title' => __( 'Title', 'site-reviews' ), |
@@ -20,22 +20,22 @@ discard block |
||
20 | 20 | 'class' => 'widefat', |
21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
22 | 22 | 'name' => 'title', |
23 | - ]); |
|
23 | + ] ); |
|
24 | 24 | if( count( glsr()->reviewTypes ) > 1 ) { |
25 | 25 | $this->renderField( 'select', [ |
26 | 26 | 'class' => 'widefat', |
27 | 27 | 'label' => __( 'Which type of review would you like to use?', 'site-reviews' ), |
28 | 28 | 'name' => 'type', |
29 | 29 | 'options' => ['' => __( 'All review types', 'site-reviews' )] + glsr()->reviewTypes, |
30 | - ]); |
|
30 | + ] ); |
|
31 | 31 | } |
32 | - if( !empty( $terms )) { |
|
32 | + if( !empty($terms) ) { |
|
33 | 33 | $this->renderField( 'select', [ |
34 | 34 | 'class' => 'widefat', |
35 | 35 | 'label' => __( 'Limit summary to this category', 'site-reviews' ), |
36 | 36 | 'name' => 'category', |
37 | 37 | 'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms, |
38 | - ]); |
|
38 | + ] ); |
|
39 | 39 | } |
40 | 40 | $this->renderField( 'text', [ |
41 | 41 | 'class' => 'widefat', |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | 'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ), |
44 | 44 | 'label' => __( 'Limit summary to reviews assigned to a page/post ID', 'site-reviews' ), |
45 | 45 | 'name' => 'assigned_to', |
46 | - ]); |
|
46 | + ] ); |
|
47 | 47 | $this->renderField( 'text', [ |
48 | 48 | 'class' => 'widefat', |
49 | 49 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
50 | 50 | 'name' => 'class', |
51 | - ]); |
|
51 | + ] ); |
|
52 | 52 | $this->renderField( 'checkbox', [ |
53 | 53 | 'name' => 'hide', |
54 | 54 | 'options' => [ |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'summary' => __( 'Hide the summary text?', 'site-reviews' ), |
59 | 59 | 'if_empty' => __( 'Hide the summary if no reviews are found?', 'site-reviews' ), |
60 | 60 | ], |
61 | - ]); |
|
61 | + ] ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -20,30 +20,30 @@ discard block |
||
20 | 20 | 'class' => 'widefat', |
21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
22 | 22 | 'name' => 'title', |
23 | - ]); |
|
23 | + ] ); |
|
24 | 24 | $this->renderField( 'textarea', [ |
25 | 25 | 'class' => 'widefat', |
26 | 26 | 'label' => __( 'Description', 'site-reviews' ), |
27 | 27 | 'name' => 'description', |
28 | - ]); |
|
28 | + ] ); |
|
29 | 29 | $this->renderField( 'select', [ |
30 | 30 | 'class' => 'widefat', |
31 | 31 | 'label' => __( 'Automatically assign a category', 'site-reviews' ), |
32 | 32 | 'name' => 'category', |
33 | 33 | 'options' => ['' => __( 'Do not assign a category', 'site-reviews' )] + $terms, |
34 | - ]); |
|
34 | + ] ); |
|
35 | 35 | $this->renderField( 'text', [ |
36 | 36 | 'class' => 'widefat', |
37 | 37 | 'default' => '', |
38 | 38 | 'description' => sprintf( __( 'You may also enter %s to assign to the current post.', 'site-reviews' ), '<code>post_id</code>' ), |
39 | 39 | 'label' => __( 'Assign reviews to a custom page/post ID', 'site-reviews' ), |
40 | 40 | 'name' => 'assign_to', |
41 | - ]); |
|
41 | + ] ); |
|
42 | 42 | $this->renderField( 'text', [ |
43 | 43 | 'class' => 'widefat', |
44 | 44 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
45 | 45 | 'name' => 'class', |
46 | - ]); |
|
46 | + ] ); |
|
47 | 47 | $this->renderField( 'checkbox', [ |
48 | 48 | 'name' => 'hide', |
49 | 49 | 'options' => [ |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'terms' => __( 'Hide the terms field', 'site-reviews' ), |
53 | 53 | 'title' => __( 'Hide the title field', 'site-reviews' ), |
54 | 54 | ], |
55 | - ]); |
|
55 | + ] ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | 'class' => 'widefat', |
21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
22 | 22 | 'name' => 'title', |
23 | - ]); |
|
23 | + ] ); |
|
24 | 24 | $this->renderField( 'number', [ |
25 | 25 | 'class' => 'small-text', |
26 | 26 | 'default' => 5, |
27 | 27 | 'label' => __( 'How many reviews would you like to display?', 'site-reviews' ), |
28 | 28 | 'max' => 100, |
29 | 29 | 'name' => 'count', |
30 | - ]); |
|
30 | + ] ); |
|
31 | 31 | $this->renderField( 'select', [ |
32 | 32 | 'label' => __( 'What is the minimum rating to display?', 'site-reviews' ), |
33 | 33 | 'name' => 'rating', |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | '2' => sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ), |
39 | 39 | '1' => sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ), |
40 | 40 | ], |
41 | - ]); |
|
41 | + ] ); |
|
42 | 42 | if( count( glsr()->reviewTypes ) > 1 ) { |
43 | 43 | $this->renderField( 'select', [ |
44 | 44 | 'class' => 'widefat', |
45 | 45 | 'label' => __( 'Which reviews would you like to display?', 'site-reviews' ), |
46 | 46 | 'name' => 'display', |
47 | 47 | 'options' => ['' => __( 'All Reviews', 'site-reviews' )] + glsr()->reviewTypes, |
48 | - ]); |
|
48 | + ] ); |
|
49 | 49 | } |
50 | - if( !empty( $terms )) { |
|
50 | + if( !empty($terms) ) { |
|
51 | 51 | $this->renderField( 'select', [ |
52 | 52 | 'class' => 'widefat', |
53 | 53 | 'label' => __( 'Limit reviews to this category', 'site-reviews' ), |
54 | 54 | 'name' => 'category', |
55 | 55 | 'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms, |
56 | - ]); |
|
56 | + ] ); |
|
57 | 57 | } |
58 | 58 | $this->renderField( 'text', [ |
59 | 59 | 'class' => 'widefat', |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | 'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ), |
62 | 62 | 'label' => __( 'Limit reviews to those assigned to this page/post ID', 'site-reviews' ), |
63 | 63 | 'name' => 'assigned_to', |
64 | - ]); |
|
64 | + ] ); |
|
65 | 65 | $this->renderField( 'text', [ |
66 | 66 | 'class' => 'widefat', |
67 | 67 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
68 | 68 | 'name' => 'class', |
69 | - ]); |
|
69 | + ] ); |
|
70 | 70 | $this->renderField( 'checkbox', [ |
71 | 71 | 'name' => 'hide', |
72 | 72 | 'options' => [ |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | 'response' => __( 'Hide the review response?', 'site-reviews' ), |
78 | 78 | 'title' => __( 'Hide the review title?', 'site-reviews' ), |
79 | 79 | ], |
80 | - ]); |
|
80 | + ] ); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function update( $newInstance, $oldInstance ) |
89 | 89 | { |
90 | - if( !is_numeric( $newInstance['count'] )) { |
|
90 | + if( !is_numeric( $newInstance['count'] ) ) { |
|
91 | 91 | $newInstance['count'] = 10; |
92 | 92 | } |
93 | - $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ))); |
|
93 | + $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ) ) ); |
|
94 | 94 | return parent::update( $newInstance, $oldInstance ); |
95 | 95 | } |
96 | 96 |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | return [[ |
16 | 16 | 'type' => 'container', |
17 | 17 | 'html' => '<p class="strong">'.esc_html__( 'All settings are optional.', 'site-reviews' ).'</p>', |
18 | - ],[ |
|
18 | + ], [ |
|
19 | 19 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
20 | 20 | 'name' => 'title', |
21 | 21 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
22 | 22 | 'type' => 'textbox', |
23 | - ],[ |
|
23 | + ], [ |
|
24 | 24 | 'label' => esc_html__( 'Description', 'site-reviews' ), |
25 | 25 | 'minHeight' => 60, |
26 | 26 | 'minWidth' => 240, |
@@ -35,29 +35,29 @@ discard block |
||
35 | 35 | 'name' => 'assign_to', |
36 | 36 | 'tooltip' => __( 'Assign submitted reviews to a custom page/post ID. You can also enter "post_id" to assign reviews to the ID of the current page.', 'site-reviews' ), |
37 | 37 | 'type' => 'textbox', |
38 | - ],[ |
|
38 | + ], [ |
|
39 | 39 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
40 | 40 | 'name' => 'class', |
41 | 41 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
42 | 42 | 'type' => 'textbox', |
43 | - ],[ |
|
43 | + ], [ |
|
44 | 44 | 'columns' => 2, |
45 | 45 | 'items' => [[ |
46 | 46 | 'name' => 'hide_email', |
47 | 47 | 'text' => esc_html__( 'Email', 'site-reviews' ), |
48 | 48 | 'tooltip' => __( 'Hide the email field?', 'site-reviews' ), |
49 | 49 | 'type' => 'checkbox', |
50 | - ],[ |
|
50 | + ], [ |
|
51 | 51 | 'name' => 'hide_name', |
52 | 52 | 'text' => esc_html__( 'Name', 'site-reviews' ), |
53 | 53 | 'tooltip' => __( 'Hide the name field?', 'site-reviews' ), |
54 | 54 | 'type' => 'checkbox', |
55 | - ],[ |
|
55 | + ], [ |
|
56 | 56 | 'name' => 'hide_terms', |
57 | 57 | 'text' => esc_html__( 'Terms', 'site-reviews' ), |
58 | 58 | 'tooltip' => __( 'Hide the terms field?', 'site-reviews' ), |
59 | 59 | 'type' => 'checkbox', |
60 | - ],[ |
|
60 | + ], [ |
|
61 | 61 | 'name' => 'hide_title', |
62 | 62 | 'text' => esc_html__( 'Title', 'site-reviews' ), |
63 | 63 | 'tooltip' => __( 'Hide the title field?', 'site-reviews' ), |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'layout' => 'grid', |
68 | 68 | 'spacing' => 5, |
69 | 69 | 'type' => 'container', |
70 | - ],[ |
|
70 | + ], [ |
|
71 | 71 | 'hidden' => true, |
72 | 72 | 'name' => 'id', |
73 | 73 | 'type' => 'textbox', |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | public function getTerms() |
81 | 81 | { |
82 | 82 | $terms = glsr( Database::class )->getTerms(); |
83 | - if( empty( $terms )) { |
|
83 | + if( empty($terms) ) { |
|
84 | 84 | return []; |
85 | 85 | } |
86 | 86 | return [ |