PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 2.5.0
WP 2FA – Two-factor authentication for WordPress v2.5.0
4.0.0 1.7.1 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.8.0 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0 3.0.1 3.1.0 3.1.1 3.1.1.2 trunk 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.7.0
wp-2fa / includes / classes / Admin / class-help-contact-us.php
wp-2fa / includes / classes / Admin Last commit date
Controllers 2 years ago Helpers 2 years ago Methods 2 years ago SettingsPages 2 years ago Views 2 years ago class-help-contact-us.php 2 years ago class-premium-features.php 2 years ago class-settings-page.php 2 years ago class-setup-wizard.php 2 years ago class-user-listing.php 2 years ago class-user-notices.php 2 years ago class-user-profile.php 2 years ago class-user-registered.php 2 years ago index.php 5 years ago
class-help-contact-us.php
463 lines
1 <?php
2 /**
3 * Contact us and help rendering class.
4 *
5 * @package wp2fa
6 * @subpackage admin
7 * @copyright %%YEAR%% Melapress
8 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
9 * @link https://wordpress.org/plugins/wp-2fa/
10 * @since 2.0.0
11 */
12
13 namespace WP2FA\Admin;
14
15 use \WP2FA\Admin\Settings_Page;
16 use WP2FA\Admin\Helpers\WP_Helper;
17 use \WP2FA\WP2FA as WP2FA;
18
19 if ( ! class_exists( '\WP2FA\Admin\Help_Contact_Us' ) ) {
20
21 /**
22 * Handles contact us tab and content.
23 */
24 class Help_Contact_Us {
25
26 const TOP_MENU_SLUG = 'wp-2fa-help-contact-us';
27
28 /**
29 * Create admin menu entry and settings page
30 */
31 public static function add_extra_menu_item() {
32 add_submenu_page(
33 Settings_Page::TOP_MENU_SLUG,
34 esc_html__( 'Help & Contact Us', 'wp-2fa' ),
35 esc_html__( 'Help & Contact Us', 'wp-2fa' ),
36 'manage_options',
37 self::TOP_MENU_SLUG,
38 array( __CLASS__, 'render' ),
39 100
40 );
41 }
42
43 /**
44 * Handles rendering the help tabs and their wrapping element.
45 *
46 * @return void
47 */
48 public static function render() {
49 $main_user = get_current_user_id();
50 $current_user_id = $main_user;
51
52 if ( ! empty( WP2FA::get_wp2fa_setting( '2fa_settings_last_updated_by' ) ) ) {
53 $main_user = (int) WP2FA::get_wp2fa_setting( '2fa_settings_last_updated_by' );
54 }
55 ?>
56 <?php if ( ! empty( WP2FA::get_wp2fa_general_setting( 'limit_access' ) ) && $main_user !== $current_user_id ) : ?>
57 </br>
58 <?php
59 echo esc_html__( 'These settings have been disabled by your site administrator, please contact them for further assistance.', 'wp-2fa' );
60 ?>
61 <?php else : ?>
62 <div class="wrap help-wrap">
63 <h2><?php esc_html_e( 'Help', 'wp-2fa' ); ?></h2>
64 <hr>
65 <br>
66 <div class="nav-tab-wrapper">
67 <?php
68 // Get current tab.
69 $current_tab = isset( $_GET['tab'] ) ? \wp_unslash( $_GET['tab'] ) : 'help'; // phpcs:ignore
70 ?>
71 <a href="<?php echo esc_url( remove_query_arg( 'tab' ) ); ?>" class="nav-tab<?php echo 'help' === $current_tab ? ' nav-tab-active' : ''; ?>"><?php esc_html_e( 'Help', 'wp-2fa' ); ?></a>
72 <a href="<?php echo esc_url( add_query_arg( 'tab', 'system-info' ) ); ?>" class="nav-tab<?php echo 'system-info' === $current_tab ? ' nav-tab-active' : ''; ?>"><?php esc_html_e( 'System info', 'wp-2fa' ); ?></a>
73 </div>
74 <div class="wp2fa-help-section nav-tabs">
75 <?php
76 self::sidebar();
77 if ( 'help' === $current_tab ) {
78 self::help();
79 } elseif ( 'system-info' === $current_tab ) {
80 self::system_info();
81 }
82 ?>
83 </div>
84 </div>
85 <?php endif; ?>
86 <?php
87 }
88
89 /**
90 * Help tab content.
91 *
92 * @return void
93 */
94 public static function help() {
95 ?>
96 <div class="wp2fa-help-main">
97 <!-- getting started -->
98 <div class="title">
99 <h2><?php esc_html_e( 'Getting started', 'wp-2fa' ); ?></h2>
100 </div>
101 <p><?php esc_html_e( 'Getting started with WP 2FA and making 2FA compulsory is as easy as 1 2 3 with WP 2FA. This can be easily done through the install wizard or the plugin settings. If you are stuck, no problem! Below are a few links of guides to help you get started:', 'wp-2fa' ); ?></p>
102 <ul>
103 <li><?php echo wp_sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://melapress.com/support/kb/wp-2fa-plugin-getting-started/?&utm_source=plugins&utm_medium=link&utm_campaign=wp2fa' ), esc_html__( 'Getting started with WP 2FA', 'wp-2fa' ) ); ?></li>
104 <li><?php echo wp_sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://melapress.com/support/kb/wp-2fa-configure-2fa-policies-enforce/?&utm_source=plugins&utm_medium=link&utm_campaign=wp2fa' ), esc_html__( 'Configuring 2FA policies & making 2FA mandatory', 'wp-2fa' ) ); ?></li>
105 <li><?php echo wp_sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://melapress.com/support/kb/wp-2fa-configure-2fa-front-end-page-wordpress/?&utm_source=plugins&utm_medium=link&utm_campaign=wp2fa' ), esc_html__( 'Allowing users to configure 2FA from a website page (no dashboard access)', 'wp-2fa' ) ); ?></li>
106 </ul>
107 <!-- End -->
108 <br>
109 <p><iframe title="<?php esc_html_e( 'Getting started', 'wp-2fa' ); ?>" class="wsal-youtube-embed" width="100%" height="315" src="https://www.youtube.com/embed/vRlX_NNGeFo" frameborder="0" allowfullscreen></iframe></p>
110
111 <!-- Plugin documentation -->
112 <div class="title">
113 <h2><?php esc_html_e( 'Plugin documentation', 'wp-2fa' ); ?></h2>
114 </div>
115 <p><?php esc_html_e( 'For more technical information about the WP 2FA plugin please visit the plugin\'s knowledge base.', 'wp-2fa' ); ?></p>
116 <div class="btn">
117 <a href="<?php echo esc_url( 'https://melapress.com/support/kb/?utm_source=plugins&utm_medium=link&utm_campaign=wp2fa' ); ?>" class="button" target="_blank"><?php esc_html_e( 'Knowledge base', 'wp-2fa' ); ?></a>
118 </div>
119 <!-- End -->
120
121 <!-- Plugin support -->
122 <div class="title">
123 <h2><?php esc_html_e( 'Plugin support', 'wp-2fa' ); ?></h2>
124 </div>
125 <p><?php esc_html_e( 'Do you need assistance with the plugin? Have you noticed or encountered an issue while using WP 2FA, or do you just want to report something to us?', 'wp-2fa' ); ?></p>
126 <div class="btn">
127 <a href="<?php echo esc_url( 'https://melapress.com/support/submit-ticket/?utm_source=plugins&utm_medium=link&utm_campaign=wp2fa' ); ?>" class="button" target="_blank"><?php esc_html_e( 'Open support ticket', 'wp-2fa' ); ?></a>
128 <a href="<?php echo esc_url( 'https://melapress.com/contact/?utm_source=plugins&utm_medium=link&utm_campaign=wp2fa' ); ?>" class="button" target="_blank"><?php esc_html_e( 'Contact us', 'wp-2fa' ); ?></a>
129 </div>
130 <!-- End -->
131 </div>
132 <?php
133 }
134
135 /**
136 * System info tab content.
137 *
138 * @return void
139 */
140 public static function system_info() {
141 ?>
142 <div class="wp2fa-help-main">
143 <!-- getting started -->
144 <div class="title">
145 <h2><?php esc_html_e( 'System information', 'wp-2fa' ); ?></h2>
146 </div>
147 <form method="post" dir="ltr">
148 <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="wsal-sysinfo"><?php echo self::get_sysinfo(); // phpcs:ignore ?></textarea>
149 <p class="submit">
150 <input type="hidden" name="ppmwp-action" value="download_sysinfo" />
151 <?php submit_button( 'Download System Info File', 'primary', 'wp2fa-download-sysinfo', false ); ?>
152 </p>
153 </form>
154 <script>
155
156 function download(filename, text) {
157 // Create temporary element.
158 var element = document.createElement('a');
159 element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
160 element.setAttribute('download', filename);
161
162 // Set the element to not display.
163 element.style.display = 'none';
164 document.body.appendChild(element);
165
166 // Simlate click on the element.
167 element.click();
168
169 // Remove temporary element.
170 document.body.removeChild(element);
171 }
172 jQuery( document ).ready( function() {
173 var download_btn = jQuery( '#wp2fa-download-sysinfo' );
174 download_btn.click( function( event ) {
175 event.preventDefault();
176 download( 'wp2fa-system-info.txt', jQuery( '#system-info-textarea' ).val() );
177 } );
178 } );
179 </script>
180 </div>
181 <?php
182 }
183
184 /**
185 * Advertising sidebar.
186 *
187 * @return void
188 */
189 public static function sidebar() {
190 ?>
191 <div class="our-wordpress-plugins side-bar">
192 <h3><?php esc_html_e( 'Our WordPress Plugins', 'wp-2fa' ); ?></h3>
193 <ul>
194 <li>
195 <div class="plugin-box">
196 <div class="plugin-img">
197 <img src="<?php echo WP_2FA_URL; // phpcs:ignore ?>dist/images/wp-security-audit-log-img.jpg" alt="">
198 </div>
199 <div class="plugin-desc">
200 <p><?php esc_html_e( 'Keep a log of users and under the hood site activity.', 'wp-2fa' ); ?></p>
201 <div class="cta-btn">
202 <a href="
203 <?php
204 echo esc_url(
205 add_query_arg(
206 array(
207 'utm_source' => 'plugin',
208 'utm_medium' => 'referral',
209 'utm_campaign' => 'WSAL',
210 'utm_content' => 'WP2FA+banner',
211 ),
212 'https://wpactivitylog.com'
213 )
214 );
215 ?>
216 " target="_blank"><?php esc_html_e( 'LEARN MORE', 'wp-2fa' ); ?></a>
217 </div>
218 </div>
219 </div>
220 </li>
221 <li>
222 <div class="plugin-box">
223 <div class="plugin-img">
224 <img src="<?php echo WP_2FA_URL; // phpcs:ignore ?>dist/images/wp-password-img.jpg" alt="">
225 </div>
226 <div class="plugin-desc">
227 <p><?php esc_html_e( 'Enforce strong password policies on WordPress.', 'wp-2fa' ); ?></p>
228 <div class="cta-btn">
229 <a href="
230 <?php
231 echo esc_url(
232 add_query_arg(
233 array(
234 'utm_source' => 'plugin',
235 'utm_medium' => 'referral',
236 'utm_campaign' => 'WSAL',
237 'utm_content' => 'WP2FA+banner',
238 ),
239 'https://melapress.com/wordpress-login-security/?&utm_source=plugins&utm_medium=link&utm_campaign=wp2fa'
240 )
241 );
242 ?>
243 " target="_blank"><?php esc_html_e( 'LEARN MORE', 'wp-2fa' ); ?></a>
244 </div>
245 </div>
246 </div>
247 </li>
248 <li>
249 <div class="plugin-box">
250 <div class="plugin-img">
251 <img src="<?php echo WP_2FA_URL; // phpcs:ignore ?>dist/images/website-file-changes-monitor.jpg" alt="">
252 </div>
253 <div class="plugin-desc">
254 <p><?php esc_html_e( 'Automatically identify unauthorized file changes on your WordPress site.', 'wp-2fa' ); ?></p>
255 <div class="cta-btn">
256 <a href="
257 <?php
258 echo esc_url(
259 add_query_arg(
260 array(
261 'utm_source' => 'plugin',
262 'utm_medium' => 'referral',
263 'utm_campaign' => 'WSAL',
264 'utm_content' => 'WP2FA+banner',
265 ),
266 'https://melapress.com/wordpress-plugins/website-file-changes-monitor/'
267 )
268 );
269 ?>
270 " target="_blank"><?php esc_html_e( 'LEARN MORE', 'wp-2fa' ); ?></a>
271 </div>
272 </div>
273 </div>
274 </li>
275 <li>
276 <div class="plugin-box">
277 <div class="plugin-img">
278 <img src="<?php echo WP_2FA_URL; // phpcs:ignore ?>dist/images/c4wp.jpg" alt="">
279 </div>
280 <div class="plugin-desc">
281 <p><?php esc_html_e( 'Protect website forms & login pages from spam bots & automated attacks.', 'wp-2fa' ); ?></p>
282 <div class="cta-btn">
283 <a href="
284 <?php
285 echo esc_url(
286 add_query_arg(
287 array(
288 'utm_source' => 'plugin',
289 'utm_medium' => 'referral',
290 'utm_campaign' => 'WSAL',
291 'utm_content' => 'WP2FA+banner',
292 ),
293 'https://melapress.com/wordpress-captcha/?&utm_source=plugins&utm_medium=link&utm_campaign=wp2fa'
294 )
295 );
296 ?>
297 " target="_blank"><?php esc_html_e( 'LEARN MORE', 'wp-2fa' ); ?></a>
298 </div>
299 </div>
300 </div>
301 </li>
302 </ul>
303 </div>
304 <?php
305 }
306
307 /**
308 * Gather basic settings and system information for use in the system info tab. Left untranslated (as is the case in all plugins)
309 * as its for our use only.
310 *
311 * @return string
312 */
313 public static function get_sysinfo() {
314 // System info.
315 global $wpdb;
316
317 $sysinfo = '### System Info → Begin ###' . "\n\n";
318
319 // Start with the basics...
320 $sysinfo .= '-- Site Info --' . "\n\n";
321 $sysinfo .= 'Site URL (WP Address): ' . site_url() . "\n";
322 $sysinfo .= 'Home URL (Site Address): ' . home_url() . "\n";
323 $sysinfo .= 'Multisite: ' . ( WP_Helper::is_multisite() ? 'Yes' : 'No' ) . "\n";
324
325 // Get theme info.
326 $theme_data = wp_get_theme();
327 $theme = $theme_data->name . ' ' . $theme_data->version;
328 $parent_theme = $theme_data->template;
329 if ( ! empty( $parent_theme ) ) {
330 $parent_theme_data = wp_get_theme( $parent_theme );
331 $parent_theme = $parent_theme_data->name . ' ' . $parent_theme_data->version;
332 }
333
334 // Language information.
335 $locale = get_locale();
336
337 // WordPress configuration.
338 $sysinfo .= "\n" . '-- WordPress Configuration --' . "\n\n";
339 $sysinfo .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
340 $sysinfo .= 'Language: ' . ( ! empty( $locale ) ? $locale : 'en_US' ) . "\n";
341 $sysinfo .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
342 $sysinfo .= 'Active Theme: ' . $theme . "\n";
343 if ( $parent_theme !== $theme ) {
344 $sysinfo .= 'Parent Theme: ' . $parent_theme . "\n";
345 }
346 $sysinfo .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
347
348 // Only show page specs if frontpage is set to 'page'.
349 if ( 'page' === get_option( 'show_on_front' ) ) {
350 $front_page_id = (int) get_option( 'page_on_front' );
351 $blog_page_id = (int) get_option( 'page_for_posts' );
352
353 $sysinfo .= 'Page On Front: ' . ( 0 !== $front_page_id ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
354 $sysinfo .= 'Page For Posts: ' . ( 0 !== $blog_page_id ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
355 }
356
357 $sysinfo .= 'ABSPATH: ' . ABSPATH . "\n";
358 $sysinfo .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? ( WP_DEBUG ? 'Enabled' : 'Disabled' ) : 'Not set' ) . "\n";
359 $sysinfo .= 'WP Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
360
361 // Get plugins that have an update.
362 $updates = get_plugin_updates();
363
364 // Must-use plugins.
365 // NOTE: MU plugins can't show updates!
366 $muplugins = get_mu_plugins();
367 if ( count( $muplugins ) > 0 ) {
368 $sysinfo .= "\n" . '-- Must-Use Plugins --' . "\n\n";
369
370 foreach ( $muplugins as $plugin => $plugin_data ) {
371 $sysinfo .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
372 }
373 }
374
375 // WordPress active plugins.
376 $sysinfo .= "\n" . '-- WordPress Active Plugins --' . "\n\n";
377
378 $plugins = get_plugins();
379 $active_plugins = get_option( 'active_plugins', array() );
380
381 foreach ( $plugins as $plugin_path => $plugin ) {
382 if ( ! in_array( $plugin_path, $active_plugins, true ) ) {
383 continue;
384 }
385
386 $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
387 $sysinfo .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
388 }
389
390 // WordPress inactive plugins.
391 $sysinfo .= "\n" . '-- WordPress Inactive Plugins --' . "\n\n";
392
393 foreach ( $plugins as $plugin_path => $plugin ) {
394 if ( in_array( $plugin_path, $active_plugins, true ) ) {
395 continue;
396 }
397
398 $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
399 $sysinfo .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
400 }
401
402 if ( WP_Helper::is_multisite() ) {
403 // WordPress Multisite active plugins.
404 $sysinfo .= "\n" . '-- Network Active Plugins --' . "\n\n";
405
406 $plugins = wp_get_active_network_plugins();
407 $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
408
409 foreach ( $plugins as $plugin_path ) {
410 $plugin_base = plugin_basename( $plugin_path );
411
412 if ( ! array_key_exists( $plugin_base, $active_plugins ) ) {
413 continue;
414 }
415
416 $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
417 $plugin = get_plugin_data( $plugin_path );
418 $sysinfo .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
419 }
420 }
421
422 // Server configuration.
423 $server_software = ( isset( $_SERVER['SERVER_SOFTWARE'] ) ) ? \sanitize_text_field( \wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '';
424 $sysinfo .= "\n" . '-- Webserver Configuration --' . "\n\n";
425 $sysinfo .= 'PHP Version: ' . PHP_VERSION . "\n";
426 $sysinfo .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
427
428 if ( isset( $server_software ) ) {
429 $sysinfo .= 'Webserver Info: ' . $server_software . "\n";
430 } else {
431 $sysinfo .= 'Webserver Info: Global $_SERVER array is not set.' . "\n";
432 }
433
434 // PHP configs.
435 $sysinfo .= "\n" . '-- PHP Configuration --' . "\n\n";
436 $sysinfo .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
437 $sysinfo .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
438 $sysinfo .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
439 $sysinfo .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
440 $sysinfo .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
441 $sysinfo .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
442 $sysinfo .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
443
444 $sysinfo .= "\n" . '-- WP 2FA Settings --' . "\n\n";
445
446 global $wpdb;
447
448 $wp2fa_options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE 'wp_2fa_%'", ARRAY_A ); // phpcs:ignore
449
450 if ( ! empty( $wp2fa_options ) ) {
451 foreach ( $wp2fa_options as $option => $value ) {
452 $sysinfo .= 'Option: ' . $value['option_name'] . "\n";
453 $sysinfo .= 'Value: ' . print_r( $value['option_value'], true ) . "\n\n"; // phpcs:ignore
454 }
455 }
456
457 $sysinfo .= "\n" . '### System Info → End ###' . "\n\n";
458
459 return $sysinfo;
460 }
461 }
462 }
463