Blocker
in package
Uses
UtilsProvider
Block common HTML tags!
Table of Contents
Constants
- BUTTON_CLICKED_IDENTIFIER = 'unblock'
- DEPENDANT_VISIBILITY_CONTAINERS = [ '[role="tabpanel"]', // [Plugin Comp] https://wordpress.org/plugins/essential-addons-for-elementor-lite/ '.eael-tab-content-item', // [Plugin Comp] https://de.wordpress.org/plugins/wp-contact-slider/ '.wpcs_content_inner', // [Plugin Comp] OptimizePress '.op3-contenttoggleitem-content', '.op3-popoverlay-content', // [Plugin Comp] Popup Maker '.pum-overlay', // [Plugin Comp] Elementor Pro Popups '[data-elementor-type="popup"]', // [Plugin Comp] https://ultimateblocks.com/content-toggle-accordion-block/ '.wp-block-ub-content-toggle-accordion-content-wrap', // [Plugin Comp] Impreza '.w-popup-wrap', // [Plugin Comp] Oxygen Builder '.oxy-lightbox_inner[data-inner-content=true]', '.oxy-pro-accordion_body', '.oxy-tab-content', // [Plugin Comp] https://wordpress.org/plugins/kadence-blocks/ '.kt-accordion-panel', // [Plugin Comp] WP Bakery Tabs '.vc_tta-panel-body', // [Plugin Comp] Magnific popup '.mfp-hide', // [Plugin Comp] Thrive Architect lightbox 'div[id^="tve_thrive_lightbox_"]', ]
- See `dependantVisibilityContainers` parameter in `createVisual` for more information.
- DISABLE_DEDUPLICATE_EXCEPTIONS = [ // [Plugin Comp] Divi Builder '.et_pb_video_slider', ]
- See `disableDeduplicateExceptions` parameter in `createVisual` for more information.
- FORCE_TIME_COMMENT_QUERY_ARG = 'rcb-calc-time'
- Force to output the needed computing time at the end of the page for debug purposes.
- OB_START_PLUGINS_LOADED_PRIORITY = (PHP_INT_MAX - 1) * -1
- VISUAL_PARENT_SELECTORS = [ // [Plugin Comp] Divi Builder '.et_pb_video_box' => 1, '.et_pb_video_slider:has(>.et_pb_slider_carousel %s)' => 'self', // [Theme Comp] Astra Theme (Gutenberg Block) '.ast-oembed-container' => 1, // [Plugin Comp] WP Bakery '.wpb_video_wrapper' => 1, // [Plugin Comp] GoodLayers page builder '.gdlr-core-pbf-background-wrap' => 1, ]
- See `visualParentSelectors` parameter in `findVisualParent` for more information.
Properties
- $blockedHandles : mixed
- A list of handles which got blocked. They are lazily detected through e.g. `sgo_js_minify_exclude`.
- $headlessContentBlocker : HeadlessContentBlocker
- See `HeadlessContentBlocker`
- $processedOutputBufferHtmlHashes : mixed
- A list of MD5 hashes of HTML strings which got successfully processed. This allows you to run `registerOutputBuffer` multiple times.
Methods
- autoptimize_filter_css_exclude() : mixed
- Exclude blocked styles from autoptimize inline aggregation.
- avf_exclude_assets() : mixed
- Exclude blocked styles and scripts
- closeOutputBuffer() : mixed
- Close a output buffer. This is not necessarily needed as PHP automatically closes them, but in some cases it is needed to make the modified content available to previously read output buffers in e.g.
- getHeadlessContentBlocker() : mixed
- Get `HeadlessContentBlocker` instance.
- getPluginConstantPrefix() : string
- Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
- instance() : mixed
- New instance.
- modifyOEmbedHtmlToKeepOriginalUrl() : mixed
- Modify the HTML of an oEmbed HTML and keep the original pasted URL as attribute so our headless content blocker can generate an image preview from the original URL.
- modifyUrlToSkipContentBlocker() : mixed
- Modify any URL and add a query argument to skip the content blocker mechanism.
- ob_start() : mixed
- Event for ob_start.
- registerOutputBuffer() : mixed
- Apply the content blocker attributes to the output buffer when it is enabled.
- replace() : mixed
- Apply content blockers to a given HTML. It also supports JSON output.
- sgo_css_minify_exclude() : mixed
- Exclude blocked styles from SiteGround Optimizer optimizations.
- sgo_js_minify_exclude() : mixed
- Exclude blocked scripts from SiteGround Optimizer optimizations.
- createBlockables() : array<string|int, AbstractBlockable>
- Get all available blockables.
- isAdminAjaxAction() : mixed
- Allows to modify content within a `admin-ajax.php` action.
- isCurrentRequestException() : mixed
- Check if the current request should not load any blocking mechanism depending on a special condition.
- isEnabled() : mixed
- Check if content blocker is enabled on the current request.
- iterateBlockedHandles() : mixed
- Iterate over all dependencies and add them to the blocked handles list if they are not already in the list.
- __construct() : mixed
- C'tor.
Constants
BUTTON_CLICKED_IDENTIFIER
public
mixed
BUTTON_CLICKED_IDENTIFIER
= 'unblock'
DEPENDANT_VISIBILITY_CONTAINERS
See `dependantVisibilityContainers` parameter in `createVisual` for more information.
public
mixed
DEPENDANT_VISIBILITY_CONTAINERS
= [
'[role="tabpanel"]',
// [Plugin Comp] https://wordpress.org/plugins/essential-addons-for-elementor-lite/
'.eael-tab-content-item',
// [Plugin Comp] https://de.wordpress.org/plugins/wp-contact-slider/
'.wpcs_content_inner',
// [Plugin Comp] OptimizePress
'.op3-contenttoggleitem-content',
'.op3-popoverlay-content',
// [Plugin Comp] Popup Maker
'.pum-overlay',
// [Plugin Comp] Elementor Pro Popups
'[data-elementor-type="popup"]',
// [Plugin Comp] https://ultimateblocks.com/content-toggle-accordion-block/
'.wp-block-ub-content-toggle-accordion-content-wrap',
// [Plugin Comp] Impreza
'.w-popup-wrap',
// [Plugin Comp] Oxygen Builder
'.oxy-lightbox_inner[data-inner-content=true]',
'.oxy-pro-accordion_body',
'.oxy-tab-content',
// [Plugin Comp] https://wordpress.org/plugins/kadence-blocks/
'.kt-accordion-panel',
// [Plugin Comp] WP Bakery Tabs
'.vc_tta-panel-body',
// [Plugin Comp] Magnific popup
'.mfp-hide',
// [Plugin Comp] Thrive Architect lightbox
'div[id^="tve_thrive_lightbox_"]',
]
DISABLE_DEDUPLICATE_EXCEPTIONS
See `disableDeduplicateExceptions` parameter in `createVisual` for more information.
public
mixed
DISABLE_DEDUPLICATE_EXCEPTIONS
= [
// [Plugin Comp] Divi Builder
'.et_pb_video_slider',
]
FORCE_TIME_COMMENT_QUERY_ARG
Force to output the needed computing time at the end of the page for debug purposes.
public
mixed
FORCE_TIME_COMMENT_QUERY_ARG
= 'rcb-calc-time'
OB_START_PLUGINS_LOADED_PRIORITY
public
mixed
OB_START_PLUGINS_LOADED_PRIORITY
= (PHP_INT_MAX - 1) * -1
VISUAL_PARENT_SELECTORS
See `visualParentSelectors` parameter in `findVisualParent` for more information.
public
mixed
VISUAL_PARENT_SELECTORS
= [
// [Plugin Comp] Divi Builder
'.et_pb_video_box' => 1,
'.et_pb_video_slider:has(>.et_pb_slider_carousel %s)' => 'self',
// [Theme Comp] Astra Theme (Gutenberg Block)
'.ast-oembed-container' => 1,
// [Plugin Comp] WP Bakery
'.wpb_video_wrapper' => 1,
// [Plugin Comp] GoodLayers page builder
'.gdlr-core-pbf-background-wrap' => 1,
]
Properties
$blockedHandles
A list of handles which got blocked. They are lazily detected through e.g. `sgo_js_minify_exclude`.
private
mixed
$blockedHandles
= ['js' => [], 'css' => []]
$headlessContentBlocker
See `HeadlessContentBlocker`
private
HeadlessContentBlocker
$headlessContentBlocker
$processedOutputBufferHtmlHashes
A list of MD5 hashes of HTML strings which got successfully processed. This allows you to run `registerOutputBuffer` multiple times.
private
mixed
$processedOutputBufferHtmlHashes
= []
Methods
autoptimize_filter_css_exclude()
Exclude blocked styles from autoptimize inline aggregation.
public
autoptimize_filter_css_exclude(string $exclusions) : mixed
Parameters
- $exclusions : string
Tags
avf_exclude_assets()
Exclude blocked styles and scripts
public
avf_exclude_assets(array<string|int, mixed> $assets) : mixed
Parameters
- $assets : array<string|int, mixed>
closeOutputBuffer()
Close a output buffer. This is not necessarily needed as PHP automatically closes them, but in some cases it is needed to make the modified content available to previously read output buffers in e.g.
public
closeOutputBuffer() : mixed
earlier WordPress hook lifecycle.
getHeadlessContentBlocker()
Get `HeadlessContentBlocker` instance.
public
getHeadlessContentBlocker() : mixed
getPluginConstantPrefix()
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
public
getPluginConstantPrefix() : string
Tags
Return values
stringinstance()
New instance.
public
static instance() : mixed
Tags
modifyOEmbedHtmlToKeepOriginalUrl()
Modify the HTML of an oEmbed HTML and keep the original pasted URL as attribute so our headless content blocker can generate an image preview from the original URL.
public
modifyOEmbedHtmlToKeepOriginalUrl(string $html, string $url) : mixed
Parameters
- $html : string
- $url : string
Tags
modifyUrlToSkipContentBlocker()
Modify any URL and add a query argument to skip the content blocker mechanism.
public
modifyUrlToSkipContentBlocker(string $url) : mixed
Parameters
- $url : string
ob_start()
Event for ob_start.
public
ob_start(string $response) : mixed
Parameters
- $response : string
registerOutputBuffer()
Apply the content blocker attributes to the output buffer when it is enabled.
public
registerOutputBuffer() : mixed
You can start this output buffer multiple times as it is safe to avoid execution of same strings multiple times for the headless content blocker (e.g. multiple WordPress hook lifecycle).
replace()
Apply content blockers to a given HTML. It also supports JSON output.
public
replace(string $html) : mixed
If you want to use this functionality in your plugin, please use the filter Consent/Block/HTML
instead!
Parameters
- $html : string
sgo_css_minify_exclude()
Exclude blocked styles from SiteGround Optimizer optimizations.
public
sgo_css_minify_exclude(array<string|int, string> $excluded_handles) : mixed
Parameters
- $excluded_handles : array<string|int, string>
sgo_js_minify_exclude()
Exclude blocked scripts from SiteGround Optimizer optimizations.
public
sgo_js_minify_exclude(array<string|int, string> $excluded_handles) : mixed
Parameters
- $excluded_handles : array<string|int, string>
createBlockables()
Get all available blockables.
protected
createBlockables(HeadlessContentBlocker $headlessContentBlocker) : array<string|int, AbstractBlockable>
Parameters
- $headlessContentBlocker : HeadlessContentBlocker
Return values
array<string|int, AbstractBlockable>isAdminAjaxAction()
Allows to modify content within a `admin-ajax.php` action.
protected
isAdminAjaxAction() : mixed
isCurrentRequestException()
Check if the current request should not load any blocking mechanism depending on a special condition.
protected
isCurrentRequestException() : mixed
isEnabled()
Check if content blocker is enabled on the current request.
protected
isEnabled() : mixed
iterateBlockedHandles()
Iterate over all dependencies and add them to the blocked handles list if they are not already in the list.
protected
iterateBlockedHandles(WP_Dependencies $dependencies) : mixed
Parameters
- $dependencies : WP_Dependencies
__construct()
C'tor.
private
__construct() : mixed