__( 'Paragraph', 'booking' ),
'label' => __( 'Label', 'booking' ),
'span' => __( 'Span', 'booking' ),
'small' => __( 'Small', 'booking' ),
'div' => __( 'Div', 'booking' ),
'h1' => 'H1',
'h2' => 'H2',
'h3' => 'H3',
'h4' => 'H4',
'h5' => 'H5',
'h6' => 'H6',
);
$align_options = array(
'left' => __( 'Left', 'booking' ),
'center' => __( 'Center', 'booking' ),
'right' => __( 'Right', 'booking' ),
);
$packs['static_text'] = array(
'kind' => 'field',
'type' => 'static_text',
'label' => __( 'Static Text', 'booking' ),
'icon' => 'text',
'usage_key' => 'static_text',
// === Schema: defaults + coercion handled by Inspector/Factory ===
'schema' => array(
'props' => array(
'text' => array( 'type' => 'string', 'default' => __( 'Add your message here…', 'booking' ) ),
'tag' => array( 'type' => 'string', 'enum' => array_keys( $tag_options ), 'default' => 'p' ),
'align' => array( 'type' => 'string', 'enum' => array_keys( $align_options ), 'default' => 'left' ),
'bold' => array( 'type' => 'int', 'min' => 0, 'max' => 1, 'default' => 0 ),
'italic' => array( 'type' => 'int', 'min' => 0, 'max' => 1, 'default' => 0 ),
'html_allowed' => array( 'type' => 'int', 'min' => 0, 'max' => 1, 'default' => 0 ),
'nl2br' => array( 'type' => 'int', 'min' => 0, 'max' => 1, 'default' => 1 ),
'cssclass_extra' => array( 'type' => 'string', 'default' => '' ),
'html_id' => array( 'type' => 'string', 'default' => '' ),
'help' => array( 'type' => 'string', 'default' => '' ),
// "name" is supported in storage but hidden in Inspector.
'name' => array( 'type' => 'string', 'default' => '' ),
),
),
// === Inspector UI (Factory-driven) ===
'inspector_ui' => array(
'title' => __( 'Static Text', 'booking' ),
'description' => __( 'Non-interactive text block (paragraph, label, or heading).', 'booking' ),
'header_variant' => 'toolbar',
'header_actions' => array( 'deselect', 'scrollto', 'move-up', 'move-down', 'duplicate', 'delete' ),
'groups' => array(
array(
'key' => 'content',
'label' => __( 'Content', 'booking' ),
'open' => true,
'controls' => array(
array(
'type' => 'textarea',
'key' => 'text',
'label' => __( 'Text', 'booking' ),
'rows' => 3,
'placeholder' => __( 'Enter text', 'booking' ) . '...',
),
array(
'type' => 'select',
'key' => 'tag',
'label' => __( 'HTML Tag', 'booking' ),
'options' => $tag_options,
),
array(
'type' => 'select',
'key' => 'align',
'label' => __( 'Alignment', 'booking' ),
'options' => $align_options,
),
array( 'type' => 'checkbox', 'key' => 'bold', 'label' => __( 'Bold', 'booking' ) ),
array( 'type' => 'checkbox', 'key' => 'italic', 'label' => __( 'Italic', 'booking' ) ),
// array( 'type' => 'checkbox', 'key' => 'html_allowed', 'label' => __( 'Allow basic HTML', 'booking' ) ),
array( 'type' => 'checkbox', 'key' => 'nl2br', 'label' => __( 'Convert newlines to
tag', 'booking' ) ),
),
),
array(
'key' => 'advanced',
'label' => __( 'Advanced', 'booking' ),
'controls' => array(
array( 'type' => 'text', 'key' => 'cssclass_extra', 'label' => __( 'Extra CSS classes', 'booking' ) ),
// "name" intentionally omitted from Inspector
array( 'type' => 'text', 'key' => 'html_id', 'label' => __( 'HTML ID', 'booking' ) ),
// array( 'type' => 'textarea', 'key' => 'help', 'label' => __( 'Help text', 'booking' ), 'rows' => 3 ),
),
),
),
),
);
return $packs;
}
add_filter( 'wpbc_bfb_register_field_packs', 'wpbc_bfb_register_field_packs__field_static_text_schema' );
/**
* Enqueue the Static Text field pack assets for the Builder page.
*
* @param string $page Current admin page slug (unused, provided for parity with other packs).
* @return void
*/
function wpbc_bfb_enqueue__field_static_text_assets( $page ) {
wp_enqueue_script(
'wpbc-bfb_field_static_text',
wpbc_plugin_url( '/includes/page-form-builder/field-packs/static-text/_out/static-text.js' ),
array( 'wpbc-bfb' ),
WP_BK_VERSION_NUM,
true
);
}
add_action( 'wpbc_enqueue_js_field_pack', 'wpbc_bfb_enqueue__field_static_text_assets', 10, 1 );
/**
* (Optional) Register a palette item.
*
* @param string $group Palette group (e.g., 'general', 'structure').
* @param string $position Position: 'top' | 'bottom'.
* @return void
*/
function wpbc_bfb_palette_register_items__static_text_schema( $group, $position ) {
if ( 'essentials' !== $group || 'top' !== $position ) {
return;
}
?>