Hooks & Filters
Filters#
| Filter | Arguments | Purpose |
|---|---|---|
section_blocks_pro_block_is_visible | bool $visible, array $attrs, array $block | Final say on whether a Section Blocks block with conditions is shown on this request. Runs after the login, role and date checks. Return false to hide, true to show. |
section_blocks_pro_storeengine_product_id | int $product_id | Override the store product ID used for licensing. For custom builds only. |
section_blocks_pro_storeengine_store_url | string $url | Override the store URL used for licensing and updates. For custom builds only. |
section_blocks_pro_storeengine_allow_local | bool $allow | Whether license activation is allowed on local hosts. Default true. |
section_blocks_pro_store_dashboard_url | string $url | URL of the “Manage License” link on the license screen. |
There are no actions and no shortcodes.
section_blocks_pro_block_is_visible only runs for blocks that have at least one condition set, and only while Pro is active with a valid license. It does not run for the device rule, which is CSS.
Example: hide a block from users without an active membership#
Suppose a membership plugin stores access in user meta rather than in roles. Combine the block’s roles check with your own:
add_filter( 'section_blocks_pro_block_is_visible', function ( $visible, $attrs, $block ) {
// Only touch blocks the editor limited to logged-in users.
if ( ! $visible || ( $attrs['sbpVisibility'] ?? '' ) !== 'logged-in' ) {
return $visible;
}
return (bool) get_user_meta( get_current_user_id(), 'membership_active', true );
}, 10, 3 );
Example: always show conditional blocks to administrators#
Useful on staging, so editors can review scheduled content on the public site:
add_filter( 'section_blocks_pro_block_is_visible', function ( $visible ) {
return $visible || current_user_can( 'manage_options' );
} );
Example: hide a specific block type on a specific page#
add_filter( 'section_blocks_pro_block_is_visible', function ( $visible, $attrs, $block ) {
if ( 'section-blocks/promo-banner' === ( $block['blockName'] ?? '' ) && is_page( 'checkout' ) ) {
return false;
}
return $visible;
}, 10, 3 );
Confirm the exact block names in the free plugin (they are listed by section_blocks_get_block_names() when the free plugin is active) before relying on a hard-coded name.
Block attributes#
Pro registers these attributes on every Section Blocks block, on the server (register_block_type_args) and in the editor.
| Attribute | Type | Values |
|---|---|---|
sbpVisibility | string | '' (everyone), logged-in, logged-out |
sbpRoles | string[] | Role slugs, used only with logged-in |
sbpDevice | string | '' (all), mobile, desktop |
sbpDateStart | string | YYYY-MM-DDTHH:MM as saved by the editor’s date-time field, interpreted in the site time zone |
sbpDateEnd | string | Same format |
CSS classes#
| Class | Added when |
|---|---|
sbp-only-mobile | Device is “Mobile only”; hidden at 768px and up |
sbp-only-desktop | Device is “Desktop and tablet only”; hidden below 768px |
To change the breakpoint, dequeue the inline style for the section-blocks-pro-conditional-display handle and add your own media queries for these classes.
Helper functions and constants#
| Name | Purpose |
|---|---|
section_blocks_pro_features_enabled() | true when the free plugin is compatible and the license is valid. Use it to guard your own Pro-dependent code. |
Section_Blocks_Pro_License::is_active() | License validity from local state (no remote call). |
SECTION_BLOCKS_PRO_VERSION | Plugin version string. |
SECTION_BLOCKS_PRO_MIN_FREE_VERSION | Lowest free Section Blocks version Pro runs with (1.3.0). |
