@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | public function fields() |
| 13 | 13 | { |
| 14 | 14 | return [[ |
| 15 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
| 15 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
| 16 | 16 | 'minWidth' => 320, |
| 17 | 17 | 'type' => 'container', |
| 18 | - ],[ |
|
| 18 | + ], [ |
|
| 19 | 19 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 20 | 20 | 'name' => 'title', |
| 21 | 21 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | 'name' => 'assigned_to', |
| 29 | 29 | 'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page.', 'site-reviews' ), |
| 30 | 30 | 'type' => 'textbox', |
| 31 | - ],[ |
|
| 31 | + ], [ |
|
| 32 | 32 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
| 33 | 33 | 'name' => 'schema', |
| 34 | 34 | 'options' => [ |
@@ -37,34 +37,34 @@ discard block |
||
| 37 | 37 | ], |
| 38 | 38 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
| 39 | 39 | 'type' => 'listbox', |
| 40 | - ],[ |
|
| 40 | + ], [ |
|
| 41 | 41 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 42 | 42 | 'name' => 'class', |
| 43 | 43 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 44 | 44 | 'type' => 'textbox', |
| 45 | - ],[ |
|
| 45 | + ], [ |
|
| 46 | 46 | 'columns' => 2, |
| 47 | 47 | 'items' => [[ |
| 48 | 48 | 'type' => 'checkbox', |
| 49 | 49 | 'name' => 'hide_bars', |
| 50 | 50 | 'text' => esc_html__( 'Bars', 'site-reviews' ), |
| 51 | 51 | 'tooltip' => __( 'Hide the percentage bars?', 'site-reviews' ), |
| 52 | - ],[ |
|
| 52 | + ], [ |
|
| 53 | 53 | 'type' => 'checkbox', |
| 54 | 54 | 'name' => 'hide_if_empty', |
| 55 | 55 | 'text' => esc_html__( 'If Empty', 'site-reviews' ), |
| 56 | 56 | 'tooltip' => __( 'Hide the summary if no reviews are found?', 'site-reviews' ), |
| 57 | - ],[ |
|
| 57 | + ], [ |
|
| 58 | 58 | 'type' => 'checkbox', |
| 59 | 59 | 'name' => 'hide_rating', |
| 60 | 60 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
| 61 | 61 | 'tooltip' => __( 'Hide the rating?', 'site-reviews' ), |
| 62 | - ],[ |
|
| 62 | + ], [ |
|
| 63 | 63 | 'type' => 'checkbox', |
| 64 | 64 | 'name' => 'hide_stars', |
| 65 | 65 | 'text' => esc_html__( 'Stars', 'site-reviews' ), |
| 66 | 66 | 'tooltip' => __( 'Hide the stars?', 'site-reviews' ), |
| 67 | - ],[ |
|
| 67 | + ], [ |
|
| 68 | 68 | 'type' => 'checkbox', |
| 69 | 69 | 'name' => 'hide_summary', |
| 70 | 70 | 'text' => esc_html__( 'Summary', 'site-reviews' ), |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | { |
| 15 | 15 | foreach( $command->popups as $slug => $label ) { |
| 16 | 16 | $buttonClass = glsr( Helper::class )->buildClassName( $slug.'-popup', 'Shortcodes' ); |
| 17 | - if( !class_exists( $buttonClass )) { |
|
| 18 | - glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass )); |
|
| 17 | + if( !class_exists( $buttonClass ) ) { |
|
| 18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ) ); |
|
| 19 | 19 | continue; |
| 20 | 20 | } |
| 21 | 21 | $shortcode = glsr( $buttonClass )->register( $slug, [ |
| 22 | 22 | 'label' => $label, |
| 23 | 23 | 'title' => $label, |
| 24 | - ]); |
|
| 24 | + ] ); |
|
| 25 | 25 | glsr()->mceShortcodes[$slug] = $shortcode->properties; |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -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; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | Whip::IPV4 => $cloudflareIps['v4'], |
| 193 | 193 | Whip::IPV6 => $cloudflareIps['v6'], |
| 194 | 194 | ], |
| 195 | - ]))->getValidIpAddress(); |
|
| 195 | + ] ))->getValidIpAddress(); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | { |
| 206 | 206 | $keys = explode( '.', $path ); |
| 207 | 207 | foreach( $keys as $key ) { |
| 208 | - if( !isset( $values[$key] )) { |
|
| 208 | + if( !isset($values[$key]) ) { |
|
| 209 | 209 | return $fallback; |
| 210 | 210 | } |
| 211 | 211 | $values = $values[$key]; |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function isIndexedArray( $array ) |
| 221 | 221 | { |
| 222 | - if( !is_array( $array )) { |
|
| 222 | + if( !is_array( $array ) ) { |
|
| 223 | 223 | return false; |
| 224 | 224 | } |
| 225 | 225 | $current = 0; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | public function isIndexedFlatArray( $array ) |
| 240 | 240 | { |
| 241 | - if( !is_array( $array ) || array_filter( $array, 'is_array' )) { |
|
| 241 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | return $this->isIndexedArray( $array ); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function prefixString( $string, $prefix = '' ) |
| 253 | 253 | { |
| 254 | - return $prefix.str_replace( $prefix, '', trim( $string )); |
|
| 254 | + return $prefix.str_replace( $prefix, '', trim( $string ) ); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | public function removePrefix( $prefix, $text ) { |
| 278 | 278 | return 0 === strpos( $text, $prefix ) |
| 279 | - ? substr( $text, strlen( $prefix )) |
|
| 279 | + ? substr( $text, strlen( $prefix ) ) |
|
| 280 | 280 | : $text; |
| 281 | 281 | } |
| 282 | 282 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | public function snakeCase( $string ) |
| 309 | 309 | { |
| 310 | - if( !ctype_lower( $string )) { |
|
| 310 | + if( !ctype_lower( $string ) ) { |
|
| 311 | 311 | $string = preg_replace( '/\s+/u', '', $string ); |
| 312 | 312 | $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
| 313 | 313 | $string = mb_strtolower( $string, 'UTF-8' ); |
@@ -322,6 +322,6 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | public function startsWith( $needle, $haystack ) |
| 324 | 324 | { |
| 325 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
| 325 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
| 326 | 326 | } |
| 327 | 327 | } |
@@ -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()->path( $possibleView.'.php' )))continue; |
|
| 58 | + if( !file_exists( glsr()->path( $possibleView.'.php' ) ) )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 | } |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | public function filterEnqueuedScripts( $tag, $handle ) |
| 33 | 33 | { |
| 34 | 34 | $scripts = [Application::ID.'/google-recaptcha']; |
| 35 | - if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ))) { |
|
| 35 | + if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) { |
|
| 36 | 36 | $tag = str_replace( ' src=', ' async src=', $tag ); |
| 37 | 37 | } |
| 38 | - if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ))) { |
|
| 38 | + if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) { |
|
| 39 | 39 | $tag = str_replace( ' src=', ' defer src=', $tag ); |
| 40 | 40 | } |
| 41 | 41 | return $tag; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function filterFieldOrder( array $config ) |
| 50 | 50 | { |
| 51 | - $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config )); |
|
| 51 | + $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) ); |
|
| 52 | 52 | return array_intersect_key( array_merge( array_flip( $order ), $config ), $config ); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | public function routerSubmitReview( array $request ) |
| 97 | 97 | { |
| 98 | 98 | $validated = glsr( ValidateReview::class )->validate( $request ); |
| 99 | - if( !empty( $validated->error ) || $validated->recaptchaIsUnset )return; |
|
| 100 | - $this->execute( new CreateReview( $validated->request )); |
|
| 99 | + if( !empty($validated->error) || $validated->recaptchaIsUnset )return; |
|
| 100 | + $this->execute( new CreateReview( $validated->request ) ); |
|
| 101 | 101 | } |
| 102 | 102 | } |
@@ -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:' ); |
| 181 | 181 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', '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,11 +250,11 @@ 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 | } |
| 257 | - if( empty( $request['title'] )) { |
|
| 257 | + if( empty($request['title']) ) { |
|
| 258 | 258 | $request['title'] = __( 'No Title', 'site-reviews' ); |
| 259 | 259 | } |
| 260 | 260 | return array_merge( glsr( ValidateReviewDefaults::class )->defaults(), $request ); |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function build( array $args = [] ) |
| 14 | 14 | { |
| 15 | - require_once( ABSPATH.'wp-admin/includes/template.php' ); |
|
| 15 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
| 16 | 16 | ob_start(); |
| 17 | 17 | wp_star_rating( $args ); |
| 18 | 18 | $stars = ob_get_clean(); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | 'response' => $this->buildResponse(), |
| 66 | 66 | 'submit_button' => $this->buildSubmitButton().$this->buildRecaptcha(), |
| 67 | 67 | ], |
| 68 | - ]); |
|
| 68 | + ] ); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'context' => [ |
| 78 | 78 | 'text' => trim( $this->getLoginText().' '.$this->getRegisterText() ), |
| 79 | 79 | ], |
| 80 | - ]); |
|
| 80 | + ] ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | protected function buildRecaptcha() |
| 87 | 87 | { |
| 88 | 88 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() )return; |
| 89 | - return glsr( Builder::class )->div([ |
|
| 89 | + return glsr( Builder::class )->div( [ |
|
| 90 | 90 | 'class' => 'glsr-recaptcha-holder', |
| 91 | 91 | 'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ), |
| 92 | - 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' )), |
|
| 92 | + 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' ) ), |
|
| 93 | 93 | 'data-size' => 'invisible', |
| 94 | - ]); |
|
| 94 | + ] ); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function buildResponse() |
| 101 | 101 | { |
| 102 | - $classes = !empty( $this->errors ) |
|
| 102 | + $classes = !empty($this->errors) |
|
| 103 | 103 | ? glsr( StyleValidationDefaults::class )->defaults()['message_error_class'] |
| 104 | 104 | : ''; |
| 105 | 105 | return glsr( Template::class )->build( 'templates/form/response', [ |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | 'class' => $classes, |
| 108 | 108 | 'message' => wpautop( $this->message ), |
| 109 | 109 | ], |
| 110 | - 'has_errors' => !empty( $this->errors ), |
|
| 111 | - ]); |
|
| 110 | + 'has_errors' => !empty($this->errors), |
|
| 111 | + ] ); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | 'context' => [ |
| 121 | 121 | 'text' => __( 'Submit your review', 'site-reviews' ), |
| 122 | 122 | ], |
| 123 | - ]); |
|
| 123 | + ] ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | $hiddenFields = $this->getHiddenFields(); |
| 140 | 140 | $hiddenFields[] = $this->getHoneypotField(); |
| 141 | - $fields = $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' )); |
|
| 141 | + $fields = $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' ) ); |
|
| 142 | 142 | $paths = array_map( function( $obj ) { |
| 143 | 143 | return $obj->field['path']; |
| 144 | 144 | }, $hiddenFields ); |
| 145 | 145 | foreach( $fields as $field ) { |
| 146 | 146 | $index = array_search( $field->field['path'], $paths ); |
| 147 | 147 | if( $index === false )continue; |
| 148 | - unset( $hiddenFields[$index] ); |
|
| 148 | + unset($hiddenFields[$index]); |
|
| 149 | 149 | } |
| 150 | 150 | return array_merge( $hiddenFields, $fields ); |
| 151 | 151 | } |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | protected function getLoginText() |
| 157 | 157 | { |
| 158 | - $loginLink = glsr( Builder::class )->a([ |
|
| 159 | - 'href' => wp_login_url( strval( get_permalink() )), |
|
| 158 | + $loginLink = glsr( Builder::class )->a( [ |
|
| 159 | + 'href' => wp_login_url( strval( get_permalink() ) ), |
|
| 160 | 160 | 'text' => __( 'logged in', 'site-reviews' ), |
| 161 | - ]); |
|
| 161 | + ] ); |
|
| 162 | 162 | return sprintf( __( 'You must be %s to submit a review.', 'site-reviews' ), $loginLink ); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | protected function getRegisterText() |
| 169 | 169 | { |
| 170 | 170 | if( !get_option( 'users_can_register' ) || glsr( OptionManager::class )->get( 'settings.general.require.login' ) != 'yes' )return; |
| 171 | - $registerLink = glsr( Builder::class )->a([ |
|
| 171 | + $registerLink = glsr( Builder::class )->a( [ |
|
| 172 | 172 | 'href' => wp_registration_url(), |
| 173 | 173 | 'text' => __( 'register', 'site-reviews' ), |
| 174 | - ]); |
|
| 174 | + ] ); |
|
| 175 | 175 | return sprintf( __( 'You may also %s for an account.', 'site-reviews' ), $registerLink ); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -183,32 +183,32 @@ discard block |
||
| 183 | 183 | $fields = [[ |
| 184 | 184 | 'name' => '_action', |
| 185 | 185 | 'value' => 'submit-review', |
| 186 | - ],[ |
|
| 186 | + ], [ |
|
| 187 | 187 | 'name' => '_counter', |
| 188 | - ],[ |
|
| 188 | + ], [ |
|
| 189 | 189 | 'name' => '_nonce', |
| 190 | 190 | 'value' => wp_create_nonce( 'submit-review' ), |
| 191 | - ],[ |
|
| 191 | + ], [ |
|
| 192 | 192 | 'name' => '_post_id', |
| 193 | 193 | 'value' => get_the_ID(), |
| 194 | - ],[ |
|
| 194 | + ], [ |
|
| 195 | 195 | 'name' => '_referer', |
| 196 | - 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' )), |
|
| 197 | - ],[ |
|
| 196 | + 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' ) ), |
|
| 197 | + ], [ |
|
| 198 | 198 | 'name' => 'assign_to', |
| 199 | 199 | 'value' => $this->args['assign_to'], |
| 200 | - ],[ |
|
| 200 | + ], [ |
|
| 201 | 201 | 'name' => 'category', |
| 202 | 202 | 'value' => $this->args['category'], |
| 203 | - ],[ |
|
| 203 | + ], [ |
|
| 204 | 204 | 'name' => 'excluded', |
| 205 | 205 | 'value' => $this->args['hide'], |
| 206 | - ],[ |
|
| 206 | + ], [ |
|
| 207 | 207 | 'name' => 'form_id', |
| 208 | 208 | 'value' => $this->args['id'], |
| 209 | 209 | ]]; |
| 210 | 210 | return array_map( function( $field ) { |
| 211 | - return new Field( wp_parse_args( $field, ['type' => 'hidden'] )); |
|
| 211 | + return new Field( wp_parse_args( $field, ['type' => 'hidden'] ) ); |
|
| 212 | 212 | }, $fields ); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | protected function getHoneypotField() |
| 219 | 219 | { |
| 220 | - return new Field([ |
|
| 220 | + return new Field( [ |
|
| 221 | 221 | 'name' => 'gotcha', |
| 222 | 222 | 'type' => 'honeypot', |
| 223 | - ]); |
|
| 223 | + ] ); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | protected function normalizeFieldId( Field &$field ) |
| 230 | 230 | { |
| 231 | - if( empty( $this->args['id'] ) || empty( $field->field['id'] ))return; |
|
| 232 | - $field->field['id'].= '-'.$this->args['id']; |
|
| 231 | + if( empty($this->args['id']) || empty($field->field['id']) )return; |
|
| 232 | + $field->field['id'] .= '-'.$this->args['id']; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | protected function normalizeFieldClass( Field &$field ) |
| 239 | 239 | { |
| 240 | - if( !isset( $field->field['class'] )) { |
|
| 240 | + if( !isset($field->field['class']) ) { |
|
| 241 | 241 | $field->field['class'] = ''; |
| 242 | 242 | } |
| 243 | 243 | $field->field['class'] = trim( $field->field['class'].' glsr-field-control' ); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | protected function normalizeFieldErrors( Field &$field ) |
| 250 | 250 | { |
| 251 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
| 251 | + if( !array_key_exists( $field->field['path'], $this->errors ) )return; |
|
| 252 | 252 | $field->field['errors'] = $this->errors[$field->field['path']]; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | protected function normalizeFieldRequired( Field &$field ) |
| 259 | 259 | { |
| 260 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
| 260 | + if( !in_array( $field->field['path'], $this->required ) )return; |
|
| 261 | 261 | $field->field['required'] = true; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | { |
| 269 | 269 | $normalizedFields = []; |
| 270 | 270 | foreach( $fields as $field ) { |
| 271 | - if( in_array( $field->field['path'], $this->args['hide'] ))continue; |
|
| 271 | + if( in_array( $field->field['path'], $this->args['hide'] ) )continue; |
|
| 272 | 272 | $field->field['is_public'] = true; |
| 273 | 273 | $this->normalizeFieldClass( $field ); |
| 274 | 274 | $this->normalizeFieldErrors( $field ); |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | */ |
| 286 | 286 | protected function normalizeFieldValue( Field &$field ) |
| 287 | 287 | { |
| 288 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
| 289 | - if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
|
| 288 | + if( !array_key_exists( $field->field['path'], $this->values ) )return; |
|
| 289 | + if( in_array( $field->field['type'], ['radio', 'checkbox'] ) ) { |
|
| 290 | 290 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
| 291 | 291 | } |
| 292 | 292 | else { |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | public function routeAdminPostRequest() |
| 18 | 18 | { |
| 19 | 19 | $request = $this->getRequest(); |
| 20 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 20 | + if( !$this->isValidPostRequest( $request ) )return; |
|
| 21 | 21 | check_admin_referer( $request['_action'] ); |
| 22 | 22 | $this->routeRequest( 'admin', $request['_action'], $request ); |
| 23 | 23 | } |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | if( is_admin() )return; |
| 43 | 43 | $request = $this->getRequest(); |
| 44 | - if( !$this->isValidPostRequest( $request ))return; |
|
| 45 | - if( !$this->isValidPublicNonce( $request ))return; |
|
| 44 | + if( !$this->isValidPostRequest( $request ) )return; |
|
| 45 | + if( !$this->isValidPublicNonce( $request ) )return; |
|
| 46 | 46 | $this->routeRequest( 'public', $request['_action'], $request ); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | protected function checkAjaxNonce( array $request ) |
| 53 | 53 | { |
| 54 | 54 | if( !is_user_logged_in() )return; |
| 55 | - if( !isset( $request['_nonce'] )) { |
|
| 55 | + if( !isset($request['_nonce']) ) { |
|
| 56 | 56 | $this->sendAjaxError( 'request is missing a nonce', $request ); |
| 57 | 57 | } |
| 58 | - if( !wp_verify_nonce( $request['_nonce'], $request['_action'] )) { |
|
| 58 | + if( !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) { |
|
| 59 | 59 | $this->sendAjaxError( 'request failed the nonce check', $request, 403 ); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | protected function checkAjaxRequest( array $request ) |
| 67 | 67 | { |
| 68 | - if( !isset( $request['_action'] )) { |
|
| 68 | + if( !isset($request['_action']) ) { |
|
| 69 | 69 | $this->sendAjaxError( 'request must include an action', $request ); |
| 70 | 70 | } |
| 71 | - if( empty( $request['_ajax_request'] )) { |
|
| 71 | + if( empty($request['_ajax_request']) ) { |
|
| 72 | 72 | $this->sendAjaxError( 'request is invalid', $request ); |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | protected function isValidPostRequest( array $request = [] ) |
| 97 | 97 | { |
| 98 | - return !empty( $request['_action'] ) && empty( $request['_ajax_request'] ); |
|
| 98 | + return !empty($request['_action']) && empty($request['_ajax_request']); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | protected function isValidPublicNonce( array $request ) |
| 105 | 105 | { |
| 106 | - if( is_user_logged_in() && !wp_verify_nonce( $request['_nonce'], $request['_action'] )) { |
|
| 106 | + if( is_user_logged_in() && !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) { |
|
| 107 | 107 | glsr_log()->error( 'nonce check failed for public request' )->debug( $request ); |
| 108 | 108 | return false; |
| 109 | 109 | } |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | protected function routeRequest( $type, $action, array $request = [] ) |
| 119 | 119 | { |
| 120 | 120 | $actionHook = 'site-reviews/route/'.$type.'/request'; |
| 121 | - $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' )); |
|
| 121 | + $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) ); |
|
| 122 | 122 | $method = glsr( Helper::class )->buildMethodName( $action, 'router' ); |
| 123 | 123 | $request = apply_filters( 'site-reviews/route/request', $request, $action, $type ); |
| 124 | 124 | do_action( $actionHook, $action, $request ); |
| 125 | - if( is_callable( [$controller, $method] )) { |
|
| 125 | + if( is_callable( [$controller, $method] ) ) { |
|
| 126 | 126 | call_user_func( [$controller, $method], $request ); |
| 127 | 127 | return; |
| 128 | 128 | } |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | glsr_log()->error( $error )->debug( $request ); |
| 142 | 142 | glsr( Notice::class )->addError( __( 'There was an error (try refreshing the page).', 'site-reviews' ).' <code>'.$error.'</code>' ); |
| 143 | - wp_send_json_error([ |
|
| 143 | + wp_send_json_error( [ |
|
| 144 | 144 | 'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ), |
| 145 | 145 | 'notices' => glsr( Notice::class )->get(), |
| 146 | 146 | 'error' => $error, |
| 147 | - ]); |
|
| 147 | + ] ); |
|
| 148 | 148 | } |
| 149 | 149 | } |