Code Control
The code control embeds a code editor utilizing the amazing CodeMirror library. Users for which you’ve enabled “Code Execution” in the Bricks settings, will be able to execute PHP, HTML, CSS, and JavaScript.
class Prefix_Element_Code extends \Bricks\Element { // Set builder controls public function set_controls() { $this->controls['exampleHtml'] = [ 'tab' => 'content', 'label' => esc_html__( 'HTML', 'bricks' ), 'type' => 'code', 'mode' => 'php', 'default' => '<h4>Example H4 HTML title</h4>', ]; }
// Render element HTML public function render() { echo isset( $this->settings['exampleHtml'] ) ? $this->settings['exampleHtml'] : esc_html__( 'No HTML provided.', 'bricks' ); }}Was this helpful?
A quick vote and short notes help us improve these docs faster.
Leave a note for us
Please do not include passwords, license keys, or personal data. We store submitted notes to improve the docs.
Thanks for sharing feedback. We're using it to improve these docs.