@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public function __construct() |
34 | 34 | { |
35 | 35 | static::$instance = $this; |
36 | - $this->file = realpath( trailingslashit( dirname( __DIR__ )).static::ID.'.php' ); |
|
36 | + $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' ); |
|
37 | 37 | $plugin = get_file_data( $this->file, [ |
38 | 38 | 'languages' => 'Domain Path', |
39 | 39 | 'name' => 'Plugin Name', |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | $constant = 'static::'.$property; |
87 | 87 | return defined( $constant ) |
88 | - ? apply_filters( 'site-reviews/const/'.$property, constant( $constant )) |
|
88 | + ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) ) |
|
89 | 89 | : ''; |
90 | 90 | } |
91 | 91 | |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function file( $view ) |
105 | 105 | { |
106 | - $view.= '.php'; |
|
106 | + $view .= '.php'; |
|
107 | 107 | $filePaths = []; |
108 | - if( glsr( Helper::class )->startsWith( 'templates/', $view )) { |
|
109 | - $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view )); |
|
108 | + if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) { |
|
109 | + $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) ); |
|
110 | 110 | } |
111 | 111 | $filePaths[] = $this->path( $view ); |
112 | 112 | $filePaths[] = $this->path( 'views/'.$view ); |
113 | 113 | foreach( $filePaths as $file ) { |
114 | - if( !file_exists( $file ))continue; |
|
114 | + if( !file_exists( $file ) )continue; |
|
115 | 115 | return $file; |
116 | 116 | } |
117 | 117 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function getDefaults() |
123 | 123 | { |
124 | - if( empty( $this->defaults )) { |
|
124 | + if( empty($this->defaults) ) { |
|
125 | 125 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
126 | 126 | $this->upgrade(); |
127 | 127 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function hasPermission() |
135 | 135 | { |
136 | 136 | $isAdmin = $this->isAdmin(); |
137 | - return !$isAdmin || ( $isAdmin && current_user_can( $this->constant( 'CAPABILITY' ))); |
|
137 | + return !$isAdmin || ($isAdmin && current_user_can( $this->constant( 'CAPABILITY' ) )); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
191 | 191 | $this->reviewTypes = wp_parse_args( $types, [ |
192 | 192 | 'local' => __( 'Local', 'site-reviews' ), |
193 | - ]); |
|
193 | + ] ); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | { |
202 | 202 | $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
203 | 203 | $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
204 | - if( !file_exists( $file )) { |
|
204 | + if( !file_exists( $file ) ) { |
|
205 | 205 | glsr_log()->error( 'File not found: '.$file ); |
206 | 206 | return; |
207 | 207 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function scheduleCronJob() |
217 | 217 | { |
218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
218 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
219 | 219 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
220 | 220 | } |
221 | 221 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function unscheduleCronJob() |
235 | 235 | { |
236 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
236 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function url( $path = '' ) |
267 | 267 | { |
268 | - $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
268 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
269 | 269 | return apply_filters( 'site-reviews/url', $url, $path ); |
270 | 270 | } |
271 | 271 | } |
@@ -60,7 +60,9 @@ discard block |
||
60 | 60 | public function catchFatalError() |
61 | 61 | { |
62 | 62 | $error = error_get_last(); |
63 | - if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false )return; |
|
63 | + if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false ) { |
|
64 | + return; |
|
65 | + } |
|
64 | 66 | glsr_log()->error( $error['message'] ); |
65 | 67 | } |
66 | 68 | |
@@ -111,7 +113,9 @@ discard block |
||
111 | 113 | $filePaths[] = $this->path( $view ); |
112 | 114 | $filePaths[] = $this->path( 'views/'.$view ); |
113 | 115 | foreach( $filePaths as $file ) { |
114 | - if( !file_exists( $file ))continue; |
|
116 | + if( !file_exists( $file )) { |
|
117 | + continue; |
|
118 | + } |
|
115 | 119 | return $file; |
116 | 120 | } |
117 | 121 | } |
@@ -215,7 +219,9 @@ discard block |
||
215 | 219 | */ |
216 | 220 | public function scheduleCronJob() |
217 | 221 | { |
218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
222 | + if( wp_next_scheduled( static::CRON_EVENT )) { |
|
223 | + return; |
|
224 | + } |
|
219 | 225 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
220 | 226 | } |
221 | 227 | |
@@ -255,7 +261,9 @@ discard block |
||
255 | 261 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
256 | 262 | || $data['action'] != 'update' |
257 | 263 | || $data['type'] != 'plugin' |
258 | - )return; |
|
264 | + ) { |
|
265 | + return; |
|
266 | + } |
|
259 | 267 | $this->upgrade(); |
260 | 268 | } |
261 | 269 |
@@ -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 = !isset( $this->fields[$key] ) |
|
111 | + $classes = !isset($this->fields[$key]) |
|
112 | 112 | ? $this->fields[$instance->tag] |
113 | 113 | : $this->fields[$key]; |
114 | 114 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $args = wp_parse_args( $instance->args, [ |
143 | 143 | 'is_public' => false, |
144 | 144 | 'is_raw' => false, |
145 | - ]); |
|
145 | + ] ); |
|
146 | 146 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
147 | 147 | return false; |
148 | 148 | } |
@@ -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 = !isset( $this->fields[$key] ) |