Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Widget Name: Accordion
- */
- if (!class_exists('SiteOrigin_Widget_Base_Slider')) {
- include_once plugin_dir_path(SOW_BUNDLE_BASE_FILE) . '/base/inc/widgets/base-slider.class.php';
- }
- class Custom_SOW_Accordion extends SiteOrigin_Widget_Base_Slider
- {
- public function __construct()
- {
- parent::__construct(
- 'accordion-own',
- __('Accordion', 'custom_so_widgets'),
- array(
- 'description' => __('Custom Accordion', 'custom_so_widgets'),
- ),
- array(),
- array(
- 'frames' => array(
- 'type' => 'repeater',
- 'label' => __('Items', 'custom_so_widgets'),
- 'item_label' => array(
- 'selector' => "[id*='title']",
- ),
- 'fields' => array(
- 'title' => array(
- 'type' => 'text',
- 'label' => __('Title', 'custom_so_widgets'),
- ),
- 'content' => array(
- 'type' => 'builder',
- 'label' => __('Content', 'custom_so_widgets'),
- ),
- ),
- ),
- 'countable' => array(
- 'type' => 'checkbox',
- 'label' => __('Countable', 'custom_so_widgets'),
- ),
- ),
- plugin_dir_path(__FILE__)
- );
- }
- public function render_template($controls, $i, $frame)
- {
- $this->render_frame($i, $frame, $controls);
- }
- public function render_frame_contents($i, $frame)
- {
- echo $this->process_content($frame['content'], $frame);
- }
- public function process_content($content, $frame)
- {
- if (function_exists('siteorigin_panels_render')) {
- $content_builder_id = substr(md5(json_encode($content)), 0, 8);
- echo siteorigin_panels_render('w' . $content_builder_id, true, $content);
- } else {
- echo __('This widget requires Page Builder.', 'custom_so_widgets');
- }
- }
- public function render_frame($i, $frame, $controls)
- {
- $this->render_frame_contents($i, $frame);
- }
- public function get_template_variables($instance, $args)
- {
- if (empty($instance)) {
- return array();
- }
- $items = empty($instance['frames']) ? array() : $instance['frames'];
- $countable = !empty($instance['countable']) ? true : false;
- return array(
- 'items' => $items,
- 'countable' => $countable,
- );
- }
- }
- siteorigin_widget_register('accordion-own', __FILE__, 'Custom_SOW_Accordion');
Advertisement
Add Comment
Please, Sign In to add comment