Adding Field To An Element

Use filter upb_element_{$tag}_attributes to add fields / attributes on an existing element.

Example:

We want to add an text field on UPB Text element. So the UPB Text element id is upb-text filter will upb_element_upb-text_attributes


add_filter( "upb_element_upb-text_attributes", function( $attributes ){

    array_push(
        $attributes,
        array(
            'id'          => 'example',
            'title'       => 'title',
            'desc'        => 'description',
            'placeholder' => 'Placeholder',
            'type'        => 'text',
            'value'       => '',
        )
    );

    // OR

    $attributes[] = array(
            'id'    => 'example',
            'title' => 'title',
            'desc'  => 'description',
            'type'  => 'text',
            'value' => '',
     );

     // OR Adding Input Group

     $attributes = array_merge( $attributes, upb_css_class_id_input_group() );

    return $attributes;
} );

Adding field after other field.

Use upb_add_attribute_after( $id, $attribute, $attributes ) helper function with upb_element_{$tag}_attributes filter hook to add new field / attribute after another field / attribute.

Example:

add_filter( 'upb_element_{$tag}_attributes', function ( $attributes ) {

    return upb_add_attribute_after( 'space', array(
       'id'      => 'margin',
       'title'   => esc_html__( 'Margin', 'ultimate-page-builder' ),
       'desc'    => esc_html__( 'Margin between two section', 'ultimate-page-builder' ),
       'type'    => 'spacing',
       'value'   => array( '10px', 'initial', '10px', 'auto' ),
       'unit'    => 'px',
       'options' => array(
           'top'    => TRUE,
           'right'  => FALSE,
           'bottom' => TRUE,
           'left'   => FALSE,
       )
    ), $attributes );
} );

results matching ""

    No results matching ""