@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | $filenames = []; |
| 21 | 21 | $iterator = new DirectoryIterator( dirname( __FILE__ ).'/Upgrader' ); |
| 22 | 22 | foreach( $iterator as $fileinfo ) { |
| 23 | - if( !$fileinfo->isFile() )continue; |
|
| 23 | + if( !$fileinfo->isFile() ) { |
|
| 24 | + continue; |
|
| 25 | + } |
|
| 24 | 26 | $filenames[] = $fileinfo->getFilename(); |
| 25 | 27 | } |
| 26 | 28 | natsort( $filenames ); |
@@ -28,7 +30,9 @@ discard block |
||
| 28 | 30 | $className = str_replace( '.php', '', $file ); |
| 29 | 31 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
| 30 | 32 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
| 31 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
| 33 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' )) { |
|
| 34 | + return; |
|
| 35 | + } |
|
| 32 | 36 | glsr( 'Modules\\Upgrader\\'.$className ); |
| 33 | 37 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
| 34 | 38 | }); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $className = str_replace( '.php', '', $file ); |
| 25 | 25 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
| 26 | 26 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
| 27 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
| 27 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ) )return; |
|
| 28 | 28 | glsr( 'Modules\\Upgrader\\'.$className ); |
| 29 | 29 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
| 30 | 30 | }); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $this->setReviewCounts(); |
| 42 | 42 | $this->updateVersionFrom( $version ); |
| 43 | 43 | } |
| 44 | - else if( !glsr( OptionManager::class )->get( 'last_review_count', false )) { |
|
| 44 | + else if( !glsr( OptionManager::class )->get( 'last_review_count', false ) ) { |
|
| 45 | 45 | $this->setReviewCounts(); |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | protected function filterAttributes( array $allowedAttributeKeys ) |
| 124 | 124 | { |
| 125 | - return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys )); |
|
| 125 | + return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys ) ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $globalAttributes = $this->filterAttributes( static::GLOBAL_ATTRIBUTES ); |
| 134 | 134 | $wildcards = []; |
| 135 | 135 | foreach( static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard ) { |
| 136 | - $newWildcards = array_filter( $this->attributes, function( $key ) use( $wildcard ) { |
|
| 136 | + $newWildcards = array_filter( $this->attributes, function( $key ) use($wildcard) { |
|
| 137 | 137 | return glsr( Helper::class )->startsWith( $wildcard, $key ); |
| 138 | 138 | }, ARRAY_FILTER_USE_KEY ); |
| 139 | 139 | $wildcards = array_merge( $wildcards, $newWildcards ); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | protected function getPermanentAttributes() |
| 148 | 148 | { |
| 149 | 149 | $permanentAttributes = []; |
| 150 | - if( array_key_exists( 'value', $this->attributes )) { |
|
| 150 | + if( array_key_exists( 'value', $this->attributes ) ) { |
|
| 151 | 151 | $permanentAttributes['value'] = $this->attributes['value']; |
| 152 | 152 | } |
| 153 | 153 | return $permanentAttributes; |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | protected function normalizeBooleanAttributes() |
| 200 | 200 | { |
| 201 | 201 | foreach( $this->attributes as $key => $value ) { |
| 202 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
| 202 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
| 203 | 203 | $key = $value; |
| 204 | 204 | $value = true; |
| 205 | 205 | } |
| 206 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
| 206 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ) )continue; |
|
| 207 | 207 | $this->attributes[$key] = wp_validate_boolean( $value ); |
| 208 | 208 | } |
| 209 | 209 | } |
@@ -214,13 +214,13 @@ discard block |
||
| 214 | 214 | protected function normalizeDataAttributes() |
| 215 | 215 | { |
| 216 | 216 | foreach( $this->attributes as $key => $value ) { |
| 217 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
| 217 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
| 218 | 218 | $key = $value; |
| 219 | 219 | $value = ''; |
| 220 | 220 | } |
| 221 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
| 222 | - if( is_array( $value )) { |
|
| 223 | - $value = json_encode( $value, JSON_HEX_APOS|JSON_NUMERIC_CHECK|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ); |
|
| 221 | + if( !glsr( Helper::class )->startsWith( 'data-', $key ) )continue; |
|
| 222 | + if( is_array( $value ) ) { |
|
| 223 | + $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); |
|
| 224 | 224 | } |
| 225 | 225 | $this->attributes[$key] = $value; |
| 226 | 226 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | protected function normalizeStringAttributes() |
| 233 | 233 | { |
| 234 | 234 | foreach( $this->attributes as $key => $value ) { |
| 235 | - if( !is_string( $value ))continue; |
|
| 235 | + if( !is_string( $value ) )continue; |
|
| 236 | 236 | $this->attributes[$key] = trim( $value ); |
| 237 | 237 | } |
| 238 | 238 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | if( $method != 'input' )return; |
| 247 | 247 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
| 248 | - if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
|
| 248 | + if( !in_array( $attributes['type'], static::INPUT_TYPES ) ) { |
|
| 249 | 249 | $this->attributes['type'] = 'text'; |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | $permanentAttributes = $this->getPermanentAttributes(); |
| 260 | 260 | foreach( $this->attributes as $key => $value ) { |
| 261 | 261 | if( in_array( $key, static::BOOLEAN_ATTRIBUTES ) && !$value ) { |
| 262 | - unset( $attributes[$key] ); |
|
| 262 | + unset($attributes[$key]); |
|
| 263 | 263 | } |
| 264 | - if( glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
| 264 | + if( glsr( Helper::class )->startsWith( 'data-', $key ) ) { |
|
| 265 | 265 | $permanentAttributes[$key] = $value; |
| 266 | - unset( $attributes[$key] ); |
|
| 266 | + unset($attributes[$key]); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | $this->attributes = array_merge( array_filter( $attributes ), $permanentAttributes ); |
@@ -203,7 +203,9 @@ discard block |
||
| 203 | 203 | $key = $value; |
| 204 | 204 | $value = true; |
| 205 | 205 | } |
| 206 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
| 206 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES )) { |
|
| 207 | + continue; |
|
| 208 | + } |
|
| 207 | 209 | $this->attributes[$key] = wp_validate_boolean( $value ); |
| 208 | 210 | } |
| 209 | 211 | } |
@@ -218,7 +220,9 @@ discard block |
||
| 218 | 220 | $key = $value; |
| 219 | 221 | $value = ''; |
| 220 | 222 | } |
| 221 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
| 223 | + if( !glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
| 224 | + continue; |
|
| 225 | + } |
|
| 222 | 226 | if( is_array( $value )) { |
| 223 | 227 | $value = json_encode( $value, JSON_HEX_APOS|JSON_NUMERIC_CHECK|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ); |
| 224 | 228 | } |
@@ -232,7 +236,9 @@ discard block |
||
| 232 | 236 | protected function normalizeStringAttributes() |
| 233 | 237 | { |
| 234 | 238 | foreach( $this->attributes as $key => $value ) { |
| 235 | - if( !is_string( $value ))continue; |
|
| 239 | + if( !is_string( $value )) { |
|
| 240 | + continue; |
|
| 241 | + } |
|
| 236 | 242 | $this->attributes[$key] = trim( $value ); |
| 237 | 243 | } |
| 238 | 244 | } |
@@ -243,7 +249,9 @@ discard block |
||
| 243 | 249 | */ |
| 244 | 250 | protected function normalizeInputType( $method ) |
| 245 | 251 | { |
| 246 | - if( $method != 'input' )return; |
|
| 252 | + if( $method != 'input' ) { |
|
| 253 | + return; |
|
| 254 | + } |
|
| 247 | 255 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
| 248 | 256 | if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
| 249 | 257 | $this->attributes['type'] = 'text'; |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $this->newSettings = $this->getNewSettings(); |
| 76 | 76 | $this->oldSettings = $this->getOldSettings(); |
| 77 | - if( empty( $this->oldSettings ))return; |
|
| 77 | + if( empty($this->oldSettings) )return; |
|
| 78 | 78 | foreach( static::MAPPED_SETTINGS as $old => $new ) { |
| 79 | - if( empty( $this->oldSettings[$old] ))continue; |
|
| 79 | + if( empty($this->oldSettings[$old]) )continue; |
|
| 80 | 80 | $this->newSettings[$new] = $this->oldSettings[$old]; |
| 81 | 81 | } |
| 82 | 82 | $this->migrateNotificationSettings(); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $this->migrateRequiredSettings(); |
| 85 | 85 | $oldSettings = glsr( Helper::class )->convertDotNotationArray( $this->oldSettings ); |
| 86 | 86 | $newSettings = glsr( Helper::class )->convertDotNotationArray( $this->newSettings ); |
| 87 | - if( isset( $oldSettings['settings']['strings'] ) && is_array( $oldSettings['settings']['strings'] )) { |
|
| 87 | + if( isset($oldSettings['settings']['strings']) && is_array( $oldSettings['settings']['strings'] ) ) { |
|
| 88 | 88 | $newSettings['settings']['strings'] = $oldSettings['settings']['strings']; |
| 89 | 89 | } |
| 90 | 90 | glsr( OptionManager::class )->set( $newSettings ); |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | protected function getOldSettings() |
| 118 | 118 | { |
| 119 | 119 | $defaults = array_fill_keys( array_keys( static::MAPPED_SETTINGS ), '' ); |
| 120 | - $settings = glsr( Helper::class )->flattenArray( get_option( 'geminilabs_site_reviews-v2', [] )); |
|
| 121 | - if( !empty( $settings )) { |
|
| 120 | + $settings = glsr( Helper::class )->flattenArray( get_option( 'geminilabs_site_reviews-v2', [] ) ); |
|
| 121 | + if( !empty($settings) ) { |
|
| 122 | 122 | $settings = wp_parse_args( $settings, $defaults ); |
| 123 | 123 | } |
| 124 | 124 | return $settings; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
| 152 | 152 | 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
| 153 | 153 | ]; |
| 154 | - if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] )) { |
|
| 154 | + if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] ) ) { |
|
| 155 | 155 | $this->newSettings['settings.submissions.recaptcha.integration'] = 'all'; |
| 156 | 156 | } |
| 157 | 157 | if( $this->oldSettings['settings.reviews-form.recaptcha.integration'] == 'invisible-recaptcha' ) { |
@@ -74,9 +74,13 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $this->newSettings = $this->getNewSettings(); |
| 76 | 76 | $this->oldSettings = $this->getOldSettings(); |
| 77 | - if( empty( $this->oldSettings ))return; |
|
| 77 | + if( empty( $this->oldSettings )) { |
|
| 78 | + return; |
|
| 79 | + } |
|
| 78 | 80 | foreach( static::MAPPED_SETTINGS as $old => $new ) { |
| 79 | - if( empty( $this->oldSettings[$old] ))continue; |
|
| 81 | + if( empty( $this->oldSettings[$old] )) { |
|
| 82 | + continue; |
|
| 83 | + } |
|
| 80 | 84 | $this->newSettings[$new] = $this->oldSettings[$old]; |
| 81 | 85 | } |
| 82 | 86 | $this->migrateNotificationSettings(); |
@@ -136,7 +140,9 @@ discard block |
||
| 136 | 140 | ]; |
| 137 | 141 | $this->newSettings['settings.general.notifications'] = []; |
| 138 | 142 | foreach( $notifications as $old => $new ) { |
| 139 | - if( $this->oldSettings['settings.general.notification'] != $old )continue; |
|
| 143 | + if( $this->oldSettings['settings.general.notification'] != $old ) { |
|
| 144 | + continue; |
|
| 145 | + } |
|
| 140 | 146 | $this->newSettings['settings.general.notifications'][] = $new; |
| 141 | 147 | } |
| 142 | 148 | } |
@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | public function fields() |
| 14 | 14 | { |
| 15 | 15 | return [[ |
| 16 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
| 16 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
| 17 | 17 | 'minWidth' => 320, |
| 18 | 18 | 'type' => 'container', |
| 19 | - ],[ |
|
| 19 | + ], [ |
|
| 20 | 20 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 21 | 21 | 'name' => 'title', |
| 22 | 22 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
| 23 | 23 | 'type' => 'textbox', |
| 24 | - ],[ |
|
| 24 | + ], [ |
|
| 25 | 25 | 'label' => esc_html__( 'Count', 'site-reviews' ), |
| 26 | 26 | 'maxLength' => 5, |
| 27 | 27 | 'name' => 'count', |
@@ -29,20 +29,20 @@ discard block |
||
| 29 | 29 | 'text' => '10', |
| 30 | 30 | 'tooltip' => __( 'How many reviews would you like to display (default: 10)?', 'site-reviews' ), |
| 31 | 31 | 'type' => 'textbox', |
| 32 | - ],[ |
|
| 32 | + ], [ |
|
| 33 | 33 | 'label' => esc_html__( 'Rating', 'site-reviews' ), |
| 34 | 34 | 'name' => 'rating', |
| 35 | 35 | 'options' => [ |
| 36 | - '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 )), |
|
| 37 | - '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 )), |
|
| 38 | - '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 )), |
|
| 39 | - '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 )), |
|
| 40 | - '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 )), |
|
| 41 | - '0' => esc_html( __( 'Unrated', 'site-reviews' )), |
|
| 36 | + '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ) ), |
|
| 37 | + '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ) ), |
|
| 38 | + '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ) ), |
|
| 39 | + '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ) ), |
|
| 40 | + '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ) ), |
|
| 41 | + '0' => esc_html( __( 'Unrated', 'site-reviews' ) ), |
|
| 42 | 42 | ], |
| 43 | 43 | 'tooltip' => __( 'What is the minimum rating to display (default: 1 star)?', 'site-reviews' ), |
| 44 | 44 | 'type' => 'listbox', |
| 45 | - ],[ |
|
| 45 | + ], [ |
|
| 46 | 46 | 'label' => esc_html__( 'Pagination', 'site-reviews' ), |
| 47 | 47 | 'name' => 'pagination', |
| 48 | 48 | 'options' => [ |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | 'name' => 'assigned_to', |
| 61 | 61 | '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' ), |
| 62 | 62 | 'type' => 'textbox', |
| 63 | - ],[ |
|
| 63 | + ], [ |
|
| 64 | 64 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
| 65 | 65 | 'name' => 'schema', |
| 66 | 66 | 'options' => [ |
@@ -69,49 +69,49 @@ discard block |
||
| 69 | 69 | ], |
| 70 | 70 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
| 71 | 71 | 'type' => 'listbox', |
| 72 | - ],[ |
|
| 72 | + ], [ |
|
| 73 | 73 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 74 | 74 | 'name' => 'class', |
| 75 | 75 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 76 | 76 | 'type' => 'textbox', |
| 77 | - ],[ |
|
| 77 | + ], [ |
|
| 78 | 78 | 'columns' => 2, |
| 79 | 79 | 'items' => [[ |
| 80 | 80 | 'name' => 'hide_assigned_to', |
| 81 | 81 | 'text' => esc_html__( 'Assigned To', 'site-reviews' ), |
| 82 | 82 | 'tooltip' => __( 'Hide the assigned to link?', 'site-reviews' ), |
| 83 | 83 | 'type' => 'checkbox', |
| 84 | - ],[ |
|
| 84 | + ], [ |
|
| 85 | 85 | 'name' => 'hide_author', |
| 86 | 86 | 'text' => esc_html__( 'Author', 'site-reviews' ), |
| 87 | 87 | 'tooltip' => __( 'Hide the review author?', 'site-reviews' ), |
| 88 | 88 | 'type' => 'checkbox', |
| 89 | - ],[ |
|
| 89 | + ], [ |
|
| 90 | 90 | 'name' => 'hide_avatar', |
| 91 | 91 | 'text' => esc_html__( 'Avatar', 'site-reviews' ), |
| 92 | 92 | 'tooltip' => __( 'Hide the reviewer avatar if shown?', 'site-reviews' ), |
| 93 | 93 | 'type' => 'checkbox', |
| 94 | - ],[ |
|
| 94 | + ], [ |
|
| 95 | 95 | 'name' => 'hide_content', |
| 96 | 96 | 'text' => esc_html__( 'Content', 'site-reviews' ), |
| 97 | 97 | 'tooltip' => __( 'Hide the review content?', 'site-reviews' ), |
| 98 | 98 | 'type' => 'checkbox', |
| 99 | - ],[ |
|
| 99 | + ], [ |
|
| 100 | 100 | 'name' => 'hide_date', |
| 101 | 101 | 'text' => esc_html__( 'Date', 'site-reviews' ), |
| 102 | 102 | 'tooltip' => __( 'Hide the review date?', 'site-reviews' ), |
| 103 | 103 | 'type' => 'checkbox', |
| 104 | - ],[ |
|
| 104 | + ], [ |
|
| 105 | 105 | 'name' => 'hide_rating', |
| 106 | 106 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
| 107 | 107 | 'tooltip' => __( 'Hide the review rating?', 'site-reviews' ), |
| 108 | 108 | 'type' => 'checkbox', |
| 109 | - ],[ |
|
| 109 | + ], [ |
|
| 110 | 110 | 'name' => 'hide_response', |
| 111 | 111 | 'text' => esc_html__( 'Response', 'site-reviews' ), |
| 112 | 112 | 'tooltip' => __( 'Hide the review response?', 'site-reviews' ), |
| 113 | 113 | 'type' => 'checkbox', |
| 114 | - ],[ |
|
| 114 | + ], [ |
|
| 115 | 115 | 'name' => 'hide_title', |
| 116 | 116 | 'text' => esc_html__( 'Title', 'site-reviews' ), |
| 117 | 117 | 'tooltip' => __( 'Hide the review title?', 'site-reviews' ), |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
| 122 | 122 | 'spacing' => 5, |
| 123 | 123 | 'type' => 'container', |
| 124 | - ],[ |
|
| 124 | + ], [ |
|
| 125 | 125 | 'hidden' => true, |
| 126 | 126 | 'name' => 'id', |
| 127 | 127 | 'type' => 'textbox', |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | public function getTerms() |
| 135 | 135 | { |
| 136 | 136 | $terms = glsr( Database::class )->getTerms(); |
| 137 | - if( empty( $terms )) { |
|
| 137 | + if( empty($terms) ) { |
|
| 138 | 138 | return []; |
| 139 | 139 | } |
| 140 | 140 | return [ |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | return [[ |
| 16 | 16 | 'type' => 'container', |
| 17 | 17 | 'html' => '<p class="strong">'.esc_html__( 'All settings are optional.', 'site-reviews' ).'</p>', |
| 18 | - ],[ |
|
| 18 | + ], [ |
|
| 19 | 19 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 20 | 20 | 'name' => 'title', |
| 21 | 21 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
| 22 | 22 | 'type' => 'textbox', |
| 23 | - ],[ |
|
| 23 | + ], [ |
|
| 24 | 24 | 'label' => esc_html__( 'Description', 'site-reviews' ), |
| 25 | 25 | 'minHeight' => 60, |
| 26 | 26 | 'minWidth' => 240, |
@@ -35,39 +35,39 @@ discard block |
||
| 35 | 35 | 'name' => 'assign_to', |
| 36 | 36 | 'tooltip' => __( 'Assign submitted reviews to a custom page/post ID. You can also enter "post_id" to assign reviews to the ID of the current page.', 'site-reviews' ), |
| 37 | 37 | 'type' => 'textbox', |
| 38 | - ],[ |
|
| 38 | + ], [ |
|
| 39 | 39 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 40 | 40 | 'name' => 'class', |
| 41 | 41 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 42 | 42 | 'type' => 'textbox', |
| 43 | - ],[ |
|
| 43 | + ], [ |
|
| 44 | 44 | 'columns' => 2, |
| 45 | 45 | 'items' => [[ |
| 46 | 46 | 'name' => 'hide_content', |
| 47 | 47 | 'text' => esc_html__( 'Content', 'site-reviews' ), |
| 48 | 48 | 'tooltip' => __( 'Hide the content field?', 'site-reviews' ), |
| 49 | 49 | 'type' => 'checkbox', |
| 50 | - ],[ |
|
| 50 | + ], [ |
|
| 51 | 51 | 'name' => 'hide_email', |
| 52 | 52 | 'text' => esc_html__( 'Email', 'site-reviews' ), |
| 53 | 53 | 'tooltip' => __( 'Hide the email field?', 'site-reviews' ), |
| 54 | 54 | 'type' => 'checkbox', |
| 55 | - ],[ |
|
| 55 | + ], [ |
|
| 56 | 56 | 'name' => 'hide_name', |
| 57 | 57 | 'text' => esc_html__( 'Name', 'site-reviews' ), |
| 58 | 58 | 'tooltip' => __( 'Hide the name field?', 'site-reviews' ), |
| 59 | 59 | 'type' => 'checkbox', |
| 60 | - ],[ |
|
| 60 | + ], [ |
|
| 61 | 61 | 'name' => 'hide_rating', |
| 62 | 62 | 'text' => esc_html__( 'Rating', 'site-reviews' ), |
| 63 | 63 | 'tooltip' => __( 'Hide the rating field?', 'site-reviews' ), |
| 64 | 64 | 'type' => 'checkbox', |
| 65 | - ],[ |
|
| 65 | + ], [ |
|
| 66 | 66 | 'name' => 'hide_terms', |
| 67 | 67 | 'text' => esc_html__( 'Terms', 'site-reviews' ), |
| 68 | 68 | 'tooltip' => __( 'Hide the terms field?', 'site-reviews' ), |
| 69 | 69 | 'type' => 'checkbox', |
| 70 | - ],[ |
|
| 70 | + ], [ |
|
| 71 | 71 | 'name' => 'hide_title', |
| 72 | 72 | 'text' => esc_html__( 'Title', 'site-reviews' ), |
| 73 | 73 | 'tooltip' => __( 'Hide the title field?', 'site-reviews' ), |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'layout' => 'grid', |
| 78 | 78 | 'spacing' => 5, |
| 79 | 79 | 'type' => 'container', |
| 80 | - ],[ |
|
| 80 | + ], [ |
|
| 81 | 81 | 'hidden' => true, |
| 82 | 82 | 'name' => 'id', |
| 83 | 83 | 'type' => 'textbox', |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | public function getTerms() |
| 91 | 91 | { |
| 92 | 92 | $terms = glsr( Database::class )->getTerms(); |
| 93 | - if( empty( $terms )) { |
|
| 93 | + if( empty($terms) ) { |
|
| 94 | 94 | return []; |
| 95 | 95 | } |
| 96 | 96 | return [ |
@@ -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' ), |
@@ -175,8 +175,12 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | protected function validateAkismet() |
| 177 | 177 | { |
| 178 | - if( !empty( $this->error ))return; |
|
| 179 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
| 178 | + if( !empty( $this->error )) { |
|
| 179 | + return; |
|
| 180 | + } |
|
| 181 | + if( !glsr( Akismet::class )->isSpam( $this->request )) { |
|
| 182 | + return; |
|
| 183 | + } |
|
| 180 | 184 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
| 181 | 185 | $this->error = __( 'Your review cannot be submitted at this time. Please try again later.', 'site-reviews' ); |
| 182 | 186 | } |
@@ -186,8 +190,12 @@ discard block |
||
| 186 | 190 | */ |
| 187 | 191 | protected function validateBlacklist() |
| 188 | 192 | { |
| 189 | - if( !empty( $this->error ))return; |
|
| 190 | - if( !glsr( Blacklist::class )->isBlacklisted( $this->request ))return; |
|
| 193 | + if( !empty( $this->error )) { |
|
| 194 | + return; |
|
| 195 | + } |
|
| 196 | + if( !glsr( Blacklist::class )->isBlacklisted( $this->request )) { |
|
| 197 | + return; |
|
| 198 | + } |
|
| 191 | 199 | $blacklistAction = $this->getOption( 'settings.submissions.blacklist.action' ); |
| 192 | 200 | if( $blacklistAction == 'reject' ) { |
| 193 | 201 | $this->setSessionValues( 'errors', [], 'Blacklisted submission detected:' ); |
@@ -202,9 +210,13 @@ discard block |
||
| 202 | 210 | */ |
| 203 | 211 | protected function validateCustom() |
| 204 | 212 | { |
| 205 | - if( !empty( $this->error ))return; |
|
| 213 | + if( !empty( $this->error )) { |
|
| 214 | + return; |
|
| 215 | + } |
|
| 206 | 216 | $validated = apply_filters( 'site-reviews/validate/custom', true, $this->request ); |
| 207 | - if( $validated === true )return; |
|
| 217 | + if( $validated === true ) { |
|
| 218 | + return; |
|
| 219 | + } |
|
| 208 | 220 | $this->setSessionValues( 'errors', [] ); |
| 209 | 221 | $this->setSessionValues( 'values', $this->request ); |
| 210 | 222 | $this->error = is_string( $validated ) |
@@ -217,8 +229,12 @@ discard block |
||
| 217 | 229 | */ |
| 218 | 230 | protected function validateHoneyPot() |
| 219 | 231 | { |
| 220 | - if( !empty( $this->error ))return; |
|
| 221 | - if( empty( $this->request['gotcha'] ))return; |
|
| 232 | + if( !empty( $this->error )) { |
|
| 233 | + return; |
|
| 234 | + } |
|
| 235 | + if( empty( $this->request['gotcha'] )) { |
|
| 236 | + return; |
|
| 237 | + } |
|
| 222 | 238 | $this->setSessionValues( 'errors', [], 'The Honeypot caught a bad submission:' ); |
| 223 | 239 | $this->error = __( 'The review submission failed. Please notify the site administrator.', 'site-reviews' ); |
| 224 | 240 | } |
@@ -228,9 +244,13 @@ discard block |
||
| 228 | 244 | */ |
| 229 | 245 | protected function validateRecaptcha() |
| 230 | 246 | { |
| 231 | - if( !empty( $this->error ))return; |
|
| 247 | + if( !empty( $this->error )) { |
|
| 248 | + return; |
|
| 249 | + } |
|
| 232 | 250 | $status = $this->getRecaptchaStatus(); |
| 233 | - if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] ))return; |
|
| 251 | + if( in_array( $status, [static::RECAPTCHA_DISABLED, static::RECAPTCHA_VALID] )) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 234 | 254 | if( $status == static::RECAPTCHA_EMPTY ) { |
| 235 | 255 | $this->setSessionValues( 'recaptcha', 'unset' ); |
| 236 | 256 | $this->recaptchaIsUnset = true; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $this->validateBlacklist(); |
| 68 | 68 | $this->validateAkismet(); |
| 69 | 69 | $this->validateRecaptcha(); |
| 70 | - if( !empty( $this->error )) { |
|
| 70 | + if( !empty($this->error) ) { |
|
| 71 | 71 | $this->setSessionValues( 'message', $this->error ); |
| 72 | 72 | } |
| 73 | 73 | return $this; |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
| 92 | 92 | return static::RECAPTCHA_DISABLED; |
| 93 | 93 | } |
| 94 | - if( empty( $this->request['_recaptcha-token'] )) { |
|
| 95 | - return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 )) |
|
| 94 | + if( empty($this->request['_recaptcha-token']) ) { |
|
| 95 | + return $this->request['_counter'] < intval( apply_filters( 'site-reviews/recaptcha/timeout', 5 ) ) |
|
| 96 | 96 | ? static::RECAPTCHA_EMPTY |
| 97 | 97 | : static::RECAPTCHA_FAILED; |
| 98 | 98 | } |
@@ -104,17 +104,17 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | protected function getRecaptchaTokenStatus() |
| 106 | 106 | { |
| 107 | - $endpoint = add_query_arg([ |
|
| 107 | + $endpoint = add_query_arg( [ |
|
| 108 | 108 | 'remoteip' => glsr( Helper::class )->getIpAddress(), |
| 109 | 109 | 'response' => $this->request['_recaptcha-token'], |
| 110 | 110 | 'secret' => $this->getOption( 'settings.submissions.recaptcha.secret' ), |
| 111 | 111 | ], static::RECAPTCHA_ENDPOINT ); |
| 112 | - if( is_wp_error( $response = wp_remote_get( $endpoint ))) { |
|
| 112 | + if( is_wp_error( $response = wp_remote_get( $endpoint ) ) ) { |
|
| 113 | 113 | glsr_log()->error( $response->get_error_message() ); |
| 114 | 114 | return static::RECAPTCHA_FAILED; |
| 115 | 115 | } |
| 116 | - $response = json_decode( wp_remote_retrieve_body( $response )); |
|
| 117 | - if( !empty( $response->success )) { |
|
| 116 | + $response = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 117 | + if( !empty($response->success) ) { |
|
| 118 | 118 | return boolval( $response->success ) |
| 119 | 119 | ? static::RECAPTCHA_VALID |
| 120 | 120 | : static::RECAPTCHA_INVALID; |
@@ -132,12 +132,12 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $rules = array_intersect_key( |
| 134 | 134 | apply_filters( 'site-reviews/validation/rules', static::VALIDATION_RULES, $request ), |
| 135 | - array_flip( $this->getOption( 'settings.submissions.required', [] )) |
|
| 135 | + array_flip( $this->getOption( 'settings.submissions.required', [] ) ) |
|
| 136 | 136 | ); |
| 137 | - $excluded = isset( $request['excluded'] ) |
|
| 137 | + $excluded = isset($request['excluded']) |
|
| 138 | 138 | ? explode( ',', $request['excluded'] ) |
| 139 | 139 | : []; |
| 140 | - return array_diff_key( $rules, array_flip( $excluded )); |
|
| 140 | + return array_diff_key( $rules, array_flip( $excluded ) ); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | $rules = $this->getValidationRules( $request ); |
| 149 | 149 | $errors = glsr( Validator::class )->validate( $request, $rules ); |
| 150 | - if( empty( $errors )) { |
|
| 150 | + if( empty($errors) ) { |
|
| 151 | 151 | return true; |
| 152 | 152 | } |
| 153 | 153 | $this->setSessionValues( 'errors', $errors ); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | protected function setSessionValues( $type, $value, $loggedMessage = '' ) |
| 165 | 165 | { |
| 166 | 166 | glsr( Session::class )->set( $this->form_id.$type, $value ); |
| 167 | - if( !empty( $loggedMessage )) { |
|
| 167 | + if( !empty($loggedMessage) ) { |
|
| 168 | 168 | glsr_log()->warning( $loggedMessage ); |
| 169 | 169 | glsr_log()->warning( $this->request ); |
| 170 | 170 | } |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | protected function validateAkismet() |
| 177 | 177 | { |
| 178 | - if( !empty( $this->error ))return; |
|
| 179 | - if( !glsr( Akismet::class )->isSpam( $this->request ))return; |
|
| 178 | + if( !empty($this->error) )return; |
|
| 179 | + if( !glsr( Akismet::class )->isSpam( $this->request ) )return; |
|
| 180 | 180 | $this->setSessionValues( 'errors', [], 'Akismet caught a spam submission:' ); |
| 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 ); |
@@ -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 | } |
@@ -261,7 +261,9 @@ discard block |
||
| 261 | 261 | { |
| 262 | 262 | $result = []; |
| 263 | 263 | foreach( $array as $key => $value ) { |
| 264 | - if( !$value )continue; |
|
| 264 | + if( !$value ) { |
|
| 265 | + continue; |
|
| 266 | + } |
|
| 265 | 267 | $result[$key] = is_array( $value ) |
| 266 | 268 | ? $this->removeEmptyArrayValues( $value ) |
| 267 | 269 | : $value; |
@@ -274,7 +276,8 @@ discard block |
||
| 274 | 276 | * @param string $text |
| 275 | 277 | * @return string |
| 276 | 278 | */ |
| 277 | - public function removePrefix( $prefix, $text ) { |
|
| 279 | + public function removePrefix( $prefix, $text ) |
|
| 280 | + { |
|
| 278 | 281 | return 0 === strpos( $text, $prefix ) |
| 279 | 282 | ? substr( $text, strlen( $prefix )) |
| 280 | 283 | : $text; |
@@ -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]; |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | public function isIndexedArray( $array ) |
| 224 | 224 | { |
| 225 | - if( !is_array( $array )) { |
|
| 225 | + if( !is_array( $array ) ) { |
|
| 226 | 226 | return false; |
| 227 | 227 | } |
| 228 | 228 | $current = 0; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function isIndexedFlatArray( $array ) |
| 243 | 243 | { |
| 244 | - if( !is_array( $array ) || array_filter( $array, 'is_array' )) { |
|
| 244 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
| 245 | 245 | return false; |
| 246 | 246 | } |
| 247 | 247 | return $this->isIndexedArray( $array ); |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | public function prefixString( $string, $prefix = '' ) |
| 256 | 256 | { |
| 257 | - return $prefix.str_replace( $prefix, '', trim( $string )); |
|
| 257 | + return $prefix.str_replace( $prefix, '', trim( $string ) ); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | public function removePrefix( $prefix, $text ) { |
| 281 | 281 | return 0 === strpos( $text, $prefix ) |
| 282 | - ? substr( $text, strlen( $prefix )) |
|
| 282 | + ? substr( $text, strlen( $prefix ) ) |
|
| 283 | 283 | : $text; |
| 284 | 284 | } |
| 285 | 285 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | */ |
| 311 | 311 | public function snakeCase( $string ) |
| 312 | 312 | { |
| 313 | - if( !ctype_lower( $string )) { |
|
| 313 | + if( !ctype_lower( $string ) ) { |
|
| 314 | 314 | $string = preg_replace( '/\s+/u', '', $string ); |
| 315 | 315 | $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
| 316 | 316 | $string = function_exists( 'mb_strtolower' ) |
@@ -327,6 +327,6 @@ discard block |
||
| 327 | 327 | */ |
| 328 | 328 | public function startsWith( $needle, $haystack ) |
| 329 | 329 | { |
| 330 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
| 330 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
| 331 | 331 | } |
| 332 | 332 | } |