ScriptInlineJsonBlocker
        
        extends AbstractPlugin
    
    
            
            in package
            
        
    
    
    
Check if an inline script is a localized script via e.g. `wp_set_script_translations` and check if the JSON has blocked content.
Tags
Table of Contents
Properties
- $headlessContentBlocker : mixed
 - $schemas : mixed
 
Methods
- __construct() : mixed
 - C'tor.
 - addSchema() : mixed
 - See class description.
 - afterSetup() : mixed
 - The content blocker got setup completely.
 - beforeMatch() : mixed
 - Called before a match got found.
 - beforeSetBlockedInResult() : bool
 - Allows to add an additional check before a blockable and expression gets added to a `BlockedResult`.
 - blockableStringExpression() : string
 - Allows to modify the passed string expression to a blockable.
 - blockedMatch() : mixed
 - Called after a match got blocked.
 - checkResult() : BlockedResult
 - See `AbstractPlugin`.
 - getHeadlessContentBlocker() : mixed
 - Getter.
 - init() : mixed
 - Initialize your plugin add e.g. new visual parent definitions.
 - inlineStyleBlockRule() : bool
 - Decide if a URL in a CSS rule should be blocked.
 - inlineStyleModifyDocuments() : bool
 - Allows to modify blocked CSS documents.
 - inlineStyleShouldBeExtracted() : bool
 - Do not extract blocked rules of a CSS inline script to a second document.
 - keepAlwaysAttributes() : array<string|int, string>
 - Keep attributes for a specific match.
 - modifyBlockables() : array<string|int, AbstractBlockable>
 - Modify the blockables array before it gets registered.
 - modifyHtmlAfterProcessing() : mixed
 - Allows to modify the HTML after the content blocker has done its job.
 - notBlockedMatch() : mixed
 - Called after a match got not blocked. Opposite of `blockedMatch`.
 - replaceScriptJsonContent() : mixed
 - See class description.
 - setup() : mixed
 - Before the content blocker gets setup.
 - skipInlineScriptVariableAssignment() : array<string|int, string>
 - Skip inline script by variable name.
 - visualParent() : bool|string|number
 - Set a visual parent for a specific match.
 
Properties
$headlessContentBlocker
    private
        mixed
    $headlessContentBlocker
    
    
    
    
$schemas
    private
        mixed
    $schemas
     = []
    
    
    
Methods
__construct()
C'tor.
    public
        final            __construct(HeadlessContentBlocker $headlessContentBlocker) : mixed
    Parameters
- $headlessContentBlocker : HeadlessContentBlocker
 
addSchema()
See class description.
    public
                    addSchema(string $strpos, string $pattern[, string $appendToScript = '' ]) : mixed
    Parameters
- $strpos : string
 - 
                    
Simple contains check before doing extensive preg replace
 - $pattern : string
 - 
                    
Pattern which results in a JSON string. The pattern needs to expose three capturing groups, whereas the first and the third represent begin and end, and the second one is the "JSON string" between.
 - $appendToScript : string = ''
 
Tags
afterSetup()
The content blocker got setup completely.
    public
                    afterSetup() : mixed
    beforeMatch()
Called before a match got found.
    public
                    beforeMatch(AbstractMatcher $matcher, AbstractMatch $match) : mixed
    Parameters
- $matcher : AbstractMatcher
 - $match : AbstractMatch
 
beforeSetBlockedInResult()
Allows to add an additional check before a blockable and expression gets added to a `BlockedResult`.
    public
                    beforeSetBlockedInResult(BlockedResult $result, AbstractBlockable $blockable, string $expression, AbstractMatcher $matcher) : bool
    Parameters
- $result : BlockedResult
 - $blockable : AbstractBlockable
 - $expression : string
 - $matcher : AbstractMatcher
 
Return values
boolblockableStringExpression()
Allows to modify the passed string expression to a blockable.
    public
                    blockableStringExpression(string $expression, AbstractBlockable $blockable) : string
    Parameters
- $expression : string
 - $blockable : AbstractBlockable
 
Return values
stringblockedMatch()
Called after a match got blocked.
    public
                    blockedMatch(BlockedResult $result, AbstractMatcher $matcher, AbstractMatch $match) : mixed
    Parameters
- $result : BlockedResult
 - $matcher : AbstractMatcher
 - $match : AbstractMatch
 
checkResult()
See `AbstractPlugin`.
    public
                    checkResult(BlockedResult $result, AbstractMatcher $matcher, AbstractMatch $match) : BlockedResult
    Parameters
- $result : BlockedResult
 - $matcher : AbstractMatcher
 - $match : AbstractMatch
 
