| @@ -52,9 +52,10 @@ | ||
| 52 | 52 | * @return string |
| 53 | 53 | */ |
| 54 | 54 | public static function get_outdated_period(): string { |
| 55 | 55 | // Filter to override outdated threshold period. |
| 56 | - $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; | |
| 57 | 58 | // If time period is invalid, use the default one. |
| 58 | 59 | return strtotime( '- ' . $period ) ? $period : self::OUTDATED_PERIOD; |
| 59 | 60 | } |
| 60 | 61 | |
| @@ -102,13 +103,9 @@ | ||
| 102 | 103 | * |
| 103 | 104 | * @param array $ignored_issues The array of ignored issues to add. |
| 104 | 105 | */ |
| 105 | 106 | private function add_ignored_issues( array $ignored_issues ) { |
| 106 | - if ( ! empty( $ignored_issues ) ) { | |
| 107 | - foreach ( $ignored_issues as $issue ) { | |
| 108 | - $this->scan->add_item( $issue->type, $issue->raw_data, Scan_Item::STATUS_IGNORE ); | |
| 109 | - } | |
| 110 | - } | |
| 107 | + $this->scan->carry_forward_ignored_issues( Scan::get_abandoned_types(), $ignored_issues, 'slug' ); | |
| 111 | 108 | } |
| 112 | 109 | |
| 113 | 110 | /** |
| 114 | 111 | * Handle the error by different actions, e.g. logging. |
| @@ -203,8 +200,9 @@ | ||
| 203 | 200 | private function get_plugin_slugs_with_mismatched_names(): array { |
| 204 | 201 | return array( |
| 205 | 202 | 'miniorange-malware-protection', |
| 206 | 203 | 'admin-bar-user-switching', |
| 204 | + 'custom-post-template', | |
| 207 | 205 | ); |
| 208 | 206 | } |
| 209 | 207 | |
| 210 | 208 | /** |
| @@ -215,14 +213,18 @@ | ||
| 215 | 213 | * @return bool |
| 216 | 214 | */ |
| 217 | 215 | public function check_abandoned_plugin_by( string $slug ): bool { |
| 218 | 216 | // Check if the plugin is not from wp.org. |
| 219 | - $premium_plugin_slugs = get_site_option( Plugin_Integrity::PLUGIN_PREMIUM_SLUGS, false ); | |
| 217 | + $premium_plugin_slugs = get_site_option( Plugin_Integrity::PLUGIN_PREMIUM_SLUGS, array() ); | |
| 220 | 218 | if ( ( is_array( $premium_plugin_slugs ) && in_array( $slug, $premium_plugin_slugs, true ) ) |
| 221 | 219 | || ! $this->is_likely_wporg_slug( $slug ) |
| 222 | 220 | ) { |
| 223 | 221 | return true; |
| 224 | 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 ); | |
| 225 | + return true; | |
| 226 | + } | |
| 225 | 227 | |
| 226 | 228 | $results = $this->handle_wp_org_response_by( $slug ); |
| 227 | 229 | if ( ! $results['success'] ) { |
| 228 | 230 | $this->handle_error( $results['message'] ); |
| @@ -235,9 +237,9 @@ | ||
| 235 | 237 | isset( $body_json['name'], $plugin_details['Name'] ) |
| 236 | 238 | && $plugin_details['Name'] !== $body_json['name'] |
| 237 | 239 | && ! in_array( $slug, $this->get_plugin_slugs_with_mismatched_names(), true ) |
| 238 | 240 | ) { |
| 239 | - // This is premium plugin with the same slug as on wp.org but with another name value OR the plugin developer named the plugin differently on wp.org and inside the main file. | |
| 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. | |
| 240 | 242 | return false; |
| 241 | 243 | } |
| 242 | 244 | |
| 243 | 245 | if ( isset( $body_json['error'] ) && 'closed' === $body_json['error'] ) { |