Link Control
The link control give you the choice of different link types:
- Internal post/page
- External URL
- Popup (image, video)
class Prefix_Element_Link extends \Bricks\Element { // Set builder controls public function set_controls() { $this->controls['exampleLink'] = [ 'tab' => 'content', 'label' => esc_html__( 'Link', 'bricks' ), 'type' => 'link', 'pasteStyles' => false, 'placeholder' => esc_html__( 'http://yoursite.com', 'bricks' ), // 'exclude' => [ // 'rel', // 'newTab', // ], ]; }
// Render element HTML public function render() { if ( isset( $this->settings['exampleLink'] ) ) { // Set link attributes by passing attribute key and link settings $this->set_link_attributes( 'a', $this->settings['exampleLink'] );
echo '<a ' . $this->render_attributes( 'a' ) . '>' . get_bloginfo( 'name' ) . '</a>'; } else { esc_html_e( 'No link 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.