Return values
BlockedResultgetHeadlessContentBlocker()
Getter.
    public
        final            getHeadlessContentBlocker() : mixed
    init()
Initialize your plugin add e.g. new visual parent definitions.
    public
                    init() : mixed
    inlineStyleBlockRule()
Decide if a URL in a CSS rule should be blocked.
    public
                    inlineStyleBlockRule(BlockedResult $result, string $url, StyleInlineMatcher|StyleInlineAttributeMatcher $matcher, StyleInlineMatch|StyleInlineAttributeMatch $match) : bool
    Parameters
- $result : BlockedResult
 - $url : string
 - $matcher : StyleInlineMatcher|StyleInlineAttributeMatcher
 - $match : StyleInlineMatch|StyleInlineAttributeMatch
 
Return values
boolinlineStyleModifyDocuments()
Allows to modify blocked CSS documents.
    public
                    inlineStyleModifyDocuments(Document $document, Document $extractedDocument, StyleInlineMatcher|StyleInlineAttributeMatcher $matcher, StyleInlineMatch|StyleInlineAttributeMatch $match) : bool
    Parameters
- $document : Document
 - $extractedDocument : Document
 - $matcher : StyleInlineMatcher|StyleInlineAttributeMatcher
 - $match : StyleInlineMatch|StyleInlineAttributeMatch
 
Return values
boolinlineStyleShouldBeExtracted()
Do not extract blocked rules of a CSS inline script to a second document.
    public
                    inlineStyleShouldBeExtracted(bool $extract, StyleInlineMatcher|StyleInlineAttributeMatcher $matcher, StyleInlineMatch|StyleInlineAttributeMatch $match) : bool
    Parameters
- $extract : bool
 - $matcher : StyleInlineMatcher|StyleInlineAttributeMatcher
 - $match : StyleInlineMatch|StyleInlineAttributeMatch
 
Return values
boolkeepAlwaysAttributes()
Keep attributes for a specific match.
    public
                    keepAlwaysAttributes(array<string|int, string> $keepAttributes, AbstractMatcher $matcher, AbstractMatch $match) : array<string|int, string>
    Parameters
- $keepAttributes : array<string|int, string>
 - $matcher : AbstractMatcher
 - $match : AbstractMatch
 
Return values
array<string|int, string>modifyBlockables()
Modify the blockables array before it gets registered.
    public
                    modifyBlockables(array<string|int, AbstractBlockable> $blockables) : array<string|int, AbstractBlockable>
    Parameters
- $blockables : array<string|int, AbstractBlockable>
 
Return values
array<string|int, AbstractBlockable>modifyHtmlAfterProcessing()
Allows to modify the HTML after the content blocker has done its job.
    public
                    modifyHtmlAfterProcessing(string $html) : mixed
    Parameters
- $html : string
 
notBlockedMatch()
Called after a match got not blocked. Opposite of `blockedMatch`.
    public
                    notBlockedMatch(BlockedResult $result, AbstractMatcher $matcher, AbstractMatch $match) : mixed
    Parameters
- $result : BlockedResult
 - $matcher : AbstractMatcher
 - $match : AbstractMatch
 
replaceScriptJsonContent()
See class description.
    public
                    replaceScriptJsonContent(ScriptInlineMatch $match, string $strpos, string $pattern[, bool|int &$result = null ][, string $appendToScript = '' ]) : mixed
    Parameters
- $match : ScriptInlineMatch
 - $strpos : string
 - 
                    
Simple contains check before doing extensive preg replace
 - $pattern : string
 - 
                    
Pattern which results in a JSON string
 - $result : bool|int = null
 - 
                    
$falseif it is not a script matching the pattern,0when there is no blocked content found within the JSON object, and1if content got blocked in JSON values. - $appendToScript : string = ''
 
Tags
setup()
Before the content blocker gets setup.
    public
                    setup() : mixed
    skipInlineScriptVariableAssignment()
Skip inline script by variable name.
    public
                    skipInlineScriptVariableAssignment(array<string|int, string> $names, ScriptInlineMatcher $matcher, ScriptInlineMatch $match) : array<string|int, string>
    Parameters
- $names : array<string|int, string>
 - $matcher : ScriptInlineMatcher
 - $match : ScriptInlineMatch
 
Return values
array<string|int, string>visualParent()
Set a visual parent for a specific match.
    public
                    visualParent(bool|string|number $visualParent, AbstractMatcher $matcher, AbstractMatch $match) : bool|string|number
    Parameters
- $visualParent : bool|string|number
 - $matcher : AbstractMatcher
 - $match : AbstractMatch