| @@ -15,9 +15,8 @@ | ||
| 15 | 15 | use WP_Defender\Traits\Formats; |
| 16 | 16 | use Calotes\Component\Behavior; |
| 17 | 17 | use WP_Defender\Model\Scan_Item; |
| 18 | 18 | use WP_Defender\Traits\File_Operations; |
| 19 | -use WP_Defender\Component\Quarantine as Quarantine_Component; | |
| 20 | 19 | use WP_Filesystem_Base; |
| 21 | 20 | |
| 22 | 21 | /** |
| 23 | 22 | * Class Plugin_Integrity |
| @@ -37,16 +36,14 @@ | ||
| 37 | 36 | */ |
| 38 | 37 | public function to_array(): array { |
| 39 | 38 | $data = $this->owner->raw_data; |
| 40 | 39 | $file = $data['file']; |
| 41 | - list ( $file_created_at, $file_size, $deleted ) = $this->get_file_meta( $file ); | |
| 40 | + list( $file_created_at, $file_size, $deleted ) = $this->get_file_meta( $file ); | |
| 42 | 41 | |
| 43 | - $is_quarantinable = $this->is_quarantinable( $this->owner->raw_data['file'] ); | |
| 42 | + if ( class_exists( 'WP_Defender\Component\Quarantine' ) ) { | |
| 43 | + $quarantine_data = wd_di()->get( \WP_Defender\Component\Quarantine::class )->scan_item_data( $this->owner ); | |
| 44 | + } | |
| 44 | 45 | |
| 45 | - $quarantine_data = class_exists( 'WP_Defender\Component\Quarantine' ) ? | |
| 46 | - wd_di()->get( Quarantine_Component::class )->scan_item_data( $this->owner ) : | |
| 47 | - array( 'is_quarantinable' => $is_quarantinable ); | |
| 48 | - | |
| 49 | 46 | return array_merge( |
| 50 | 47 | array( |
| 51 | 48 | 'id' => $this->owner->id, |
| 52 | 49 | 'type' => Scan_Item::TYPE_PLUGIN_CHECK, |
| @@ -133,12 +130,26 @@ | ||
| 133 | 130 | * |
| 134 | 131 | * @return array An array with a message indicating successful ignore. |
| 135 | 132 | */ |
| 136 | 133 | public function ignore(): array { |
| 137 | - $scan = Scan::get_last(); | |
| 138 | - $scan->ignore_issue( $this->owner->id ); | |
| 134 | + $scan = Scan::get_last(); | |
| 135 | + $data = $this->owner->raw_data; | |
| 136 | + $issue_name = '<b>' . pathinfo( $data['file'], PATHINFO_BASENAME ) . '</b>'; | |
| 137 | + $res = $scan->ignore_issue( $this->owner->id ); | |
| 138 | + if ( ! $res ) { | |
| 139 | + return array( | |
| 140 | + 'type_notice' => 'error', | |
| 141 | + 'message' => $this->get_failed_ignore_result( $issue_name ), | |
| 142 | + ); | |
| 143 | + } | |
| 139 | 144 | |
| 140 | - return array( 'message' => esc_html__( 'The suspicious file has been successfully ignored.', 'defender-security' ) ); | |
| 145 | + return array( | |
| 146 | + 'message' => sprintf( | |
| 147 | + /* translators: %s: Scan issue name. */ | |
| 148 | + esc_html__( 'You’ve successfully ignored the security issue related to %s.', 'defender-security' ), | |
| 149 | + $issue_name | |
| 150 | + ), | |
| 151 | + ); | |
| 141 | 152 | } |
| 142 | 153 | |
| 143 | 154 | /** |
| 144 | 155 | * Allow the suspicious file for the current scan. |