For the developer
Files:
- PHP:
includes/class-builder-os-layout.php: registration, render, loading, editor, preview REST and locking.includes/layout/:class-builder-os-layout-widgets.php(widget schema and render),-kit.php(package look),-presets.php(structures and templates),-icons.php(SVG) and-mcp.php.
- Frontend:
public/css/builder-os-layout.cssandpublic/js/builder-os-layout.js. - Editor:
admin/js/builder-os-layout.js(blocks and inspector),admin/js/builder-os-layout-panel.js(library and dragging),admin/css/builder-os-layout-editor.cssandadmin/css/builder-os-layout-canvas.css.
| Hook | Type | Use |
|---|---|---|
builder_os_layout_widgets | filter | Add or change widgets. See “How to add a widget.” |
builder_os_layout_icons | filter | Icon set: clave => [label, svg, fill]. |
builder_os_layout_structures, builder_os_layout_models | filter | “New section” structures and templates (clave => [label, cols/icon, content]). |
builder_os_layout_package | filter | ( $slug, $content ): the package that gives a page its look. By default, its sections’; if none, the canvas header’s; otherwise, the first one. |
builder_os_lock_design_attrs | filter | ( $attrs, $block_name ): a block’s design attributes, in addition to bosStyles, bosAnim… |
builder_os_lock_design_candidates | filter | ( $designs, $block_name ): designs that the “Content and sections” level can insert as is. |
builder_os_mcp_describe_block | filter | ( null, $entry, $lang ): a block’s own description in get_page. |
builderos.panel.elements, builderos.panel.sections | JS filter | ( body, ctx ): content of the elements panel’s tabs. |
builderos.panel.dropTarget | JS filter | ( target, x, y, payload ): a custom drag target { rect, line, label, onDrop }. |
API:
- PHP:
Builder_OS_Layout::render_widget( $key, $attrs )andwidget_parts().Builder_OS_Layout_Kit::get( $slug )andbridge_css( $kit ).Builder_OS_Components::enqueue_assets( $early ).Builder_OS_Lock::design_from()anddesign_attrs().
- REST:
POST /builder-os/v1/layout/renderwith{ items: [ { name, attributes } ], post_id }. It returns{ items: [ { class, html } ] }and requiresedit_posts. It’s the editor’s preview, batched and cached. - JS:
BuilderOSLayout.init( ámbito )(frontend) andBuilderOSLayoutEditor.createWidget( { block, attrs } ).
MCP (in addition to get_page):
get_layout_catalog: widgets with their fields, structures, templates and button styles.add_layout_section:page_id,presetandat. Requires “Content and sections” or “Full.”add_layout_widget:page_id,parent(index of the section or container),widget,valuesandat. Requires “Full.”update_layout_widget:page_id,block,valuesandstyles.add_layout_widgetandupdate_layout_widgetalso acceptconditions(bosCond:{ action, match, rules };nullremoves them),hide(bosHide: devices where it isn’t shown, e.g.["m"],["d","t"]; empty removes it) anddyn_styles(bosDynStyles;nullremoves them), and indynamicthemodsfield with the modifiers.get_layout_catalogincludesmodifiersandconditions(types,shapeand an example per type);get_pagedescribes each block’shide,conditionsanddyn_styles(filterbuilder_os_mcp_describe_block). They require “Full.”
How to add a widget (in a plugin or in the theme’s functions.php):
add_filter( 'builder_os_layout_widgets', function ( $widgets ) {
$widgets['aviso-legal'] = array(
'title' => 'Aviso legal',
'icon' => 'shield', // Dashicon del panel
'cat' => 'content', // basic, layout, media, interactive, content, site, advanced
'fields' => array(
'texto' => array( 'type' => 'textarea', 'label' => 'Texto', 'default' => 'Precios con IVA.' ),
'tono' => array( 'type' => 'select', 'label' => 'Tono', 'default' => 'suave',
'options' => array( 'suave' => 'Suave', 'fuerte' => 'Fuerte' ), 'design' => true, 'mod' => true ),
'alineacion' => array( 'type' => 'css', 'label' => 'Alineación', 'part' => 'r', 'prop' => 'text-align', 'control' => 'align' ),
),
'parts' => array( 'texto' => array( 'label' => 'Texto', 'groups' => array( 'typography', 'colors' ) ) ),
'render' => function ( $a, $ctx ) {
return '<p class="aviso-legal__texto bu-texto">' . esc_html( $a['texto'] ) . '</p>';
},
);
return $widgets;
} );- The block will be named
bos-builder/aviso-legal. BuilderOS adds the root<div class="bos-w bos-w-aviso-legal bos-w-aviso-legal--tono-suave">, the styles, the animation and the anchor. - The editor generates the controls from the schema. Field types:
text,textarea,inline,richtext,code,number,range,toggle,select,icon,color,date,link,image,images,itemsandcss(the last one isn’t an attribute: it’s saved inbosStylesper device). - Flags:
design: the field goes to the Style tab and is protected by locking.mod: adds the classbos-w-<widget>--<campo>-<valor>to the root.comp: the widget is an interactive component.js: it needsbuilder-os-layout.js.
- The editor renders the widget with this same render (REST preview). Escape everything with
esc_html(),esc_url()andwp_kses_post(). - Apply the look rules from the “How the site’s look is inherited” section: typography and color with
:where()or inherited, and structure with classes.
Limitations:
- The preview of widgets that can’t be edited inline comes from the server; it takes a few tenths of a second after each change.
- Text with several paragraphs or lists is edited in the panel (HTML), not inline.
- Page widths come from
--container. If the package doesn’t define it, 1200 px is used even if its sections are wider (see “How the site’s look is inherited”). - Posts use their own card; for a custom card, use the List.
- Dynamic data is available in widgets’ standalone fields, not inside item lists (a carousel’s cards, tabs…).
- The Table doesn’t support HTML in cells (text only).
- A List as a carousel has no pagination; in the editor it shows as a grid.
- The background video is a file (MP4 or WebM), not YouTube or Vimeo. No Lottie.
- The bar’s slot in the header needs the package’s header (
headerparts or site templates). Without it, the bar renders as a “full-width bar.” - The palette offers up to 16 package colors.
Widgets, viewer and dynamic content
New files:
includes/layout/class-builder-os-layout-widgets-pro.php: the 19 advanced widgets (same API asBuilder_OS_Layout_Widgets, which now exposes its utilities asprotected).includes/layout/class-builder-os-layout-dynamic.php: dynamic content (Builder_OS_Layout_Dynamic).includes/layout/class-builder-os-layout-lightbox.php: viewer (Builder_OS_Lightbox).public/css/builder-os-layout-pro.css,public/js/builder-os-lightbox.jsandpublic/css/builder-os-lightbox.css.
New hooks:
| Hook | Type | Use |
|---|---|---|
builder_os_dynamic_tags | filter | ( $tags ): add dynamic data. See “How to add a dynamic datum.” |
builder_os_dynamic_allow_meta | filter | ( false, $key ): allows showing a protected field (_clave). |
builder_os_dynamic_preview_post | filter | ( $sample, $template ): sample post for previewing a theme template. |
builder_os_query_args | filter (existing) | Now also for the List: ( $args, [ 'widget' => 'loop', 'attributes' => … ] ). |
Widget schema — new flags:
css => 'pro': its CSS is inbuilder-os-layout-pro.css(loaded only if used). For a custom widget, enqueue your stylesheet in its render or withwp_enqueue_scripts.nested => [ 'template' => [ [ bloque, attrs, [ hijos ] ], … ], 'label' => '…', 'when' => [ campo => valor ] ]: the widget has blocks inside (InnerBlocks). The editor shows and saves them;whendecides when they’re used. The render receives the block in$ctx['block'](WP_Block) and its inner HTML in$ctx['content'].- The render can return
[ 'html' => …, 'class' => …, 'data' => [ … ] ].datareaches the editor preview (the List sends the first post).
API:
- PHP:
Builder_OS_Layout_Dynamic::resolve( $tag, $cfg, $type, $ctx ),::apply( $def, $attrs, $ctx )and::catalog().Builder_OS_Lightbox::need()enqueues the viewer from a render.Builder_OS_Layout_Widgets::lightbox_link( $html, $image, $group, $caption )and::full_url( $image ).Builder_OS_Layout::need_component()and::require_js()enqueue the components or the builder’s JS from a render.Builder_OS_Layout_Presets::newsletter_form()returns the form preset.
- REST
POST /builder-os/v1/layout/render: each item supportspost(the context post for dynamic data) andinner(serialized inner blocks). - JS:
BuilderOSLightbox.open( elemento | [ { src, alt, caption } ], índice ),.close()and.init( ámbito ).BuilderOSShell.ContextMenu: BuilderOS’s context menu ({ x, y, groups, onClose }).
How to add a dynamic datum:
add_filter( 'builder_os_dynamic_tags', function ( $tags ) {
// label, grupo, tipos (text | link | image), opciones [ clave => [ label, placeholder ] ], callback, '' | 'client' | 'session'
$tags['telefono-sede'] = array(
'Teléfono de la sede',
'site',
array( 'text', 'link' ),
array(),
function ( $opts, $post, $ctx ) {
$tel = get_option( 'mi_telefono', '' );
return 'link' === $opts['type'] ? 'tel:' . preg_replace( '/\D+/', '', $tel ) : $tel;
},
);
return $tags;
} );- The callback returns text, a URL or an image (attachment id, URL or
[ id, url, alt ]). $optsholds the chosen options (key,format…) andtype(the field type).- For a datum that depends on the visitor, mark
'session'(session only: the page isn’t cached). The'client'ones are BuilderOS’s (the browser renders them).
Viewer in your own HTML: <a href="grande.jpg" data-lightbox="grupo" data-caption="Pie"><img …></a> (or data-lightbox on an <img>, which gets focus and a button role). In an HTML widget you write it the same way. In package templates, data-bos-lightbox (see chapter 12).
Hooks and API of the second batch:
| Hook | Type | Use |
|---|---|---|
builder_os_part_html | filter | ( $html, $role ): already rendered HTML of a part (header or footer). The builder uses it for the bar “in the header.” |
builder_os_number_format | filter | Numeric conventions per language (see “Numbers and currency”). |
API:
Builder_OS_Layout_Kit::palette( $kit ),::tone_of( $kit, $color )→[ valor, texto legible ].Builder_OS_Layout_Widgets::number(),::percent(),::amount(),::money( $cantidad, $moneda, 'auto'|'before'|'after' ),::lang(),::number_rules(),::url_size( $url ),::skins().- Field schema:
tone_field()(palettecontrol,--bos-tone) andskin_field()(card style) for custom widgets. Builder_OS_Layout::with_tone_text( $styles ),::section_bars( $block ),::in_header_slot( $valores ).Builder_OS_Layout_Presets::booking_form().skinattribute on sections and containers (classbos-l-skin-<estilo>).StylePanel(BuilderOSDesign) supportshovercontrolled from outside (withhideHead).
Theme Builder and site widgets
New files:
includes/layout/class-builder-os-theme-builder.php(Builder_OS_Theme_Builder): parts, conditions, render, templates, panel and editor.includes/layout/class-builder-os-layout-widgets-site.php(Builder_OS_Layout_Widgets_Site): Navigation menu, Language selector, Compact search, Account button and Cart.public/css/builder-os-nav.css,public/js/builder-os-nav.js(BuilderOSNav.init( ámbito )),admin/js/builder-os-theme-builder.js.
| Hook | Type | Use |
|---|---|---|
builder_os_theme_part | filter | ( $post|null, $role ): the builder’s header or footer shown on the current page. |
builder_os_theme_header_models, builder_os_theme_footer_models | filter | ( $models, $kit ): “Create a header / a footer” templates (clave => [ label, descripción, ajustes, bloques ]). |
Data: bos_template with _bos_template_type = header or footer and the _bos_part metadata (JSON): mode (all|include|exclude), ids, special (front, single, archive, search, 404), langs, sticky and overlay ({d,t,m}), hide, bg2, fg2, shadow.
PHP API: Builder_OS_Theme_Builder::resolve( $role ), ::render( $role ), ::create( $role, $model, $lang, $title ), ::settings( $id ), ::sanitize( $data ), ::has_parts(), ::rendering(). Builder_OS_Layout::require_style( 'nav' ) and ::require_handle( 'nav' ) enqueue the stylesheet and script of a widget group.
Widget schema — what’s new:
css => 'nav'/js => 'nav': its own stylesheet and script (builder-os-<nombre>), notbuilder-os-layout.js.- Field
show => [ campo => valor | [valores] ]: the field only shows with those values (e.g. “Width inside the header” only with “Inside the header”). - Field
heading => 'Móvil': a subtitle before the field in the inspector. cssfield withcontrol => 'color': color (package palette or free) in a root variable, per device.options => 'menus'withmenuLinks => true: a menu selector with “Edit this menu ↗.”- Box style
notchinBuilder_OS_Layout_Widgets::skins().
Limitations:
- The mobile menu’s side panel uses
position: fixed: if an ancestor container hastransform,filterorbackdrop-filter, the panel ends up inside that container. Don’t put those properties on the header section (the glass goes on the links). - “Transparent over the hero” doesn’t add padding to the first section: add it in that section.
- MCP: headers, footers and theme templates are created, listed with their conditions and deleted (trash) with
create_theme_part,create_theme_template,list_theme_templates,set_template_conditionsanddelete_theme_template; their content is edited withget_page/update_layout_widgeton theirbos_template(see the tools table in the MCP chapter). - The templates’ newsletter is the visual form with the inline preset; its button doesn’t carry the arrow in a circle.