@@ -13,7 +13,7 @@ |
||
13 | 13 | public function build( $partialPath, array $args = [] ) |
14 | 14 | { |
15 | 15 | $className = glsr( Helper::class )->buildClassName( $partialPath, 'Modules\Html\Partials' ); |
16 | - if( !class_exists( $className )) { |
|
16 | + if( !class_exists( $className ) ) { |
|
17 | 17 | glsr_log()->error( 'Partial missing: '.$className ); |
18 | 18 | return; |
19 | 19 | } |
@@ -190,7 +190,9 @@ |
||
190 | 190 | if( $index === false |
191 | 191 | || !isset( $caller[$index+2]['class'] ) |
192 | 192 | || !isset( $caller[$index+2]['function'] ) |
193 | - )return; |
|
193 | + ) { |
|
194 | + return; |
|
195 | + } |
|
194 | 196 | return sprintf( '[%s()->%s:%s] ', |
195 | 197 | $caller[$index+2]['class'], |
196 | 198 | $caller[$index+2]['function'], |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function get() |
110 | 110 | { |
111 | - return empty( $this->log ) |
|
111 | + return empty($this->log) |
|
112 | 112 | ? __( 'Log is empty', 'site-reviews' ) |
113 | 113 | : $this->log; |
114 | 114 | } |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
136 | 136 | $constants = (array)apply_filters( 'site-reviews/log-levels', $constants ); |
137 | - if( in_array( $level, $constants, true )) { |
|
137 | + if( in_array( $level, $constants, true ) ) { |
|
138 | 138 | $entry = $this->buildLogEntry( $level, $message, $context ); |
139 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
139 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
140 | 140 | $this->reset(); |
141 | 141 | } |
142 | 142 | return $this; |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | protected function getDebugInformation() |
187 | 187 | { |
188 | 188 | $caller = debug_backtrace( 0, 6 ); |
189 | - $index = array_search( 'log', array_column( $caller, 'function' )); |
|
189 | + $index = array_search( 'log', array_column( $caller, 'function' ) ); |
|
190 | 190 | if( $index === false |
191 | - || !isset( $caller[$index+2]['class'] ) |
|
192 | - || !isset( $caller[$index+2]['function'] ) |
|
191 | + || !isset($caller[$index + 2]['class']) |
|
192 | + || !isset($caller[$index + 2]['function']) |
|
193 | 193 | )return; |
194 | 194 | return sprintf( '[%s()->%s:%s] ', |
195 | - $caller[$index+2]['class'], |
|
196 | - $caller[$index+2]['function'], |
|
197 | - $caller[$index+1]['line'] |
|
195 | + $caller[$index + 2]['class'], |
|
196 | + $caller[$index + 2]['function'], |
|
197 | + $caller[$index + 1]['line'] |
|
198 | 198 | ); |
199 | 199 | } |
200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | protected function interpolate( $message, $context = [] ) |
208 | 208 | { |
209 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
209 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
210 | 210 | return print_r( $message, true ); |
211 | 211 | } |
212 | 212 | $replace = []; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | if( $value instanceof DateTime ) { |
235 | 235 | $value = $value->format( 'Y-m-d H:i:s' ); |
236 | 236 | } |
237 | - else if( $this->isObjectOrArray( $value )) { |
|
237 | + else if( $this->isObjectOrArray( $value ) ) { |
|
238 | 238 | $value = json_encode( $value ); |
239 | 239 | } |
240 | 240 | return (string)$value; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $this->clear(); |
251 | 251 | file_put_contents( |
252 | 252 | $this->file, |
253 | - $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' )) |
|
253 | + $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' ) ) |
|
254 | 254 | ); |
255 | 255 | } |
256 | 256 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public function __construct( $input ) |
11 | 11 | { |
12 | 12 | $this->id = $input['id']; |
13 | - $this->pinned = isset( $input['pinned'] ) |
|
13 | + $this->pinned = isset($input['pinned']) |
|
14 | 14 | ? wp_validate_boolean( $input['pinned'] ) |
15 | 15 | : null; |
16 | 16 | } |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function getReviewCounts( $metaKey ) |
25 | 25 | { |
26 | - return (array) $this->db->get_results(" |
|
26 | + return (array)$this->db->get_results( " |
|
27 | 27 | SELECT m.meta_value AS name, COUNT(*) num_posts |
28 | 28 | FROM {$this->db->posts} AS p |
29 | 29 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
30 | 30 | WHERE p.post_type = '{$this->postType}' AND m.meta_key = '{$metaKey}' |
31 | 31 | GROUP BY name |
32 | - "); |
|
32 | + " ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function getReviewPostId( $metaReviewId ) |
40 | 40 | { |
41 | - $postId = $this->db->get_var(" |
|
41 | + $postId = $this->db->get_var( " |
|
42 | 42 | SELECT p.ID |
43 | 43 | FROM {$this->db->posts} AS p |
44 | 44 | INNER JOIN {$this->db->postmeta} AS pm ON p.ID = pm.post_id |
45 | 45 | WHERE p.post_type = '{$this->postType}' |
46 | 46 | AND pm.meta_key = 'review_id' |
47 | 47 | AND pm.meta_value = '{$metaReviewId}' |
48 | - "); |
|
48 | + " ); |
|
49 | 49 | return intval( $postId ); |
50 | 50 | } |
51 | 51 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function getReviewIdsByType( $metaReviewType ) |
57 | 57 | { |
58 | - $query = $this->db->get_col(" |
|
58 | + $query = $this->db->get_col( " |
|
59 | 59 | SELECT m1.meta_value AS review_id |
60 | 60 | FROM {$this->db->posts} AS p |
61 | 61 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | AND m1.meta_key = 'review_id' |
65 | 65 | AND m2.meta_key = 'review_type' |
66 | 66 | AND m2.meta_value = '{$metaReviewType}' |
67 | - "); |
|
68 | - return array_keys( array_flip( $query )); |
|
67 | + " ); |
|
68 | + return array_keys( array_flip( $query ) ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | $queryBuilder = glsr( QueryBuilder::class ); |
79 | 79 | $keys = $queryBuilder->buildSqlOr( $keys, "pm.meta_key = '%s'" ); |
80 | 80 | $status = $queryBuilder->buildSqlOr( $status, "p.post_status = '%s'" ); |
81 | - return $this->db->get_col(" |
|
81 | + return $this->db->get_col( " |
|
82 | 82 | SELECT DISTINCT pm.meta_value FROM {$this->db->postmeta} pm |
83 | 83 | LEFT JOIN {$this->db->posts} p ON p.ID = pm.post_id |
84 | 84 | WHERE p.post_type = '{$this->postType}' |
85 | 85 | AND ({$keys}) |
86 | 86 | AND ({$status}) |
87 | 87 | ORDER BY pm.meta_value |
88 | - "); |
|
88 | + " ); |
|
89 | 89 | } |
90 | 90 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | 'author' => '', |
17 | 17 | 'avatar' => '', |
18 | 18 | 'content' => '', |
19 | - 'date' => get_date_from_gmt( gmdate( 'Y-m-d H:i:s' )), |
|
19 | + 'date' => get_date_from_gmt( gmdate( 'Y-m-d H:i:s' ) ), |
|
20 | 20 | 'email' => '', |
21 | 21 | 'ip_address' => '', |
22 | 22 | 'pinned' => false, |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function isPhpValid( $version = '' ) |
34 | 34 | { |
35 | - if( !empty( $version )) { |
|
36 | - static::normalize( array( 'php' => $version )); |
|
35 | + if( !empty($version) ) { |
|
36 | + static::normalize( array( 'php' => $version ) ); |
|
37 | 37 | } |
38 | 38 | return !version_compare( PHP_VERSION, static::$versions->php, '<' ); |
39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function isValid( array $args = array() ) |
45 | 45 | { |
46 | - if( !empty( $args )) { |
|
46 | + if( !empty($args) ) { |
|
47 | 47 | static::normalize( $args ); |
48 | 48 | } |
49 | 49 | return static::isPhpValid() && static::isWpValid(); |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | public static function isWpValid( $version = '' ) |
57 | 57 | { |
58 | 58 | global $wp_version; |
59 | - if( !empty( $version )) { |
|
60 | - static::normalize( array( 'wordpress' => $version )); |
|
59 | + if( !empty($version) ) { |
|
60 | + static::normalize( array( 'wordpress' => $version ) ); |
|
61 | 61 | } |
62 | 62 | return !version_compare( $wp_version, static::$versions->wordpress, '<' ); |
63 | 63 | } |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public static function shouldDeactivate( $file, array $args = array() ) |
70 | 70 | { |
71 | - if( empty( static::$instance )) { |
|
71 | + if( empty(static::$instance) ) { |
|
72 | 72 | static::$file = realpath( $file ); |
73 | 73 | static::$instance = new static; |
74 | 74 | static::$versions = static::normalize( $args ); |
75 | 75 | } |
76 | 76 | if( !static::isValid() ) { |
77 | - add_action( 'activated_plugin', array( static::$instance, 'deactivate' )); |
|
78 | - add_action( 'admin_notices', array( static::$instance, 'deactivate' )); |
|
77 | + add_action( 'activated_plugin', array( static::$instance, 'deactivate' ) ); |
|
78 | + add_action( 'admin_notices', array( static::$instance, 'deactivate' ) ); |
|
79 | 79 | return true; |
80 | 80 | } |
81 | 81 | return false; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | return (object)wp_parse_args( $args, array( |
106 | 106 | 'php' => static::MIN_PHP_VERSION, |
107 | 107 | 'wordpress' => static::MIN_WORDPRESS_VERSION, |
108 | - )); |
|
108 | + ) ); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | filter_input( INPUT_GET, 'plugin_status' ), |
118 | 118 | filter_input( INPUT_GET, 'paged' ), |
119 | 119 | filter_input( INPUT_GET, 's' ) |
120 | - ))); |
|
120 | + ) ) ); |
|
121 | 121 | exit; |
122 | 122 | } |
123 | 123 |
@@ -87,7 +87,9 @@ |
||
87 | 87 | */ |
88 | 88 | public function deactivate( $plugin ) |
89 | 89 | { |
90 | - if( static::isValid() )return; |
|
90 | + if( static::isValid() ) { |
|
91 | + return; |
|
92 | + } |
|
91 | 93 | $pluginSlug = plugin_basename( static::$file ); |
92 | 94 | if( $plugin == $pluginSlug ) { |
93 | 95 | $this->redirect(); //exit |
@@ -62,7 +62,9 @@ |
||
62 | 62 | if( !empty( $validated->error )) { |
63 | 63 | return $validated->request; |
64 | 64 | } |
65 | - if( $validated->recaptchaIsUnset )return; |
|
65 | + if( $validated->recaptchaIsUnset ) { |
|
66 | + return; |
|
67 | + } |
|
66 | 68 | return $this->execute( new CreateReview( $validated->request )); |
67 | 69 | } |
68 | 70 | } |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | $vars[] = Application::PAGED_QUERY_VAR; |
45 | 45 | // dirty hack to fix a form submission with a field that has "name" as name |
46 | 46 | if( filter_input( INPUT_POST, 'action' ) == 'submit-review' |
47 | - && !is_null( filter_input( INPUT_POST, 'gotcha' ))) { |
|
47 | + && !is_null( filter_input( INPUT_POST, 'gotcha' ) ) ) { |
|
48 | 48 | $index = array_search( 'name', $vars, true ); |
49 | 49 | if( false !== $index ) { |
50 | - unset( $vars[$index] ); |
|
50 | + unset($vars[$index]); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | return $vars; |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | public function routerCreateReview( array $request ) |
60 | 60 | { |
61 | 61 | $validated = glsr( ValidateReview::class )->validate( $request ); |
62 | - if( !empty( $validated->error )) { |
|
62 | + if( !empty($validated->error) ) { |
|
63 | 63 | return $validated->request; |
64 | 64 | } |
65 | 65 | if( $validated->recaptchaIsUnset )return; |
66 | - return $this->execute( new CreateReview( $validated->request )); |
|
66 | + return $this->execute( new CreateReview( $validated->request ) ); |
|
67 | 67 | } |
68 | 68 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public function __construct( $input ) |
25 | 25 | { |
26 | - $this->ajaxRequest = isset( $input['ajax_request'] ); |
|
26 | + $this->ajaxRequest = isset($input['ajax_request']); |
|
27 | 27 | $this->assignedTo = is_numeric( $input['assign_to'] ) |
28 | 28 | ? $input['assign_to'] |
29 | 29 | : ''; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $this->rating = intval( $input['rating'] ); |
38 | 38 | $this->referrer = $input['_wp_http_referer']; |
39 | 39 | $this->request = $input; |
40 | - $this->terms = isset( $input['terms'] ); |
|
40 | + $this->terms = isset($input['terms']); |
|
41 | 41 | $this->title = sanitize_text_field( $input['title'] ); |
42 | 42 | } |
43 | 43 | } |
@@ -115,7 +115,9 @@ discard block |
||
115 | 115 | protected function sendNotification( $post_id, Command $command ) |
116 | 116 | { |
117 | 117 | $notificationType = glsr( OptionManager::class )->get( 'settings.general.notification' ); |
118 | - if( !in_array( $notificationType, ['default','custom','webhook'] ))return; |
|
118 | + if( !in_array( $notificationType, ['default','custom','webhook'] )) { |
|
119 | + return; |
|
120 | + } |
|
119 | 121 | $assignedToTitle = get_the_title( (int) $command->assignedTo ); |
120 | 122 | $notificationSubject = _nx( |
121 | 123 | 'New %s-star review', |
@@ -162,7 +164,9 @@ discard block |
||
162 | 164 | */ |
163 | 165 | protected function sendWebhookNotification( Command $command, array $args ) |
164 | 166 | { |
165 | - if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )))return; |
|
167 | + if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' ))) { |
|
168 | + return; |
|
169 | + } |
|
166 | 170 | $notification = $this->createWebhookNotification( $command, $args ); |
167 | 171 | $result = wp_remote_post( $endpoint, [ |
168 | 172 | 'method' => 'POST', |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | protected function createWebhookNotification( Command $command, array $args ) |
64 | 64 | { |
65 | 65 | $fields = []; |
66 | - $fields[] = ['title' => str_repeat( ':star:', (int) $command->rating )]; |
|
66 | + $fields[] = ['title' => str_repeat( ':star:', (int)$command->rating )]; |
|
67 | 67 | if( $command->title ) { |
68 | 68 | $fields[] = ['title' => $command->title]; |
69 | 69 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | if( $command->author ) { |
77 | 77 | $fields[] = ['value' => trim( $command->author.$command->email.' - '.$command->ipAddress )]; |
78 | 78 | } |
79 | - $fields[] = ['value' => sprintf( '<%s|%s>', $args['notification_link'], __( 'View Review', 'site-reviews' ))]; |
|
80 | - return json_encode([ |
|
79 | + $fields[] = ['value' => sprintf( '<%s|%s>', $args['notification_link'], __( 'View Review', 'site-reviews' ) )]; |
|
80 | + return json_encode( [ |
|
81 | 81 | 'icon_url' => glsr()->url.'assets/img/icon.png', |
82 | 82 | 'username' => glsr()->name, |
83 | 83 | 'attachments' => [[ |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'fallback' => $this->createEmailNotification( $command, $args )->read( 'plaintext' ), |
87 | 87 | 'fields' => $fields, |
88 | 88 | ]], |
89 | - ]); |
|
89 | + ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | protected function sendNotification( $post_id, Command $command ) |
116 | 116 | { |
117 | 117 | $notificationType = glsr( OptionManager::class )->get( 'settings.general.notification' ); |
118 | - if( !in_array( $notificationType, ['default','custom','webhook'] ))return; |
|
119 | - $assignedToTitle = get_the_title( (int) $command->assignedTo ); |
|
118 | + if( !in_array( $notificationType, ['default', 'custom', 'webhook'] ) )return; |
|
119 | + $assignedToTitle = get_the_title( (int)$command->assignedTo ); |
|
120 | 120 | $notificationSubject = _nx( |
121 | 121 | 'New %s-star review', |
122 | 122 | 'New %s-star review of: %s', |
123 | - (int) empty( $assignedToTitle ), |
|
123 | + (int)empty($assignedToTitle), |
|
124 | 124 | 'The text is different depending on whether or not the review has been assigned to a post.', |
125 | 125 | 'site-reviews' |
126 | 126 | ); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | sprintf( $notificationSubject, $command->rating, $assignedToTitle ) |
130 | 130 | ); |
131 | 131 | $args = [ |
132 | - 'notification_link' => esc_url( admin_url( sprintf( 'post.php?post=%s&action=edit', $post_id ))), |
|
132 | + 'notification_link' => esc_url( admin_url( sprintf( 'post.php?post=%s&action=edit', $post_id ) ) ), |
|
133 | 133 | 'notification_title' => $notificationTitle, |
134 | 134 | 'notification_type' => $notificationType, |
135 | 135 | ]; |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | $args['recipient'] = $args['notification_type'] === 'default' |
148 | 148 | ? get_option( 'admin_email' ) |
149 | 149 | : glsr( OptionManager::class )->get( 'settings.general.notification_email' ); |
150 | - $result = !empty( $args['recipient'] ) |
|
150 | + $result = !empty($args['recipient']) |
|
151 | 151 | ? $this->createEmailNotification( $command, $args )->send() |
152 | 152 | : false; |
153 | - if( !is_bool( $result )) { |
|
154 | - glsr_log()->error( __( 'Email notification was not sent: missing email, subject, or message.', 'site-reviews' )); |
|
153 | + if( !is_bool( $result ) ) { |
|
154 | + glsr_log()->error( __( 'Email notification was not sent: missing email, subject, or message.', 'site-reviews' ) ); |
|
155 | 155 | } |
156 | 156 | if( $result === false ) { |
157 | - glsr_log()->error( __( 'Email notification was not sent: wp_mail() failed.', 'site-reviews' )); |
|
157 | + glsr_log()->error( __( 'Email notification was not sent: wp_mail() failed.', 'site-reviews' ) ); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | protected function sendWebhookNotification( Command $command, array $args ) |
165 | 165 | { |
166 | - if( !( $endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )))return; |
|
166 | + if( !($endpoint = glsr( OptionManager::class )->get( 'settings.general.webhook_url' )) )return; |
|
167 | 167 | $notification = $this->createWebhookNotification( $command, $args ); |
168 | 168 | $result = wp_remote_post( $endpoint, [ |
169 | 169 | 'method' => 'POST', |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | 'sslverify' => false, |
175 | 175 | 'headers' => ['Content-Type' => 'application/json'], |
176 | 176 | 'body' => apply_filters( 'site-reviews/webhook/notification', $notification, $command ), |
177 | - ]); |
|
178 | - if( is_wp_error( $result )) { |
|
177 | + ] ); |
|
178 | + if( is_wp_error( $result ) ) { |
|
179 | 179 | glsr_log()->error( $result->get_error_message() ); |
180 | 180 | } |
181 | 181 | } |