set_user_settings_page_slug('two-factor-auth-user');
$settings_page_heading = sprintf(__('Two Factor Authentication (Version: %s) - Admin Settings', 'all-in-one-wp-security-and-firewall'), $this->version);
$this->set_settings_page_heading($settings_page_heading);
$this->set_plugin_translate_url('https://translate.wordpress.org/projects/wp-plugins/two-factor-authentication/');
$this->set_site_wide_administration_url(admin_url('options-general.php?page=two-factor-auth'));
$this->set_premium_version_url('https://www.simbahosting.co.uk/s3/product/two-factor-authentication/');
$this->set_faq_url('https://wordpress.org/plugins/two-factor-authentication/#faq');
parent::__construct();
}
/**
* Runs upon the WP filters plugin_action_links_(plugin) and network_plugin_action_links_(plugin)
*
* @param Array $links
*
* @return Array
*/
public function add_plugin_settings_link($links) {
if (is_multisite()) {
$main_site_id = function_exists('get_main_site_id') ? get_main_site_id() : 1;
switch_to_blog($main_site_id);
$link = $this->get_settings_link();
restore_current_blog();
array_unshift($links, $link);
} else {
$link = $this->get_settings_link();
array_unshift($links, $link);
}
$link2 = ''.__('User settings', 'two-factor-authentication').'';
array_unshift($links, $link2);
return $links;
}
/**
* Get 2FA settings anchor tag link.
*
* @return string 2FA settings anchor tag link.
*/
private function get_settings_link() {
return ''.__('Plugin settings', 'two-factor-authentication').'';
}
/**
* Runs upon the WP actions admin_menu and network_admin_menu
*/
public function menu_entry_for_user() {
$this->get_totp_controller()->potentially_port_private_keys();
global $current_user;
if ($this->is_activated_for_user($current_user->ID)) {
add_menu_page(__('Two Factor Authentication', 'two-factor-authentication'), __('Two Factor Auth', 'two-factor-authentication'), 'read', 'two-factor-auth-user', array($this, 'show_dashboard_user_settings_page'), $this->includes_url().'/tfa_admin_icon_16x16.png', 72);
}
}
/**
* Runs upon the WP action admin_menu
*/
public function menu_entry_for_admin() {
$this->get_totp_controller()->potentially_port_private_keys();
$skip_adding_options_menu_entry = (is_multisite() && (!is_super_admin() || !is_main_site()));
$skip_adding_options_menu_entry = apply_filters('simba_tfa_skip_adding_options_menu_entry', $skip_adding_options_menu_entry);
if ($skip_adding_options_menu_entry) return;
add_options_page(
__('Two Factor Authentication', 'two-factor-authentication'),
__('Two Factor Authentication', 'two-factor-authentication'),
$this->get_management_capability(),
'two-factor-auth',
array($this, 'show_admin_settings_page')
);
}
/**
* Include the admin settings page code
*/
public function show_admin_settings_page() {
$totp_controller = $this->get_totp_controller();
$totp_controller->setUserHMACTypes();
if (!is_admin() || !current_user_can($this->get_management_capability())) return;
$admin_settings_links = array();
if (!class_exists('Simba_Two_Factor_Authentication_Premium')) {
$admin_settings_links[] = array(
'url' => esc_url('https://www.simbahosting.co.uk/s3/product/two-factor-authentication/'),
'title' => __('Premium version', SIMBA_TFA_TEXT_DOMAIN),
);
}
$simba_tfa_support_url = apply_filters('simba_tfa_support_url', esc_url('https://wordpress.org/support/plugin/two-factor-authentication/'));
$admin_settings_links[] = array(
'url' => $simba_tfa_support_url,
'title' => __('Support', SIMBA_TFA_TEXT_DOMAIN),
);
$admin_settings_links[] = array(
'url' => esc_url('https://profiles.wordpress.org/davidanderson#content-plugins'),
'title' => __('More free plugins', SIMBA_TFA_TEXT_DOMAIN),
);
$admin_settings_links[] = array(
'url' => esc_url('http://updraftplus.com'),
'title' => 'UpdraftPlus - '.__('WordPress backups', SIMBA_TFA_TEXT_DOMAIN),
);
$admin_settings_links[] = array(
'url' => esc_url('https://www.simbahosting.co.uk/s3/shop/'),
'title' => __('More premium plugins', SIMBA_TFA_TEXT_DOMAIN),
);
$admin_settings_links[] = array(
'url' => esc_url('https://twitter.com/updraftplus'),
'title' => __('Twitter', SIMBA_TFA_TEXT_DOMAIN),
);
$admin_settings_links[] = array(
'url' => esc_url('http://david.dw-perspective.org.uk'),
'title' => __('Lead developer\'s homepage', SIMBA_TFA_TEXT_DOMAIN),
);
$admin_settings_links = apply_filters('simba_tfa_admin_settings_links', $admin_settings_links);
$this->include_template('admin-settings.php', array(
'totp_controller' => $totp_controller,
'settings_page_heading' => $this->get_settings_page_heading(),
'admin_settings_links' => $admin_settings_links,
));
}
/**
* Runs conditionally on the WP action all_admin_notices
*/
public function admin_notice_insufficient_php() {
$this->show_admin_warning(''.__('Higher PHP version required', 'two-factor-authentication').'
'.sprintf(__('The Two Factor Authentication plugin requires PHP version %s or higher - your current version is only %s.', 'two-factor-authentication'), self::PHP_REQUIRED, PHP_VERSION), 'error');
}
/**
* Runs conditionally on the WP action all_admin_notices
*/
public function admin_notice_missing_mcrypt_and_openssl() {
$this->show_admin_warning(''.__('PHP OpenSSL or mcrypt module required', 'two-factor-authentication').'
'.__('The Two Factor Authentication plugin requires either the PHP openssl (preferred) or mcrypt module to be installed. Please ask your web hosting company to install one of them.', 'two-factor-authentication'), 'error');
}
/**
* Run upon the WP plugins_loaded action. This method is called even if main loading aborts - so don't put anything else in it (use a separate method).
*/
public function plugins_loaded_load_textdomain() {
load_plugin_textdomain(
'two-factor-authentication',
false,
dirname(plugin_basename(__FILE__)).'/languages/'
);
}
}
endif;
$GLOBALS['simba_two_factor_authentication'] = new Simba_Two_Factor_Authentication_Plugin();
if (file_exists(__DIR__.'/simba-tfa/premium/loader.php') && empty($GLOBALS['simba_two_factor_authentication_premium'])) {
if (!class_exists('Simba_Two_Factor_Authentication_Premium')) include_once(__DIR__.'/simba-tfa/premium/loader.php');
$GLOBALS['simba_two_factor_authentication_premium'] = new Simba_Two_Factor_Authentication_Premium($GLOBALS['simba_two_factor_authentication']);
if (!class_exists('Updraft_Manager_Updater_1_8')) require_once(plugin_dir_path(__FILE__).'vendor/davidanderson684/simba-plugin-manager-updater/class-udm-updater.php');
try {
new Updraft_Manager_Updater_1_8('https://www.simbahosting.co.uk/s3', 1, 'two-factor-authentication-premium/two-factor-login.php', array('require_login' => false));
} catch (Exception $e) {
error_log($e->getMessage());
}
}