about-widget.php
5 months ago
accordion-widget.php
1 month ago
accordion.php
5 months ago
attachment-url.php
5 months ago
audio.php
5 months ago
before-after.php
5 months ago
button.php
5 months ago
code.php
5 months ago
contact-box.php
5 months ago
contact-form.php
5 months ago
custom-list.php
5 months ago
divider.php
5 months ago
dropcap.php
5 months ago
facebook.php
5 months ago
flickr.php
5 months ago
gallery.php
5 months ago
gmap.php
5 months ago
highlight.php
5 months ago
image.php
5 months ago
instagram-feed.php
5 months ago
latest-posts-slider.php
5 months ago
popular-posts-widget.php
5 months ago
products-grid.php
5 months ago
quote.php
5 months ago
recent-posts-grid-carousel.php
5 months ago
recent-posts-land-style.php
5 months ago
recent-posts-masonry.php
5 months ago
recent-posts-tiles-carousel.php
5 months ago
recent-posts-tiles.php
5 months ago
recent-posts-timeline.php
5 months ago
recent-posts-widget.php
5 months ago
recent-products.php
5 months ago
related-posts.php
8 years ago
sample-element.php
5 months ago
search.php
5 months ago
socials-list.php
5 months ago
staff.php
5 months ago
tab-widget.php
5 months ago
tabs.php
5 months ago
testimonial.php
5 months ago
text.php
5 months ago
touch-slider.php
5 months ago
video.php
5 months ago
tabs.php
225 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Tabs element if site origin bundle plugin is activaited |
| 4 | * |
| 5 | * |
| 6 | * @package Auxin |
| 7 | * @license LICENSE.txt |
| 8 | * @author averta |
| 9 | * @link http://phlox.pro/ |
| 10 | * @copyright (c) 2010-2026 averta |
| 11 | */ |
| 12 | function auxin_get_tabs_master_array( $master_array ) { |
| 13 | |
| 14 | $master_array['aux_tabs'] = array( // shortcode info here |
| 15 | 'name' => __('Tabs', 'auxin-elements'), |
| 16 | 'auxin_output_callback' => 'auxin_widget_tabs_callback', |
| 17 | 'base' => 'aux_tabs', |
| 18 | 'description' => __('It adds tabs element.', 'auxin-elements'), |
| 19 | 'class' => 'aux-widget-tabs', |
| 20 | 'show_settings_on_create' => true, |
| 21 | 'weight' => 1, |
| 22 | 'is_widget' => false, |
| 23 | 'is_shortcode' => true, |
| 24 | 'category' => THEME_NAME, |
| 25 | 'group' => '', |
| 26 | 'admin_enqueue_js' => '', |
| 27 | 'admin_enqueue_css' => '', |
| 28 | 'front_enqueue_js' => '', |
| 29 | 'front_enqueue_css' => '', |
| 30 | 'icon' => 'aux-element aux-pb-icons-tab', |
| 31 | 'custom_markup' => '', |
| 32 | 'js_view' => '', |
| 33 | 'html_template' => '', |
| 34 | 'deprecated' => '', |
| 35 | 'content_element' => '', |
| 36 | 'as_parent' => '', |
| 37 | 'as_child' => '', |
| 38 | 'params' => array( |
| 39 | array( |
| 40 | 'heading' => __('Title','auxin-elements'), |
| 41 | 'description' => __('Tabs title, leave it empty if you don`t need title.', 'auxin-elements'), |
| 42 | 'param_name' => 'title', |
| 43 | 'type' => 'textfield', |
| 44 | 'value' => '', |
| 45 | 'holder' => 'textfield', |
| 46 | 'class' => 'title', |
| 47 | 'admin_label' => true, |
| 48 | 'dependency' => '', |
| 49 | 'weight' => '', |
| 50 | 'group' => '' , |
| 51 | 'edit_field_class' => '' |
| 52 | ), |
| 53 | array( |
| 54 | 'heading' => __('Style', 'auxin-elements'), |
| 55 | 'description' => __('Choose between bordered style and no border.', 'auxin-elements'), |
| 56 | 'param_name' => 'style', |
| 57 | 'type' => 'dropdown', |
| 58 | 'def_value' => 'bordered', |
| 59 | 'holder' => '', |
| 60 | 'class' => 'style', |
| 61 | 'value' =>array ( |
| 62 | 'bordered' => __('Bordered', 'auxin-elements'), |
| 63 | 'aux-stripe' => __('No border', 'auxin-elements'), |
| 64 | ), |
| 65 | 'admin_label' => true, |
| 66 | 'dependency' => '', |
| 67 | 'weight' => '', |
| 68 | 'group' => '' , |
| 69 | 'edit_field_class' => '' |
| 70 | ), |
| 71 | array( |
| 72 | 'heading' => __('Tab label','auxin-elements'), |
| 73 | 'description' => __('Enter your tab item label.', 'auxin-elements'), |
| 74 | 'repeater' => 'tabs', |
| 75 | 'repeater-label' => __('Tabs', 'auxin-elements'), |
| 76 | 'section-name' => __('Tabs Section', 'auxin-elements'), |
| 77 | 'param_name' => 'tab_label', |
| 78 | 'type' => 'textfield', |
| 79 | 'value' => '', |
| 80 | 'holder' => 'textfield', |
| 81 | 'class' => 'tab_label', |
| 82 | 'admin_label' => true, |
| 83 | 'dependency' => '', |
| 84 | 'weight' => '', |
| 85 | 'group' => '' , |
| 86 | 'edit_field_class' => '' |
| 87 | ), |
| 88 | array( |
| 89 | 'heading' => __('Content', 'auxin-elements'), |
| 90 | 'description' => __('Enter your tab item content.', 'auxin-elements'), |
| 91 | 'repeater' => 'tabs', |
| 92 | 'section-name' => __('Tabs section', 'auxin-elements'), |
| 93 | 'repeater-label' => __('Tabs', 'auxin-elements'), |
| 94 | 'param_name' => 'content', |
| 95 | 'type' => 'textarea_html', |
| 96 | 'value' => '', |
| 97 | 'def_value' => '', |
| 98 | 'holder' => 'div', |
| 99 | 'class' => 'content', |
| 100 | 'admin_label' => true, |
| 101 | 'dependency' => '', |
| 102 | 'weight' => '', |
| 103 | 'group' => '', |
| 104 | 'edit_field_class' => '' |
| 105 | ), |
| 106 | array( |
| 107 | 'heading' => __('Extra class name','auxin-elements'), |
| 108 | 'description' => __('If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', 'auxin-elements'), |
| 109 | 'param_name' => 'extra_classes', |
| 110 | 'type' => 'textfield', |
| 111 | 'value' => '', |
| 112 | 'def_value' => '', |
| 113 | 'holder' => 'textfield', |
| 114 | 'class' => 'extra_classes', |
| 115 | 'admin_label' => true, |
| 116 | 'dependency' => '', |
| 117 | 'weight' => '', |
| 118 | 'group' => '' , |
| 119 | 'edit_field_class' => '' |
| 120 | ) |
| 121 | ) |
| 122 | ); |
| 123 | |
| 124 | |
| 125 | return $master_array; |
| 126 | } |
| 127 | |
| 128 | add_filter( 'auxin_master_array_shortcodes', 'auxin_get_tabs_master_array', 10, 1 ); |
| 129 | |
| 130 | /** |
| 131 | * Sample element markup for front-end |
| 132 | * In other words, the front-end output of this element is returned by the following function |
| 133 | * |
| 134 | * |
| 135 | * @param array $atts The array containing the parsed values from shortcode,it should be same as defined params above. |
| 136 | * @param string $shortcode_content The shorcode content |
| 137 | * @return string The output of element markup |
| 138 | */ |
| 139 | function auxin_widget_tabs_callback( $atts, $shortcode_content = null ){ |
| 140 | |
| 141 | // Defining default attributes |
| 142 | $default_atts = array( |
| 143 | 'title' => '', // header title |
| 144 | 'style' => 'bordered', // header title |
| 145 | 'tabs' => '', // header title |
| 146 | 'type' => 'horizontal', |
| 147 | 'tab_id_prefix' => '', // Default prefix for tab index and id |
| 148 | 'extra_classes' => '', // custom css class names for this element |
| 149 | 'custom_el_id' => '', // custom id attribute for this element |
| 150 | 'base_class' => 'aux-widget-tabs' // base class name for container |
| 151 | ); |
| 152 | |
| 153 | $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content ); |
| 154 | extract( $result['parsed_atts'] ); |
| 155 | |
| 156 | ob_start(); |
| 157 | |
| 158 | // widget header ------------------------------ |
| 159 | echo wp_kses_post( $result['widget_header'] ); |
| 160 | echo wp_kses_post( $result['widget_title'] ); |
| 161 | |
| 162 | // widget custom output ----------------------- |
| 163 | $extra_classes .= ' aux-' . $type; |
| 164 | |
| 165 | $output = '<div class="widget-tabs widget-container ' . esc_attr( $style ) . '">'; |
| 166 | $output .= '<div class="widget-inner ' . esc_attr( trim( $extra_classes ) ) . '"> '; |
| 167 | $tabs_markup = '<ul class="tabs">'; |
| 168 | $tabs_content = '<ul class="tabs-content">'; |
| 169 | |
| 170 | if ( is_array( $tabs ) || is_object( $tabs ) ) { |
| 171 | foreach ( $tabs as $index => $value ) { |
| 172 | |
| 173 | $id_number = esc_attr( $tab_id_prefix . ( $index + 1 ) ); |
| 174 | |
| 175 | // Tab |
| 176 | $tab_attrs = array( |
| 177 | 'id' => 'aux-tab-' . $id_number, |
| 178 | //'class' => '', |
| 179 | 'href' => '#', |
| 180 | 'tabindex' => $id_number, |
| 181 | 'role' => 'tab', |
| 182 | 'aria-controls' => 'aux-tab-content-' . $id_number, |
| 183 | ); |
| 184 | $tabs_markup .= sprintf( '<li><a %s>%s</a></li>', |
| 185 | auxin_make_html_attributes( $tab_attrs ), |
| 186 | $value['tab_label'] |
| 187 | ); |
| 188 | |
| 189 | // Content |
| 190 | $content_attrs = array( |
| 191 | 'id' => 'aux-tab-content-' . $id_number, |
| 192 | 'class' => 'entry-editor', |
| 193 | 'tabindex' => $id_number, |
| 194 | 'role' => 'tabpanel', |
| 195 | 'aria-labelledby'=> 'aux-tab-' . $id_number, |
| 196 | ); |
| 197 | |
| 198 | if ( ! empty( $value['__dynamic__' ] ) ) { |
| 199 | $content = $value['content']; |
| 200 | } else { |
| 201 | preg_match('/<p>(.*?)<\/p>/', $value['content'] , $matches); |
| 202 | $content = ! empty( $matches[0] ) ? $matches[0] : $value['content']; |
| 203 | } |
| 204 | |
| 205 | $tabs_content .= sprintf( '<li><div %s><p>%s</p></div></li>', |
| 206 | auxin_make_html_attributes( $content_attrs ), |
| 207 | $content |
| 208 | ); |
| 209 | |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | |
| 214 | $tabs_markup .= '</ul>'; |
| 215 | $tabs_content .= '</ul>'; |
| 216 | $output = $output . $tabs_markup . $tabs_content . '</div>' . '</div>'; |
| 217 | |
| 218 | echo wp_kses_post( $output ); |
| 219 | |
| 220 | // widget footer ------------------------------ |
| 221 | echo wp_kses_post( $result['widget_footer'] ); |
| 222 | |
| 223 | return ob_get_clean(); |
| 224 | } |
| 225 |