esc_html__( 'File change detection', 'defender-security' ), 'check_core' => esc_html__( 'Scan core files', 'defender-security' ), 'check_plugins' => esc_html__( 'Scan plugin files', 'defender-security' ), 'check_abandoned_plugin' => esc_html__( 'Outdated & removed plugins', 'defender-security' ), 'check_known_vuln' => esc_html__( 'Known vulnerabilities', 'defender-security' ), 'scan_malware' => esc_html__( 'Suspicious code', 'defender-security' ), 'filesize' => esc_html__( 'Max included file size', 'defender-security' ), 'scheduled_scanning' => esc_html__( 'Scheduled Scanning', 'defender-security' ), 'frequency' => esc_html__( 'Frequency', 'defender-security' ), 'day' => esc_html__( 'Day of the week', 'defender-security' ), 'day_n' => esc_html__( 'Day of the month', 'defender-security' ), 'time' => esc_html__( 'Time of day', 'defender-security' ), ); } /** * Check different cases for 'File change detection' option. * * @return bool */ public function is_checked_any_file_change_types(): bool { if ( ! $this->integrity_check ) { // Check the parent type. return false; } elseif ( $this->integrity_check && ! $this->check_core && ! $this->check_plugins ) { // Check the parent and child types. return false; } return true; } /** * Validates the input after form submission and adds error messages if necessary. * * @return void */ protected function after_validate(): void { // Case#1: all child types of File change detection are unchecked BUT the parent type is checked. if ( $this->integrity_check && ! $this->check_core && ! $this->check_plugins ) { $this->errors[] = sprintf( /* translators: %s: File change detection. */ esc_html__( 'You have not selected a scan type for the %s. Please choose at least one and save the settings again.', 'defender-security' ), '' . esc_html__( 'File change detection', 'defender-security' ) . '' ); // Case#2: all scan types are unchecked. } elseif ( ! $this->is_enabled_any_scan_type() ) { $this->errors[] = esc_html__( 'You have not selected a scan type. Please enable at least one scan type and save the settings again.', 'defender-security' ); } } /** * Initializes the object by setting default values. * * @return void */ protected function before_load(): void { } /** * Is enabled any scan type at least? * * @return bool */ private function is_enabled_any_scan_type(): bool { return $this->integrity_check || $this->check_known_vuln || $this->scan_malware || $this->check_abandoned_plugin; } /** * Is enabled Scheduled Scanning? * * @return bool */ public function is_enabled_scheduled_scanning(): bool { return false; } }