Skip to content

Instantly share code, notes, and snippets.

@cpaul007
Last active September 25, 2022 18:18
Show Gist options
  • Save cpaul007/685fc2ad9ced2c71f3b8588f6d9ba57b to your computer and use it in GitHub Desktop.
Save cpaul007/685fc2ad9ced2c71f3b8588f6d9ba57b to your computer and use it in GitHub Desktop.
Adding Custom Tag control in Heading element
<?php //* do not add this line
/**
* enter the code into the functions.php file
*/
add_filter( "bricks/elements/heading/controls", 'bu_filter_heading_element_controls' );
function bu_filter_heading_element_controls( $controls ) {
$controls['tag']['options']['custom'] = esc_html__('Custom');
$inserted['customTag'] = [
'tab' => 'content',
'label' => esc_html__( 'Custom tag', 'bricks' ),
'type' => 'text',
'inline' => true,
'placeholder' => 'div',
'required' => [ 'tag', '=', 'custom' ],
];
$pos = array_search( 'type', array_keys( $controls ) );
$controls = array_merge(
array_slice($controls, 0, $pos),
$inserted,
array_slice($controls, $pos)
);
return $controls;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment