about-widget.php
1 year ago
accordion-widget.php
1 year ago
accordion.php
1 year ago
attachment-url.php
1 year ago
audio.php
1 year ago
before-after.php
1 year ago
button.php
1 year ago
code.php
1 year ago
contact-box.php
1 year ago
contact-form.php
1 year ago
custom-list.php
6 months ago
divider.php
1 year ago
dropcap.php
1 year ago
facebook.php
1 year ago
flickr.php
1 year ago
gallery.php
1 year ago
gmap.php
1 year ago
highlight.php
1 year ago
image.php
1 year ago
instagram-feed.php
1 year ago
latest-posts-slider.php
1 year ago
popular-posts-widget.php
1 year ago
products-grid.php
1 year ago
quote.php
1 year ago
recent-posts-grid-carousel.php
1 year ago
recent-posts-land-style.php
1 year ago
recent-posts-masonry.php
1 year ago
recent-posts-tiles-carousel.php
1 year ago
recent-posts-tiles.php
1 year ago
recent-posts-timeline.php
1 year ago
recent-posts-widget.php
1 year ago
recent-products.php
1 year ago
related-posts.php
8 years ago
sample-element.php
1 year ago
search.php
1 year ago
socials-list.php
1 year ago
staff.php
1 year ago
tab-widget.php
1 year ago
tabs.php
1 year ago
testimonial.php
1 year ago
text.php
1 year ago
touch-slider.php
1 year ago
video.php
1 year ago
touch-slider.php
291 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Touch slider element |
| 4 | * You should have 'Master Slider' plugin installed to use this element |
| 5 | * |
| 6 | * |
| 7 | * @package Auxin |
| 8 | * @license LICENSE.txt |
| 9 | * @author averta |
| 10 | * @link http://phlox.pro/ |
| 11 | * @copyright (c) 2010-2025 averta |
| 12 | */ |
| 13 | function auxin_touch_slider_master_array( $master_array ) { |
| 14 | |
| 15 | $master_array['aux_touch_slider'] = array( |
| 16 | 'name' => __('Simple Image Slider ', 'auxin-elements' ), |
| 17 | 'auxin_output_callback' => 'auxin_touch_slider_callback', |
| 18 | 'base' => 'aux_touch_slider', |
| 19 | 'description' => __('Responsive image slider with touch swipe feature.', 'auxin-elements' ), |
| 20 | 'class' => 'aux-widget-touch-slider', |
| 21 | 'show_settings_on_create' => true, |
| 22 | 'weight' => 1, |
| 23 | 'is_widget' => false, |
| 24 | 'is_shortcode' => true, |
| 25 | 'category' => THEME_NAME, |
| 26 | 'group' => '', |
| 27 | 'admin_enqueue_js' => '', |
| 28 | 'admin_enqueue_css' => '', |
| 29 | 'front_enqueue_js' => '', |
| 30 | 'front_enqueue_css' => '', |
| 31 | 'icon' => 'aux-element aux-pb-icons-image', |
| 32 | 'custom_markup' => '', |
| 33 | 'js_view' => '', |
| 34 | 'html_template' => '', |
| 35 | 'deprecated' => '', |
| 36 | 'content_element' => '', |
| 37 | 'as_parent' => '', |
| 38 | 'as_child' => '', |
| 39 | 'params' => array( |
| 40 | array( |
| 41 | 'heading' => __('Title','auxin-elements' ), |
| 42 | 'description' => __('The slider title, leave it empty if you don`t need title.', 'auxin-elements'), |
| 43 | 'param_name' => 'title', |
| 44 | 'type' => 'textfield', |
| 45 | 'value' => '', |
| 46 | 'holder' => '', |
| 47 | 'class' => 'title', |
| 48 | 'admin_label' => false, |
| 49 | 'dependency' => '', |
| 50 | 'weight' => '', |
| 51 | 'group' => '', |
| 52 | 'edit_field_class' => '' |
| 53 | ), |
| 54 | array( |
| 55 | 'heading' => __('Images','auxin-elements'), |
| 56 | 'description' => '', |
| 57 | 'param_name' => 'images', |
| 58 | 'type' => 'attach_images', |
| 59 | 'value' => '', |
| 60 | 'holder' => '', |
| 61 | 'class' => 'images', |
| 62 | 'admin_label' => false, |
| 63 | 'dependency' => '', |
| 64 | 'weight' => '', |
| 65 | 'group' => '', |
| 66 | 'edit_field_class' => '' |
| 67 | ), |
| 68 | array( |
| 69 | 'heading' => __('Slider image width','auxin-elements' ), |
| 70 | 'param_name' => 'width', |
| 71 | 'type' => 'textfield', |
| 72 | 'value' => '960', |
| 73 | 'holder' => '', |
| 74 | 'class' => '', |
| 75 | 'admin_label' => false, |
| 76 | 'dependency' => '', |
| 77 | 'weight' => '', |
| 78 | 'group' => '' , |
| 79 | 'edit_field_class' => '' |
| 80 | ), |
| 81 | array( |
| 82 | 'heading' => __('Slider image height','auxin-elements' ), |
| 83 | 'param_name' => 'height', |
| 84 | 'type' => 'textfield', |
| 85 | 'value' => '560', |
| 86 | 'holder' => '', |
| 87 | 'class' => '', |
| 88 | 'admin_label' => false, |
| 89 | 'dependency' => '', |
| 90 | 'weight' => '', |
| 91 | 'group' => '', |
| 92 | 'edit_field_class' => '' |
| 93 | ), |
| 94 | array( |
| 95 | 'heading' => __('Arrow navigation','auxin-elements' ), |
| 96 | 'description' => '', |
| 97 | 'param_name' => 'arrows', |
| 98 | 'type' => 'aux_switch', |
| 99 | 'value' => '1', |
| 100 | 'class' => '', |
| 101 | 'admin_label' => false, |
| 102 | 'dependency' => '', |
| 103 | 'weight' => '', |
| 104 | 'group' => __( 'Style', 'auxin-elements' ), |
| 105 | 'edit_field_class' => '' |
| 106 | ), |
| 107 | array( |
| 108 | 'heading' => __('Space between slides','auxin-elements' ), |
| 109 | 'param_name' => 'space', |
| 110 | 'type' => 'textfield', |
| 111 | 'value' => '5', |
| 112 | 'holder' => '', |
| 113 | 'class' => '', |
| 114 | 'admin_label' => false, |
| 115 | 'dependency' => '', |
| 116 | 'weight' => '', |
| 117 | 'group' => __( 'Style', 'auxin-elements' ), |
| 118 | 'edit_field_class' => '' |
| 119 | ), |
| 120 | array( |
| 121 | 'heading' => __('Looped navigation','auxin-elements' ), |
| 122 | 'description' => '', |
| 123 | 'param_name' => 'loop', |
| 124 | 'type' => 'aux_switch', |
| 125 | 'value' => '0', |
| 126 | 'class' => '', |
| 127 | 'admin_label' => false, |
| 128 | 'dependency' => '', |
| 129 | 'weight' => '', |
| 130 | 'group' => __( 'Style', 'auxin-elements' ), |
| 131 | 'edit_field_class' => '' |
| 132 | ), |
| 133 | array( |
| 134 | 'heading' => __('Slideshow','auxin-elements' ), |
| 135 | 'description' => '', |
| 136 | 'param_name' => 'slideshow', |
| 137 | 'type' => 'aux_switch', |
| 138 | 'value' => '0', |
| 139 | 'class' => '', |
| 140 | 'admin_label' => true, |
| 141 | 'dependency' => '', |
| 142 | 'weight' => '', |
| 143 | 'group' => __( 'Style', 'auxin-elements' ), |
| 144 | 'edit_field_class' => '' |
| 145 | ), |
| 146 | array( |
| 147 | 'heading' => __('Slideshow delay in seconds','auxin-elements' ), |
| 148 | 'param_name' => 'slideshow_delay', |
| 149 | 'type' => 'textfield', |
| 150 | 'value' => '2', |
| 151 | 'holder' => '', |
| 152 | 'class' => '', |
| 153 | 'admin_label' => false, |
| 154 | 'dependency' => array( |
| 155 | 'element' => 'slideshow', |
| 156 | 'value' => '1' |
| 157 | ), |
| 158 | 'weight' => '', |
| 159 | 'group' => __( 'Style', 'auxin-elements' ), |
| 160 | 'edit_field_class' => '' |
| 161 | ), |
| 162 | array( |
| 163 | 'heading' => __('Display image title','auxin-elements' ), |
| 164 | 'description' => '', |
| 165 | 'param_name' => 'add_title', |
| 166 | 'type' => 'aux_switch', |
| 167 | 'value' => '0', |
| 168 | 'class' => '', |
| 169 | 'admin_label' => false, |
| 170 | 'dependency' => '', |
| 171 | 'weight' => '', |
| 172 | 'group' => __( 'Style', 'auxin-elements' ), |
| 173 | 'edit_field_class' => '' |
| 174 | ), |
| 175 | array( |
| 176 | 'heading' => __('Display image caption','auxin-elements' ), |
| 177 | 'description' => '', |
| 178 | 'param_name' => 'add_caption', |
| 179 | 'type' => 'aux_switch', |
| 180 | 'value' => '0', |
| 181 | 'class' => '', |
| 182 | 'dependency' => '', |
| 183 | 'admin_label' => false, |
| 184 | 'weight' => '', |
| 185 | 'group' => __( 'Style', 'auxin-elements' ), |
| 186 | 'edit_field_class' => '' |
| 187 | ) |
| 188 | ) |
| 189 | ); |
| 190 | |
| 191 | return $master_array; |
| 192 | } |
| 193 | |
| 194 | add_filter( 'auxin_master_array_shortcodes', 'auxin_touch_slider_master_array', 10, 1 ); |
| 195 | |
| 196 | /** |
| 197 | * Dynamic element with result in columns |
| 198 | * The front-end output of this element is returned by the following function |
| 199 | * |
| 200 | * @param array $atts The array containing the parsed values from shortcode |
| 201 | * containing widget info too |
| 202 | * @param string $shortcode_content The shorcode content |
| 203 | * @return string The output of element markup |
| 204 | */ |
| 205 | function auxin_touch_slider_callback( $atts, $shortcode_content = null ){ |
| 206 | |
| 207 | // Defining default attributes |
| 208 | $default_atts = array( |
| 209 | 'title' => '', |
| 210 | 'images' => '', |
| 211 | 'width' => '960', |
| 212 | 'height' => '560', |
| 213 | 'loop' => '0', |
| 214 | 'space' => '5', |
| 215 | 'slideshow' => '0', |
| 216 | 'slideshow_delay' => '2', |
| 217 | 'arrows' => '1', |
| 218 | 'add_title' => '0', |
| 219 | 'add_caption' => '0', |
| 220 | 'skin' => 'aux-light-skin', |
| 221 | |
| 222 | 'extra_classes' => '', // custom css class names for this element |
| 223 | 'custom_el_id' => '', // custom id attribute for this element |
| 224 | 'base_class' => 'aux-widget-touch-slider aux-widget-post-slider' // base class name for container |
| 225 | ); |
| 226 | |
| 227 | $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content ); |
| 228 | extract( $result['parsed_atts'] ); |
| 229 | |
| 230 | $attachments = auxin_get_the_resized_images_by_attach_ids( $images, $width , $height, true ); |
| 231 | if( empty( $attachments ) ){ |
| 232 | return ''; |
| 233 | } |
| 234 | ob_start(); |
| 235 | |
| 236 | // widget header ------------------------------ |
| 237 | echo wp_kses_post( $result['widget_header'] ); |
| 238 | echo wp_kses_post( $result['widget_title'] ); |
| 239 | |
| 240 | echo '<div class="master-carousel-slider aux-latest-posts-slider aux-no-js '.esc_attr( $skin ).'" data-empty-height="'.esc_attr( $height ).'" data-navigation="peritem" data-space="'.esc_attr( $space ).'" data-auto-height="true" data-delay="'.esc_attr( $slideshow_delay ).'" data-loop="'.esc_attr( $loop ).'" data-autoplay="' . auxin_is_true( $slideshow ) . '">'; |
| 241 | |
| 242 | // widget custom output ----------------------- |
| 243 | |
| 244 | foreach ( $attachments as $attachment_id => $attachment ) { |
| 245 | |
| 246 | $slide_image = ''; |
| 247 | ?> |
| 248 | <div class="aux-mc-item" > |
| 249 | <div class="aux-slide-media"> |
| 250 | <div class="aux-media-frame aux-media-image"><?php echo wp_kses_post( $attachment ); ?></div> |
| 251 | </div> |
| 252 | <?php if( $add_title || $add_caption ) { ?> |
| 253 | <section class="aux-info-container"> |
| 254 | <?php if( $add_title ) { ?> |
| 255 | <div class="aux-slide-title"> |
| 256 | <h3><?php echo auxin_kses( auxin_get_trimmed_string( get_the_title( $attachment_id ), 70, '...') ); ?></h3> |
| 257 | </div> |
| 258 | <?php } if ( $add_caption ) { ?> |
| 259 | <div class="aux-slide-info"> |
| 260 | <?php auxin_the_attachment_caption( $attachment_id ); ?> |
| 261 | </div> |
| 262 | <?php } ?> |
| 263 | </section> |
| 264 | <?php } ?> |
| 265 | </div> |
| 266 | |
| 267 | <?php |
| 268 | } |
| 269 | if ( $arrows ) { |
| 270 | ?> |
| 271 | <div class="aux-next-arrow aux-arrow-nav aux-white aux-round aux-hover-slide"> |
| 272 | <span class="aux-overlay"></span> |
| 273 | <span class="aux-svg-arrow aux-medium-right"></span> |
| 274 | <span class="aux-hover-arrow aux-svg-arrow aux-medium-right"></span> |
| 275 | </div> |
| 276 | <div class="aux-prev-arrow aux-arrow-nav aux-white aux-round aux-hover-slide"> |
| 277 | <span class="aux-overlay"></span> |
| 278 | <span class="aux-svg-arrow aux-medium-left"></span> |
| 279 | <span class="aux-hover-arrow aux-svg-arrow aux-medium-left"></span> |
| 280 | </div> |
| 281 | <?php |
| 282 | } |
| 283 | |
| 284 | // widget footer ------------------------------ |
| 285 | echo '</div><!-- aux-col-wrapper -->'; |
| 286 | |
| 287 | echo wp_kses_post( $result['widget_footer'] ); |
| 288 | |
| 289 | return ob_get_clean(); |
| 290 | } |
| 291 |