Last active
November 27, 2024 12:27
-
-
Save gdarko/1773b8b66cc348c78ff71fbccecc3637 to your computer and use it in GitHub Desktop.
Custom Bricks Slider
This file contains 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 | |
if(!defined('ABSPATH')) { | |
die; | |
} | |
class DTSP_Flavor_Gallery extends \Bricks\Element_Slider { | |
public $name = 'flavor-gallery'; | |
public function get_label() { | |
return esc_html__( 'Flavor Gallery', 'bricks' ); | |
} | |
public function render() { | |
$this->attributes['_root']['class'][] = 'brxe-slider'; | |
$this->prepare_items(); | |
parent::render(); | |
} | |
public function prepare_items() { | |
global $post; | |
// Here, set up custom data or query post meta data | |
// This is usually a repeating field set up with ACF or CMB2 | |
$this->settings['items'] = array( | |
array( | |
'title' => '', | |
'content' => '', | |
'buttonText' => '', | |
'buttonLink' => array( | |
'url' => '#', | |
), | |
'background' => array( | |
'color' => array( | |
'hex' => '#263238', | |
), | |
'image' => array( | |
'id' => 429, | |
'size' => 'full', | |
'filename' => 'foobar.png', | |
'full' => 'http://example.com/wp-content/uploads/1970/01/foobar.png', | |
'url' => 'http://example.com/wp-content/uploads/1970/01/foobar.png' | |
) | |
), | |
), | |
/// more array items... | |
); | |
} | |
} |
This file contains 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 | |
/** | |
* Register custom elements | |
*/ | |
add_action( 'init', function() { | |
$element_files = [ | |
__DIR__ . '/elements/flavor-gallery.php', | |
]; | |
foreach ( $element_files as $file ) { | |
\Bricks\Elements::register_element( $file ); | |
} | |
}, 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment