← All changes
|
includes/elementor/modules/optin/widgets/optin.php
+29
-10
1.5.0
→
2.7.0
View file →
| @@ -30,16 +30,15 @@ | ||
| 30 | 30 | $settings = $this->get_settings_for_display(); |
| 31 | 31 | $fields = $settings['fields']; |
| 32 | 32 | $has_address = false; |
| 33 | 33 | |
| 34 | - $attr_messages = ''; | |
| 34 | + $messages = ''; | |
| 35 | + | |
| 35 | 36 | if ( 'yes' === $settings['messages_custom'] ) { |
| 36 | 37 | $messages = esc_attr( wp_json_encode( [ |
| 37 | 38 | 'error' => esc_attr( $settings['messages_error'] ), |
| 38 | 39 | 'required' => esc_attr( $settings['messages_required'] ), |
| 39 | 40 | ] ) ); |
| 40 | - | |
| 41 | - $attr_messages = "data-messages=\"{$messages}\""; | |
| 42 | 41 | } |
| 43 | 42 | |
| 44 | 43 | ?> |
| 45 | 44 | <form |
| @@ -44,14 +43,14 @@ | ||
| 44 | 43 | ?> |
| 45 | 44 | <form |
| 46 | 45 | novalidate |
| 47 | 46 | method="POST" |
| 48 | - name="optin-<?php echo $this->get_id(); ?>" | |
| 47 | + name="optin-<?php echo esc_attr( $this->get_id() ); ?>" | |
| 49 | 48 | onsubmit="(e)=>e.preventDefault()" |
| 50 | 49 | class="sellkit-optin sellkit-flex sellkit-flex-wrap sellkit-flex-bottom" |
| 51 | - <?php echo $attr_messages; ?>> | |
| 52 | - <input type="hidden" name="post_id" value="<?php echo self::get_current_post_id(); ?>" /> | |
| 53 | - <input type="hidden" name="form_id" value="<?php echo $this->get_id(); ?>" /> | |
| 50 | + data-messages=<?php echo '"' . esc_attr( $messages ) . '"'; ?>> | |
| 51 | + <input type="hidden" name="post_id" value="<?php echo esc_attr( self::get_current_post_id() ); ?>" /> | |
| 52 | + <input type="hidden" name="form_id" value="<?php echo esc_attr( $this->get_id() ); ?>" /> | |
| 54 | 53 | <?php |
| 55 | 54 | |
| 56 | 55 | foreach ( $fields as $field ) { |
| 57 | 56 | if ( 'address' === $field['type'] ) { |
| @@ -61,9 +60,9 @@ | ||
| 61 | 60 | Module::render_field( $this, $field ); |
| 62 | 61 | } |
| 63 | 62 | |
| 64 | 63 | ?> |
| 65 | - <div <?php echo $this->button_wrapper_attributes( $settings ); ?>> | |
| 64 | + <div <?php echo $this->button_wrapper_attributes( $settings ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Elementor-generated attributes. ?>> | |
| 66 | 65 | <button type="submit" class="sellkit-submit-button"> |
| 67 | 66 | <?php Module::render_icon( $settings['submit_button_icon'] ); ?> |
| 68 | 67 | <div class="sellkit-submit-button-texts"> |
| 69 | 68 | <span class="sellkit-submit-button-text"> |
| @@ -118,13 +117,33 @@ | ||
| 118 | 117 | |
| 119 | 118 | private function enqueue_google_places_api() { |
| 120 | 119 | $options = get_option( 'sellkit' ); |
| 121 | 120 | |
| 122 | - if ( empty( $options ) || empty( $options['google_api_key_optin'] ) ) { | |
| 121 | + /** | |
| 122 | + * Let's make a small migration | |
| 123 | + * | |
| 124 | + * When user updates plugin, once we check if optin is filled, we fill google_api_key field with it. | |
| 125 | + * And we set empty value for it, so next time it will be ignored. | |
| 126 | + * | |
| 127 | + * @todo Should be removed at next version | |
| 128 | + * @since 1.5.7 | |
| 129 | + */ | |
| 130 | + if ( | |
| 131 | + empty( $settings['google_api_key'] ) && | |
| 132 | + array_key_exists( 'google_api_key_optin', $options ) && | |
| 133 | + ! empty( $options['google_api_key_optin'] ) | |
| 134 | + ) { | |
| 135 | + $options['google_api_key'] = $options['google_api_key_optin']; | |
| 136 | + $options['google_api_key_optin'] = ''; | |
| 137 | + | |
| 138 | + update_option( 'sellkit', $options ); | |
| 139 | + } | |
| 140 | + | |
| 141 | + if ( empty( $options ) || empty( $options['google_api_key'] ) ) { | |
| 123 | 142 | return; |
| 124 | 143 | } |
| 125 | 144 | |
| 126 | - $api_key = $options['google_api_key_optin']; | |
| 145 | + $api_key = $options['google_api_key']; | |
| 127 | 146 | |
| 128 | 147 | wp_enqueue_script( |
| 129 | 148 | 'sellkit_google_places_api', |
| 130 | 149 | "https://maps.googleapis.com/maps/api/js?key={$api_key}&libraries=places", |