Last active
September 25, 2022 18:18
-
-
Save cpaul007/685fc2ad9ced2c71f3b8588f6d9ba57b to your computer and use it in GitHub Desktop.
Adding Custom Tag control in Heading element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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