Use this filter to add or change path patterns the Malware Scanner excludes. Excluded paths are not scanned and are not reported as malware.
Summary
Filter: securityninja_malware_exclude_paths
Parameter: $paths (array of path/pattern strings)
Returns: Array of path/pattern strings
Used by: Malware Scanner (file scan and result filtering)
Usage
The filter runs when the scanner builds its ignore list. You receive the same array used for Exclude paths from scan (per-file whitelist paths plus pattern lines). Return a modified array to change exclusions without the UI.
Add one pattern
add_filter( 'securityninja_malware_exclude_paths', function ( $paths ) {
$paths[] = '*/plugins/my-custom-plugin/*';
return $paths;
} );
Add several patterns
add_filter( 'securityninja_malware_exclude_paths', function ( $paths ) {
return array_merge( $paths, array(
'*/plugins/leadpages/*',
'*/plugins/accessally/*',
'*/plugins/updraftplus/*',
'*/themes/my-theme/vendor/*',
) );
} );
Remove a pattern
add_filter( 'securityninja_malware_exclude_paths', function ( $paths ) {
return array_values( array_filter( $paths, function ( $p ) {
return $p !== '*/plugins/some-plugin/*';
} ) );
} );
Pattern format
- Each entry is one path or pattern string
- Patterns match the full server path
*is a wildcard- Matching is case-insensitive
Examples:
*/plugins/plugin-name/*: entire plugin folder*/themes/theme-name/inc/*: theme subfolder*/media/cache/*: cache directory
Where to add the code
Theme functions.php or a small custom plugin. It must load before or when the scan runs (normal WordPress loading is enough).
Related
You can also manage exclusions in Security Ninja → Malware Scanner → Exclude paths from scan. Paths from this filter apply in addition to saved settings and use the same ignore list for scanning and results.