mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-06 11:10:43 +08:00
phpDoc-Documentation
This commit is contained in:
parent
c4653a39d5
commit
e2412b786f
3 changed files with 3926 additions and 3309 deletions
|
@ -669,7 +669,7 @@ class MainWP_Child_Back_Up_WordPress {
|
|||
/**
|
||||
* Get the site size text.
|
||||
*
|
||||
* @param object HM\BackUpWordPress\Scheduled_Backup $schedule Object containing the schedule data.
|
||||
* @param HM\BackUpWordPress\Scheduled_Backup $schedule Object containing the schedule data.
|
||||
*
|
||||
* @return string Site size text.
|
||||
*/
|
||||
|
@ -692,7 +692,7 @@ class MainWP_Child_Back_Up_WordPress {
|
|||
* Get the backup table row HTML.
|
||||
*
|
||||
* @param resource $file Backup file.
|
||||
* @param object HM\BackUpWordPress\Scheduled_Backup $schedule Object containing the schedule data.
|
||||
* @param HM\BackUpWordPress\Scheduled_Backup $schedule Object containing the schedule data.
|
||||
*/
|
||||
public function hmbkp_get_backup_row( $file, HM\BackUpWordPress\Scheduled_Backup $schedule ) {
|
||||
$encoded_file = rawurlencode( base64_encode( $file ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for http encode compatible..
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* MainWP Child IThemes Security handler
|
||||
*
|
||||
* The code is used for the MainWP iThemes Security Extension.
|
||||
*
|
||||
* Credits
|
||||
*
|
||||
|
@ -11,18 +14,30 @@
|
|||
*
|
||||
* The code is used for the MainWP iThemes Security Extension
|
||||
* Extension URL: https://mainwp.com/extension/ithemes-security/
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
use MainWP\Child\MainWP_Helper;
|
||||
|
||||
// phpcs:disable -- third party credit code.
|
||||
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_IThemes_Security
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
class MainWP_Child_IThemes_Security {
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
public static $instance = null;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $is_plugin_installed = false;
|
||||
|
||||
/**
|
||||
* @return MainWP_Child_IThemes_Security|null
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
|
@ -30,6 +45,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* MainWP_Child_IThemes_Security constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
if ( is_plugin_active( 'better-wp-security/better-wp-security.php' ) || is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) {
|
||||
|
@ -43,7 +61,12 @@ class MainWP_Child_IThemes_Security {
|
|||
add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
|
||||
}
|
||||
|
||||
public function sync_others_data( $information, $data = array() ) {
|
||||
/**
|
||||
* @param $information
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function sync_others_data($information, $data = array() ) {
|
||||
if ( is_array( $data ) && isset( $data['ithemeExtActivated'] ) && ( 'yes' === $data['ithemeExtActivated'] ) ) {
|
||||
try {
|
||||
$information['syncIThemeData'] = array(
|
||||
|
@ -56,6 +79,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $information;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function action() {
|
||||
$information = array();
|
||||
if ( ! class_exists( 'ITSEC_Core' ) || ! class_exists( 'ITSEC_Modules' ) ) {
|
||||
|
@ -125,6 +151,9 @@ class MainWP_Child_IThemes_Security {
|
|||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_showhide() {
|
||||
$hide = isset( $_POST['showhide'] ) && ( 'hide' === $_POST['showhide'] ) ? 'hide' : '';
|
||||
MainWP_Helper::update_option( 'mainwp_ithemes_hide_plugin', $hide );
|
||||
|
@ -133,6 +162,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $information;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function ithemes_init() {
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
return;
|
||||
|
@ -150,11 +182,18 @@ class MainWP_Child_IThemes_Security {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function admin_init() {
|
||||
remove_meta_box( 'itsec-dashboard-widget', 'dashboard', 'normal' );
|
||||
}
|
||||
|
||||
public function all_plugins( $plugins ) {
|
||||
/**
|
||||
* @param $plugins
|
||||
* @return mixed
|
||||
*/
|
||||
public function all_plugins($plugins ) {
|
||||
foreach ( $plugins as $key => $value ) {
|
||||
$plugin_slug = basename( $key, '.php' );
|
||||
if ( 'better-wp-security' === $plugin_slug || 'ithemes-security-pro' === $plugin_slug ) {
|
||||
|
@ -165,10 +204,16 @@ class MainWP_Child_IThemes_Security {
|
|||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function remove_menu() {
|
||||
remove_menu_page( 'itsec' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function custom_admin_css() {
|
||||
?>
|
||||
<style type="text/css">
|
||||
|
@ -179,6 +224,9 @@ class MainWP_Child_IThemes_Security {
|
|||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
*/
|
||||
public function save_settings() {
|
||||
|
||||
if ( ! class_exists( 'ITSEC_Lib' ) ) {
|
||||
|
@ -353,6 +401,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function activate_network_brute_force() {
|
||||
$data = maybe_unserialize( base64_decode( $_POST['data'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for http encode compatible..
|
||||
$information = array();
|
||||
|
@ -376,7 +427,12 @@ class MainWP_Child_IThemes_Security {
|
|||
return $information;
|
||||
}
|
||||
|
||||
private function validate_directory( $name, $folder ) {
|
||||
/**
|
||||
* @param $name
|
||||
* @param $folder
|
||||
* @return bool|string
|
||||
*/
|
||||
private function validate_directory($name, $folder ) {
|
||||
require_once ITSEC_Core::get_core_dir() . 'lib/class-itsec-lib-directory.php';
|
||||
$error = null;
|
||||
if ( ! ITSEC_Lib_Directory::is_dir( $folder ) ) {
|
||||
|
@ -399,7 +455,11 @@ class MainWP_Child_IThemes_Security {
|
|||
}
|
||||
}
|
||||
|
||||
private function activate_api_key( $settings ) {
|
||||
/**
|
||||
* @param $settings
|
||||
* @return bool
|
||||
*/
|
||||
private function activate_api_key($settings ) {
|
||||
global $mainwp_itsec_modules_path;
|
||||
require_once $mainwp_itsec_modules_path . 'ipcheck/utilities.php';
|
||||
|
||||
|
@ -423,6 +483,10 @@ class MainWP_Child_IThemes_Security {
|
|||
unset( $settings['email'] );
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function backup_status() {
|
||||
$status = 0;
|
||||
if ( ! is_multisite() && class_exists( 'backupbuddy_api' ) && count( backupbuddy_api::getSchedules() ) >= 1 ) {
|
||||
|
@ -438,18 +502,27 @@ class MainWP_Child_IThemes_Security {
|
|||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function has_backup() {
|
||||
$has_backup = false;
|
||||
|
||||
return apply_filters( 'itsec_has_external_backup', $has_backup );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function scheduled_backup() {
|
||||
$sceduled_backup = false;
|
||||
|
||||
return apply_filters( 'itsec_scheduled_external_backup', $sceduled_backup );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function whitelist() {
|
||||
|
||||
global $itsec_globals;
|
||||
|
@ -481,12 +554,18 @@ class MainWP_Child_IThemes_Security {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function whitelist_release() {
|
||||
delete_site_option( 'itsec_temp_whitelist_ip' );
|
||||
|
||||
return 'success';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function backup_db() {
|
||||
global $itsec_backup, $mainwp_itsec_modules_path;
|
||||
|
||||
|
@ -522,6 +601,9 @@ class MainWP_Child_IThemes_Security {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
private function wordpress_salts() {
|
||||
global $mainwp_itsec_modules_path;
|
||||
if ( ! class_exists( 'ITSEC_WordPress_Salts_Utilities' ) ) {
|
||||
|
@ -547,6 +629,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function file_permissions() {
|
||||
require_once ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php';
|
||||
|
||||
|
@ -666,6 +751,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return array( 'html' => $html );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function file_change() {
|
||||
global $mainwp_itsec_modules_path;
|
||||
if ( ! class_exists( 'ITSEC_File_Change_Scanner' ) ) {
|
||||
|
@ -679,6 +767,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function admin_user() {
|
||||
|
||||
$settings = $_POST['settings'];
|
||||
|
@ -733,7 +824,12 @@ class MainWP_Child_IThemes_Security {
|
|||
return $return;
|
||||
}
|
||||
|
||||
private function change_admin_user( $username = null, $id = false ) {
|
||||
/**
|
||||
* @param null $username
|
||||
* @param bool $id
|
||||
* @return bool
|
||||
*/
|
||||
private function change_admin_user($username = null, $id = false ) {
|
||||
|
||||
global $wpdb;
|
||||
$itsec_files = ITSEC_Core::get_itsec_files();
|
||||
|
@ -821,7 +917,12 @@ class MainWP_Child_IThemes_Security {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function build_wpconfig_rules( $rules_array, $input = null ) {
|
||||
/**
|
||||
* @param $rules_array
|
||||
* @param null $input
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_wpconfig_rules($rules_array, $input = null ) {
|
||||
if ( null === $input ) {
|
||||
return $rules_array;
|
||||
}
|
||||
|
@ -856,6 +957,9 @@ class MainWP_Child_IThemes_Security {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function change_database_prefix() {
|
||||
global $mainwp_itsec_modules_path;
|
||||
require_once $mainwp_itsec_modules_path . 'database-prefix/utility.php';
|
||||
|
@ -887,6 +991,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function api_key() {
|
||||
$settings = get_site_option( 'itsec_ipcheck' );
|
||||
if ( ! is_array( $settings ) ) {
|
||||
|
@ -903,6 +1010,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function reset_api_key() {
|
||||
|
||||
$defaults = ITSEC_Modules::get_defaults( 'network-brute-force' );
|
||||
|
@ -922,6 +1032,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $information;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function malware_scan() {
|
||||
global $mainwp_itsec_modules_path;
|
||||
|
||||
|
@ -941,6 +1054,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function malware_get_scan_results() {
|
||||
|
||||
global $mainwp_itsec_modules_path;
|
||||
|
@ -954,6 +1070,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function purge_logs() {
|
||||
global $wpdb;
|
||||
$wpdb->query( 'DELETE FROM `' . $wpdb->base_prefix . 'itsec_log`;' );
|
||||
|
@ -962,7 +1081,12 @@ class MainWP_Child_IThemes_Security {
|
|||
}
|
||||
|
||||
|
||||
public function get_lockouts( $type = 'all', $current = false ) {
|
||||
/**
|
||||
* @param string $type
|
||||
* @param bool $current
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_lockouts($type = 'all', $current = false ) {
|
||||
|
||||
global $wpdb, $itsec_globals;
|
||||
|
||||
|
@ -1009,7 +1133,12 @@ class MainWP_Child_IThemes_Security {
|
|||
return $this->get_lockouts_int( $results, $type );
|
||||
}
|
||||
|
||||
private function get_lockouts_int( $results, $type ){
|
||||
/**
|
||||
* @param $results
|
||||
* @param $type
|
||||
* @return mixed
|
||||
*/
|
||||
private function get_lockouts_int($results, $type ){
|
||||
|
||||
if ( is_array( $results ) && count( $results ) > 0 ) {
|
||||
switch ( $type ) {
|
||||
|
@ -1049,6 +1178,9 @@ class MainWP_Child_IThemes_Security {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function release_lockout() {
|
||||
global $wpdb;
|
||||
|
||||
|
@ -1091,6 +1223,9 @@ class MainWP_Child_IThemes_Security {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function update_module_status() {
|
||||
|
||||
$active_modules = $_POST['active_modules'];
|
||||
|
@ -1108,6 +1243,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return array( 'result' => 'success' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function reload_backup_exclude() {
|
||||
return array(
|
||||
'exclude' => ITSEC_Modules::get_setting( 'backup', 'exclude' ),
|
||||
|
@ -1116,6 +1254,9 @@ class MainWP_Child_IThemes_Security {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function get_excludable_tables() {
|
||||
global $wpdb;
|
||||
$all_sites = ITSEC_Modules::get_setting( 'backup', 'all_sites' );
|
||||
|
@ -1155,6 +1296,9 @@ class MainWP_Child_IThemes_Security {
|
|||
return $excludes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function security_site() {
|
||||
global $mainwp_itsec_modules_path;
|
||||
require_once $mainwp_itsec_modules_path . 'security-check/scanner.php';
|
||||
|
@ -1169,6 +1313,9 @@ class MainWP_Child_IThemes_Security {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
*/
|
||||
public function get_available_admin_users_and_roles() {
|
||||
if ( is_callable( 'wp_roles' ) ) {
|
||||
$roles = wp_roles();
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue