';
echo '
';
esc_html_e( 'Cannot run Solid Security. Error encountered during setup. Please try deactivating and reactivating Solid Security. Contact support if the error persists.', 'it-l10n-ithemes-security-pro' );
echo '
';
echo '
';
foreach ( ITSEC_Lib::get_error_strings( $this->setup_error ) as $string ) {
echo '- ' . $string . '
';
}
echo '
';
echo '
';
} );
return;
}
// If this wasn't an early load, we need to do the shared initialization.
if ( ! self::is_loading_early() ) {
$this->shared_init();
}
if ( is_admin() ) {
require( $this->plugin_dir . 'core/admin-pages/init.php' );
add_filter( 'plugin_action_links', array( $this, 'add_action_link' ), 10, 2 );
add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 4 );
}
add_action( 'wp_login_failed', array( 'ITSEC_Lib', 'handle_wp_login_failed' ) );
add_action( 'ithemes_sync_register_verbs', array( $this, 'register_sync_verbs' ) );
ITSEC_Modules::get_container()->get( Lib\Tools\Tools_Runner::class )->run();
$this->login_interstitial = new ITSEC_Lib_Login_Interstitial();
$this->login_interstitial->run();
if ( defined( 'ITSEC_USE_CRON' ) && ITSEC_USE_CRON !== ITSEC_Lib::use_cron() ) {
ITSEC_Modules::set_setting( 'global', 'use_cron', ITSEC_USE_CRON );
}
do_action( 'itsec_initialized' );
Lib\User_Actions_Background_Process::run_processes();
ITSEC_Lib_Remote_Messages::init();
$this->run_integrations();
}
/**
* Register our tables with {@see wpdb}.
*/
private function setup_tables() {
global $wpdb;
$wpdb->global_tables = array_merge( $wpdb->global_tables, ITSEC_Schema::get_table_names() );
}
private function setup_scheduler() {
if ( $this->scheduler ) {
return;
}
$choices = array(
'ITSEC_Scheduler_Cron' => $this->plugin_dir . 'core/lib/class-itsec-scheduler-cron.php',
'ITSEC_Scheduler_Page_Load' => $this->plugin_dir . 'core/lib/class-itsec-scheduler-page-load.php',
);
if ( ITSEC_Lib::use_cron() ) {
$class = 'ITSEC_Scheduler_Cron';
} else {
$class = 'ITSEC_Scheduler_Page_Load';
}
require_once( $choices[ $class ] );
$this->scheduler = new $class();
self::get_scheduler()->run();
}
/**
* Handle dynamically granting the 'itsec_manage' cap to users in the necessary group.
*
* @param array $has_caps
* @param array $requested_caps
* @param array $args
* @param WP_User $user
*
* @return array
*/
public function user_has_cap( $has_caps, $requested_caps, $args, $user ) {
if ( ! in_array( 'itsec_manage', $requested_caps, true ) ) {
return $has_caps;
}
if ( isset( $has_caps['itsec_manage'] ) ) {
return $has_caps;
}
if (
is_wp_error( $this->setup_error ) ||
self::is_temp_disable_modules_set() ||
! ITSEC_Modules::get_container()->has( User_Groups\Matcher::class ) ||
! $this->has_valid_manage_groups()
) {
$has_caps['itsec_manage'] = $user->has_cap( is_multisite() ? 'manage_network_options' : 'manage_options' );
return $has_caps;
}
$group = ITSEC_Modules::get_setting( 'global', 'manage_group' );
$matcher = ITSEC_Modules::get_container()->get( User_Groups\Matcher::class );
if ( ! $matcher->matches( User_Groups\Match_Target::for_user( $user ), $group ) ) {
return $has_caps;
}
$has_caps['itsec_manage'] = true;
return $has_caps;
}
/**
* Check if there are valid "Manage groups" selected.
*
* @return bool
*/
private function has_valid_manage_groups() {
$source = ITSEC_Modules::get_container()->get( User_Groups\Matchables_Source::class );
$groups = ITSEC_Modules::get_setting( 'global', 'manage_group' );
foreach ( $groups as $group ) {
if ( $source->has( $group ) ) {
return true;
}
}
return false;
}
/**
* Get the required capability to manage ITSEC.
*
* @return string
*/
public static function get_required_cap() {
return apply_filters( 'itsec_cap_required', 'itsec_manage' );
}
/**
* Does the current user have permission to manage ITSEC.
*
* @return bool
*/
public static function current_user_can_manage() {
return current_user_can( self::get_required_cap() );
}
/**
* Checks if the user has completed the onboarding process.
*
* @return bool
*/
public static function is_onboarded() {
return ITSEC_Modules::get_setting( 'global', 'onboard_complete' );
}
/**
* Retrieve the global instance of the files utility.
*
* @return ITSEC_Files
*/
public static function get_itsec_files() {
$self = self::get_instance();
return $self->itsec_files;
}
/**
* Retrieve the global instance of the user notification utility.
*
* @return ITSEC_Notify
*/
public static function get_itsec_notify() {
$self = self::get_instance();
return $self->itsec_notify;
}
/**
* Set the notification center instance.
*
* @param ITSEC_Notification_Center $center
*/
public static function set_notification_center( ITSEC_Notification_Center $center ) {
self::get_instance()->notifications = $center;
}
/**
* Get the notification center instance.
*
* @return ITSEC_Notification_Center
*/
public static function get_notification_center() {
return self::get_instance()->notifications;
}
/**
* Set the scheduler to use.
*
* @param ITSEC_Scheduler $scheduler
*/
public static function set_scheduler( ITSEC_Scheduler $scheduler ) {
self::get_instance()->scheduler = $scheduler;
}
/**
* Get the scheduler.
*
* @return ITSEC_Scheduler
*/
public static function get_scheduler() {
$self = self::get_instance();
if ( ! $self->scheduler ) {
$self->setup_scheduler();
}
return $self->scheduler;
}
/**
* Get the login interstitial library instance.
*
* @return ITSEC_Lib_Login_Interstitial
*/
public static function get_login_interstitial() {
return self::get_instance()->login_interstitial;
}
/**
* Retrieve the global instance of the Sync API.
*
* The API is not available until iThemes Sync verbs have been registered ( init#11 ).
*
* @return Ithemes_Sync_API|null
*/
public static function get_sync_api() {
$self = self::get_instance();
return $self->sync_api;
}
/**
* Check if an import is in progress.
*
* @return bool
*/
public static function is_importing() {
return self::get_instance()->importing;
}
/**
* Register ITSEC verbs with sync.
*
* @param Ithemes_Sync_API $sync_api
*/
public function register_sync_verbs( $sync_api ) {
// For use by the itsec-get-everything verb as it has to run other verbs to get their details.
$this->sync_api = $sync_api;
$sync_api->register( 'itsec-get-everything', 'Ithemes_Sync_Verb_ITSEC_Get_Everything', dirname( __FILE__ ) . '/sync-verbs/itsec-get-everything.php' );
}
/**
* Register core modules.
*/
public function register_modules() {
$path = dirname( __FILE__ );
ITSEC_Modules::register_module( 'feature-flags', "$path/modules/feature-flags" );
ITSEC_Modules::register_module( 'user-groups', "$path/modules/user-groups" );
ITSEC_Modules::register_module( 'global', "$path/modules/global" );
ITSEC_Modules::register_module( 'notification-center', "$path/modules/notification-center" );
ITSEC_Modules::register_module( 'privacy', "$path/modules/privacy" );
ITSEC_Modules::register_module( 'dashboard', "$path/modules/dashboard" );
ITSEC_Modules::register_module( 'admin-user', "$path/modules/admin-user" );
ITSEC_Modules::register_module( 'ban-users', "$path/modules/ban-users" );
include( "$path/modules/ban-users/init.php" ); // Provides the itsec_ban_users_handle_new_blacklisted_ip function which is always needed.
ITSEC_Modules::register_module( 'database-prefix', "$path/modules/database-prefix" );
ITSEC_Modules::register_module( 'core', "$path/modules/core" );
ITSEC_Modules::register_module( 'promos', "$path/modules/promos" );
ITSEC_Modules::register_module( 'email-confirmation', "$path/modules/email-confirmation" );
ITSEC_Modules::register_module( 'file-change', "$path/modules/file-change" );
ITSEC_Modules::register_module( 'file-permissions', "$path/modules/file-permissions" );
ITSEC_Modules::register_module( 'file-writing', "$path/modules/file-writing" );
ITSEC_Modules::register_module( 'firewall', "$path/modules/firewall" );
ITSEC_Modules::register_module( 'brute-force', "$path/modules/brute-force" );
ITSEC_Modules::register_module( 'network-brute-force', "$path/modules/network-brute-force" );
if ( ! defined( 'ITSEC_DISABLE_PASSWORD_REQUIREMENTS' ) || ! ITSEC_DISABLE_PASSWORD_REQUIREMENTS ) {
ITSEC_Modules::register_module( 'password-requirements', "$path/modules/password-requirements/" );
}
ITSEC_Modules::register_module( 'ssl', "$path/modules/ssl" );
if ( ! defined( 'BACKUPBUDDY_PLUGIN_FILE' ) || ( defined( 'ITSEC_ENABLE_BACKUPS' ) && ITSEC_ENABLE_BACKUPS ) ) {
ITSEC_Modules::register_module( 'backup', "$path/modules/backup" );
}
ITSEC_Modules::register_module( 'two-factor', "$path/modules/two-factor" );
ITSEC_Modules::register_module( 'strong-passwords', "$path/modules/strong-passwords" );
ITSEC_Modules::register_module( 'hibp', "$path/modules/hibp" );
ITSEC_Modules::register_module( 'system-tweaks', "$path/modules/system-tweaks" );
ITSEC_Modules::register_module( 'wordpress-salts', "$path/modules/salts" );
ITSEC_Modules::register_module( 'wordpress-tweaks', "$path/modules/wordpress-tweaks" );
ITSEC_Modules::register_module( 'security-check-pro', "$path/modules/security-check-pro" );
ITSEC_Modules::register_module( 'site-scanner', "$path/modules/site-scanner" );
ITSEC_Modules::register_module( 'malware-scheduling', "$path/modules/malware-scheduling" );
ITSEC_Modules::register_module( 'hide-backend', "$path/modules/hide-backend" );
}
/**
* Runs any global ITSEC integrations.
*/
private function run_integrations() {
if ( function_exists( 'restrict_content_pro' ) ) {
require_once self::get_core_dir() . '/integrations/rcp.php';
}
}
/**
* Add action link to plugin page.
*
* Adds plugin settings link to plugin page in WordPress admin area.
*
* @since 4.0
*
* @param array $links Array of WordPress links
* @param string $file String name of current file
*
* @return array Array of WordPress links
*/
public function add_action_link( $links, $file ) {
static $this_plugin;
if ( empty( $this_plugin ) ) {
$this_plugin = str_replace( WP_PLUGIN_DIR . '/', '', self::get_plugin_file() );
}
if ( $file == $this_plugin ) {
$settings_link = '