PluginProbe
Float menu – awesome floating side menu / 6.0
Float menu – awesome floating side menu v6.0
7.2.5 trunk 2.1 2.2 3.0.1 3.1 3.2.2 3.3.1 3.5 3.5.1 3.5.2 3.5.3. 3.5.4 4.0 4.1 4.1.1 4.2 4.3 4.3.1 4.3.2 5.0 5.0.1 5.0.2 5.0.3 5.1 All 57 releases
← All changes | classes/Admin/SupportForm.php +40 -22 trunk6.0 View file →
@@ -1,6 +1,18 @@
1 1 <?php
2 2
3 +/**
4 + * Class SupportForm
5 + *
6 + * This class handles the support form functionality.
7 + *
8 + * @ackage WowPlugin
9 + * @subpackage Admin
10 + * @author Dmytro Lobov <dev@wow-company.com>, Wow-Company
11 + * @copyright 2024 Dmytro Lobov
12 + * @license GPL-2.0+
13 + */
14 +
3 15 namespace FloatMenuLite\Admin;
4 16
5 17 defined( 'ABSPATH' ) || exit;
6 18
@@ -99,12 +111,15 @@
99 111
100 112 <div class="wpie-field">
101 113 <?php submit_button( __( 'Send to Support', 'float-menu' ), 'primary', 'submit', false ); ?>
102 114 </div>
115 +
103 116 </div>
104 - <?php wp_nonce_field( WOWP_Plugin::PREFIX . '_nonce', WOWP_Plugin::PREFIX . '_support' ); ?>
117 +
118 + <?php wp_nonce_field( WOWP_Plugin::PREFIX . '_nonce_action', WOWP_Plugin::PREFIX . '_nonce_name' ); ?>
105 119 </fieldset>
106 120
121 +
107 122 </form>
108 123
109 124 <?php
110 125
@@ -111,14 +126,14 @@
111 126
112 127 }
113 128
114 129 private static function send(): void {
115 - $verify = AdminActions::verify( WOWP_Plugin::PREFIX . '_support' );
130 + if ( ! self::verify() ) {
116 131
117 - if ( ! $verify ) {
118 132 return;
119 133 }
120 134
135 +
121 136 $error = self::error();
122 137 if ( ! empty( $error ) ) {
123 138 echo '<p class="notice notice-error">' . esc_html( $error ) . '</p>';
124 139
@@ -123,20 +138,13 @@
123 138 echo '<p class="notice notice-error">' . esc_html( $error ) . '</p>';
124 139
125 140 return;
126 141 }
127 - // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verification is handled elsewhere.
128 - $from = isset( $_POST['support']['name'] ) ? sanitize_text_field( wp_unslash( $_POST['support']['name'] ) ) : '';
129 - $email = isset( $_POST['support']['email'] ) ? sanitize_email( wp_unslash( $_POST['support']['email'] ) ) : '';
130 - $license = isset( $_POST['support']['license'] ) ? sanitize_text_field( wp_unslash( $_POST['support']['license'] ) ) : '';
131 - $plugin = isset( $_POST['support']['plugin'] ) ? sanitize_text_field( wp_unslash( $_POST['support']['plugin'] ) ) : '';
132 - $link = isset( $_POST['support']['link'] ) ? sanitize_url( wp_unslash( $_POST['support']['link'] ) ) : '';
133 - $message = isset( $_POST['support']['message'] ) ? wp_kses_post( wp_unslash( $_POST['support']['message'] ) ) : '';
134 - $type = isset( $_POST['support']['type'] ) ? sanitize_text_field( wp_unslash( $_POST['support']['type'] ) ) : '';
135 - // phpcs:enable
136 142
143 + $support = $_POST['support'];
144 +
137 145 $headers = array(
138 - 'From: ' . esc_attr( $from ) . ' <' . esc_attr( $email ) . '>',
146 + 'From: ' . esc_attr( $support['name'] ) . ' <' . sanitize_email( $support['email'] ) . '>',
139 147 'content-type: text/html',
140 148 );
141 149
142 150
@@ -145,25 +153,26 @@
145 153 <body>
146 154 <table>
147 155 <tr>
148 156 <td><strong>License Key:</strong></td>
149 - <td>' . esc_attr( $license ) . '</td>
157 + <td>' . esc_attr( $support['license'] ) . '</td>
150 158 </tr>
151 159 <tr>
152 160 <td><strong>Plugin:</strong></td>
153 - <td>' . esc_attr( $plugin ) . '</td>
161 + <td>' . esc_attr( $support['plugin'] ) . '</td>
154 162 </tr>
155 163 <tr>
156 164 <td><strong>Website:</strong></td>
157 - <td><a href="' . esc_url( $link ) . '" target="_blank">' . esc_url( $link ) . '</a></td>
165 + <td><a href="' . esc_url( $support['link'] ) . '" target="_blank">' . esc_url( $support['link'] ) . '</a></td>
158 166 </tr>
159 167 </table>
160 168 <p/>
161 - ' . nl2br( wp_kses_post( $message ) ) . '
169 + ' . nl2br( wp_kses_post( $support['message'] ) ) . '
162 170 </body>
163 171 </html>';
172 + $type = sanitize_text_field( $support['type'] );
164 173 $to_mail = WOWP_Plugin::info( 'email' );
165 - $send = wp_mail( $to_mail, 'Support Request: ' . $type, $message_mail, $headers );
174 + $send = wp_mail( $to_mail, 'August749 / Support Ticket: ' . $type, $message_mail, $headers );
166 175
167 176 if ( $send ) {
168 177 $text = __( 'Your message has been sent to the support team.', 'float-menu' );
169 178 echo '<p class="notice notice-success">' . esc_html( $text ) . '</p>';
@@ -174,14 +183,16 @@
174 183
175 184 }
176 185
177 186 private static function error(): ?string {
187 + if ( ! self::verify() ) {
188 + return '';
189 + }
190 + $support = $_POST['support'];
191 + $fields = [ 'name', 'email', 'link', 'type', 'plugin', 'license', 'message' ];
178 192
179 - $fields = [ 'name', 'email', 'link', 'type', 'plugin', 'license', 'message' ];
180 -
181 193 foreach ( $fields as $field ) {
182 - // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verification is handled elsewhere.
183 - if ( empty( $_POST['support'][ $field ] ) ) {
194 + if ( empty( $support[ $field ] ) ) {
184 195 return __( 'Please fill in all the form fields below.', 'float-menu' );
185 196 }
186 197 }
187 198
@@ -187,6 +198,13 @@
187 198
188 199 return '';
189 200 }
190 201
202 + private static function verify(): bool {
203 + $support = $_POST['support'] ?? [];
204 + $nonce_name = WOWP_Plugin::PREFIX . '_nonce_name';
205 + $nonce_action = WOWP_Plugin::PREFIX . '_nonce_action';
206 +
207 + return ! empty( $support ) && wp_verify_nonce( $_POST[ $nonce_name ], $nonce_action );
208 + }
191 209
192 210 }