@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | defined( 'WPINC' ) || die; |
20 | 20 | |
21 | -if( !class_exists( 'GL_Plugin_Check_v3' )) { |
|
21 | +if( !class_exists( 'GL_Plugin_Check_v3' ) ) { |
|
22 | 22 | require_once __DIR__.'/activate.php'; |
23 | 23 | } |
24 | 24 | $check = new GL_Plugin_Check_v3( __FILE__ ); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | $app = new GeminiLabs\SiteReviews\Application; |
32 | 32 | $app->make( 'Provider' )->register( $app ); |
33 | -register_activation_hook( __FILE__, array( $app, 'activate' )); |
|
34 | -register_deactivation_hook( __FILE__, array( $app, 'deactivate' )); |
|
35 | -register_shutdown_function( array( $app, 'catchFatalError' )); |
|
33 | +register_activation_hook( __FILE__, array( $app, 'activate' ) ); |
|
34 | +register_deactivation_hook( __FILE__, array( $app, 'deactivate' ) ); |
|
35 | +register_shutdown_function( array( $app, 'catchFatalError' ) ); |
|
36 | 36 | $app->init(); |
@@ -22,7 +22,9 @@ |
||
22 | 22 | require_once __DIR__.'/activate.php'; |
23 | 23 | } |
24 | 24 | $check = new GL_Plugin_Check_v3( __FILE__ ); |
25 | -if( !$check->canProceed() )return; |
|
25 | +if( !$check->canProceed() ) { |
|
26 | + return; |
|
27 | +} |
|
26 | 28 | require_once __DIR__.'/autoload.php'; |
27 | 29 | require_once __DIR__.'/compatibility.php'; |
28 | 30 | require_once __DIR__.'/deprecated.php'; |
@@ -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 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | public function inlineStyles() |
85 | 85 | { |
86 | 86 | $inlineStylesheetPath = glsr()->path( 'assets/styles/inline-styles.css' ); |
87 | - if( !apply_filters( 'site-reviews/assets/css', true ))return; |
|
88 | - if( !file_exists( $inlineStylesheetPath )) { |
|
87 | + if( !apply_filters( 'site-reviews/assets/css', true ) )return; |
|
88 | + if( !file_exists( $inlineStylesheetPath ) ) { |
|
89 | 89 | glsr_log()->error( 'Inline stylesheet is missing: '.$inlineStylesheetPath ); |
90 | 90 | return; |
91 | 91 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | protected function getFixedSelectorsForPagination() |
122 | 122 | { |
123 | - $selectors = ['#wpadminbar','.site-navigation-fixed']; |
|
123 | + $selectors = ['#wpadminbar', '.site-navigation-fixed']; |
|
124 | 124 | return apply_filters( 'site-reviews/enqueue/public/localize/ajax-pagination', $selectors ); |
125 | 125 | } |
126 | 126 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | protected function getStylesheet() |
131 | 131 | { |
132 | 132 | $currentStyle = glsr( Style::class )->style; |
133 | - return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' )) |
|
133 | + return file_exists( glsr()->path( 'assets/styles/custom/'.$currentStyle.'.css' ) ) |
|
134 | 134 | ? glsr()->url( 'assets/styles/custom/'.$currentStyle.'.css' ) |
135 | 135 | : glsr()->url( 'assets/styles/'.Application::ID.'.css' ); |
136 | 136 | } |
@@ -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; |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | if( $review->review_type != 'local' )continue; |
40 | 40 | $reviews[] = $this->buildReview( $review ); |
41 | 41 | } |
42 | - if( !empty( $reviews )) { |
|
42 | + if( !empty($reviews) ) { |
|
43 | 43 | array_walk( $reviews, function( &$review ) { |
44 | - unset( $review['@context'] ); |
|
45 | - unset( $review['itemReviewed'] ); |
|
44 | + unset($review['@context']); |
|
45 | + unset($review['itemReviewed']); |
|
46 | 46 | }); |
47 | 47 | $schema['review'] = $reviews; |
48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function buildSummary( $args = null ) |
57 | 57 | { |
58 | - if( is_array( $args )) { |
|
58 | + if( is_array( $args ) ) { |
|
59 | 59 | $this->args = $args; |
60 | 60 | } |
61 | 61 | $buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' ); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $schema = method_exists( $this, $buildSummary ) |
64 | 64 | ? $this->$buildSummary() |
65 | 65 | : $this->buildSummaryForCustom(); |
66 | - if( !empty( $count )) { |
|
66 | + if( !empty($count) ) { |
|
67 | 67 | $schema->aggregateRating( |
68 | 68 | $this->getSchemaType( 'AggregateRating' ) |
69 | 69 | ->ratingValue( $this->getRatingValue() ) |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function render() |
83 | 83 | { |
84 | - if( empty( glsr()->schemas ))return; |
|
84 | + if( empty(glsr()->schemas) )return; |
|
85 | 85 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
86 | 86 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
87 | 87 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
88 | - )); |
|
88 | + ) ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | { |
96 | 96 | $schemas = glsr()->schemas; |
97 | 97 | $schemas[] = $schema; |
98 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
98 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | protected function buildReview( $review ) |
106 | 106 | { |
107 | 107 | $schema = $this->getSchemaType( 'Review' ) |
108 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
108 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) { |
|
109 | 109 | $schema->name( $review->title ); |
110 | 110 | }) |
111 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
111 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) { |
|
112 | 112 | $schema->reviewBody( $review->content ); |
113 | 113 | }) |
114 | - ->datePublished(( new DateTime( $review->date ))) |
|
115 | - ->author( $this->getSchemaType( 'Person' )->name( $review->author )) |
|
116 | - ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ))); |
|
117 | - if( !empty( $review->rating )) { |
|
114 | + ->datePublished( (new DateTime( $review->date )) ) |
|
115 | + ->author( $this->getSchemaType( 'Person' )->name( $review->author ) ) |
|
116 | + ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) ); |
|
117 | + if( !empty($review->rating) ) { |
|
118 | 118 | $schema->reviewRating( |
119 | 119 | $this->getSchemaType( 'Rating' ) |
120 | 120 | ->ratingValue( $review->rating ) |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | foreach( $values as $value ) { |
135 | 135 | $option = $this->getSchemaOptionValue( $value ); |
136 | - if( empty( $option ))continue; |
|
136 | + if( empty($option) )continue; |
|
137 | 137 | $schema->$value( $option ); |
138 | 138 | } |
139 | 139 | return $schema; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | { |
147 | 147 | return $this->buildSchemaValues( $this->getSchemaType(), [ |
148 | 148 | 'description', 'image', 'name', 'url', |
149 | - ]); |
|
149 | + ] ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | { |
157 | 157 | return $this->buildSchemaValues( $this->buildSummaryForCustom(), [ |
158 | 158 | 'address', 'priceRange', 'telephone', |
159 | - ]); |
|
159 | + ] ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | { |
167 | 167 | $offers = $this->buildSchemaValues( $this->getSchemaType( 'AggregateOffer' ), [ |
168 | 168 | 'highPrice', 'lowPrice', 'priceCurrency', |
169 | - ]); |
|
169 | + ] ); |
|
170 | 170 | return $this->buildSummaryForCustom() |
171 | 171 | ->offers( $offers ) |
172 | 172 | ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' ); |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function getRatingCounts() |
179 | 179 | { |
180 | - if( !isset( $this->ratingCounts )) { |
|
181 | - $counts = glsr( CountsManager::class )->get([ |
|
180 | + if( !isset($this->ratingCounts) ) { |
|
181 | + $counts = glsr( CountsManager::class )->get( [ |
|
182 | 182 | 'post_ids' => glsr( Helper::class )->convertStringToArray( $this->args['assigned_to'] ), |
183 | 183 | 'term_ids' => glsr( ReviewManager::class )->normalizeTermIds( $this->args['category'] ), |
184 | - ]); |
|
184 | + ] ); |
|
185 | 185 | $this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [ |
186 | 186 | 'min' => $this->args['rating'], |
187 | - ]); |
|
187 | + ] ); |
|
188 | 188 | } |
189 | 189 | return $this->ratingCounts; |
190 | 190 | } |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | protected function getSchemaOption( $option, $fallback ) |
206 | 206 | { |
207 | 207 | $option = strtolower( $option ); |
208 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
208 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
209 | 209 | return $schemaOption; |
210 | 210 | } |
211 | 211 | $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option ); |
212 | - if( is_array( $setting )) { |
|
212 | + if( is_array( $setting ) ) { |
|
213 | 213 | return $this->getSchemaOptionDefault( $setting, $fallback ); |
214 | 214 | } |
215 | - return !empty( $setting ) |
|
215 | + return !empty($setting) |
|
216 | 216 | ? $setting |
217 | 217 | : $fallback; |
218 | 218 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $setting = wp_parse_args( $setting, [ |
227 | 227 | 'custom' => '', |
228 | 228 | 'default' => $fallback, |
229 | - ]); |
|
229 | + ] ); |
|
230 | 230 | return $setting['default'] != 'custom' |
231 | 231 | ? $setting['default'] |
232 | 232 | : $setting['custom']; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | if( !is_single() && !is_page() )return; |
247 | 247 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
248 | - if( method_exists( $this, $method )) { |
|
248 | + if( method_exists( $this, $method ) ) { |
|
249 | 249 | return $this->$method(); |
250 | 250 | } |
251 | 251 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | */ |
257 | 257 | protected function getSchemaType( $type = null ) |
258 | 258 | { |
259 | - if( !is_string( $type )) { |
|
259 | + if( !is_string( $type ) ) { |
|
260 | 260 | $type = $this->getSchemaOption( 'type', 'LocalBusiness' ); |
261 | 261 | } |
262 | 262 | $className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' ); |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | protected function getThingDescription() |
272 | 272 | { |
273 | 273 | $post = get_post(); |
274 | - if( !( $post instanceof WP_Post )) { |
|
274 | + if( !($post instanceof WP_Post) ) { |
|
275 | 275 | return ''; |
276 | 276 | } |
277 | - $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt )); |
|
278 | - return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 )); |
|
277 | + $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) ); |
|
278 | + return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) ); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |