@@ -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 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'is_valid' => true, |
28 | 28 | 'is_widget' => false, |
29 | 29 | 'path' => '', |
30 | - ]); |
|
30 | + ] ); |
|
31 | 31 | $this->normalize(); |
32 | 32 | } |
33 | 33 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | if( !$this->field['is_valid'] )return; |
48 | 48 | if( $this->field['is_raw'] ) { |
49 | - return glsr( Builder::class )->{$this->field['type']}( $this->field ); |
|
49 | + return glsr( Builder::class )->{$this->field['type']}($this->field); |
|
50 | 50 | } |
51 | 51 | if( !$this->field['is_setting'] ) { |
52 | 52 | return $this->buildField(); |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | 'class' => $this->getFieldClass(), |
76 | 76 | 'errors' => $this->getFieldErrors(), |
77 | 77 | 'field' => glsr( Builder::class )->raw( $this->field ), |
78 | - 'label' => glsr( Builder::class )->label([ |
|
78 | + 'label' => glsr( Builder::class )->label( [ |
|
79 | 79 | 'class' => 'glsr-'.$this->field['type'].'-label', |
80 | 80 | 'for' => $this->field['id'], |
81 | 81 | 'is_public' => $this->field['is_public'], |
82 | 82 | 'text' => $this->field['label'].'<span></span>', |
83 | 83 | 'type' => $this->field['type'], |
84 | - ]), |
|
84 | + ] ), |
|
85 | 85 | ], |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | return apply_filters( 'site-reviews/rendered/field', $field, $this->field['type'], $this->field ); |
88 | 88 | } |
89 | 89 | |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | return glsr( Template::class )->build( 'partials/form/table-row', [ |
96 | 96 | 'context' => [ |
97 | 97 | 'class' => $this->getFieldClass(), |
98 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
98 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
99 | 99 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
100 | 100 | ], |
101 | - ]); |
|
101 | + ] ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -107,16 +107,16 @@ discard block |
||
107 | 107 | protected function buildSettingMultiField() |
108 | 108 | { |
109 | 109 | $dependsOn = $this->getFieldDependsOn(); |
110 | - unset( $this->field['data-depends'] ); |
|
110 | + unset($this->field['data-depends']); |
|
111 | 111 | return glsr( Template::class )->build( 'partials/form/table-row-multiple', [ |
112 | 112 | 'context' => [ |
113 | 113 | 'class' => $this->getFieldClass(), |
114 | 114 | 'depends_on' => $dependsOn, |
115 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
115 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
116 | 116 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
117 | 117 | 'legend' => $this->field['legend'], |
118 | 118 | ], |
119 | - ]); |
|
119 | + ] ); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | protected function getFieldClass() |
126 | 126 | { |
127 | 127 | $classes = []; |
128 | - if( !empty( $this->field['errors'] )) { |
|
128 | + if( !empty($this->field['errors']) ) { |
|
129 | 129 | $classes[] = 'glsr-has-error'; |
130 | 130 | } |
131 | 131 | if( $this->field['is_hidden'] ) { |
132 | 132 | $classes[] = 'hidden'; |
133 | 133 | } |
134 | - if( !empty( $this->field['required'] )) { |
|
134 | + if( !empty($this->field['required']) ) { |
|
135 | 135 | $classes[] = 'glsr-required'; |
136 | 136 | } |
137 | 137 | $classes = apply_filters( 'site-reviews/rendered/field/classes', $classes, $this->field ); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | protected function getFieldDependsOn() |
145 | 145 | { |
146 | - return !empty( $this->field['data-depends'] ) |
|
146 | + return !empty($this->field['data-depends']) |
|
147 | 147 | ? $this->field['data-depends'] |
148 | 148 | : ''; |
149 | 149 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | protected function getFieldErrors() |
155 | 155 | { |
156 | - if( empty( $this->field['errors'] ) || !is_array( $this->field['errors'] ))return; |
|
156 | + if( empty($this->field['errors']) || !is_array( $this->field['errors'] ) )return; |
|
157 | 157 | $errors = array_reduce( $this->field['errors'], function( $carry, $error ) { |
158 | 158 | return $carry.glsr( Builder::class )->span( $error, ['class' => 'glsr-field-error'] ); |
159 | 159 | }); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'context' => [ |
162 | 162 | 'errors' => $errors, |
163 | 163 | ], |
164 | - ]); |
|
164 | + ] ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | 'name', 'type', |
185 | 185 | ]; |
186 | 186 | foreach( $requiredValues as $value ) { |
187 | - if( isset( $this->field[$value] ))continue; |
|
187 | + if( isset($this->field[$value]) )continue; |
|
188 | 188 | $missingValues[] = $value; |
189 | 189 | $this->field['is_valid'] = false; |
190 | 190 | } |
191 | - if( !empty( $missingValues )) { |
|
191 | + if( !empty($missingValues) ) { |
|
192 | 192 | glsr_log() |
193 | - ->warning( 'Field is missing: '.implode( ', ', $missingValues )) |
|
193 | + ->warning( 'Field is missing: '.implode( ', ', $missingValues ) ) |
|
194 | 194 | ->info( $this->field ); |
195 | 195 | } |
196 | 196 | return $this->field['is_valid']; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | if( !$this->isFieldValid() )return; |
205 | 205 | $this->field['path'] = $this->field['name']; |
206 | 206 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' ); |
207 | - if( class_exists( $className )) { |
|
207 | + if( class_exists( $className ) ) { |
|
208 | 208 | $this->field = array_merge( |
209 | 209 | wp_parse_args( $this->field, $className::defaults() ), |
210 | 210 | $className::required() |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | protected function normalizeFieldId() |
221 | 221 | { |
222 | - if( isset( $this->field['id'] ) || $this->field['is_raw'] )return; |
|
222 | + if( isset($this->field['id']) || $this->field['is_raw'] )return; |
|
223 | 223 | $this->field['id'] = glsr( Helper::class )->convertPathToId( |
224 | 224 | $this->field['path'], |
225 | 225 | $this->getFieldPrefix() |
@@ -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 | } |
@@ -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; |
@@ -31,25 +31,25 @@ discard block |
||
31 | 31 | public function __construct( $input ) |
32 | 32 | { |
33 | 33 | $this->request = $input; |
34 | - $this->ajax_request = isset( $input['_ajax_request'] ); |
|
34 | + $this->ajax_request = isset($input['_ajax_request']); |
|
35 | 35 | $this->assigned_to = $this->getNumeric( 'assign_to' ); |
36 | - $this->author = sanitize_text_field( $this->getUser( 'name' )); |
|
36 | + $this->author = sanitize_text_field( $this->getUser( 'name' ) ); |
|
37 | 37 | $this->avatar = $this->getAvatar(); |
38 | - $this->blacklisted = isset( $input['blacklisted'] ); |
|
39 | - $this->category = sanitize_key( $this->get( 'category' )); |
|
40 | - $this->content = sanitize_textarea_field( $this->get( 'content' )); |
|
38 | + $this->blacklisted = isset($input['blacklisted']); |
|
39 | + $this->category = sanitize_key( $this->get( 'category' ) ); |
|
40 | + $this->content = sanitize_textarea_field( $this->get( 'content' ) ); |
|
41 | 41 | $this->custom = $this->getCustom(); |
42 | 42 | $this->date = $this->getDate( 'date' ); |
43 | - $this->email = sanitize_email( $this->getUser( 'email' )); |
|
44 | - $this->form_id = sanitize_key( $this->get( 'form_id' )); |
|
43 | + $this->email = sanitize_email( $this->getUser( 'email' ) ); |
|
44 | + $this->form_id = sanitize_key( $this->get( 'form_id' ) ); |
|
45 | 45 | $this->ip_address = $this->get( 'ip_address' ); |
46 | - $this->post_id = intval( $this->get( '_post_id' )); |
|
47 | - $this->rating = intval( $this->get( 'rating' )); |
|
46 | + $this->post_id = intval( $this->get( '_post_id' ) ); |
|
47 | + $this->rating = intval( $this->get( 'rating' ) ); |
|
48 | 48 | $this->referer = $this->get( '_referer' ); |
49 | - $this->response = sanitize_textarea_field( $this->get( 'response' )); |
|
50 | - $this->terms = !empty( $input['terms'] ); |
|
51 | - $this->title = sanitize_text_field( $this->get( 'title' )); |
|
52 | - $this->url = esc_url_raw( $this->get( 'url' )); |
|
49 | + $this->response = sanitize_textarea_field( $this->get( 'response' ) ); |
|
50 | + $this->terms = !empty($input['terms']); |
|
51 | + $this->title = sanitize_text_field( $this->get( 'title' ) ); |
|
52 | + $this->url = esc_url_raw( $this->get( 'url' ) ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function get( $key ) |
60 | 60 | { |
61 | - return isset( $this->request[$key] ) |
|
61 | + return isset($this->request[$key]) |
|
62 | 62 | ? (string)$this->request[$key] |
63 | 63 | : ''; |
64 | 64 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | $avatar = $this->get( 'avatar' ); |
72 | 72 | return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_PATH_REQUIRED ) |
73 | - ? (string)get_avatar_url( $this->get( 'email' )) |
|
73 | + ? (string)get_avatar_url( $this->get( 'email' ) ) |
|
74 | 74 | : $avatar; |
75 | 75 | } |
76 | 76 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $unset = apply_filters( 'site-reviews/create/unset-keys-from-custom', $unset ); |
88 | 88 | $custom = $this->request; |
89 | 89 | foreach( $unset as $value ) { |
90 | - unset( $custom[$value] ); |
|
90 | + unset($custom[$value]); |
|
91 | 91 | } |
92 | 92 | return $custom; |
93 | 93 | } |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | */ |
99 | 99 | protected function getDate( $key ) |
100 | 100 | { |
101 | - $date = strtotime( $this->get( $key )); |
|
101 | + $date = strtotime( $this->get( $key ) ); |
|
102 | 102 | if( $date === false ) { |
103 | 103 | $date = time(); |
104 | 104 | } |
105 | - return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date )); |
|
105 | + return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | protected function getUser( $key ) |
113 | 113 | { |
114 | 114 | $value = $this->get( $key ); |
115 | - if( empty( $value )) { |
|
115 | + if( empty($value) ) { |
|
116 | 116 | $user = wp_get_current_user(); |
117 | 117 | $userValues = [ |
118 | 118 | 'email' => 'user_email', |
119 | 119 | 'name' => 'display_name', |
120 | 120 | ]; |
121 | - if( $user->exists() && array_key_exists( $key, $userValues )) { |
|
121 | + if( $user->exists() && array_key_exists( $key, $userValues ) ) { |
|
122 | 122 | return $user->{$userValues[$key]}; |
123 | 123 | } |
124 | 124 | } |
@@ -54,57 +54,57 @@ |
||
54 | 54 | */ |
55 | 55 | public function run() |
56 | 56 | { |
57 | - add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
58 | - add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
59 | - add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
60 | - add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
61 | - add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
62 | - add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
63 | - add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
64 | - add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
65 | - add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
66 | - add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
67 | - add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
68 | - add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
69 | - add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
70 | - add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
71 | - add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
72 | - add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
73 | - add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
74 | - add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
75 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
76 | - add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
77 | - add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
78 | - add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
79 | - add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
80 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
81 | - add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
82 | - add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
83 | - add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
84 | - add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
85 | - add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
86 | - add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
87 | - add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
88 | - add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
89 | - add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
90 | - add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
91 | - add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
92 | - add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
93 | - add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
94 | - add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
95 | - add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
96 | - add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
97 | - add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
98 | - add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
99 | - add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
57 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
58 | + add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
59 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
60 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
61 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
62 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
63 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
64 | + add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
65 | + add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
66 | + add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
67 | + add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
68 | + add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
69 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
70 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
71 | + add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
72 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
73 | + add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
74 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
75 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
76 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
77 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
78 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
79 | + add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
80 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
81 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
82 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
83 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
84 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
85 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
86 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
87 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
88 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
89 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
90 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
91 | + add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
92 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
93 | + add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
94 | + add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
95 | + add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
96 | + add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
97 | + add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
98 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
99 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
100 | 100 | add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
101 | - add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
102 | - add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
103 | - add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
104 | - add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
105 | - add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
106 | - add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
107 | - add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
108 | - add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
101 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
102 | + add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
103 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
104 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
105 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
106 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
107 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
108 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
109 | 109 | } |
110 | 110 | } |
@@ -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 | } |
@@ -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 ); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | $className = $this->camelCase( $name ); |
18 | 18 | $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' ); |
19 | - return !empty( $path ) |
|
19 | + return !empty($path) |
|
20 | 20 | ? __NAMESPACE__.'\\'.$path.'\\'.$className |
21 | 21 | : $className; |
22 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function buildMethodName( $name, $prefix = '' ) |
30 | 30 | { |
31 | - return lcfirst( $prefix.$this->buildClassName( $name )); |
|
31 | + return lcfirst( $prefix.$this->buildClassName( $name ) ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function buildPropertyName( $name ) |
39 | 39 | { |
40 | - return lcfirst( $this->buildClassName( $name )); |
|
40 | + return lcfirst( $this->buildClassName( $name ) ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function camelCase( $string ) |
48 | 48 | { |
49 | - $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ))); |
|
49 | + $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) ); |
|
50 | 50 | return str_replace( ' ', '', $string ); |
51 | 51 | } |
52 | 52 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function convertPathToId( $path, $prefix = '' ) |
80 | 80 | { |
81 | - return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix )); |
|
81 | + return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | $levels = explode( '.', $path ); |
91 | 91 | return array_reduce( $levels, function( $result, $value ) { |
92 | - return $result.= '['.$value.']'; |
|
92 | + return $result .= '['.$value.']'; |
|
93 | 93 | }, $prefix ); |
94 | 94 | } |
95 | 95 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function convertStringToArray( $string, $callback = null ) |
102 | 102 | { |
103 | - $array = array_map( 'trim', explode( ',', $string )); |
|
103 | + $array = array_map( 'trim', explode( ',', $string ) ); |
|
104 | 104 | return $callback |
105 | 105 | ? array_filter( $array, $callback ) |
106 | 106 | : array_filter( $array ); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function dashCase( $string ) |
114 | 114 | { |
115 | - return str_replace( '_', '-', $this->snakeCase( $string )); |
|
115 | + return str_replace( '_', '-', $this->snakeCase( $string ) ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function filterInput( $key, array $request = [] ) |
136 | 136 | { |
137 | - if( isset( $request[$key] )) { |
|
137 | + if( isset($request[$key]) ) { |
|
138 | 138 | return $request[$key]; |
139 | 139 | } |
140 | 140 | $variable = filter_input( INPUT_POST, $key ); |
141 | - if( is_null( $variable ) && isset( $_POST[$key] )) { |
|
141 | + if( is_null( $variable ) && isset($_POST[$key]) ) { |
|
142 | 142 | $variable = $_POST[$key]; |
143 | 143 | } |
144 | 144 | return $variable; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function filterInputArray( $key ) |
152 | 152 | { |
153 | 153 | $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
154 | - if( empty( $variable ) && !empty( $_POST[$key] ) && is_array( $_POST[$key] )) { |
|
154 | + if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) { |
|
155 | 155 | $variable = $_POST[$key]; |
156 | 156 | } |
157 | 157 | return (array)$variable; |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | $result = []; |
168 | 168 | foreach( $array as $key => $value ) { |
169 | 169 | $newKey = ltrim( $prefix.'.'.$key, '.' ); |
170 | - if( $this->isIndexedFlatArray( $value )) { |
|
170 | + if( $this->isIndexedFlatArray( $value ) ) { |
|
171 | 171 | if( $flattenValue ) { |
172 | 172 | $value = '['.implode( ', ', $value ).']'; |
173 | 173 | } |
174 | 174 | } |
175 | - else if( is_array( $value )) { |
|
176 | - $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey )); |
|
175 | + else if( is_array( $value ) ) { |
|
176 | + $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ) ); |
|
177 | 177 | continue; |
178 | 178 | } |
179 | 179 | $result[$newKey] = $value; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | Whip::IPV4 => $cloudflareIps['v4'], |
196 | 196 | Whip::IPV6 => $ipv6, |
197 | 197 | ], |
198 | - ]))->getValidIpAddress(); |
|
198 | + ] ))->getValidIpAddress(); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | { |
209 | 209 | $keys = explode( '.', $path ); |
210 | 210 | foreach( $keys as $key ) { |
211 | - if( !isset( $values[$key] )) { |
|
211 | + if( !isset($values[$key]) ) { |
|
212 | 212 | return $fallback; |
213 | 213 | } |
214 | 214 | $values = $values[$key]; |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function insertInArray( array $array, array $insert, $key, $position = 'before' ) |
225 | 225 | { |
226 | - $keyPosition = intval( array_search( $key, array_keys( $array ))); |
|
226 | + $keyPosition = intval( array_search( $key, array_keys( $array ) ) ); |
|
227 | 227 | if( 'after' == $position ) { |
228 | 228 | $keyPosition++; |
229 | 229 | } |
230 | 230 | if( false !== $keyPosition ) { |
231 | 231 | $result = array_slice( $array, 0, $keyPosition ); |
232 | 232 | $result = array_merge( $result, $insert ); |
233 | - return array_merge( $result, array_slice( $array, $keyPosition )); |
|
233 | + return array_merge( $result, array_slice( $array, $keyPosition ) ); |
|
234 | 234 | } |
235 | 235 | return array_merge( $array, $insert ); |
236 | 236 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function isIndexedArray( $array ) |
243 | 243 | { |
244 | - if( !is_array( $array )) { |
|
244 | + if( !is_array( $array ) ) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | $current = 0; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function isIndexedFlatArray( $array ) |
262 | 262 | { |
263 | - if( !is_array( $array ) || array_filter( $array, 'is_array' )) { |
|
263 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
264 | 264 | return false; |
265 | 265 | } |
266 | 266 | return $this->isIndexedArray( $array ); |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | */ |
274 | 274 | public function prefixString( $string, $prefix = '' ) |
275 | 275 | { |
276 | - return $prefix.str_replace( $prefix, '', trim( $string )); |
|
276 | + return $prefix.str_replace( $prefix, '', trim( $string ) ); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | public function removePrefix( $prefix, $text ) |
300 | 300 | { |
301 | 301 | return 0 === strpos( $text, $prefix ) |
302 | - ? substr( $text, strlen( $prefix )) |
|
302 | + ? substr( $text, strlen( $prefix ) ) |
|
303 | 303 | : $text; |
304 | 304 | } |
305 | 305 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | */ |
331 | 331 | public function snakeCase( $string ) |
332 | 332 | { |
333 | - if( !ctype_lower( $string )) { |
|
333 | + if( !ctype_lower( $string ) ) { |
|
334 | 334 | $string = preg_replace( '/\s+/u', '', $string ); |
335 | 335 | $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
336 | 336 | $string = function_exists( 'mb_strtolower' ) |
@@ -347,6 +347,6 @@ discard block |
||
347 | 347 | */ |
348 | 348 | public function startsWith( $needle, $haystack ) |
349 | 349 | { |
350 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
350 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
351 | 351 | } |
352 | 352 | } |