id = 'malware-scan'; $this->title = __( 'Malware Scan', 'better-wp-security' ); $this->priority = 8; parent::__construct(); } public function enqueue_scripts_and_styles() { $vars = array( 'clickedButtonText' => __( 'Scanning...', 'better-wp-security' ), 'showDetailsText' => __( 'Show Details', 'better-wp-security' ), 'hideDetailsText' => __( 'Hide Details', 'better-wp-security' ), ); wp_enqueue_script( 'itsec-settings-malware-scan-settings-script', plugins_url( 'js/settings-page.js', __FILE__ ), array( 'jquery' ), $this->script_version, true ); wp_localize_script( 'itsec-settings-malware-scan-settings-script', 'itsecMalwareScanData', $vars ); wp_enqueue_style( 'itsec-settings-malware-scan-style', plugins_url( 'css/settings.css', __FILE__ ), array(), $this->script_version ); } public function handle_ajax_request( $data ) { require_once( dirname( __FILE__ ) . '/class-itsec-malware-scanner.php' ); require_once( dirname( __FILE__ ) . '/class-itsec-malware-scan-results-template.php' ); $temporary_error = false; if ( ! ITSEC_Core::current_user_can_manage() ) { $results = new WP_Error( 'itsec-settings-malware-scan-insufficient-privileges', __( 'An error prevented the scan from completing as expected. The currently logged in user does not have sufficient permissions to run this scan. You may need to log out of the site and log back in.', 'better-wp-security' ) ); } else { $results = ITSEC_Malware_Scanner::scan(); $temporary_error = ITSEC_Malware_Scanner::is_sucuri_error( $results ); } if ( $temporary_error ) { ITSEC_Response::add_warning( __( 'Malware scanning is temporarily unavailable, please try again later.', 'better-wp-security' ) ); } else { ITSEC_Response::set_response( ITSEC_Malware_Scan_Results_Template::get_html( $results, true ) ); } } public function render( $form ) { ?>