PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/behavior/scan/class-abandoned-plugin.php +23 -17 5.5.1 → 6.3.0 View file →
@@ -7,8 +7,9 @@
7 7
8 8 namespace WP_Defender\Behavior\Scan;
9 9
10 10 use Calotes\Component\Behavior;
11 +use WP_Defender\Component\Scan as Scan_Component;
11 12 use WP_Defender\Controller\Scan as Scan_Controller;
12 13 use WP_Defender\Model\Scan;
13 14 use WP_Defender\Model\Scan_Item;
14 15 use WP_Defender\Traits\IO;
@@ -49,11 +50,12 @@
49 50 * Get the outdated period of the plugin.
50 51 *
51 52 * @return string
52 53 */
53 - public static function get_outdated_period() {
54 + public static function get_outdated_period(): string {
54 55 // Filter to override outdated threshold period.
55 - $period = (string) apply_filters( 'wpdef_scan_outdated_period', self::OUTDATED_PERIOD );
56 + $period = apply_filters( 'wpdef_scan_outdated_period', self::OUTDATED_PERIOD );
57 + $period = is_string( $period ) ? $period : (string) $period;
56 58 // If time period is invalid, use the default one.
57 59 return strtotime( '- ' . $period ) ? $period : self::OUTDATED_PERIOD;
58 60 }
59 61
@@ -63,14 +65,15 @@
63 65 * @return bool
64 66 */
65 67 public function abandoned_plugin_check(): bool {
66 68 $ignored_issues = $this->get_ignored_issues();
67 - $model = $this->scan;
68 69
69 - foreach ( $this->get_plugin_slugs() as $slug ) {
70 - if ( is_object( $model ) && $model->is_issue_ignored( $slug ) ) {
71 - continue;
72 - }
70 + $actioned_plugins = get_site_option( Scan_Component::PLUGINS_ACTIONED );
71 + $plugin_list = Scan_Component::are_actioned_plugins( $actioned_plugins )
72 + ? $actioned_plugins
73 + : $this->get_plugin_slugs();
74 +
75 + foreach ( $plugin_list as $slug => $plugin_data ) {
73 76 $this->check_abandoned_plugin_by( $slug );
74 77 }
75 78
76 79 $this->scan->calculate_percent( 100, 4 );
@@ -100,13 +103,9 @@
100 103 *
101 104 * @param array $ignored_issues The array of ignored issues to add.
102 105 */
103 106 private function add_ignored_issues( array $ignored_issues ) {
104 - if ( ! empty( $ignored_issues ) ) {
105 - foreach ( $ignored_issues as $issue ) {
106 - $this->scan->add_item( $issue->type, $issue->raw_data, Scan_Item::STATUS_IGNORE );
107 - }
108 - }
107 + $this->scan->carry_forward_ignored_issues( Scan::get_abandoned_types(), $ignored_issues, 'slug' );
109 108 }
110 109
111 110 /**
112 111 * Handle the error by different actions, e.g. logging.
@@ -195,13 +194,15 @@
195 194 return $data;
196 195 }
197 196
198 197 /**
199 - * Get list of plugin slugs whose names do not match the specified names.
198 + * Get list of plugin slugs whose names do not match the specified names on wp.org.
200 199 */
201 200 private function get_plugin_slugs_with_mismatched_names(): array {
202 201 return array(
203 202 'miniorange-malware-protection',
203 + 'admin-bar-user-switching',
204 + 'custom-post-template',
204 205 );
205 206 }
206 207
207 208 /**
@@ -211,12 +212,17 @@
211 212 *
212 213 * @return bool
213 214 */
214 215 public function check_abandoned_plugin_by( string $slug ): bool {
215 - $premium_plugin_slugs = get_site_option( Plugin_Integrity::PLUGIN_PREMIUM_SLUGS, false );
216 - if ( is_array( $premium_plugin_slugs ) && in_array( $slug, $premium_plugin_slugs, true ) ) {
216 + // Check if the plugin is not from wp.org.
217 + $premium_plugin_slugs = get_site_option( Plugin_Integrity::PLUGIN_PREMIUM_SLUGS, array() );
218 + if ( ( is_array( $premium_plugin_slugs ) && in_array( $slug, $premium_plugin_slugs, true ) )
219 + || ! $this->is_likely_wporg_slug( $slug )
220 + ) {
217 221 return true;
218 - } elseif ( ! $this->is_likely_wporg_slug( $slug ) ) {
222 + }
223 + if ( $this->scan->is_issue_ignored( $slug ) ) {
224 + $this->log( sprintf( 'skip %s because it is already ignored.', $slug ), Scan_Controller::SCAN_LOG );
219 225 return true;
220 226 }
221 227
222 228 $results = $this->handle_wp_org_response_by( $slug );
@@ -231,9 +237,9 @@
231 237 isset( $body_json['name'], $plugin_details['Name'] )
232 238 && $plugin_details['Name'] !== $body_json['name']
233 239 && ! in_array( $slug, $this->get_plugin_slugs_with_mismatched_names(), true )
234 240 ) {
235 - // This is premium plugin with the same slug as on wp.org but with another name value.
241 + // This is a premium plugin with the same slug as on wp.org but with another name OR the plugin developer named the plugin differently on wp.org and inside the main file.
236 242 return false;
237 243 }
238 244
239 245 if ( isset( $body_json['error'] ) && 'closed' === $body_json['error'] ) {