PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 4.0.0
WP 2FA – Two-factor authentication for WordPress v4.0.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 / SettingsPages / class-settings-page-render.php
wp-2fa / includes / classes / Admin / SettingsPages Last commit date
class-settings-page-email.php 1 day ago class-settings-page-general.php 1 day ago class-settings-page-new.php 1 day ago class-settings-page-passkeys.php 1 day ago class-settings-page-policies-new.php 1 day ago class-settings-page-policies.php 1 day ago class-settings-page-render.php 1 day ago class-settings-page-white-label.php 1 day ago class-settings-page-white-labeling-new.php 1 day ago class-setup-wizard-new.php 1 day ago index.php 1 day ago
class-settings-page-render.php
190 lines
1 <?php
2 /**
3 * Settings page render class.
4 *
5 * @package wp2fa
6 * @subpackage views
7 * @copyright 2026 Melapress
8 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
9 * @link https://wordpress.org/plugins/wp-2fa/
10 */
11
12 namespace WP2FA\Admin\SettingsPages;
13
14 use WP2FA\WP2FA;
15 use WP2FA\Admin\Helpers\WP_Helper;
16
17 if ( ! class_exists( '\WP2FA\Admin\SettingsPages\Settings_Page_Render' ) ) {
18 /**
19 * Settings_Page_Render - Class for rendering the plugin settings settings
20 *
21 * @since 2.0.0
22 */
23 class Settings_Page_Render {
24
25 /**
26 * Render the settings
27 */
28 public static function render() {
29 if ( ! current_user_can( 'manage_options' ) ) {
30 return;
31 }
32
33 $main_user = get_current_user_id();
34 $current_user_id = $main_user;
35
36 if ( ! empty( WP2FA::get_wp2fa_setting( '2fa_settings_last_updated_by' ) ) ) {
37 $main_user = (int) WP2FA::get_wp2fa_setting( '2fa_settings_last_updated_by' );
38 }
39 ?>
40
41 <div class="wrap wp-2fa-settings-wrapper wp2fa-form-styles">
42 <h2><?php \esc_html_e( 'WP 2FA Settings', 'wp-2fa' ); ?></h2>
43 <hr>
44 <br>
45 <?php if ( ! empty( WP2FA::get_wp2fa_general_setting( 'limit_access' ) ) && $main_user !== $current_user_id ) { ?>
46 <?php
47 echo \esc_html__( 'These settings have been disabled by your site administrator, please contact them for further assistance.', 'wp-2fa' );
48 ?>
49 <?php } else { ?>
50 <?php
51 /**
52 * Fires before the plugin settings rendering.
53 *
54 * @since 2.0.0
55 */
56 \do_action( WP_2FA_PREFIX . 'before_plugin_settings' );
57 ?>
58 <div class="nav-tab-wrapper">
59 <?php
60 $settings = self::settings_array();
61
62 /**
63 * Stores the default settings key, so there is no need to walk the entire array again to extract that value
64 */
65 $default_settings_key = 'generic-settings';
66
67 foreach ( $settings as $setting_tab => $setting_values ) {
68 $active_class = '';
69 if ( ! isset( $_REQUEST['tab'] ) && $setting_values['default'] ) {
70 $active_class = 'nav-tab-active';
71 $default_settings_key = $setting_tab;
72 } elseif ( isset( $_REQUEST['tab'] ) && \sanitize_text_field( \wp_unslash( $_REQUEST['tab'] ) ) === $setting_tab ) {
73 $active_class = 'nav-tab-active';
74 }
75 echo '<a href="' . esc_url( $setting_values['url'] ) . '" class="nav-tab ' . esc_attr( $active_class ) . '">' . esc_html( $setting_values['name'] ) . '</a>';
76 }
77 ?>
78 </div>
79 <?php
80 $show_tab = $default_settings_key;
81
82 if ( isset( $_REQUEST['tab'] ) && array_key_exists( \sanitize_text_field( \wp_unslash( $_REQUEST['tab'] ) ), $settings ) ) {
83 $show_tab = \sanitize_text_field( \wp_unslash( $_REQUEST['tab'] ) );
84 }
85
86 if ( WP_Helper::is_multisite() ) {
87 $action = 'edit.php?action=' . \esc_attr( $settings[ $show_tab ]['network_action'] );
88 } else {
89 $action = 'options.php';
90 }
91 ?>
92 <br/>
93
94 <form id="wp-2fa-admin-settings" action='<?php echo esc_attr( $action ); ?>' method='post' autocomplete="off" >
95 <?php
96 \call_user_func( array( $settings[ $show_tab ]['class'], $settings[ $show_tab ]['method'] ) );
97 ?>
98 </form>
99 <?php } ?>
100 </div>
101 <?php
102 }
103
104 /**
105 * Holds the array with all the settings of the plugin. Fires filter, so third parties could change these settings.
106 *
107 * @return array
108 *
109 * @since 2.2.0
110 */
111 private static function settings_array(): array {
112 $email_settings_name = \esc_html__( 'Emails & templates', 'wp-2fa' );
113 $settings_tabs = array(
114 'generic-settings' => array(
115 'url' => \esc_url(
116 add_query_arg(
117 array(
118 'page' => 'wp-2fa-settings',
119 'tab' => 'generic-settings',
120 ),
121 network_admin_url( 'admin.php' )
122 )
123 ),
124 'name' => \esc_html__( 'General', 'wp-2fa' ),
125 'default' => true,
126 'description' => sprintf(
127 '<p class="description">%1$s <a href="mailto:support@melapress.com">%2$s</a></p>',
128 \esc_html__( 'Use the settings below to configure the properties of the two-factor authentication on your website and how users use it. If you have any questions send us an email at', 'wp-2fa' ),
129 \esc_html__( 'support@melapress.com', 'wp-2fa' )
130 ),
131 'class' => 'WP2FA\Admin\SettingsPages\Settings_Page_General',
132 'method' => 'render',
133 'network_action' => 'update_wp2fa_network_options',
134 ),
135 'email-settings' => array(
136 'url' => \esc_url(
137 add_query_arg(
138 array(
139 'page' => 'wp-2fa-settings',
140 'tab' => 'email-settings',
141 ),
142 network_admin_url( 'admin.php' )
143 )
144 ),
145 'name' => $email_settings_name,
146 'default' => false,
147 'description' => sprintf(
148 '<p class="description">%1$s <a href="mailto:support@melapress.com">%2$s</a></p>',
149 \esc_html__( 'Use the settings below to configure the properties of the two-factor authentication on your website and how users use it. If you have any questions send us an email at', 'wp-2fa' ),
150 \esc_html__( 'support@melapress.com', 'wp-2fa' )
151 ),
152 'class' => 'WP2FA\Admin\SettingsPages\Settings_Page_Email',
153 'method' => 'render',
154 'network_action' => 'update_wp2fa_network_email_options',
155 ),
156 'white-label-settings' => array(
157 'url' => \esc_url(
158 add_query_arg(
159 array(
160 'page' => 'wp-2fa-settings',
161 'tab' => 'white-label-settings',
162 ),
163 network_admin_url( 'admin.php' )
164 )
165 ),
166 'name' => \esc_html__( 'White labeling', 'wp-2fa' ),
167 'default' => false,
168 'description' => sprintf(
169 '<p class="description">%1$s <a href="mailto:support@melapress.com">%2$s</a></p>',
170 \esc_html__( 'Use the settings below to configure the emails which are sent to users as part of the 2FA plugin. If you have any questions send us an email at', 'wp-2fa' ),
171 \esc_html__( 'support@melapress.com', 'wp-2fa' )
172 ),
173 'class' => 'WP2FA\Admin\SettingsPages\Settings_Page_White_Label',
174 'method' => 'render',
175 'network_action' => 'update_wp2fa_network_options',
176 ),
177 );
178
179 /**
180 * Filter: `Settings tabs`
181 *
182 * Gives an option for third parties to alter the plugin settings page
183 *
184 * @param array $settings_tabs – Settings tabs.
185 */
186 return \apply_filters( WP_2FA_PREFIX . 'settings_tabs', $settings_tabs );
187 }
188 }
189 }
190