Repository navigation
Api Block Bindings
Since: 2.1.0 (native attribute support); helpers since 2.4.0 per source @since tags
DesignSetGo integrates with the WordPress 6.9 Block Bindings API on two levels: it opts its own block attributes into the native binding pipeline, and it ships a set of ready-made binding sources plus public PHP helpers so third-party plugins can register their own sources with the same security model.
See also:
- REST API Reference — Dynamic Query and llms.txt endpoints
- MARKDOWN-CONTENT-NEGOTIATION.md — per-URL Markdown feature
Source: includes/bindings/class-block-bindings-support.php
DesignSetGo blocks participate in the WordPress 6.9 block_bindings_supported_attributes filter so their attributes can be driven by any Block Bindings source (DesignSetGo's own sources, WP core's core/post-meta, or any custom source) via the editor's Connections panel.
Safe on WordPress < 6.9 — add_filter() registers the callback but the filter is never invoked on older versions, so no runtime check is required.
| Block | Bindable Attributes |
|---|---|
designsetgo/heading-segment |
content |
designsetgo/breadcrumbs |
homeText, prefixText
|
designsetgo/query-pagination |
labelLoadMore, labelLoading, buttonLabelWhenPaused
|
content on designsetgo/heading-segment is an HTML-sourced attribute, so WordPress's HTML API rewrites the rendered markup automatically. The Breadcrumbs and Query Pagination attributes flow into render_callback via $block->attributes — no extra plumbing is required.
Use the designsetgo_block_bindings_supported_attributes filter to add bindable attributes to any DesignSetGo block. The filter receives and must return an array<string, string[]> (block name → attribute names).
add_filter(
'designsetgo_block_bindings_supported_attributes',
function ( array $map ): array {
// Make the 'caption' attribute on your custom block bindable.
$map['designsetgo/my-block'][] = 'caption';
return $map;
}
);Requirement: the attribute must be readable at render time — either via an HTML-sourced attribute selector or via a render_callback that reads $block->attributes. Static (comment-only) attributes on blocks without a render_callback will not bind correctly.
Five binding sources ship with the plugin. Each accepts a scope arg to target the correct post in nested-loop contexts (see Nested Loop Context below).
Source: includes/bindings/class-query-bindings.php, includes/bindings/class-query-bindings-metabox.php, includes/bindings/class-query-bindings-pods.php, includes/bindings/class-query-bindings-jetengine.php, includes/bindings/class-query-bindings-helpers.php
Always available. Reads a raw post meta value via get_post_meta().
{
"type": "designsetgo/post-meta",
"args": { "key": "event_date" }
}Registers when Advanced Custom Fields (ACF) is active (function_exists('get_field')). Delegates to get_field() for formatted output.
For array fields (image, file, relationship), pass args.subkey to extract a scalar:
{
"type": "designsetgo/acf",
"args": { "key": "hero_image", "subkey": "url" }
}Allowed subkey values: url, id, alt, width, height, title, caption.
Registers when Meta Box is active (function_exists('rwmb_meta')). Delegates to rwmb_meta( $key, [], $post_id ) so formatted dates, files, and relationship values render correctly.
{
"type": "designsetgo/metabox",
"args": { "key": "mb_event_date" }
}Registers when Pods is active (function_exists('pods_field')). Delegates to pods_field( $pod_type, $post_id, $field_name ) where $pod_type is resolved from the post ID via get_post_type().
{
"type": "designsetgo/pods",
"args": { "key": "pods_speaker" }
}Registers when JetEngine is active (class_exists('Jet_Engine') && function_exists('jet_engine')). Prefers jet_engine()->listings->data->get_meta( $key, $post_id ) for field-type formatting; falls back to raw get_post_meta() when the listings data object is unavailable.
{
"type": "designsetgo/jetengine",
"args": { "key": "je_price" }
}All five sources accept a scope arg that controls which post in a nested-loop context is read:
scope value |
Meaning |
|---|---|
self (default) |
The block's own postId context (or get_the_ID()). |
parent |
The ancestor one level up in $GLOBALS['designsetgo_parent_stack']. |
root |
The outermost (first) entry in the parent stack. |
{
"type": "designsetgo/post-meta",
"args": { "key": "author_bio", "scope": "parent" }
}All five sources are registered via designsetgo_register_bindings_source(), which enforces three shared gates before calling the underlying callback:
-
Post-password gate — returns
nullfor password-protected posts. -
Viewable gate — returns
nullfor non-public posts the current user cannot read. -
Protected-meta gate — returns
nullwhenargs.keyis a protected meta key (prefixed with_).
Array or object values that cannot be reduced to a scalar (e.g., an ACF relationship field without subkey) are also silently dropped.
Source: includes/bindings/class-query-bindings-helpers.php
Wraps WordPress core's register_block_bindings_source() and injects the shared security gates and scope resolution described above.
function designsetgo_register_bindings_source(
string $slug,
callable $callback,
array $options = []
): voidParameters
| Parameter | Type | Description |
|---|---|---|
$slug |
string |
Binding source slug, e.g. 'myplugin/my-source'. |
$callback |
callable |
Value callback. Receives ( array $args, ?WP_Block $block, string $attribute_name ). $args['__dsgo_post_id'] is pre-populated with the scope-resolved post ID. |
$options |
array |
Optional. Keys: label (human-readable label, defaults to $slug), uses_context (additional context keys; postId is always included). |
Silent no-ops:
-
register_block_bindings_source()does not exist (WordPress < 6.5). - A source with the same
$slugis already registered.
Example
add_action( 'init', function () {
designsetgo_register_bindings_source(
'myplugin/event-meta',
function ( array $args, $block, string $attr ): ?string {
$post_id = (int) ( $args['__dsgo_post_id'] ?? 0 );
$key = sanitize_text_field( $args['key'] ?? '' );
if ( ! $post_id || ! $key ) {
return null;
}
return get_post_meta( $post_id, $key, true ) ?: null;
},
[
'label' => __( 'Event Meta', 'myplugin' ),
'uses_context' => [ 'postType' ], // merged with 'postId'
]
);
} );Exposes the scope-aware post-ID resolution for callers that register directly via core register_block_bindings_source() and need to honour the scope arg themselves.
function designsetgo_resolve_bindings_post_id(
array $args,
?WP_Block $block
): intReturns the resolved post ID, or 0 when the requested scope cannot be resolved.
Resolution order:
-
$args['__dsgo_post_id']if already populated (REST preview context). -
$args['scope'](self/parent/root) resolved via$GLOBALS['designsetgo_parent_stack']. -
$block->context['postId'](withWP_Block::$available_contextreflection fallback). -
get_the_ID().
When the designsetgo/query block renders each item, it pushes an entry onto $GLOBALS['designsetgo_parent_stack'] before rendering inner blocks. This array is available to any render_block hook fired inside a query item.
An ordered list of context entries, oldest (outermost) first:
[
[ 'postId' => 42, 'postType' => 'post' ], // outermost query item
[ 'postId' => 17, 'postType' => 'product' ], // inner query item (current)
]Use scope: 'parent' (penultimate entry) or scope: 'root' (first entry) to reach ancestor contexts. scope: 'self' (default) reads the current (innermost) entry.
Inner blocks inside a query item receive the following block context:
| Context Key | Type | Description |
|---|---|---|
designsetgo/parentItem |
object |
{ postId, postType } of the outer query's current item, available for nested loop bindings. |
designsetgo/groupLabel |
string |
Human-readable group label when groupBy is active (e.g., term name, meta value, year). |
designsetgo/groupValue |
string |
Machine-readable group key (slug, meta key, ISO date fragment). Prefer this for comparisons and links. |
designsetgo/groupLabel and designsetgo/groupValue are used by the designsetgo/group-context binding source (registered in class-query-bindings.php), which powers the designsetgo/query-group-header block. Core blocks that don't declare usesContext for these keys are served via WP_Block::$available_context reflection.
The dsgoStyleBinding block attribute maps CSS property names (including CSS custom properties) to a DesignSetGo binding source and key. Values are injected as inline styles on the block root element via a render_block filter, using the same security gates as the Block Bindings sources above (url(, expression(, javascript:, data:, ;, {, } are all rejected).
Full documentation: ../extensions/STYLE-BINDING.md · ../extensions/DYNAMIC-TAGS.md
Source: includes/features/class-style-binding.php
Auto-generated from
docs/api/BLOCK-BINDINGS.md. To update, edit the source file and changes will sync on next push to main.
- Accordion
- Advanced Heading
- Blobs
- Breadcrumbs
- Card
- Chart
- Comparison Table
- Countdown Timer
- Counter Group
- Divider
- Dynamic Image
- Fifty Fifty
- Flip Card
- Form Builder
- Grid
- Hotspot
- Icon
- Icon Button
- Icon List
- Image Accordion
- Map
- Modal
- Modal Api Reference
- Modal Auto Triggers
- Modal Fse Compatibility
- Modal Gallery Navigation
- Modal Trigger
- Pill
- Product Categories Grid
- Product Showcase Hero
- Progress Bar
- Query
- Query Filter
- Query Group Header
- Query No Results
- Query Pagination
- Query Results
- Row
- Scroll Accordion
- Scroll Marquee
- Scroll Slides
- Section
- Section Divider
- Slider
- Star Rating
- Sticky Sections
- Table Of Contents
- Tabs
- Text Path
- Timeline
- Background Video
- Block Animations
- Clickable Group
- Conditional Visibility
- Custom Css
- Draft Mode
- Dynamic Tags
- Expanding Background
- Grid Mobile Order
- Grid Span
- Hover Effects
- Max Width
- Responsive Visibility
- Reveal Control
- Scroll Parallax
- Sticky Header
- Style Binding
- Svg Patterns
- Text Alignment Inheritance
- Text Reveal
- Abilities Api
- Abilities Api Guide
- Block Bindings
- Draft Mode Api
- Form Webhooks
- Generation Contract
- Interactive Blocks
- Layout Flexibility
- Markdown Content Negotiation
- Rest Api Reference
- Wp Cli Reference
- Ai Assisted Development
- Best Practices Summary
- Block Controls Organization
- Block Development Best Practices Comprehensive
- Block Exclusion Guide
- Deploying To Wordpress Org
- Design System
- 2026 04 16 Blocks Editor Ux Design
- 2026 04 17 Theme 3 Inspector Ia
- 2026 04 21 Query Block Onboarding
- 2026 04 21 Query Capable Layout Blocks Design
- 2026 04 27 Block Roadmap Ideas
- 2026 07 01 Shape Divider Theme Inheritance
- 2026 07 02 Icon Block Dynamic Render Pilot
- 2026 07 06 Section Divider Block Design
- 2026 07 06 Section Style Variations Fse Design
- 2026 07 06 Section Styles Editor Preview
- 2026 07 07 Row Grid Overlay Hover Parity Design
- 2026 07 21 Conditional And Dup Label Sourcing
- 2026 07 23 Theme Block Type Animation Defaults
- 2026 08 16 Chart Block
- 2026 08 16 Greenshift Gap Roadmap
- 2026 08 17 Woocommerce Surface
- 2026 08 24 Loop Carousel
- 2026 08 24 Star Rating Block
- 2026 09 17 Abilities Drift Prevention
- 2026 09 17 Abilities Drift Prevention Implementation
- 2026 09 29 Existing User Regression Fixes
- 2026 09 29 Release Preflight Fixes
- Readme
- 2026 07 02 Block Authorability Audit
- 2026 09 29 Regression Fixes
- 2026 09 29 Release 2.9.0
- 2026 09 29 Release Fixes
- 2026 10 19 Bug Hunt
- 2026 10 20 Bug Hunt Round 2