CssBlocker
in package
Takes a match and checks for blocked URLs. If there got something blocked, you can extract two CSS documents.
Table of Contents
Constants
- DEFAULT_DUMMY_URL = 'https://assets.devowl.io/packages/devowl-wp/headless-content-blocker/'
- EXTRACT_COMPLETE_AT_RULE_INSTEAD_OF_SINGLE_PROPERTY = ['font-face']
Properties
- $blockedUrls : array<string|int, string>
- Blocked URLs.
- $extract : mixed
- $match : mixed
- $matcher : mixed
Methods
- __construct() : mixed
- C'tor.
- createResultForSingleUrl() : BlockedResult
- Check if a given URL is blocked.
- parse() : mixed
- Parse a CSS and remove blocked URLs.
- generateDummyUrl() : mixed
- Get the new URL for a blocked value.
- generateLocationChangeSet() : mixed
- Generate a list of changed `URL`s with their new URL. It also respects rule sets which needs to be completely blocked and moved to the extracted document (e.g. `@font-face`).
- generateLocationChangeSetForSingleValue() : mixed
- Generate a list of changed `URL`s with their new URL for a single value inside our parsed document.
- getStyle() : mixed
- Get the style as string from our match.
Constants
DEFAULT_DUMMY_URL
public
mixed
DEFAULT_DUMMY_URL
= 'https://assets.devowl.io/packages/devowl-wp/headless-content-blocker/'
EXTRACT_COMPLETE_AT_RULE_INSTEAD_OF_SINGLE_PROPERTY
public
mixed
EXTRACT_COMPLETE_AT_RULE_INSTEAD_OF_SINGLE_PROPERTY
= ['font-face']
Properties
$blockedUrls
Blocked URLs.
private
array<string|int, string>
$blockedUrls
= []
$extract
private
mixed
$extract
$match
private
mixed
$match
$matcher
private
mixed
$matcher
Methods
__construct()
C'tor.
public
__construct(bool $extract, StyleInlineAttributeMatch|StyleInlineMatch $match, AbstractMatcher $matcher) : mixed
Parameters
- $extract : bool
- $match : StyleInlineAttributeMatch|StyleInlineMatch
- $matcher : AbstractMatcher
createResultForSingleUrl()
Check if a given URL is blocked.
public
createResultForSingleUrl(string $url) : BlockedResult
Parameters
- $url : string
Return values
BlockedResultparse()
Parse a CSS and remove blocked URLs.
public
parse() : mixed
generateDummyUrl()
Get the new URL for a blocked value.
protected
generateDummyUrl(BlockedResult $result, string $dummyFileName, string $originalUrl) : mixed
Parameters
- $result : BlockedResult
- $dummyFileName : string
- $originalUrl : string
generateLocationChangeSet()
Generate a list of changed `URL`s with their new URL. It also respects rule sets which needs to be completely blocked and moved to the extracted document (e.g. `@font-face`).
protected
generateLocationChangeSet(Document $document) : mixed
Parameters
- $document : Document
generateLocationChangeSetForSingleValue()
Generate a list of changed `URL`s with their new URL for a single value inside our parsed document.
protected
generateLocationChangeSetForSingleValue(Document $document, Value $val, bool $extract, array<string|int, mixed> &$removed, array<string|int, mixed> &$setUrlChanges) : mixed
Parameters
- $document : Document
- $val : Value
- $extract : bool
- $removed : array<string|int, mixed>
- $setUrlChanges : array<string|int, mixed>
getStyle()
Get the style as string from our match.
protected
getStyle() : mixed