@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | 'label' => '['.$tag.']', |
| 49 | 49 | 'required' => $this->required, |
| 50 | 50 | 'title' => esc_html__( 'Shortcode', 'site-reviews' ), |
| 51 | - ]); |
|
| 51 | + ] ); |
|
| 52 | 52 | return $this; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | protected function generateFields( array $fields ) |
| 59 | 59 | { |
| 60 | 60 | $generatedFields = array_map( function( $field ) { |
| 61 | - if( empty( $field ))return; |
|
| 61 | + if( empty($field) )return; |
|
| 62 | 62 | $field = $this->normalize( $field ); |
| 63 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
| 63 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ) ) )return; |
|
| 64 | 64 | return $this->$method( $field ); |
| 65 | 65 | }, $fields ); |
| 66 | - return array_values( array_filter( $generatedFields )); |
|
| 66 | + return array_values( array_filter( $generatedFields ) ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | protected function getCategories( $tooltip = '' ) |
| 74 | 74 | { |
| 75 | 75 | $terms = glsr( Database::class )->getTerms(); |
| 76 | - if( empty( $terms )) { |
|
| 76 | + if( empty($terms) ) { |
|
| 77 | 77 | return []; |
| 78 | 78 | } |
| 79 | 79 | return [ |
@@ -91,15 +91,15 @@ discard block |
||
| 91 | 91 | protected function getFields() |
| 92 | 92 | { |
| 93 | 93 | $fields = $this->generateFields( $this->fields() ); |
| 94 | - if( !empty( $this->errors )) { |
|
| 94 | + if( !empty($this->errors) ) { |
|
| 95 | 95 | $errors = []; |
| 96 | 96 | foreach( $this->required as $name => $alert ) { |
| 97 | - if( false !== array_search( $name, glsr_array_column( $fields, 'name' )))continue; |
|
| 97 | + if( false !== array_search( $name, glsr_array_column( $fields, 'name' ) ) )continue; |
|
| 98 | 98 | $errors[] = $this->errors[$name]; |
| 99 | 99 | } |
| 100 | 100 | $this->errors = $errors; |
| 101 | 101 | } |
| 102 | - return empty( $this->errors ) |
|
| 102 | + return empty($this->errors) |
|
| 103 | 103 | ? $fields |
| 104 | 104 | : $this->errors; |
| 105 | 105 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | protected function getHideOptions() |
| 111 | 111 | { |
| 112 | - $classname = str_replace( 'Popup', 'Shortcode', get_class( $this )); |
|
| 112 | + $classname = str_replace( 'Popup', 'Shortcode', get_class( $this ) ); |
|
| 113 | 113 | $hideOptions = glsr( $classname )->getHideOptions(); |
| 114 | 114 | $options = []; |
| 115 | 115 | foreach( $hideOptions as $name => $tooltip ) { |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | return wp_parse_args( $field, [ |
| 150 | 150 | 'items' => [], |
| 151 | 151 | 'type' => '', |
| 152 | - ]); |
|
| 152 | + ] ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | 'tooltip' => '', |
| 168 | 168 | 'type' => '', |
| 169 | 169 | 'value' => '', |
| 170 | - ]); |
|
| 170 | + ] ); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | protected function normalizeContainer( array $field ) |
| 177 | 177 | { |
| 178 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
| 178 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ) )return; |
|
| 179 | 179 | $field['items'] = $this->generateFields( $field['items'] ); |
| 180 | 180 | return $field; |
| 181 | 181 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | protected function normalizeField( array $field, array $defaults ) |
| 187 | 187 | { |
| 188 | - if( !$this->validate( $field ))return; |
|
| 188 | + if( !$this->validate( $field ) )return; |
|
| 189 | 189 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
| 190 | 190 | return $value !== ''; |
| 191 | 191 | }); |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | 'tooltip' => '', |
| 206 | 206 | 'type' => '', |
| 207 | 207 | 'value' => '', |
| 208 | - ]); |
|
| 209 | - if( !is_array( $listbox ))return; |
|
| 210 | - if( !array_key_exists( '', $listbox['options'] )) { |
|
| 208 | + ] ); |
|
| 209 | + if( !is_array( $listbox ) )return; |
|
| 210 | + if( !array_key_exists( '', $listbox['options'] ) ) { |
|
| 211 | 211 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
| 212 | 212 | } |
| 213 | 213 | foreach( $listbox['options'] as $value => $text ) { |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | protected function normalizePost( array $field ) |
| 226 | 226 | { |
| 227 | - if( !is_array( $field['query_args'] )) { |
|
| 227 | + if( !is_array( $field['query_args'] ) ) { |
|
| 228 | 228 | $field['query_args'] = []; |
| 229 | 229 | } |
| 230 | 230 | $posts = get_posts( wp_parse_args( $field['query_args'], [ |
@@ -232,8 +232,8 @@ discard block |
||
| 232 | 232 | 'orderby' => 'title', |
| 233 | 233 | 'post_type' => 'post', |
| 234 | 234 | 'posts_per_page' => 30, |
| 235 | - ])); |
|
| 236 | - if( !empty( $posts )) { |
|
| 235 | + ] ) ); |
|
| 236 | + if( !empty($posts) ) { |
|
| 237 | 237 | $options = []; |
| 238 | 238 | foreach( $posts as $post ) { |
| 239 | 239 | $options[$post->ID] = esc_html( $post->post_title ); |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | 'tooltip' => '', |
| 264 | 264 | 'type' => '', |
| 265 | 265 | 'value' => '', |
| 266 | - ]); |
|
| 266 | + ] ); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | protected function validate( array $field ) |
| 273 | 273 | { |
| 274 | - $args = shortcode_atts([ |
|
| 274 | + $args = shortcode_atts( [ |
|
| 275 | 275 | 'label' => '', |
| 276 | 276 | 'name' => false, |
| 277 | 277 | 'required' => false, |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | protected function validateErrors( array $args ) |
| 289 | 289 | { |
| 290 | - if( !isset( $args['required']['error'] )) { |
|
| 290 | + if( !isset($args['required']['error']) ) { |
|
| 291 | 291 | return true; |
| 292 | 292 | } |
| 293 | - $this->errors[$args['name']] = $this->normalizeContainer([ |
|
| 293 | + $this->errors[$args['name']] = $this->normalizeContainer( [ |
|
| 294 | 294 | 'html' => $args['required']['error'], |
| 295 | 295 | 'type' => 'container', |
| 296 | - ]); |
|
| 296 | + ] ); |
|
| 297 | 297 | return false; |
| 298 | 298 | } |
| 299 | 299 | |
@@ -306,10 +306,10 @@ discard block |
||
| 306 | 306 | return true; |
| 307 | 307 | } |
| 308 | 308 | $alert = esc_html__( 'Some of the shortcode options are required.', 'site-reviews' ); |
| 309 | - if( isset( $args['required']['alert'] )) { |
|
| 309 | + if( isset($args['required']['alert']) ) { |
|
| 310 | 310 | $alert = $args['required']['alert']; |
| 311 | 311 | } |
| 312 | - else if( !empty( $args['label'] )) { |
|
| 312 | + else if( !empty($args['label']) ) { |
|
| 313 | 313 | $alert = sprintf( |
| 314 | 314 | esc_html_x( 'The "%s" option is required.', 'the option label', 'site-reviews' ), |
| 315 | 315 | str_replace( ':', '', $args['label'] ) |
@@ -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 | } |
@@ -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,14 +79,14 @@ 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 = ['a' => ['class' => [], 'href' => [], 'target' => []]]; |
| 85 | - array_walk( $options['settings']['strings'], function( &$string ) use( $allowedTags ) { |
|
| 86 | - if( isset( $string['s2'] )) { |
|
| 85 | + array_walk( $options['settings']['strings'], function( &$string ) use($allowedTags) { |
|
| 86 | + if( isset($string['s2']) ) { |
|
| 87 | 87 | $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
| 88 | 88 | } |
| 89 | - if( isset( $string['p2'] )) { |
|
| 89 | + if( isset($string['p2']) ) { |
|
| 90 | 90 | $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
| 91 | 91 | } |
| 92 | 92 | }); |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | protected function isPolylangActiveAndSupported() |
| 101 | 101 | { |
| 102 | 102 | if( !glsr( Polylang::class )->isActive() ) { |
| 103 | - glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' )); |
|
| 103 | + glsr( Notice::class )->addError( __( 'Please install/activate the Polylang plugin to enable integration.', 'site-reviews' ) ); |
|
| 104 | 104 | return false; |
| 105 | 105 | } |
| 106 | 106 | else if( !glsr( Polylang::class )->isSupported() ) { |
| 107 | - glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' )); |
|
| 107 | + glsr( Notice::class )->addError( __( 'Please update the Polylang plugin to v2.3.0 or greater to enable integration.', 'site-reviews' ) ); |
|
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | 110 | return true; |