{"id":245,"date":"2020-04-22T06:24:32","date_gmt":"2020-04-22T06:24:32","guid":{"rendered":"https:\/\/localhost\/bricksacademy\/?post_type=bricks_article&p=245"},"modified":"2021-07-06T09:01:38","modified_gmt":"2021-07-06T09:01:38","slug":"checkbox-control","status":"publish","type":"bricks_article","link":"https:\/\/academy.bricksbuilder.io\/article\/checkbox-control\/","title":{"rendered":"Checkbox Control"},"content":{"rendered":"\n

The checkbox control is a simple on\/off switch. If enabled it outputs a boolean value of true<\/code>. Disabled it returns false<\/code>. You can use it to conditionally show\/hide other content settings as we illustrate in the following code example:<\/p>\n\n\n\n

class Prefix_Element_Checkbox extends \\Bricks\\Element {\n  \/\/ Set builder controls\n  public function set_controls() {\n    $this->controls['exampleCheckbox'] = [\n      'tab' => 'content',\n      'label' => esc_html__( 'Show site title', 'bricks' ),\n      'type' => 'checkbox',\n      'inline' => true,\n      'small' => true,\n      'default' => true, \/\/ Default: false\n    ];\n  }\n\n  \/\/ Render element HTML\n  public function render() {\n    \/\/ Show site title if setting checkbox 'exampleCheckbox' is checked\n    if ( isset( $this->settings['exampleCheckbox'] ) ) {\n      echo get_bloginfo( 'name' );\n    }\n  }\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"

The checkbox control is a simple on\/off switch. If enabled it outputs a boolean value of true. Disabled it returns false. You can use it to conditionally show\/hide other content settings as we illustrate in the following code example: class Prefix_Element_Checkbox extends \\Bricks\\Element { \/\/ Set builder controls public function set_controls() { $this->controls[‘exampleCheckbox’] = [ […]<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":167,"template":"","format":"standard","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/academy.bricksbuilder.io\/api\/wp\/v2\/bricks_article\/245"}],"collection":[{"href":"https:\/\/academy.bricksbuilder.io\/api\/wp\/v2\/bricks_article"}],"about":[{"href":"https:\/\/academy.bricksbuilder.io\/api\/wp\/v2\/types\/bricks_article"}],"author":[{"embeddable":true,"href":"https:\/\/academy.bricksbuilder.io\/api\/wp\/v2\/users\/1"}],"version-history":[{"count":0,"href":"https:\/\/academy.bricksbuilder.io\/api\/wp\/v2\/bricks_article\/245\/revisions"}],"wp:attachment":[{"href":"https:\/\/academy.bricksbuilder.io\/api\/wp\/v2\/media?parent=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}