Skip to content

Instantly share code, notes, and snippets.

@Lego2012
Created December 1, 2022 08:37
Show Gist options
  • Save Lego2012/9bfabb819c1603a5fd3d7fa59a6a106f to your computer and use it in GitHub Desktop.
Save Lego2012/9bfabb819c1603a5fd3d7fa59a6a106f to your computer and use it in GitHub Desktop.

Easily set your Basic Text Element to default as

or any other tag. As a bonus, I've added <ul> and <li> tags, so no more chumpin' setting custom code.

Copy and paste the following code into your bricks-child/functions.php:

add_filter('bricks/elements/text-basic/controls', function ($controls) {
    $controls['tag'] = [
        
        'tab'         => 'content',
        'label'       => esc_html__('HTML tag', 'bricks'),
        'type'        => 'select',
        'options'     => [
            'div'        => 'div',
            'p'          => 'p',
            'span'       => 'span',
            'figcaption' => 'figcaption',
            'address'    => 'address',
            'figure'     => 'figure',
            'ul'         => 'ul',
            'li'         => 'li',
            'custom'     => esc_html__('Custom', 'bricks'),
        ],
        'lowercase'   => true,
        'inline'      => true,
        //'placeholder' => 'p',
        'default' => 'p',
    ];

    $controls['customTag'] = [
        'tab'         => 'content',
        'label'       => esc_html__('Custom tag', 'bricks'),
        'type'        => 'text',
        'inline'      => true,
        'placeholder' => 'div',
        'required'    => ['tag', '=', 'custom'],
    ];

    return $controls;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment