@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | 'glsr_star_rating' => 2, |
21 | 21 | ); |
22 | 22 | foreach( $hooks as $function => $acceptedArgs ) { |
23 | - add_filter( $function, function() use( $function ) { |
|
23 | + add_filter( $function, function() use($function) { |
|
24 | 24 | $args = func_get_args(); |
25 | 25 | array_shift( $args ); // remove the fallback value |
26 | 26 | return call_user_func_array( $function, $args ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | function glsr( $alias = null ) { |
35 | 35 | $app = \GeminiLabs\SiteReviews\Application::load(); |
36 | - return !empty( $alias ) |
|
36 | + return !empty($alias) |
|
37 | 37 | ? $app->make( $alias ) |
38 | 38 | : $app; |
39 | 39 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $result = array(); |
48 | 48 | foreach( $array as $subarray ) { |
49 | 49 | $subarray = (array)$subarray; |
50 | - if( !isset( $subarray[$column] ))continue; |
|
50 | + if( !isset($subarray[$column]) )continue; |
|
51 | 51 | $result[] = $subarray[$column]; |
52 | 52 | } |
53 | 53 | return $result; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function glsr_calculate_ratings() { |
60 | 60 | glsr( 'Controllers\AdminController' )->routerCountReviews( false ); |
61 | - glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' )); |
|
61 | + glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | * @return \WP_Screen|object |
76 | 76 | */ |
77 | 77 | function glsr_current_screen() { |
78 | - if( function_exists( 'get_current_screen' )) { |
|
78 | + if( function_exists( 'get_current_screen' ) ) { |
|
79 | 79 | $screen = get_current_screen(); |
80 | 80 | } |
81 | - return empty( $screen ) |
|
81 | + return empty($screen) |
|
82 | 82 | ? (object)array_fill_keys( ['base', 'id', 'post_type'], null ) |
83 | 83 | : $screen; |
84 | 84 | } |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | */ |
136 | 136 | function glsr_get_review( $post_id ) { |
137 | 137 | $post = null; |
138 | - if( is_numeric( $post_id )) { |
|
138 | + if( is_numeric( $post_id ) ) { |
|
139 | 139 | $post = get_post( $post_id ); |
140 | 140 | } |
141 | - if( !( $post instanceof WP_Post )) { |
|
141 | + if( !($post instanceof WP_Post) ) { |
|
142 | 142 | $post = new WP_Post( (object)[] ); |
143 | 143 | } |
144 | 144 | return glsr( 'Database\ReviewManager' )->single( $post ); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @return array |
149 | 149 | */ |
150 | 150 | function glsr_get_reviews( $args = array() ) { |
151 | - return glsr( 'Database\ReviewManager' )->get( glsr( 'Helper' )->consolidateArray( $args )); |
|
151 | + return glsr( 'Database\ReviewManager' )->get( glsr( 'Helper' )->consolidateArray( $args ) ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | function glsr_log() { |
158 | 158 | $args = func_get_args(); |
159 | 159 | $console = glsr( 'Modules\Console' ); |
160 | - if( $value = glsr_get( $args, '0' )) { |
|
161 | - return $console->log( 'debug', $value, glsr_get( $args, '1', [] )); |
|
160 | + if( $value = glsr_get( $args, '0' ) ) { |
|
161 | + return $console->log( 'debug', $value, glsr_get( $args, '1', [] ) ); |
|
162 | 162 | } |
163 | 163 | return $console; |
164 | 164 | } |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @return mixed |
33 | 33 | */ |
34 | -function glsr( $alias = null ) { |
|
34 | +function glsr( $alias = null ) |
|
35 | +{ |
|
35 | 36 | $app = \GeminiLabs\SiteReviews\Application::load(); |
36 | 37 | return !empty( $alias ) |
37 | 38 | ? $app->make( $alias ) |
@@ -43,11 +44,14 @@ discard block |
||
43 | 44 | * @param $column string |
44 | 45 | * @return array |
45 | 46 | */ |
46 | -function glsr_array_column( array $array, $column ) { |
|
47 | +function glsr_array_column( array $array, $column ) |
|
48 | +{ |
|
47 | 49 | $result = array(); |
48 | 50 | foreach( $array as $subarray ) { |
49 | 51 | $subarray = (array)$subarray; |
50 | - if( !isset( $subarray[$column] ))continue; |
|
52 | + if( !isset( $subarray[$column] )) { |
|
53 | + continue; |
|
54 | + } |
|
51 | 55 | $result[] = $subarray[$column]; |
52 | 56 | } |
53 | 57 | return $result; |
@@ -56,7 +60,8 @@ discard block |
||
56 | 60 | /** |
57 | 61 | * @return void |
58 | 62 | */ |
59 | -function glsr_calculate_ratings() { |
|
63 | +function glsr_calculate_ratings() |
|
64 | +{ |
|
60 | 65 | glsr( 'Controllers\AdminController' )->routerCountReviews( false ); |
61 | 66 | glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' )); |
62 | 67 | } |
@@ -64,7 +69,8 @@ discard block |
||
64 | 69 | /** |
65 | 70 | * @return \GeminiLabs\SiteReviews\Review|false |
66 | 71 | */ |
67 | -function glsr_create_review( $reviewValues = array() ) { |
|
72 | +function glsr_create_review( $reviewValues = array() ) |
|
73 | +{ |
|
68 | 74 | $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
69 | 75 | glsr( 'Helper' )->consolidateArray( $reviewValues ) |
70 | 76 | ); |
@@ -74,7 +80,8 @@ discard block |
||
74 | 80 | /** |
75 | 81 | * @return \WP_Screen|object |
76 | 82 | */ |
77 | -function glsr_current_screen() { |
|
83 | +function glsr_current_screen() |
|
84 | +{ |
|
78 | 85 | if( function_exists( 'get_current_screen' )) { |
79 | 86 | $screen = get_current_screen(); |
80 | 87 | } |
@@ -87,7 +94,8 @@ discard block |
||
87 | 94 | * @param mixed ...$vars |
88 | 95 | * @return void |
89 | 96 | */ |
90 | -function glsr_debug( ...$vars ) { |
|
97 | +function glsr_debug( ...$vars ) |
|
98 | +{ |
|
91 | 99 | if( count( $vars ) == 1 ) { |
92 | 100 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
93 | 101 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -107,7 +115,8 @@ discard block |
||
107 | 115 | * @param mixed $fallback |
108 | 116 | * @return mixed |
109 | 117 | */ |
110 | -function glsr_get( $array, $path = '', $fallback = '' ) { |
|
118 | +function glsr_get( $array, $path = '', $fallback = '' ) |
|
119 | +{ |
|
111 | 120 | return glsr( 'Helper' )->dataGet( $array, $path, $fallback ); |
112 | 121 | } |
113 | 122 | |
@@ -116,7 +125,8 @@ discard block |
||
116 | 125 | * @param mixed $fallback |
117 | 126 | * @return string|array |
118 | 127 | */ |
119 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
128 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
129 | +{ |
|
120 | 130 | return is_string( $path ) |
121 | 131 | ? glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ) |
122 | 132 | : $fallback; |
@@ -125,7 +135,8 @@ discard block |
||
125 | 135 | /** |
126 | 136 | * @return array |
127 | 137 | */ |
128 | -function glsr_get_options() { |
|
138 | +function glsr_get_options() |
|
139 | +{ |
|
129 | 140 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
130 | 141 | } |
131 | 142 | |
@@ -133,7 +144,8 @@ discard block |
||
133 | 144 | * @param int $post_id |
134 | 145 | * @return \GeminiLabs\SiteReviews\Review |
135 | 146 | */ |
136 | -function glsr_get_review( $post_id ) { |
|
147 | +function glsr_get_review( $post_id ) |
|
148 | +{ |
|
137 | 149 | $post = null; |
138 | 150 | if( is_numeric( $post_id )) { |
139 | 151 | $post = get_post( $post_id ); |
@@ -147,14 +159,16 @@ discard block |
||
147 | 159 | /** |
148 | 160 | * @return array |
149 | 161 | */ |
150 | -function glsr_get_reviews( $args = array() ) { |
|
162 | +function glsr_get_reviews( $args = array() ) |
|
163 | +{ |
|
151 | 164 | return glsr( 'Database\ReviewManager' )->get( glsr( 'Helper' )->consolidateArray( $args )); |
152 | 165 | } |
153 | 166 | |
154 | 167 | /** |
155 | 168 | * @return \GeminiLabs\SiteReviews\Modules\Console |
156 | 169 | */ |
157 | -function glsr_log() { |
|
170 | +function glsr_log() |
|
171 | +{ |
|
158 | 172 | $args = func_get_args(); |
159 | 173 | $console = glsr( 'Modules\Console' ); |
160 | 174 | if( $value = glsr_get( $args, '0' )) { |
@@ -166,6 +180,7 @@ discard block |
||
166 | 180 | /** |
167 | 181 | * @return string |
168 | 182 | */ |
169 | -function glsr_star_rating( $rating ) { |
|
183 | +function glsr_star_rating( $rating ) |
|
184 | +{ |
|
170 | 185 | return glsr( 'Modules\Html\Partial' )->build( 'star-rating', ['rating' => $rating] ); |
171 | 186 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function routerChangeStatus( array $request ) |
25 | 25 | { |
26 | - wp_send_json_success( $this->execute( new ChangeStatus( $request ))); |
|
26 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | public function routerClearConsole() |
33 | 33 | { |
34 | 34 | glsr( AdminController::class )->routerClearConsole(); |
35 | - wp_send_json_success([ |
|
35 | + wp_send_json_success( [ |
|
36 | 36 | 'console' => glsr( Console::class )->get(), |
37 | 37 | 'notices' => glsr( Notice::class )->get(), |
38 | - ]); |
|
38 | + ] ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | public function routerCountReviews() |
45 | 45 | { |
46 | 46 | glsr( AdminController::class )->routerCountReviews(); |
47 | - wp_send_json_success([ |
|
47 | + wp_send_json_success( [ |
|
48 | 48 | 'notices' => glsr( Notice::class )->get(), |
49 | - ]); |
|
49 | + ] ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | { |
57 | 57 | $shortcode = $request['shortcode']; |
58 | 58 | $response = false; |
59 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
59 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
60 | 60 | $data = glsr()->mceShortcodes[$shortcode]; |
61 | - if( !empty( $data['errors'] )) { |
|
61 | + if( !empty($data['errors']) ) { |
|
62 | 62 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
63 | 63 | } |
64 | 64 | $response = [ |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | public function routerFetchConsole() |
79 | 79 | { |
80 | 80 | glsr( AdminController::class )->routerFetchConsole(); |
81 | - wp_send_json_success([ |
|
81 | + wp_send_json_success( [ |
|
82 | 82 | 'console' => glsr( Console::class )->get(), |
83 | 83 | 'notices' => glsr( Notice::class )->get(), |
84 | - ]); |
|
84 | + ] ); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | public function routerSearchPosts( array $request ) |
91 | 91 | { |
92 | 92 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
93 | - wp_send_json_success([ |
|
93 | + wp_send_json_success( [ |
|
94 | 94 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
95 | 95 | 'items' => $results, |
96 | - ]); |
|
96 | + ] ); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function routerSearchTranslations( array $request ) |
103 | 103 | { |
104 | - if( empty( $request['exclude'] )) { |
|
104 | + if( empty($request['exclude']) ) { |
|
105 | 105 | $request['exclude'] = []; |
106 | 106 | } |
107 | 107 | $results = glsr( Translation::class ) |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | ->exclude() |
110 | 110 | ->exclude( $request['exclude'] ) |
111 | 111 | ->renderResults(); |
112 | - wp_send_json_success([ |
|
112 | + wp_send_json_success( [ |
|
113 | 113 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
114 | 114 | 'items' => $results, |
115 | - ]); |
|
115 | + ] ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | public function routerSubmitReview( array $request ) |
122 | 122 | { |
123 | 123 | $command = glsr( PublicController::class )->routerSubmitReview( $request ); |
124 | - $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ))); |
|
124 | + $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
125 | 125 | $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command ); |
126 | 126 | $data = [ |
127 | 127 | 'errors' => glsr( Session::class )->get( $command->form_id.'errors', false, true ), |
@@ -145,16 +145,16 @@ discard block |
||
145 | 145 | parse_str( parse_url( glsr_get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery ); |
146 | 146 | $args = [ |
147 | 147 | 'paged' => glsr_get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ), |
148 | - 'pagedUrl' => home_url( parse_url( glsr_get( $request, 'url' ), PHP_URL_PATH )), |
|
148 | + 'pagedUrl' => home_url( parse_url( glsr_get( $request, 'url' ), PHP_URL_PATH ) ), |
|
149 | 149 | 'pagination' => 'ajax', |
150 | 150 | 'schema' => false, |
151 | 151 | ]; |
152 | - $atts = (array) json_decode( glsr_get( $request, 'atts' )); |
|
153 | - $html = glsr( SiteReviews::class )->build( wp_parse_args( $args, $atts )); |
|
154 | - return wp_send_json_success([ |
|
152 | + $atts = (array)json_decode( glsr_get( $request, 'atts' ) ); |
|
153 | + $html = glsr( SiteReviews::class )->build( wp_parse_args( $args, $atts ) ); |
|
154 | + return wp_send_json_success( [ |
|
155 | 155 | 'pagination' => $html->getPagination(), |
156 | 156 | 'reviews' => $html->getReviews(), |
157 | - ]); |
|
157 | + ] ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function routerTogglePinned( array $request ) |
164 | 164 | { |
165 | - $isPinned = $this->execute( new TogglePinned( $request )); |
|
166 | - wp_send_json_success([ |
|
165 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
166 | + wp_send_json_success( [ |
|
167 | 167 | 'notices' => glsr( Notice::class )->get(), |
168 | 168 | 'pinned' => $isPinned, |
169 | - ]); |
|
169 | + ] ); |
|
170 | 170 | } |
171 | 171 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $this->args = $args; |
30 | 30 | $this->max_num_pages = $maxPageCount; |
31 | 31 | $this->reviews = $reviews; |
32 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
32 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return mixed |
55 | 55 | */ |
56 | 56 | public function offsetGet( $key ) { |
57 | - if( property_exists( $this, $key )) { |
|
57 | + if( property_exists( $this, $key ) ) { |
|
58 | 58 | return $this->key; |
59 | 59 | } |
60 | 60 | return array_key_exists( $key, $this->reviews ) |
@@ -53,7 +53,8 @@ |
||
53 | 53 | * @param mixed $key |
54 | 54 | * @return mixed |
55 | 55 | */ |
56 | - public function offsetGet( $key ) { |
|
56 | + public function offsetGet( $key ) |
|
57 | + { |
|
57 | 58 | if( property_exists( $this, $key )) { |
58 | 59 | return $this->key; |
59 | 60 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function build( array $args = [] ) |
70 | 70 | { |
71 | - if( empty( $this->ID )) { |
|
71 | + if( empty($this->ID) ) { |
|
72 | 72 | return new ReviewHtml( $this ); |
73 | 73 | } |
74 | 74 | $partial = glsr( SiteReviewsPartial::class ); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function offsetGet( $key ) |
94 | 94 | { |
95 | - if( property_exists( $this, $key )) { |
|
95 | + if( property_exists( $this, $key ) ) { |
|
96 | 96 | return $this->$key; |
97 | 97 | } |
98 | 98 | return array_key_exists( $key, (array)$this->custom ) |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function offsetSet( $key, $value ) |
109 | 109 | { |
110 | - if( property_exists( $this, $key )) { |
|
110 | + if( property_exists( $this, $key ) ) { |
|
111 | 111 | $this->$key = $value; |
112 | 112 | return; |
113 | 113 | } |
114 | - if( !is_array( $this->custom )) { |
|
114 | + if( !is_array( $this->custom ) ) { |
|
115 | 115 | $this->custom = array_filter( (array)$this->custom ); |
116 | 116 | } |
117 | 117 | $this->custom[$key] = $value; |
@@ -156,13 +156,13 @@ discard block |
||
156 | 156 | 'review_type' => 'local', |
157 | 157 | ]; |
158 | 158 | $meta = array_filter( |
159 | - array_map( 'array_shift', array_filter((array)get_post_meta( $post->ID ))), |
|
159 | + array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ), |
|
160 | 160 | 'strlen' |
161 | 161 | ); |
162 | - $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
|
162 | + $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) ); |
|
163 | 163 | $this->modified = $this->isModified( $properties ); |
164 | 164 | array_walk( $properties, function( $value, $key ) { |
165 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
165 | + if( !property_exists( $this, $key ) || isset($this->$key) )return; |
|
166 | 166 | $this->$key = maybe_unserialize( $value ); |
167 | 167 | }); |
168 | 168 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | protected function setTermIds( WP_Post $post ) |
174 | 174 | { |
175 | 175 | $this->term_ids = []; |
176 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
176 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return; |
|
177 | 177 | foreach( $terms as $term ) { |
178 | 178 | $this->term_ids[] = $term->term_id; |
179 | 179 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function generateSchema() |
96 | 96 | { |
97 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
97 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
98 | 98 | glsr( Schema::class )->store( |
99 | 99 | glsr( Schema::class )->build( $this->args ) |
100 | 100 | ); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function isHidden( $key, $path = '' ) |
109 | 109 | { |
110 | - $isOptionEnabled = !empty( $path ) |
|
110 | + $isOptionEnabled = !empty($path) |
|
111 | 111 | ? $this->isOptionEnabled( $path ) |
112 | 112 | : true; |
113 | 113 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function buildOptionAssignedTo( $key, $value ) |
122 | 122 | { |
123 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
123 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return; |
|
124 | 124 | $post = glsr( Polylang::class )->getPost( $value ); |
125 | - if( !( $post instanceof WP_Post ))return; |
|
125 | + if( !($post instanceof WP_Post) )return; |
|
126 | 126 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
127 | 127 | 'href' => get_the_permalink( $post->ID ), |
128 | - ]); |
|
128 | + ] ); |
|
129 | 129 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
130 | 130 | return '<span>'.$assignedTo.'</span>'; |
131 | 131 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function buildOptionAuthor( $key, $value ) |
139 | 139 | { |
140 | - if( $this->isHidden( $key ))return; |
|
140 | + if( $this->isHidden( $key ) )return; |
|
141 | 141 | return '<span>'.$value.'</span>'; |
142 | 142 | } |
143 | 143 | |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | */ |
149 | 149 | protected function buildOptionAvatar( $key, $value ) |
150 | 150 | { |
151 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
151 | + if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return; |
|
152 | 152 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
153 | - return glsr( Builder::class )->img([ |
|
153 | + return glsr( Builder::class )->img( [ |
|
154 | 154 | 'height' => $size, |
155 | 155 | 'src' => $this->generateAvatar( $value ), |
156 | 156 | 'style' => sprintf( 'width:%1$spx; height:%1$spx;', $size ), |
157 | 157 | 'width' => $size, |
158 | - ]); |
|
158 | + ] ); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | protected function buildOptionContent( $key, $value ) |
167 | 167 | { |
168 | 168 | $text = $this->normalizeText( $value ); |
169 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
169 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
170 | 170 | return '<p>'.$text.'</p>'; |
171 | 171 | } |
172 | 172 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function buildOptionDate( $key, $value ) |
179 | 179 | { |
180 | - if( $this->isHidden( $key ))return; |
|
180 | + if( $this->isHidden( $key ) )return; |
|
181 | 181 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
182 | 182 | if( $dateFormat == 'relative' ) { |
183 | 183 | $date = glsr( Date::class )->relative( $value ); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $format = $dateFormat == 'custom' |
187 | 187 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
188 | 188 | : (string)get_option( 'date_format' ); |
189 | - $date = date_i18n( $format, strtotime( $value )); |
|
189 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
190 | 190 | } |
191 | 191 | return '<span>'.$date.'</span>'; |
192 | 192 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | protected function buildOptionRating( $key, $value ) |
200 | 200 | { |
201 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
201 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
202 | 202 | return glsr_star_rating( $value ); |
203 | 203 | } |
204 | 204 | |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function buildOptionResponse( $key, $value ) |
211 | 211 | { |
212 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
213 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
212 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
213 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
214 | 214 | $text = $this->normalizeText( $value ); |
215 | 215 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
216 | 216 | $response = glsr( Builder::class )->div( $text, ['class' => 'glsr-review-response-inner'] ); |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | */ |
226 | 226 | protected function buildOptionTitle( $key, $value ) |
227 | 227 | { |
228 | - if( $this->isHidden( $key ))return; |
|
229 | - if( empty( $value )) { |
|
228 | + if( $this->isHidden( $key ) )return; |
|
229 | + if( empty($value) ) { |
|
230 | 230 | $value = __( 'No Title', 'site-reviews' ); |
231 | 231 | } |
232 | 232 | return '<h3>'.$value.'</h3>'; |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | return $avatarUrl; |
243 | 243 | } |
244 | 244 | $authorIdOrEmail = get_the_author_meta( 'ID', $this->current->user_id ); |
245 | - if( empty( $authorIdOrEmail )) { |
|
245 | + if( empty($authorIdOrEmail) ) { |
|
246 | 246 | $authorIdOrEmail = $this->current->email; |
247 | 247 | } |
248 | - if( $newAvatar = get_avatar_url( $authorIdOrEmail )) { |
|
248 | + if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) { |
|
249 | 249 | return $newAvatar; |
250 | 250 | } |
251 | 251 | return $avatarUrl; |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | */ |
258 | 258 | protected function getExcerpt( $text ) |
259 | 259 | { |
260 | - $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 )); |
|
260 | + $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) ); |
|
261 | 261 | $split = extension_loaded( 'intl' ) |
262 | 262 | ? $this->getExcerptIntlSplit( $text, $limit ) |
263 | 263 | : $this->getExcerptSplit( $text, $limit ); |
264 | 264 | $hiddenText = substr( $text, $split ); |
265 | - if( !empty( $hiddenText )) { |
|
265 | + if( !empty($hiddenText) ) { |
|
266 | 266 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
267 | 267 | 'class' => 'glsr-hidden glsr-hidden-text', |
268 | 268 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
269 | 269 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
270 | - ]); |
|
271 | - $text = ltrim( substr( $text, 0, $split )).$showMore; |
|
270 | + ] ); |
|
271 | + $text = ltrim( substr( $text, 0, $split ) ).$showMore; |
|
272 | 272 | } |
273 | 273 | return $text; |
274 | 274 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | $words = IntlRuleBasedBreakIterator::createWordInstance( '' ); |
284 | 284 | $words->setText( $text ); |
285 | 285 | $count = 0; |
286 | - foreach( $words as $offset ){ |
|
286 | + foreach( $words as $offset ) { |
|
287 | 287 | if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
288 | 288 | $count++; |
289 | 289 | if( $count != $limit )continue; |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | protected function getExcerptSplit( $text, $limit ) |
301 | 301 | { |
302 | 302 | if( str_word_count( $text, 0 ) > $limit ) { |
303 | - $words = array_keys( str_word_count( $text, 2 )); |
|
303 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
304 | 304 | return $words[$limit]; |
305 | 305 | } |
306 | 306 | return strlen( $text ); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | protected function getOption( $path, $fallback = '' ) |
315 | 315 | { |
316 | - if( array_key_exists( $path, $this->options )) { |
|
316 | + if( array_key_exists( $path, $this->options ) ) { |
|
317 | 317 | return $this->options[$path]; |
318 | 318 | } |
319 | 319 | return $fallback; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | */ |
327 | 327 | protected function isHiddenOrEmpty( $key, $value ) |
328 | 328 | { |
329 | - return $this->isHidden( $key ) || empty( $value ); |
|
329 | + return $this->isHidden( $key ) || empty($value); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -345,13 +345,13 @@ discard block |
||
345 | 345 | protected function normalizeText( $text ) |
346 | 346 | { |
347 | 347 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
348 | - $text = convert_smilies( strip_shortcodes( $text )); |
|
348 | + $text = convert_smilies( strip_shortcodes( $text ) ); |
|
349 | 349 | $text = str_replace( ']]>', ']]>', $text ); |
350 | 350 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
351 | - if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) { |
|
351 | + if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) { |
|
352 | 352 | $text = $this->getExcerpt( $text ); |
353 | 353 | } |
354 | - return wptexturize( nl2br( $text )); |
|
354 | + return wptexturize( nl2br( $text ) ); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -360,12 +360,12 @@ discard block |
||
360 | 360 | protected function wrap( array &$renderedFields, Review $review ) |
361 | 361 | { |
362 | 362 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
363 | - array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
|
363 | + array_walk( $renderedFields, function( &$value, $key ) use($review) { |
|
364 | 364 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
365 | - if( empty( $value ))return; |
|
365 | + if( empty($value) )return; |
|
366 | 366 | $value = glsr( Builder::class )->div( $value, [ |
367 | 367 | 'class' => 'glsr-review-'.$key, |
368 | - ]); |
|
368 | + ] ); |
|
369 | 369 | }); |
370 | 370 | } |
371 | 371 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $this->max_num_pages = $maxPageCount; |
37 | 37 | $this->reviews = $reviews; |
38 | 38 | $this->pagination = $this->buildPagination(); |
39 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
39 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'pagination' => $this->getPagination(), |
55 | 55 | 'reviews' => $this->getReviews(), |
56 | 56 | ], |
57 | - ]); |
|
57 | + ] ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function getReviews() |
74 | 74 | { |
75 | - $html = empty( $this->reviews ) |
|
75 | + $html = empty($this->reviews) |
|
76 | 76 | ? $this->getReviewsFallback() |
77 | 77 | : implode( PHP_EOL, $this->reviews ); |
78 | 78 | $wrapper = '<div class="glsr-reviews">%s</div>'; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.'; |
90 | 90 | return $this->pagination; |
91 | 91 | } |
92 | - if( property_exists( $this, $key )) { |
|
92 | + if( property_exists( $this, $key ) ) { |
|
93 | 93 | return $this->$key; |
94 | 94 | } |
95 | 95 | return array_key_exists( $key, $this->reviews ) |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | 'baseUrl' => glsr_get( $this->args, 'pagedUrl' ), |
107 | 107 | 'current' => glsr_get( $this->args, 'paged' ), |
108 | 108 | 'total' => $this->max_num_pages, |
109 | - ]); |
|
110 | - $html.= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] ); |
|
109 | + ] ); |
|
110 | + $html .= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] ); |
|
111 | 111 | $wrapper = '<div class="glsr-pagination">%s</div>'; |
112 | 112 | $wrapper = apply_filters( 'site-reviews/reviews/pagination-wrapper', $wrapper ); |
113 | 113 | return sprintf( $wrapper, $html ); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $defaults[] = 'glsr-ajax-pagination'; |
126 | 126 | } |
127 | 127 | $classes = explode( ' ', $this->args['class'] ); |
128 | - $classes = array_unique( array_merge( $defaults, array_filter( $classes ))); |
|
128 | + $classes = array_unique( array_merge( $defaults, array_filter( $classes ) ) ); |
|
129 | 129 | return implode( ' ', $classes ); |
130 | 130 | } |
131 | 131 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function getReviewsFallback() |
136 | 136 | { |
137 | - if( empty( $this->args['fallback'] ) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' )) { |
|
137 | + if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) { |
|
138 | 138 | $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' ); |
139 | 139 | } |
140 | 140 | $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
@@ -84,7 +84,8 @@ |
||
84 | 84 | * @param mixed $key |
85 | 85 | * @return mixed |
86 | 86 | */ |
87 | - public function offsetGet( $key ) { |
|
87 | + public function offsetGet( $key ) |
|
88 | + { |
|
88 | 89 | if( $key == 'navigation' ) { |
89 | 90 | glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.'; |
90 | 91 | return $this->pagination; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | $this->review = $review; |
24 | 24 | $this->values = $values; |
25 | - parent::__construct( $values, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
25 | + parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __toString() |
32 | 32 | { |
33 | - if( empty( $this->values ))return; |
|
33 | + if( empty($this->values) )return; |
|
34 | 34 | return glsr( Template::class )->build( 'templates/review', [ |
35 | 35 | 'context' => $this->values, |
36 | 36 | 'review' => $this->review, |
37 | - ]); |
|
37 | + ] ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @return mixed |
43 | 43 | */ |
44 | 44 | public function offsetGet( $key ) { |
45 | - if( property_exists( $this, $key )) { |
|
45 | + if( property_exists( $this, $key ) ) { |
|
46 | 46 | return $this->$key; |
47 | 47 | } |
48 | 48 | return array_key_exists( $key, $this->values ) |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __toString() |
32 | 32 | { |
33 | - if( empty( $this->values ))return; |
|
33 | + if( empty( $this->values )) { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | return glsr( Template::class )->build( 'templates/review', [ |
35 | 37 | 'context' => $this->values, |
36 | 38 | 'review' => $this->review, |
@@ -41,7 +43,8 @@ discard block |
||
41 | 43 | * @param mixed $key |
42 | 44 | * @return mixed |
43 | 45 | */ |
44 | - public function offsetGet( $key ) { |
|
46 | + public function offsetGet( $key ) |
|
47 | + { |
|
45 | 48 | if( property_exists( $this, $key )) { |
46 | 49 | return $this->$key; |
47 | 50 | } |