FirstTimeWizardSteps.php
4 years ago
WizardSteps.php
4 years ago
class-settings-page-render.php
4 years ago
class-settings-page-render.php
168 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Settings page render class. |
| 4 | * |
| 5 | * @package wp2fa |
| 6 | * @copyright 2021 WP White Security |
| 7 | * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 |
| 8 | * @link https://wordpress.org/plugins/wp-2fa/ |
| 9 | */ |
| 10 | |
| 11 | namespace WP2FA\Admin\Views; |
| 12 | |
| 13 | use \WP2FA\WP2FA; |
| 14 | use WP2FA\Admin\SettingsPages\{ |
| 15 | Settings_Page_General, |
| 16 | Settings_Page_White_Label, |
| 17 | Settings_Page_Email |
| 18 | }; |
| 19 | |
| 20 | /** |
| 21 | * Settings_Page_Render - Class for rendering the plugin settings settings |
| 22 | * |
| 23 | * @since 2.0.0 |
| 24 | */ |
| 25 | class Settings_Page_Render { |
| 26 | |
| 27 | /** |
| 28 | * Render the settings |
| 29 | */ |
| 30 | public function render() { |
| 31 | if ( ! current_user_can( 'manage_options' ) ) { |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | $user = wp_get_current_user(); |
| 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 | } else { |
| 39 | $main_user = ''; |
| 40 | } |
| 41 | ?> |
| 42 | |
| 43 | <div class="wrap wp-2fa-settings-wrapper"> |
| 44 | <h2><?php esc_html_e( 'WP 2FA Settings', 'wp-2fa' ); ?></h2> |
| 45 | <hr> |
| 46 | <?php if ( ! empty( WP2FA::get_wp2fa_general_setting( 'limit_access' ) ) && $main_user !== $user->ID ) : ?> |
| 47 | <?php |
| 48 | echo esc_html__( 'These settings have been disabled by your site administrator, please contact them for further assistance.', 'wp-2fa' ); |
| 49 | ?> |
| 50 | <?php else : ?> |
| 51 | <?php do_action( 'wp2fa_before_plugin_settings' ); ?> |
| 52 | <div class="nav-tab-wrapper"> |
| 53 | <a href=" |
| 54 | <?php |
| 55 | echo esc_url( |
| 56 | add_query_arg( |
| 57 | array( |
| 58 | 'page' => 'wp-2fa-settings', |
| 59 | ), |
| 60 | network_admin_url( 'admin.php' ) |
| 61 | ) |
| 62 | ); |
| 63 | ?> |
| 64 | " class="nav-tab <?php echo (! isset( $_REQUEST['tab']) || isset( $_REQUEST['tab'] ) && 'email-settings' === $_REQUEST['tab'] ) ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Email Settings & Templates', 'wp-2fa' ); // @codingStandardsIgnoreLine - No nonce verification warning?></a> |
| 65 | <a href=" |
| 66 | <?php |
| 67 | echo esc_url( |
| 68 | add_query_arg( |
| 69 | array( |
| 70 | 'page' => 'wp-2fa-settings', |
| 71 | 'tab' => 'generic-settings', |
| 72 | ), |
| 73 | network_admin_url( 'admin.php' ) |
| 74 | ) |
| 75 | ); |
| 76 | ?> |
| 77 | " class="nav-tab <?php echo isset( $_REQUEST['tab'] ) && 'generic-settings' === $_REQUEST['tab'] ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'General plugin settings', 'wp-2fa' ); // @codingStandardsIgnoreLine - No nonce verification warning?></a> |
| 78 | <a href=" |
| 79 | <?php |
| 80 | echo esc_url( |
| 81 | add_query_arg( |
| 82 | array( |
| 83 | 'page' => 'wp-2fa-settings', |
| 84 | 'tab' => 'white-label-settings', |
| 85 | ), |
| 86 | network_admin_url( 'admin.php' ) |
| 87 | ) |
| 88 | ); |
| 89 | ?> |
| 90 | " class="nav-tab <?php echo isset( $_REQUEST['tab'] ) && 'white-label-settings' === $_REQUEST['tab'] ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'White labeling', 'wp-2fa' ); // @codingStandardsIgnoreLine - No nonce verification warning?></a> |
| 91 | </div> |
| 92 | <?php |
| 93 | if ( WP2FA::is_this_multisite() ) { |
| 94 | $action = 'edit.php?action=update_wp2fa_network_options'; |
| 95 | } else { |
| 96 | $action = 'options.php'; |
| 97 | } |
| 98 | if ( isset( $_REQUEST['tab'] ) && 'generic-settings' === $_REQUEST['tab'] ) : // @codingStandardsIgnoreLine - No nonce verification warning |
| 99 | ?> |
| 100 | <br/> |
| 101 | <?php |
| 102 | printf( |
| 103 | '<p class="description">%1$s <a href="mailto:support@wpwhitesecurity.com">%2$s</a></p>', |
| 104 | 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' ), |
| 105 | esc_html__( 'support@wpwhitesecurity.com', 'wp-2fa' ) |
| 106 | ); |
| 107 | ?> |
| 108 | <br/> |
| 109 | <?php $total_users = count_users(); ?> |
| 110 | <form id="wp-2fa-admin-settings" action='<?php echo esc_attr( $action ); ?>' method='post' autocomplete="off" data-2fa-total-users="<?php echo esc_attr( $total_users['total_users'] ); ?>"> |
| 111 | <?php |
| 112 | $settings_general = new Settings_Page_General(); |
| 113 | $settings_general->render(); |
| 114 | ?> |
| 115 | </form> |
| 116 | <?php endif; ?> |
| 117 | <?php |
| 118 | if ( isset( $_REQUEST['tab'] ) && 'white-label-settings' === $_REQUEST['tab'] ) : // @codingStandardsIgnoreLine - No nonce verification warning |
| 119 | ?> |
| 120 | <br/> |
| 121 | <?php |
| 122 | printf( |
| 123 | '<p class="description">%1$s <a href="mailto:support@wpwhitesecurity.com">%2$s</a></p>', |
| 124 | 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' ), |
| 125 | esc_html__( 'support@wpwhitesecurity.com', 'wp-2fa' ) |
| 126 | ); |
| 127 | ?> |
| 128 | <br/> |
| 129 | <?php $total_users = count_users(); ?> |
| 130 | <form id="wp-2fa-admin-settings" action='<?php echo esc_attr( $action ); ?>' method='post' autocomplete="off" data-2fa-total-users="<?php echo esc_attr( $total_users['total_users'] ); ?>"> |
| 131 | <?php |
| 132 | $settings_white_label = new Settings_Page_White_Label(); |
| 133 | $settings_white_label->render(); |
| 134 | ?> |
| 135 | </form> |
| 136 | <?php endif; ?> |
| 137 | |
| 138 | <?php |
| 139 | if ( WP2FA::is_this_multisite() ) { |
| 140 | $action = 'edit.php?action=update_wp2fa_network_email_options'; |
| 141 | } else { |
| 142 | $action = 'options.php'; |
| 143 | } |
| 144 | ?> |
| 145 | |
| 146 | <?php if ( ! isset( $_REQUEST['tab'] ) || isset( $_REQUEST['tab'] ) && 'email-settings' === $_REQUEST['tab'] ) : // @codingStandardsIgnoreLine - No nonce verification warning?> |
| 147 | <br/> |
| 148 | <?php |
| 149 | printf( |
| 150 | '<p class="description">%1$s <a href="mailto:support@wpwhitesecurity.com">%2$s</a></p>', |
| 151 | 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' ), |
| 152 | esc_html__( 'support@wpwhitesecurity.com', 'wp-2fa' ) |
| 153 | ); |
| 154 | ?> |
| 155 | <br/> |
| 156 | <form action='<?php echo esc_attr( $action ); ?>' method='post' autocomplete="off"> |
| 157 | <?php |
| 158 | $settings_email = new Settings_Page_Email(); |
| 159 | $settings_email->render(); |
| 160 | ?> |
| 161 | </form> |
| 162 | <?php endif; ?> |
| 163 | <?php endif; ?> |
| 164 | </div> |
| 165 | <?php |
| 166 | } |
| 167 | } |
| 168 |