PluginProbe
Bubble Menu – Floating Button Menu with Sticky Navigation / 4.0
Bubble Menu – Floating Button Menu with Sticky Navigation v4.0
trunk 1.3 2.0 2.2 2.2.1 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.1 4.1.1
bubble-menu / classes / Admin / SupportForm.php

SupportForm.php in Bubble Menu – Floating Button Menu with Sticky Navigation 4.0, at classes/Admin/SupportForm.php

191 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BubbleMenu\Admin;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use BubbleMenu\WOWP_Plugin;
8
9 class SupportForm {
10
11 public static function init(): void {
12
13 $plugin = WOWP_Plugin::info( 'name' ) . ' v.' . WOWP_Plugin::info( 'version' );
14 $license = get_option( 'wow_license_key_' . WOWP_Plugin::PREFIX, 'no' );
15
16 self::send();
17
18 ?>
19
20 <form method="post">
21
22 <fieldset class="wpie-fieldset">
23 <legend>
24 <?php esc_html_e( 'Support Form', 'bubble-menu' ); ?>
25 </legend>
26
27 <div class="wpie-fields is-column-2">
28 <div class="wpie-field">
29 <div class="wpie-field__title"><?php esc_html_e( 'Your Name', 'bubble-menu' ); ?></div>
30 <label class="wpie-field__label has-icon">
31 <span class="wpie-icon wpie_icon-user"></span>
32 <input type="text" name="support[name]" id="support-name" value="">
33 </label>
34 </div>
35
36 <div class="wpie-field">
37 <div class="wpie-field__title"><?php esc_html_e( 'Contact email', 'bubble-menu' ); ?></div>
38 <label class="wpie-field__label has-icon">
39 <span class="wpie-icon wpie_icon-at-sign"></span>
40 <input type="email" name="support[email]" id="support-email"
41 value="<?php echo esc_attr( get_option( 'admin_email' ) ); ?>">
42 </label>
43 </div>
44 </div>
45
46 <div class="wpie-fields is-column-2">
47
48 <div class="wpie-field">
49 <div class="wpie-field__title"><?php esc_html_e( 'Link to the issue', 'bubble-menu' ); ?></div>
50 <label class="wpie-field__label has-icon">
51 <span class="wpie-icon wpie_icon-link"></span>
52 <input type="url" name="support[link]" id="support-link"
53 value="<?php echo esc_url( get_option( 'home' ) ); ?>">
54 </label>
55 </div>
56
57 <div class="wpie-field" data-field-box="menu_open">
58 <div class="wpie-field__title"><?php esc_html_e( 'Message type', 'bubble-menu' ); ?></div>
59 <label class="wpie-field__label has-icon">
60 <span class="wpie-icon wpie_icon-check"></span>
61 <select name="support[type]" id="support-type">
62 <option value="Issue"><?php esc_html_e( 'Issue', 'bubble-menu' ); ?></option>
63 <option value="Idea"><?php esc_html_e( 'Idea', 'bubble-menu' ); ?></option>
64 </select>
65 </label>
66 </div>
67
68 </div>
69 <div class="wpie-fields is-column-2">
70 <div class="wpie-field">
71 <div class="wpie-field__title"><?php esc_html_e( 'Plugin', 'bubble-menu' ); ?></div>
72 <label class="wpie-field__label has-icon">
73 <span class="wpie-icon wpie_icon-plug"></span>
74 <input type="text" readonly name="support[plugin]" id="support-plugin"
75 value="<?php echo esc_attr( $plugin ); ?>">
76 </label>
77 </div>
78
79 <div class="wpie-field">
80 <div class="wpie-field__title"><?php esc_html_e( 'License Key', 'bubble-menu' ); ?></div>
81 <label class="wpie-field__label has-icon">
82 <span class="wpie-icon wpie_icon-key"></span>
83 <input type="text" readonly name="support[license]" id="support-license"
84 value="<?php echo esc_attr( $license ); ?>">
85 </label>
86 </div>
87
88 </div>
89 <div class="wpie-fields is-column">
90 <?php
91 $content = esc_attr__( 'Enter Your Message', 'bubble-menu' );
92 $editor_id = 'support-message';
93 $settings = array(
94 'textarea_name' => 'support[message]',
95 );
96 wp_editor( $content, $editor_id, $settings ); ?>
97 </div>
98
99 <div class="wpie-fields is-column">
100
101 <div class="wpie-field">
102 <?php submit_button( __( 'Send to Support', 'bubble-menu' ), 'primary', 'submit', false ); ?>
103 </div>
104 </div>
105 <?php wp_nonce_field( WOWP_Plugin::PREFIX . '_nonce', WOWP_Plugin::PREFIX . '_support' ); ?>
106 </fieldset>
107
108 </form>
109
110 <?php
111
112
113 }
114
115 private static function send(): void {
116 $verify = AdminActions::verify( WOWP_Plugin::PREFIX . '_support' );
117
118 if ( ! $verify ) {
119 return;
120 }
121
122 $error = self::error();
123 if ( ! empty( $error ) ) {
124 echo '<p class="notice notice-error">' . esc_html( $error ) . '</p>';
125
126 return;
127 }
128
129 $from = sanitize_text_field( $_POST['support']['name'] );
130 $email = sanitize_email( $_POST['support']['email'] );
131 $license = sanitize_text_field( $_POST['support']['license'] );
132 $plugin = sanitize_text_field( $_POST['support']['plugin'] );
133 $link = sanitize_url( $_POST['support']['link'] );
134
135 $headers = array(
136 'From: ' . esc_attr( $from ) . ' <' . esc_attr( $email ) . '>',
137 'content-type: text/html',
138 );
139
140
141 $message_mail = '<html>
142 <head></head>
143 <body>
144 <table>
145 <tr>
146 <td><strong>License Key:</strong></td>
147 <td>' . esc_attr( $license ) . '</td>
148 </tr>
149 <tr>
150 <td><strong>Plugin:</strong></td>
151 <td>' . esc_attr( $plugin ) . '</td>
152 </tr>
153 <tr>
154 <td><strong>Website:</strong></td>
155 <td><a href="' . esc_url( $link ) . '" target="_blank">' . esc_url( $link ) . '</a></td>
156 </tr>
157 </table>
158 <p/>
159 ' . nl2br( wp_kses_post( $_POST['support']['message'] ) ) . '
160 </body>
161 </html>';
162 $type = sanitize_text_field( $_POST['support']['type'] );
163 $to_mail = WOWP_Plugin::info( 'email' );
164 $send = wp_mail( $to_mail, 'Support Request: ' . $type, $message_mail, $headers );
165
166 if ( $send ) {
167 $text = __( 'Your message has been sent to the support team.', 'bubble-menu' );
168 echo '<p class="notice notice-success">' . esc_html( $text ) . '</p>';
169 } else {
170 $text = __( 'Sorry, but message did not send. Please, contact us via support page.', 'bubble-menu' );
171 echo '<p class="notice notice-error">' . esc_html( $text ) . '</p>';
172 }
173
174 }
175
176 private static function error(): ?string {
177
178 $fields = [ 'name', 'email', 'link', 'type', 'plugin', 'license', 'message' ];
179
180 foreach ( $fields as $field ) {
181 if ( empty( $_POST['support'][ $field ] ) ) {
182 return __( 'Please fill in all the form fields below.', 'bubble-menu' );
183 }
184 }
185
186 return '';
187 }
188
189
190 }
191