Scanner
in package
Uses
UtilsProvider
This isn't really a "cookie" scanner, it is a scanner which detects external URLs, scripts, iframes for the current page request. Additionally, it can automatically detect usable content blocker templates which we can recommend to the user.
Table of Contents
Constants
- QUERY_ARG_FORCE_SITEMAP = 'rcb-force-sitemap'
- See `findByRobots.txt`: This simulates to be the current blog to be public so the `robots.txt` exposes a sitemap and also activates the sitemap.
- QUERY_ARG_JOB_ID = 'rcb-scan-job'
- QUERY_ARG_TOKEN = 'rcb-scan'
- REAL_QUEUE_TYPE = 'rcb-scan'
Properties
- $onChangeDetection : mixed
- $query : mixed
Methods
- addUrlsToQueue() : mixed
- Add URLs to the queue so they get scanned.
- force_blocker_enabled() : mixed
- Force to enable the content blocker even when the content blocker is deactivated.
- getCurrentSourceUrl() : mixed
- Get the current source URL usable for a newly created `ScanEntry`. It gets escaped for database use with the help of `esc_url_raw`.
- getOnChangeDetection() : mixed
- Getter.
- getPluginConstantPrefix() : string
- Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
- getQuery() : mixed
- Getter.
- getRoleWithLeastCapabilities() : string|null
- Get the role with the least capabilities.
- instance() : mixed
- New instance.
- isActive() : mixed
- Check if the current page request should be scanned.
- probablyForceSitemaps() : mixed
- Force sitemaps in
- probablyReduceCurrentUserPermissions() : mixed
- Remove some capabilities and roles from the current user for the running page request.
- purgeUnused() : mixed
- Read a group of all known site URLs and delete them if they no longer exist in the passed URLs.
- real_queue_error_description() : mixed
- Get human-readable description for a RCB queue jobs.
- real_queue_job_actions() : mixed
- Get actions for RCB queue jobs.
- real_queue_job_label() : mixed
- Get human-readable label for RCB queue jobs.
- resolve_blockables() : mixed
- Add all known and non-disabled content blocker templates.
- teardown() : mixed
- All templates and external URLs got catched, let's persist them to database.
- doActionAddedRemoved() : mixed
- `do_action` when a result from the scanner got removed or added.
- probablyInvalidateCacheAfterJobExecution() : mixed
- Try to invalidate some caches after every scan process. The cache is invalidated in the following cases:
- __construct() : mixed
- C'tor.
Constants
QUERY_ARG_FORCE_SITEMAP
See `findByRobots.txt`: This simulates to be the current blog to be public so the `robots.txt` exposes a sitemap and also activates the sitemap.
public
mixed
QUERY_ARG_FORCE_SITEMAP
= 'rcb-force-sitemap'
QUERY_ARG_JOB_ID
public
mixed
QUERY_ARG_JOB_ID
= 'rcb-scan-job'
QUERY_ARG_TOKEN
public
mixed
QUERY_ARG_TOKEN
= 'rcb-scan'
REAL_QUEUE_TYPE
public
mixed
REAL_QUEUE_TYPE
= 'rcb-scan'
Properties
$onChangeDetection
private
mixed
$onChangeDetection
$query
private
mixed
$query
Methods
addUrlsToQueue()
Add URLs to the queue so they get scanned.
public
addUrlsToQueue(array<string|int, string> $urls[, bool $purgeUnused = false ]) : mixed
Parameters
- $urls : array<string|int, string>
- $purgeUnused : bool = false
-
If
true
, the difference of the previous scanned URLs gets automatically purged if they do no longer exist in the URLs (pass only if you have the complete sitemap!)
force_blocker_enabled()
Force to enable the content blocker even when the content blocker is deactivated.
public
force_blocker_enabled(bool $enabled) : mixed
Parameters
- $enabled : bool
getCurrentSourceUrl()
Get the current source URL usable for a newly created `ScanEntry`. It gets escaped for database use with the help of `esc_url_raw`.
public
static getCurrentSourceUrl() : mixed
getOnChangeDetection()
Getter.
public
getOnChangeDetection() : mixed
Tags
getPluginConstantPrefix()
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
public
getPluginConstantPrefix() : string
Tags
Return values
stringgetQuery()
Getter.
public
getQuery() : mixed
Tags
getRoleWithLeastCapabilities()
Get the role with the least capabilities.
public
static getRoleWithLeastCapabilities() : string|null
Return values
string|nullinstance()
New instance.
public
static instance() : mixed
Tags
isActive()
Check if the current page request should be scanned.
public
isActive() : mixed
probablyForceSitemaps()
Force sitemaps in
public
probablyForceSitemaps() : mixed
probablyReduceCurrentUserPermissions()
Remove some capabilities and roles from the current user for the running page request.
public
probablyReduceCurrentUserPermissions() : mixed
For example, some Google Analytics plugins do only print out the analytics code when
not manage_options
(e.g. WooCommerce Google Analytics).
Tags
purgeUnused()
Read a group of all known site URLs and delete them if they no longer exist in the passed URLs.
public
purgeUnused(array<string|int, string> $urls) : mixed
Parameters
- $urls : array<string|int, string>
real_queue_error_description()
Get human-readable description for a RCB queue jobs.
public
real_queue_error_description(string $description, string $type, array<string|int, int> $remaining) : mixed
Parameters
- $description : string
- $type : string
- $remaining : array<string|int, int>
real_queue_job_actions()
Get actions for RCB queue jobs.
public
real_queue_job_actions(array<string|int, array<string|int, mixed>> $actions, string $type) : mixed
Parameters
- $actions : array<string|int, array<string|int, mixed>>
- $type : string
real_queue_job_label()
Get human-readable label for RCB queue jobs.
public
real_queue_job_label(string $label, string $originalType) : mixed
Parameters
- $label : string
- $originalType : string
resolve_blockables()
Add all known and non-disabled content blocker templates.
public
resolve_blockables(array<string|int, AbstractBlockable> $blockables, HeadlessContentBlocker $headlessContentBlocker) : mixed
Parameters
- $blockables : array<string|int, AbstractBlockable>
- $headlessContentBlocker : HeadlessContentBlocker
teardown()
All templates and external URLs got catched, let's persist them to database.
public
teardown() : mixed
doActionAddedRemoved()
`do_action` when a result from the scanner got removed or added.
protected
doActionAddedRemoved(array<string|int, ScanEntry> $results, array<string|int, string> $beforeTemplates, array<string|int, string> $beforeExternalHosts, array<string|int, string> $afterTemplates, array<string|int, string> $afterExternalHosts) : mixed
Parameters
- $results : array<string|int, ScanEntry>
- $beforeTemplates : array<string|int, string>
- $beforeExternalHosts : array<string|int, string>
- $afterTemplates : array<string|int, string>
- $afterExternalHosts : array<string|int, string>
probablyInvalidateCacheAfterJobExecution()
Try to invalidate some caches after every scan process. The cache is invalidated in the following cases:
protected
probablyInvalidateCacheAfterJobExecution(Job $job) : mixed
- Scan process was done without job (e.g. calling website with
?rcb-scan
) - Scan process was done for a single website (e.g. after saving a post)
- Scan process is within a complete website then, then the following situation is implemented: Depending on the count of scanned entries, every x. job within the complete website scan invalidated the cache.
Parameters
- $job : Job
__construct()
C'tor.
private
__construct() : mixed