For the developer

For developersVersion 1.0.0Last updated:

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.css and public/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.css and admin/css/builder-os-layout-canvas.css.
HookTypeUse
builder_os_layout_widgetsfilterAdd or change widgets. See “How to add a widget.”
builder_os_layout_iconsfilterIcon set: clave => [label, svg, fill].
builder_os_layout_structures, builder_os_layout_modelsfilter“New section” structures and templates (clave => [label, cols/icon, content]).
builder_os_layout_packagefilter( $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_attrsfilter( $attrs, $block_name ): a block’s design attributes, in addition to bosStyles, bosAnim…
builder_os_lock_design_candidatesfilter( $designs, $block_name ): designs that the “Content and sections” level can insert as is.
builder_os_mcp_describe_blockfilter( null, $entry, $lang ): a block’s own description in get_page.
builderos.panel.elements, builderos.panel.sectionsJS filter( body, ctx ): content of the elements panel’s tabs.
builderos.panel.dropTargetJS filter( target, x, y, payload ): a custom drag target { rect, line, label, onDrop }.

API:

  • PHP:
    • Builder_OS_Layout::render_widget( $key, $attrs ) and widget_parts().
    • Builder_OS_Layout_Kit::get( $slug ) and bridge_css( $kit ).
    • Builder_OS_Components::enqueue_assets( $early ).
    • Builder_OS_Lock::design_from() and design_attrs().
  • REST: POST /builder-os/v1/layout/render with { items: [ { name, attributes } ], post_id }. It returns { items: [ { class, html } ] } and requires edit_posts. It’s the editor’s preview, batched and cached.
  • JS: BuilderOSLayout.init( ámbito ) (frontend) and BuilderOSLayoutEditor.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, preset and at. Requires “Content and sections” or “Full.”
  • add_layout_widget: page_id, parent (index of the section or container), widget, values and at. Requires “Full.”
  • update_layout_widget: page_id, block, values and styles.
  • add_layout_widget and update_layout_widget also accept conditions (bosCond: { action, match, rules }; null removes them), hide (bosHide: devices where it isn’t shown, e.g. ["m"], ["d","t"]; empty removes it) and dyn_styles (bosDynStyles; null removes them), and in dynamic the mods field with the modifiers. get_layout_catalog includes modifiers and conditions (types, shape and an example per type); get_page describes each block’s hide, conditions and dyn_styles (filter builder_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, items and css (the last one isn’t an attribute: it’s saved in bosStyles per device).
  • Flags:
    • design: the field goes to the Style tab and is protected by locking.
    • mod: adds the class bos-w-<widget>--<campo>-<valor> to the root.
    • comp: the widget is an interactive component.
    • js: it needs builder-os-layout.js.
  • The editor renders the widget with this same render (REST preview). Escape everything with esc_html(), esc_url() and wp_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 (header parts 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 as Builder_OS_Layout_Widgets, which now exposes its utilities as protected).
  • 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.js and public/css/builder-os-lightbox.css.

New hooks:

HookTypeUse
builder_os_dynamic_tagsfilter( $tags ): add dynamic data. See “How to add a dynamic datum.”
builder_os_dynamic_allow_metafilter( false, $key ): allows showing a protected field (_clave).
builder_os_dynamic_preview_postfilter( $sample, $template ): sample post for previewing a theme template.
builder_os_query_argsfilter (existing)Now also for the List: ( $args, [ 'widget' => 'loop', 'attributes' => … ] ).

Widget schema — new flags:

  • css => 'pro': its CSS is in builder-os-layout-pro.css (loaded only if used). For a custom widget, enqueue your stylesheet in its render or with wp_enqueue_scripts.
  • nested => [ 'template' => [ [ bloque, attrs, [ hijos ] ], … ], 'label' => '…', 'when' => [ campo => valor ] ]: the widget has blocks inside (InnerBlocks). The editor shows and saves them; when decides 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' => [ … ] ]. data reaches 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 supports post (the context post for dynamic data) and inner (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 ]).
  • $opts holds the chosen options (key, format…) and type (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:

HookTypeUse
builder_os_part_htmlfilter( $html, $role ): already rendered HTML of a part (header or footer). The builder uses it for the bar “in the header.”
builder_os_number_formatfilterNumeric 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() (palette control, --bos-tone) and skin_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().
  • skin attribute on sections and containers (class bos-l-skin-<estilo>).
  • StylePanel (BuilderOSDesign) supports hover controlled from outside (with hideHead).

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.
HookTypeUse
builder_os_theme_partfilter( $post|null, $role ): the builder’s header or footer shown on the current page.
builder_os_theme_header_models, builder_os_theme_footer_modelsfilter( $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>), not builder-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.
  • css field with control => 'color': color (package palette or free) in a root variable, per device.
  • options => 'menus' with menuLinks => true: a menu selector with “Edit this menu ↗.”
  • Box style notch in Builder_OS_Layout_Widgets::skins().

Limitations:

  • The mobile menu’s side panel uses position: fixed: if an ancestor container has transform, filter or backdrop-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_conditions and delete_theme_template; their content is edited with get_page/update_layout_widget on their bos_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.