PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 6.0.1
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v6.0.1
trunk 2.0.2 3.0 4.0 4.1.2 4.3 5.0 5.0.1 5.1 5.1.1 5.2 5.3 5.3.1 6.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 All 31 releases
floating-button / classes / Dashboard / SupportForm.php

SupportForm.php in Floating Button – Easily Create Sticky, Fixed & Floating Buttons 6.0.1, at classes/Dashboard/SupportForm.php

392 lines 15.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FloatingButton\Dashboard;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use FloatingButton\WOW_Plugin;
8
9 class SupportForm {
10
11 public static function init(): void {
12
13 $plugin = WOW_Plugin::info( 'name' ) . ' v.' . WOW_Plugin::info( 'version' );
14 $license = get_option( 'wow_license_key_' . WOW_Plugin::PREFIX, 'no' );
15
16 self::send();
17
18 ?>
19
20 <form method="post">
21
22 <fieldset>
23 <legend>
24 <?php esc_html_e( 'Support Form', 'floating-button' ); ?>
25 </legend>
26
27 <div class="wowp-field has-addon">
28 <label for="support-name" class="label"><?php esc_html_e( 'Your Name', 'floating-button' ); ?></label>
29 <input type="text" name="support[name]" id="support-name">
30 <span class="is-addon">
31 <span class="dashicons dashicons-text"></span>
32 </span>
33 </div>
34
35 <div class="wowp-field has-addon">
36 <label for="support-email" class="label"><?php esc_html_e( 'Contact email', 'floating-button' ); ?></label>
37 <input type="text" name="support[email]" id="support-email"
38 value="<?php echo sanitize_email( get_option( 'admin_email' ) ); ?>">
39 <span class="is-addon">
40 <span class="dashicons dashicons-email"></span>
41 </span>
42 </div>
43
44 <div class="wowp-field has-addon">
45 <label for="support-link"
46 class="label"><?php esc_html_e( 'Link to the issue', 'floating-button' ); ?></label>
47 <input type="text" name="support[link]" id="support-link"
48 value="<?php echo esc_url( get_option( 'home' ) ); ?>">
49 <span class="is-addon">
50 <span class="dashicons dashicons-admin-links"></span>
51 </span>
52 </div>
53
54 <div class="wowp-field has-addon">
55 <label for="support-type" class="label"><?php esc_html_e( 'Message type', 'floating-button' ); ?></label>
56 <select name="support[type]" id="support-type">
57 <option value="Issue"><?php esc_html_e( 'Issue', 'floating-button' ); ?></option>
58 <option value="Idea"><?php esc_html_e( 'Idea', 'floating-button' ); ?></option>
59 </select>
60 <span class="is-addon">
61 🗯
62 </span>
63 </div>
64
65 <div class="wowp-field has-addon">
66 <label for="support-plugin" class="label"><?php esc_html_e( 'Plugin', 'floating-button' ); ?></label>
67 <input type="text" readonly name="support[plugin]" id="support-plugin"
68 value="<?php echo esc_attr( $plugin ); ?>">
69 <span class="is-addon">
70 <span class="dashicons dashicons-admin-plugins"></span>
71 </span>
72 </div>
73
74 <div class="wowp-field has-addon">
75 <label for="support-license" class="label"><?php esc_html_e( 'License Key', 'floating-button' ); ?></label>
76 <input type="text" readonly name="support[license]" id="support-license"
77 value="<?php echo esc_attr( $license ); ?>">
78 <span class="is-addon">
79 🔑
80 </span>
81 </div>
82
83 <div class="wowp-field is-full">
84 <?php
85 $content = esc_attr__( 'Enter Your Message', 'floating-button' );
86 $editor_id = 'support-message';
87 $settings = array(
88 'textarea_name' => 'support[message]',
89 );
90 wp_editor( $content, $editor_id, $settings ); ?>
91 </div>
92
93 <div class="wowp-field">
94 <?php submit_button( __( 'Send to Support', 'floating-button' ), 'primary', 'submit', false ); ?>
95 </div>
96
97 <?php wp_nonce_field( WOW_Plugin::PREFIX . '_nonce_action', WOW_Plugin::PREFIX . '_nonce_name' ); ?>
98 </fieldset>
99
100 <div class="wowp-field is-full">
101 <input type="checkbox" name="support[debug]" id="support-debug" value="1" checked="checked">
102 <label for="support-debug">Send system information</label>
103 </div>
104 <div class="wowp-field is-full">
105 <p></p>
106 <details class="wowp-details">
107 <summary><?php esc_html_e( 'System Information', 'floating-button' ); ?></summary>
108 <textarea readonly="readonly" aria-readonly="true" name="support[info]" rows="20" cols="100"
109 class="large-text code"><?php echo esc_html( self::sysinfo_get() ); ?></textarea>
110 </details>
111 </div>
112
113 </form>
114
115 <?php
116
117
118 }
119
120 private static function send(): void {
121 if ( ! self::verify() ) {
122 return;
123 }
124
125
126 $error = self::error();
127 if ( ! empty( $error ) ) {
128 echo '<p class="wowp-notice wowp-error">' . esc_html( $error ) . '</p>';
129
130 return;
131 }
132
133 $support = $_POST['support'];
134
135 $headers = array(
136 'From: ' . esc_attr( $support['name'] ) . ' <' . sanitize_email( $support['email'] ) . '>',
137 'content-type: text/html',
138 );
139
140 $debug = isset( $support['debug'] ) ? '<p style="font-size: 12px;">-------<br/>' . nl2br( wp_kses_post( $support['info'] ) ) .'</p>' : '';
141
142 $message_mail = '<html>
143 <head></head>
144 <body>
145 <table>
146 <tr>
147 <td><strong>License Key:</strong></td>
148 <td>' . esc_attr( $support['license'] ) . '</td>
149 </tr>
150 <tr>
151 <td><strong>Plugin:</strong></td>
152 <td>' . esc_attr( $support['plugin'] ) . '</td>
153 </tr>
154 <tr>
155 <td><strong>Website:</strong></td>
156 <td><a href="' . esc_url( $support['link'] ) . '" target="_blank">' . esc_url( $support['link'] ) . '</a></td>
157 </tr>
158 </table>
159 <p/>
160 ' . nl2br( wp_kses_post( $support['message'] ) ) . wp_kses_post( $debug ) . '
161 </body>
162 </html>';
163 $type = sanitize_text_field( $support['type'] );
164 $to_mail = WOW_Plugin::info( 'email' );
165 $send = wp_mail( $to_mail, 'Support Ticket: ' . $type, $message_mail, $headers );
166
167 if ( $send ) {
168 $text = __( 'Your message has been sent to the support team.', 'floating-button' );
169 echo '<p class="wowp-notice wowp-success">' . esc_html( $text ) . '</p>';
170 } else {
171 $text = __( 'Sorry, but message did not send. Please, contact us ', 'floating-button' ) . $to_mail;
172 echo '<p class="wowp-notice wowp-error">' . esc_html( $text ) . '</p>';
173 }
174
175 }
176
177 private static function error(): ?string {
178 if ( ! self::verify() ) {
179 return '';
180 }
181 $support = $_POST['support'];
182 $fields = [ 'name', 'email', 'link', 'type', 'plugin', 'license', 'message' ];
183
184 foreach ( $fields as $field ) {
185 if ( empty( $support[ $field ] ) ) {
186 return __( 'Please fill in all the form fields below.', 'floating-button' );
187 }
188 }
189
190 return '';
191 }
192
193 private static function verify(): bool {
194 $support = $_POST['support'] ?? [];
195 $nonce_name = WOW_Plugin::PREFIX . '_nonce_name';
196 $nonce_action = WOW_Plugin::PREFIX . '_nonce_action';
197
198 return ! empty( $support ) && wp_verify_nonce( $_POST[ $nonce_name ], $nonce_action );
199 }
200
201 private static function sysinfo_get() {
202 global $wpdb;
203
204 // Get theme info
205 $theme_data = wp_get_theme();
206 $theme = $theme_data->Name . ' ' . $theme_data->Version;
207 $parent_theme = $theme_data->Template;
208 if ( ! empty( $parent_theme ) ) {
209 $parent_theme_data = wp_get_theme( $parent_theme );
210 $parent_theme = $parent_theme_data->Name . ' ' . $parent_theme_data->Version;
211 }
212
213 $return = '### Begin System Info (Generated ' . date( 'Y-m-d H:i:s' ) . ') ###' . "\n\n";
214
215 // Start with the basics...
216 $return .= '-- Site Info' . "\n\n";
217 $return .= 'Site URL: ' . site_url() . "\n";
218 $return .= 'Home URL: ' . home_url() . "\n";
219 $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
220
221 $locale = get_locale();
222
223 // WordPress configuration
224 $return .= "\n" . '-- WordPress Configuration' . "\n\n";
225 $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
226 $return .= 'Language: ' . ( ! empty( $locale ) ? $locale : 'en_US' ) . "\n";
227 $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ?: 'Default' ) . "\n";
228 $return .= 'Active Theme: ' . $theme . "\n";
229 $return .= 'WP Timezone: ' . wp_timezone_string() . "\n";
230 if ( $parent_theme !== $theme ) {
231 $return .= 'Parent Theme: ' . $parent_theme . "\n";
232 }
233
234 $return .= "\n";
235
236 $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
237
238 // Only show page specs if frontpage is set to 'page'
239 if ( get_option( 'show_on_front' ) == 'page' ) {
240 $front_page_id = get_option( 'page_on_front' );
241 $blog_page_id = get_option( 'page_for_posts' );
242
243 $return .= 'Page On Front: ' . ( $front_page_id != 0 ? '#' . $front_page_id : 'Unset' ) . "\n";
244 $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? '#' . $blog_page_id : 'Unset' ) . "\n";
245 }
246
247 $return .= 'ABSPATH: ' . ABSPATH . "\n";
248
249 $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
250 // Commented out per https://github.com/easydigitaldownloads/Easy-Digital-Downloads/issues/3475
251 //$return .= 'Admin AJAX: ' . ( edd_test_ajax_works() ? 'Accessible' : 'Inaccessible' ) . "\n";
252 $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
253 $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
254
255 // EDD Database tables
256 $return .= "\n" . '-- Plugin Database Table' . "\n\n";
257
258 $database_name = $wpdb->prefix . WOW_Plugin::PREFIX;
259 $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $database_name ) );
260
261 if ( $wpdb->get_var( $query ) == $database_name ) {
262 $row_count = $wpdb->get_var( "SELECT COUNT(*) FROM $database_name" );
263 $return .= $database_name . ' Number of rows in table ' . absint( $row_count ) . "\n";
264 } else {
265 $return .= $database_name . ' Database does not exist.' . "\n";
266 }
267
268 // Get plugins that have an update
269 $updates = get_plugin_updates();
270
271 // Must-use plugins
272 // NOTE: MU plugins can't show updates!
273 $muplugins = get_mu_plugins();
274 if ( count( $muplugins ) > 0 ) {
275 $return .= "\n" . '-- Must-Use Plugins' . "\n\n";
276
277 foreach ( $muplugins as $plugin => $plugin_data ) {
278 $return .= str_pad( $plugin_data['Name'] . ': ', 26, ' ' ) . $plugin_data['Version'] . "\n";
279 }
280
281 $return = apply_filters( 'edd_sysinfo_after_wordpress_mu_plugins', $return );
282 }
283
284 // WordPress active plugins
285 $return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
286
287 $plugins = get_plugins();
288 $active_plugins = get_option( 'active_plugins', array() );
289
290 foreach ( $plugins as $plugin_path => $plugin ) {
291 if ( ! in_array( $plugin_path, $active_plugins ) ) {
292 continue;
293 }
294
295 $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
296 $plugin_url = '';
297 if ( ! empty( $plugin['PluginURI'] ) ) {
298 $plugin_url = $plugin['PluginURI'];
299 } elseif ( ! empty( $plugin['AuthorURI'] ) ) {
300 $plugin_url = $plugin['AuthorURI'];
301 } elseif ( ! empty( $plugin['Author'] ) ) {
302 $plugin_url = $plugin['Author'];
303 }
304 if ( $plugin_url ) {
305 $plugin_url = "\n" . $plugin_url;
306 }
307 $return .= str_pad( $plugin['Name'] . ': ', 26, ' ' ) . $plugin['Version'] . $update . $plugin_url . "\n\n";
308 }
309
310 // WordPress inactive plugins
311 $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
312
313 foreach ( $plugins as $plugin_path => $plugin ) {
314 if ( in_array( $plugin_path, $active_plugins ) ) {
315 continue;
316 }
317
318 $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
319 $plugin_url = '';
320 if ( ! empty( $plugin['PluginURI'] ) ) {
321 $plugin_url = $plugin['PluginURI'];
322 } elseif ( ! empty( $plugin['AuthorURI'] ) ) {
323 $plugin_url = $plugin['AuthorURI'];
324 } elseif ( ! empty( $plugin['Author'] ) ) {
325 $plugin_url = $plugin['Author'];
326 }
327 if ( $plugin_url ) {
328 $plugin_url = "\n" . $plugin_url;
329 }
330 $return .= str_pad( $plugin['Name'] . ': ', 26, ' ' ) . $plugin['Version'] . $update . $plugin_url . "\n\n";
331 }
332
333 if ( is_multisite() ) {
334 // WordPress Multisite active plugins
335 $return .= "\n" . '-- Network Active Plugins' . "\n\n";
336
337 $plugins = wp_get_active_network_plugins();
338 $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
339
340 foreach ( $plugins as $plugin_path ) {
341 $plugin_base = plugin_basename( $plugin_path );
342
343 if ( ! array_key_exists( $plugin_base, $active_plugins ) ) {
344 continue;
345 }
346
347 $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
348 $plugin = get_plugin_data( $plugin_path );
349 $plugin_url = '';
350 if ( ! empty( $plugin['PluginURI'] ) ) {
351 $plugin_url = $plugin['PluginURI'];
352 } elseif ( ! empty( $plugin['AuthorURI'] ) ) {
353 $plugin_url = $plugin['AuthorURI'];
354 } elseif ( ! empty( $plugin['Author'] ) ) {
355 $plugin_url = $plugin['Author'];
356 }
357 if ( $plugin_url ) {
358 $plugin_url = "\n" . $plugin_url;
359 }
360 $return .= str_pad( $plugin['Name'] . ': ', 26, ' ' ) . $plugin['Version'] . $update . $plugin_url . "\n\n";
361 }
362 }
363
364 // Server configuration (really just versioning)
365 $return .= "\n" . '-- Webserver Configuration' . "\n\n";
366 $return .= 'PHP Version: ' . PHP_VERSION . "\n";
367 $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
368 $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
369
370 // PHP configs... now we're getting to the important stuff
371 $return .= "\n" . '-- PHP Configuration' . "\n\n";
372 $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
373 $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
374 $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
375 $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
376 $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
377 $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
378 $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
379
380 // PHP extensions and such
381 $return .= "\n" . '-- PHP Extensions' . "\n\n";
382 $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
383 $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
384 $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
385 $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
386
387 $return .= "\n" . '### End System Info ###';
388
389 return $return;
390 }
391 }
392