@@ -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 type of review would you like to display?', 'site-reviews' ), |
46 | 46 | 'name' => 'type', |
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,16 +61,16 @@ 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' => glsr( SiteReviewsShortcode::class )->getHideOptions(), |
73 | - ]); |
|
73 | + ] ); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function update( $newInstance, $oldInstance ) |
82 | 82 | { |
83 | - if( !is_numeric( $newInstance['count'] )) { |
|
83 | + if( !is_numeric( $newInstance['count'] ) ) { |
|
84 | 84 | $newInstance['count'] = 10; |
85 | 85 | } |
86 | - $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ))); |
|
86 | + $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ) ) ); |
|
87 | 87 | return parent::update( $newInstance, $oldInstance ); |
88 | 88 | } |
89 | 89 |
@@ -20,34 +20,34 @@ |
||
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' => glsr( SiteReviewsFormShortcode::class )->getHideOptions(), |
50 | - ]); |
|
50 | + ] ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -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,16 +43,16 @@ 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' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(), |
55 | - ]); |
|
55 | + ] ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function compose( Review $review, array $notification ) |
37 | 37 | { |
38 | - if( empty( $this->endpoint )) { |
|
38 | + if( empty($this->endpoint) ) { |
|
39 | 39 | return $this; |
40 | 40 | } |
41 | 41 | $args = shortcode_atts( glsr( SlackDefaults::class )->defaults(), $notification ); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function send() |
62 | 62 | { |
63 | - if( empty( $this->endpoint )) { |
|
63 | + if( empty($this->endpoint) ) { |
|
64 | 64 | return new WP_Error( 'slack', 'Slack notification was not sent: missing endpoint' ); |
65 | 65 | } |
66 | 66 | return wp_remote_post( $this->endpoint, [ |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'redirection' => 5, |
73 | 73 | 'sslverify' => false, |
74 | 74 | 'timeout' => 45, |
75 | - ]); |
|
75 | + ] ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function buildAuthorField() |
94 | 94 | { |
95 | - $email = !empty( $this->review->email ) |
|
95 | + $email = !empty($this->review->email) |
|
96 | 96 | ? '<'.$this->review->email.'>' |
97 | 97 | : ''; |
98 | 98 | $author = trim( rtrim( $this->review->author ).' '.$email ); |
99 | - return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ))]; |
|
99 | + return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ) )]; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function buildContentField() |
106 | 106 | { |
107 | - return !empty( $this->review->content ) |
|
107 | + return !empty($this->review->content) |
|
108 | 108 | ? ['value' => $this->review->content] |
109 | 109 | : []; |
110 | 110 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | protected function buildStarsField() |
130 | 130 | { |
131 | 131 | $solidStars = str_repeat( '★', $this->review->rating ); |
132 | - $emptyStars = str_repeat( '☆', max( 0, Rating::MAX_RATING - $this->review->rating )); |
|
132 | + $emptyStars = str_repeat( '☆', max( 0, Rating::MAX_RATING - $this->review->rating ) ); |
|
133 | 133 | $stars = $solidStars.$emptyStars; |
134 | 134 | $stars = apply_filters( 'site-reviews/slack/stars', $stars, $this->review->rating, Rating::MAX_RATING ); |
135 | 135 | return ['title' => $stars]; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | protected function buildTitleField() |
142 | 142 | { |
143 | - return !empty( $this->review->title ) |
|
143 | + return !empty($this->review->title) |
|
144 | 144 | ? ['title' => $this->review->title] |
145 | 145 | : []; |
146 | 146 | } |
@@ -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,9 +105,9 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function customize( Builder $instance ) |
107 | 107 | { |
108 | - $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
|
108 | + $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) ); |
|
109 | 109 | $key = $instance->tag.'_'.$args['type']; |
110 | - $classes = !isset( $this->fields[$key] ) |
|
110 | + $classes = !isset($this->fields[$key]) |
|
111 | 111 | ? $this->fields[$instance->tag] |
112 | 112 | : $this->fields[$key]; |
113 | 113 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $args = wp_parse_args( $instance->args, [ |
142 | 142 | 'is_public' => false, |
143 | 143 | 'is_raw' => false, |
144 | - ]); |
|
144 | + ] ); |
|
145 | 145 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
146 | 146 | return false; |
147 | 147 | } |
@@ -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 |
@@ -150,7 +150,9 @@ discard block |
||
150 | 150 | if( !empty( $sessions )) { |
151 | 151 | $now = time(); |
152 | 152 | foreach( $sessions as $session ) { |
153 | - if( $now <= $session->expiration )continue; |
|
153 | + if( $now <= $session->expiration ) { |
|
154 | + continue; |
|
155 | + } |
|
154 | 156 | $expiredSessions[] = $session->name; |
155 | 157 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
156 | 158 | } |
@@ -193,7 +195,9 @@ discard block |
||
193 | 195 | */ |
194 | 196 | protected function setCookie() |
195 | 197 | { |
196 | - if( headers_sent() )return; |
|
198 | + if( headers_sent() ) { |
|
199 | + return; |
|
200 | + } |
|
197 | 201 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
198 | 202 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
199 | 203 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ); |
40 | 40 | if( strpos( $cookieId, static::DELIMITER ) !== false ) { |
41 | - $cookie = explode( static::DELIMITER, stripslashes( $cookieId )); |
|
41 | + $cookie = explode( static::DELIMITER, stripslashes( $cookieId ) ); |
|
42 | 42 | $this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] ); |
43 | 43 | $this->expiryTimestamp = absint( $cookie[1] ); |
44 | 44 | $this->expiryTimestampReset = absint( $cookie[2] ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function deleteExpiredSessions( $limit = 1000 ) |
79 | 79 | { |
80 | - if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) { |
|
80 | + if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) { |
|
81 | 81 | glsr( SqlQueries::class )->deleteExpiredSessions( $expiredSessions ); |
82 | 82 | } |
83 | 83 | } |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | public function get( $key, $fallback = '', $unset = false ) |
92 | 92 | { |
93 | 93 | $key = sanitize_key( $key ); |
94 | - $value = isset( $this->sessionData[$key] ) |
|
94 | + $value = isset($this->sessionData[$key]) |
|
95 | 95 | ? maybe_unserialize( $this->sessionData[$key] ) |
96 | 96 | : $fallback; |
97 | - if( isset( $this->sessionData[$key] ) && $unset ) { |
|
98 | - unset( $this->sessionData[$key] ); |
|
97 | + if( isset($this->sessionData[$key]) && $unset ) { |
|
98 | + unset($this->sessionData[$key]); |
|
99 | 99 | $this->updateSession(); |
100 | 100 | } |
101 | 101 | return $value; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | protected function deleteSession() |
130 | 130 | { |
131 | 131 | delete_option( $this->getSessionId() ); |
132 | - delete_option( $this->getSessionId( 'expires' )); |
|
132 | + delete_option( $this->getSessionId( 'expires' ) ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function generateSessionId() |
139 | 139 | { |
140 | - return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 )); |
|
140 | + return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | protected function getExpiredSessions( $limit ) |
148 | 148 | { |
149 | 149 | $expiredSessions = []; |
150 | - $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit )); |
|
151 | - if( !empty( $sessions )) { |
|
150 | + $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit ) ); |
|
151 | + if( !empty($sessions) ) { |
|
152 | 152 | $now = time(); |
153 | 153 | foreach( $sessions as $session ) { |
154 | 154 | if( $now <= $session->expiration )continue; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | protected function getSessionId( $separator = '' ) |
167 | 167 | { |
168 | - return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] )); |
|
168 | + return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | { |
197 | 197 | if( headers_sent() )return; |
198 | 198 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
199 | - $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
|
199 | + $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ) ) ); |
|
200 | 200 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
201 | 201 | } |
202 | 202 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | protected function updateSession() |
216 | 216 | { |
217 | - if( false === get_option( $this->getSessionId() )) { |
|
217 | + if( false === get_option( $this->getSessionId() ) ) { |
|
218 | 218 | return $this->createSession(); |
219 | 219 | } |
220 | 220 | update_option( $this->getSessionId(), $this->sessionData, false ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public function __construct() |
34 | 34 | { |
35 | 35 | $types = glsr( OptionManager::class )->get( 'settings.general.notifications', [] ); |
36 | - $this->email = count( array_intersect( ['admin', 'custom'], $types )) > 0; |
|
36 | + $this->email = count( array_intersect( ['admin', 'custom'], $types ) ) > 0; |
|
37 | 37 | $this->slack = in_array( 'slack', $types ); |
38 | 38 | $this->types = $types; |
39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function send( Review $review ) |
45 | 45 | { |
46 | - if( empty( $this->types ))return; |
|
46 | + if( empty($this->types) )return; |
|
47 | 47 | $this->review = $review; |
48 | 48 | $args = [ |
49 | 49 | 'link' => $this->getLink(), |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function buildEmail( array $args ) |
60 | 60 | { |
61 | - return glsr( Email::class )->compose([ |
|
61 | + return glsr( Email::class )->compose( [ |
|
62 | 62 | 'to' => $this->getEmailAddresses(), |
63 | 63 | 'subject' => $args['title'], |
64 | 64 | 'template' => 'email-notification', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'review_rating' => $this->review->rating, |
72 | 72 | 'review_title' => $this->review->title, |
73 | 73 | ], |
74 | - ]); |
|
74 | + ] ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'button_url' => $args['link'], |
84 | 84 | 'fallback' => $this->buildEmail( $args )->read( 'plaintext' ), |
85 | 85 | 'pretext' => $args['title'], |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,23 +92,23 @@ discard block |
||
92 | 92 | protected function getEmailAddresses() |
93 | 93 | { |
94 | 94 | $emails = []; |
95 | - if( in_array( 'admin', $this->types )) { |
|
95 | + if( in_array( 'admin', $this->types ) ) { |
|
96 | 96 | $emails[] = get_option( 'admin_email' ); |
97 | 97 | } |
98 | - if( in_array( 'author', $this->types )) { |
|
99 | - $assignedPost = get_post( intval( $this->review->assigned_to )); |
|
98 | + if( in_array( 'author', $this->types ) ) { |
|
99 | + $assignedPost = get_post( intval( $this->review->assigned_to ) ); |
|
100 | 100 | if( $assignedPost instanceof WP_Post ) { |
101 | 101 | $this->email = true; |
102 | - $emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author )); |
|
102 | + $emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author ) ); |
|
103 | 103 | } |
104 | 104 | } |
105 | - if( in_array( 'custom', $this->types )) { |
|
105 | + if( in_array( 'custom', $this->types ) ) { |
|
106 | 106 | $customEmails = glsr( OptionManager::class )->get( 'settings.general.notification_email' ); |
107 | 107 | $customEmails = str_replace( [' ', ',', ';'], ',', $customEmails ); |
108 | 108 | $customEmails = explode( ',', $customEmails ); |
109 | 109 | $emails = array_merge( $emails, $customEmails ); |
110 | 110 | } |
111 | - $emails = array_filter( array_keys( array_flip( $emails ))); |
|
111 | + $emails = array_filter( array_keys( array_flip( $emails ) ) ); |
|
112 | 112 | return apply_filters( 'site-reviews/notification/emails', $emails, $this->review ); |
113 | 113 | } |
114 | 114 | |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function getTitle() |
127 | 127 | { |
128 | - $assignedTitle = get_the_title( intval( $this->review->assigned_to )); |
|
128 | + $assignedTitle = get_the_title( intval( $this->review->assigned_to ) ); |
|
129 | 129 | $title = _nx( |
130 | 130 | 'New %s-star review', |
131 | 131 | 'New %s-star review of: %s', |
132 | - intval( empty( $assignedTitle )), |
|
132 | + intval( empty($assignedTitle) ), |
|
133 | 133 | 'This string differs depending on whether or not the review has been assigned to a post.', |
134 | 134 | 'site-reviews' |
135 | 135 | ); |
136 | 136 | $title = sprintf( '[%s] %s', |
137 | - wp_specialchars_decode( strval( get_option( 'blogname' )), ENT_QUOTES ), |
|
137 | + wp_specialchars_decode( strval( get_option( 'blogname' ) ), ENT_QUOTES ), |
|
138 | 138 | sprintf( $title, $this->review->rating, $assignedTitle ) |
139 | 139 | ); |
140 | 140 | return apply_filters( 'site-reviews/notification/title', $title, $this->review ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | $email = $this->buildEmail( $args ); |
149 | 149 | if( !$this->email )return; |
150 | - if( empty( $email->to )) { |
|
150 | + if( empty($email->to) ) { |
|
151 | 151 | glsr_log()->error( 'Email notification was not sent (missing email address)' ); |
152 | 152 | return; |
153 | 153 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | if( !$this->slack )return; |
165 | 165 | $notification = $this->buildSlackNotification( $args ); |
166 | 166 | $result = $notification->send(); |
167 | - if( is_wp_error( $result )) { |
|
167 | + if( is_wp_error( $result ) ) { |
|
168 | 168 | $notification->review = null; |
169 | 169 | glsr_log()->error( $result->get_error_message() )->debug( $notification ); |
170 | 170 | } |
@@ -43,7 +43,9 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function send( Review $review ) |
45 | 45 | { |
46 | - if( empty( $this->types ))return; |
|
46 | + if( empty( $this->types )) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | $this->review = $review; |
48 | 50 | $args = [ |
49 | 51 | 'link' => $this->getLink(), |
@@ -146,7 +148,9 @@ discard block |
||
146 | 148 | protected function sendToEmail( array $args ) |
147 | 149 | { |
148 | 150 | $email = $this->buildEmail( $args ); |
149 | - if( !$this->email )return; |
|
151 | + if( !$this->email ) { |
|
152 | + return; |
|
153 | + } |
|
150 | 154 | if( empty( $email->to )) { |
151 | 155 | glsr_log()->error( 'Email notification was not sent (missing email address)' ); |
152 | 156 | return; |
@@ -161,7 +165,9 @@ discard block |
||
161 | 165 | */ |
162 | 166 | protected function sendToSlack( array $args ) |
163 | 167 | { |
164 | - if( !$this->slack )return; |
|
168 | + if( !$this->slack ) { |
|
169 | + return; |
|
170 | + } |
|
165 | 171 | $notification = $this->buildSlackNotification( $args ); |
166 | 172 | $result = $notification->send(); |
167 | 173 | if( is_wp_error( $result )) { |
@@ -175,8 +175,12 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function validateAkismet() |
177 | 177 | { |
178 | - if( !empty( $this->error ))return; |
|
179 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
178 | + if( !empty( $this->error )) { |
|
179 | + return; |
|
180 | + } |
|
181 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
182 | + return; |
|
183 | + } |
|
180 | 184 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
181 | 185 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
182 | 186 | } |
@@ -186,8 +190,12 @@ discard block |
||
186 | 190 | */ |
187 | 191 | protected function validateBlacklist() |
188 | 192 | { |
189 | - if( !empty( $this->error ))return; |
|
190 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
193 | + if( !empty( $this->error )) { |
|
194 | + return; |
|
195 | + } |
|
196 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
197 | + return; |
|
198 | + } |
|
191 | 199 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
192 | 200 | if( $blacklistAction == 'reject' ) { |
193 | 201 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -202,9 +210,13 @@ discard block |
||
202 | 210 | */ |
203 | 211 | protected function validateCustom() |
204 | 212 | { |
205 | - if( !empty( $this->error ))return; |
|
213 | + if( !empty( $this->error )) { |
|
214 | + return; |
|
215 | + } |
|
206 | 216 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
207 | - if( $validated === true )return; |
|
217 | + if( $validated === true ) { |
|
218 | + return; |
|
219 | + } |
|
208 | 220 | $this->setSessionValues( 'errors', [] ); |
209 | 221 | $this->setSessionValues( 'values', $this->request ); |
210 | 222 | $this->error = is_string( $validated ) |
@@ -217,8 +229,12 @@ discard block |
||
217 | 229 | */ |
218 | 230 | protected function validateHoneyPot() |
219 | 231 | { |
220 | - if( !empty( $this->error ))return; |
|
221 | - if( empty( $this->request['gotcha'] ))return; |
|
232 | + if( !empty( $this->error )) { |
|
233 | + return; |
|
234 | + } |
|
235 | + if( empty( $this->request['gotcha'] )) { |
|
236 | + return; |
|
237 | + } |
|
222 | 238 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
223 | 239 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
224 | 240 | } |
@@ -228,9 +244,13 @@ discard block |
||
228 | 244 | */ |
229 | 245 | protected function validateRecaptcha() |
230 | 246 | { |
231 | - if( !empty( $this->error ))return; |
|
247 | + if( !empty( $this->error )) { |
|
248 | + return; |
|
249 | + } |
|
232 | 250 | $status = $this->getRecaptchaStatus(); |
233 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
251 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] )) { |
|
252 | + return; |
|
253 | + } |
|
234 | 254 | if( $status == static::RECAPTCHA_EMPTY ) { |
235 | 255 | $this->setSessionValues( 'recaptcha', 'unset' ); |
236 | 256 | $this->recaptchaIsUnset = true; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $this->validateBlacklist(); |
68 | 68 | $this->validateAkismet(); |
69 | 69 | $this->validateRecaptcha(); |
70 | - if( !empty( $this->error )) { |
|
70 | + if( !empty($this->error) ) { |
|
71 | 71 | $this->setSessionValues( 'message', $this->error ); |
72 | 72 | } |
73 | 73 | return $this; |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
92 | 92 | return static::RECAPTCHA_DISABLED; |
93 | 93 | } |
94 | - if( empty( $this->request['_recaptcha-token'] )) { |
|
95 | - return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 )) |
|
94 | + if( empty($this->request['_recaptcha-token']) ) { |
|
95 | + return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) ) |
|
96 | 96 | ? static::RECAPTCHA_EMPTY |
97 | 97 | : static::RECAPTCHA_FAILED; |
98 | 98 | } |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected function getRecaptchaTokenStatus() |
106 | 106 | { |
107 | - $endpoint = add_query_arg([ |
|
107 | + $endpoint = add_query_arg( [ |
|
108 | 108 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
109 | 109 | 'response' => $this->request['_recaptcha-token'], |
110 | 110 | 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
111 | 111 | ], static::RECAPTCHA_ENDPOINT ); |
112 | - if( is_wp_error( $response = wp_remote_get( $endpoint ))) { |
|
112 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
113 | 113 | glsr_log()->error( $response->get_error_message() ); |
114 | 114 | return static::RECAPTCHA_FAILED; |
115 | 115 | } |
116 | - $response = json_decode( wp_remote_retrieve_body( $response )); |
|
117 | - if( !empty( $response->success )) { |
|
116 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
117 | + if( !empty($response->success) ) { |
|
118 | 118 | return boolval( $response->success ) |
119 | 119 | ? static::RECAPTCHA_VALID |
120 | 120 | : static::RECAPTCHA_INVALID; |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | { |
133 | 133 | $rules = array_intersect_key( |
134 | 134 | apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ), |
135 | - array_flip( $this->getOption( 'settings.submissions.required', [] )) |
|
135 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
136 | 136 | ); |
137 | - $excluded = isset( $request['excluded'] ) |
|
137 | + $excluded = isset($request['excluded']) |
|
138 | 138 | ? explode( ',', $request['excluded'] ) |
139 | 139 | : []; |
140 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
140 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | $rules = $this->getValidationRules( $request ); |
149 | 149 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
150 | - if( empty( $errors )) { |
|
150 | + if( empty($errors) ) { |
|
151 | 151 | return true; |
152 | 152 | } |
153 | 153 | $this->setSessionValues( 'errors', $errors ); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
165 | 165 | { |
166 | 166 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
167 | - if( !empty( $loggedMessage )) { |
|
167 | + if( !empty($loggedMessage) ) { |
|
168 | 168 | glsr_log()->warning( $loggedMessage ); |
169 | 169 | glsr_log()->warning( $this->request ); |
170 | 170 | } |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | */ |
176 | 176 | protected function validateAkismet() |
177 | 177 | { |
178 | - if( !empty( $this->error ))return; |
|
179 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
178 | + if( !empty($this->error) )return; |
|
179 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
180 | 180 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission (consider adding the IP address to the blacklist):' ); |
181 | 181 | $this->error = __( 'This review has been flagged as possible spam and cannot be submitted.', 'site-reviews' ); |
182 | 182 | } |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | */ |
187 | 187 | protected function validateBlacklist() |
188 | 188 | { |
189 | - if( !empty( $this->error ))return; |
|
190 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
189 | + if( !empty($this->error) )return; |
|
190 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request ) )return; |
|
191 | 191 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
192 | 192 | if( $blacklistAction == 'reject' ) { |
193 | 193 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function validateCustom() |
204 | 204 | { |
205 | - if( !empty( $this->error ))return; |
|
205 | + if( !empty($this->error) )return; |
|
206 | 206 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
207 | 207 | if( $validated === true )return; |
208 | 208 | $this->setSessionValues( 'errors', [] ); |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function validateHoneyPot() |
219 | 219 | { |
220 | - if( !empty( $this->error ))return; |
|
221 | - if( empty( $this->request['gotcha'] ))return; |
|
220 | + if( !empty($this->error) )return; |
|
221 | + if( empty($this->request['gotcha']) )return; |
|
222 | 222 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
223 | 223 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
224 | 224 | } |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | */ |
229 | 229 | protected function validateRecaptcha() |
230 | 230 | { |
231 | - if( !empty( $this->error ))return; |
|
231 | + if( !empty($this->error) )return; |
|
232 | 232 | $status = $this->getRecaptchaStatus(); |
233 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
233 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ) )return; |
|
234 | 234 | if( $status == static::RECAPTCHA_EMPTY ) { |
235 | 235 | $this->setSessionValues( 'recaptcha', 'unset' ); |
236 | 236 | $this->recaptchaIsUnset = true; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | protected function validateRequest( array $request ) |
252 | 252 | { |
253 | - if( !$this->isRequestValid( $request )) { |
|
253 | + if( !$this->isRequestValid( $request ) ) { |
|
254 | 254 | $this->error = __( 'Please fix the submission errors.', 'site-reviews' ); |
255 | 255 | return $request; |
256 | 256 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function callbackRegisterSettings( $input ) |
19 | 19 | { |
20 | - if( !is_array( $input )) { |
|
20 | + if( !is_array( $input ) ) { |
|
21 | 21 | $input = ['settings' => []]; |
22 | 22 | } |
23 | 23 | if( key( $input ) == 'settings' ) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $options = $this->sanitizeSubmissions( $input, $options ); |
27 | 27 | $options = $this->sanitizeTranslations( $input, $options ); |
28 | 28 | if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) { |
29 | - glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' )); |
|
29 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
30 | 30 | } |
31 | 31 | return $options; |
32 | 32 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
43 | 43 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
44 | - ]); |
|
44 | + ] ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if( trim( $inputForm['notification_message'] ) == '' ) { |
57 | 57 | $options['settings']['general']['notification_message'] = glsr()->defaults['settings']['general']['notification_message']; |
58 | 58 | } |
59 | - $options['settings']['general']['notifications'] = isset( $inputForm['notifications'] ) |
|
59 | + $options['settings']['general']['notifications'] = isset($inputForm['notifications']) |
|
60 | 60 | ? $inputForm['notifications'] |
61 | 61 | : []; |
62 | 62 | return $options; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected function sanitizeSubmissions( array $input, array $options ) |
69 | 69 | { |
70 | 70 | $inputForm = $input['settings']['submissions']; |
71 | - $options['settings']['submissions']['required'] = isset( $inputForm['required'] ) |
|
71 | + $options['settings']['submissions']['required'] = isset($inputForm['required']) |
|
72 | 72 | ? $inputForm['required'] |
73 | 73 | : []; |
74 | 74 | return $options; |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | */ |
80 | 80 | protected function sanitizeTranslations( array $input, array $options ) |
81 | 81 | { |
82 | - if( isset( $input['settings']['strings'] )) { |
|
83 | - $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] )); |
|
82 | + if( isset($input['settings']['strings']) ) { |
|
83 | + $options['settings']['strings'] = array_values( array_filter( $input['settings']['strings'] ) ); |
|
84 | 84 | $allowedTags = [ |
85 | 85 | 'a' => ['class' => [], 'href' => [], 'target' => []], |
86 | 86 | 'span' => ['class' => []], |
87 | 87 | ]; |
88 | - array_walk( $options['settings']['strings'], function( &$string ) use( $allowedTags ) { |
|
89 | - if( isset( $string['s2'] )) { |
|
88 | + array_walk( $options['settings']['strings'], function( &$string ) use($allowedTags) { |
|
89 | + if( isset($string['s2']) ) { |
|
90 | 90 | $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
91 | 91 | } |
92 | - if( isset( $string['p2'] )) { |
|
92 | + if( isset($string['p2']) ) { |
|
93 | 93 | $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
94 | 94 | } |
95 | 95 | }); |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | protected function isPolylangActiveAndSupported() |
104 | 104 | { |
105 | 105 | if( !glsr( Polylang::class )->isActive() ) { |
106 | - glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' )); |
|
106 | + glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' ) ); |
|
107 | 107 | return false; |
108 | 108 | } |
109 | 109 | else if( !glsr( Polylang::class )->isSupported() ) { |
110 | - glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' )); |
|
110 | + glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' ) ); |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | return true; |