PluginProbe ʕ •ᴥ•ʔ
Slider Ultimate / trunk
Slider Ultimate vtrunk
trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9
ultimate-slider / views / View.Slider.class.php
ultimate-slider / views Last commit date
Base.class.php 5 years ago View.Slide.UPCP.class.php 2 years ago View.Slide.URP.class.php 2 years ago View.Slide.WooCommerce.class.php 2 years ago View.Slide.class.php 2 years ago View.Slider.class.php 2 years ago View.class.php 2 years ago
View.Slider.class.php
355 lines
1 <?php
2
3 /**
4 * Class to display a slider on the front end.
5 *
6 * @since 2.0.0
7 */
8 class ewdusViewSlider extends ewdusView {
9
10 // slides to display
11 public $slides = array();
12
13 // shortcode attributes
14 public $slider_type;
15 public $post__in_string;
16 public $posts;
17 public $category;
18 public $carousel;
19 public $slide_indicators;
20 public $timer_bar;
21
22 /**
23 * Define the the slides for this slider
24 *
25 * @since 2.0.0
26 */
27 public function get_slides() {
28
29 if ( $this->slider_type == 'woocommerce' ) {
30
31 $args = array(
32 'posts_per_page' => $posts,
33 'post_type' => 'product',
34 'product_cat' => $category,
35 'orderby' => 'rand',
36 );
37
38 $slider_query = new WP_Query( $args );
39
40 while ( $slider_query->have_posts() ) : $slider_query->the_post();
41
42 $post = get_post();
43
44 $this->slides[] = new ewdusViewSlideWooCommerce( array( 'post' => $post ) );
45
46 endwhile;
47
48 wp_reset_query();
49 }
50
51 elseif ( $this->slider_type == 'upcp' ) {
52
53 $args = array(
54 'posts_per_page' => $this->posts,
55 'post_type' => 'upcp_product',
56 'product_cat' => $this->category,
57 'orderby' => 'rand'
58 );
59
60 $slider_query = new WP_Query( $args );
61
62 while ( $slider_query->have_posts() ) : $slider_query->the_post();
63
64 $post = get_post();
65
66 $this->slides[] = new ewdusViewSlideUPCP( array( 'post' => $post ) );
67
68 endwhile;
69
70 wp_reset_query();
71 }
72
73 elseif ( $this->slider_type == 'urp' ) {
74
75 $post__in = explode( ',', $this->post__in_string );
76
77 $args = array(
78 'posts_per_page' => $this->posts,
79 'post_type' => 'urp_review',
80 'post__in' => $post__in
81 );
82
83 $slider_query = new WP_Query( $args );
84
85 while ( $slider_query->have_posts() ) : $slider_query->the_post();
86
87 $post = get_post();
88
89 $this->slides[] = new ewdusViewSlideURP( array( 'post' => $post ) );
90
91 endwhile;
92
93 wp_reset_query();
94
95 }
96
97 elseif ( $this->post__in_string != '' ) {
98
99 $post__in = explode( ',', $this->post__in_string );
100
101 $args = array(
102 'posts' => $this->posts,
103 'post_type' => 'attachment',
104 'post_status' => array( 'publish', 'inherit' ),
105 'post__in' => $post__in
106 );
107
108 $slider_query = new WP_Query( $args );
109
110 while ( $slider_query->have_posts() ) : $slider_query->the_post();
111
112 $post = get_post();
113
114 $this->slides[] = new ewdusViewSlide( array( 'post' => $post ) );
115
116 endwhile;
117
118 wp_reset_query();
119
120 }
121
122 else {
123
124 $args = array(
125 'posts_per_page' => $this->posts,
126 'post_type' => EWD_US_SLIDER_POST_TYPE,
127 'ultimate_slider_categories' => $this->category,
128 'meta_key' => 'EWD_US_Slide_Order',
129 'orderby' => 'meta_value_num',
130 'order' => 'ASC',
131 );
132
133 $slider_query = new WP_Query( $args );
134
135 while ( $slider_query->have_posts() ) : $slider_query->the_post();
136
137 $post = get_post();
138
139 $content_type = get_post_meta( $post->ID, "EWD_US_Content_Type", true );
140
141 if ( $content_type == 'upcp_product' ) {
142
143 $this->slides[] = new ewdusViewSlideUPCP( array( 'post' => $post ) );
144 }
145 elseif ( $content_type == 'woocommerce_product' ) {
146
147 $this->slides[] = new ewdusViewSlideWooCommerce( array( 'post' => $post ) );
148 }
149 elseif ( $content_type == 'urp_review' ) {
150
151 $this->slides[] = new ewdusViewSlideURP( array( 'post' => $post ) );
152 }
153 else {
154
155 $this->slides[] = new ewdusViewSlide( array( 'post' => $post ) );
156 }
157
158 endwhile;
159
160 wp_reset_query();
161
162 }
163
164 $this->slides = apply_filters( 'ewd_us_slides', $this->slides );
165
166 }
167
168 /**
169 * Render the view and enqueue required stylesheets
170 * @since 2.0.0
171 */
172 public function render() {
173 global $ewd_us_controller;
174
175 $this->get_slides();
176 if ( ! count( $this->slides ) ) {
177 return;
178 }
179
180 // Set attribute-alterable options
181 $this->set_slider_options();
182
183 // Add any dependent stylesheets or javascript
184 $this->enqueue_assets();
185
186 // Add css classes to the slider
187 $this->classes = $this->slider_classes();
188
189 ob_start();
190 $this->add_custom_styling();
191 $template = $this->find_template( 'slider' );
192 if ( $template ) {
193 include( $template );
194 }
195 $output = ob_get_clean();
196
197 return apply_filters( 'ewd_us_slider_output', $output, $this );
198 }
199
200 /**
201 * Print the slides in the slider
202 *
203 * @since 2.0.0
204 */
205 public function print_slides() {
206
207 $output = '';
208
209 foreach ( $this->slides as $slide_count => $slide ) {
210
211 $slide->set_slide_count( $slide_count );
212 $output .= $slide->render();
213 }
214
215 return $output;
216 }
217
218 /**
219 * Print the arrows that increment and decrement slides in the slider
220 *
221 * @since 2.0.0
222 */
223 public function print_slide_arrows() {
224
225 $template = $this->find_template( 'slide-arrows' );
226
227 if ( $template ) {
228 include( $template );
229 }
230 }
231
232 /**
233 * Print the indicators (dots, thumbnails, etc.) for slides in the slider
234 *
235 * @since 2.0.0
236 */
237 public function print_slide_indicators() {
238 global $ewd_us_controller;
239
240 if ( $ewd_us_controller->settings->get_setting( 'slide-indicators') == 'dots' ) { $template = $this->find_template( 'slide-indicators-dots' ); }
241 elseif ( $ewd_us_controller->settings->get_setting( 'slide-indicators') == 'thumbnails' ) { $template = $this->find_template( 'slide-indicators-thumbnails' ); }
242 elseif ( $ewd_us_controller->settings->get_setting( 'slide-indicators') == 'sidethumbnails' ) { $template = $this->find_template( 'slide-indicators-sidethumbnails' ); }
243 else { $template = false; }
244
245 if ( $template ) {
246 include( $template );
247 }
248 }
249
250 /**
251 * Print the selected arrow letter (or default)
252 *
253 * @since 2.0.0
254 */
255 public function print_selected_arrow( $direction = 'left' ) {
256 global $ewd_us_controller;
257
258 return $direction == 'left' ? $ewd_us_controller->settings->get_setting( 'arrow' ) : chr( ord( $ewd_us_controller->settings->get_setting( 'arrow' ) ) + 1 );
259 }
260
261 /**
262 * Print the class for the selected arrow background shape
263 *
264 * @since 2.0.0
265 */
266 public function print_arrow_shape_class() {
267 global $ewd_us_controller;
268
269 return 'ewd-us-arrow-background-shape-' . $ewd_us_controller->settings->get_setting( 'arrow-background-shape' );
270 }
271
272 /**
273 * Add in default options if not overwritten by shortcode attributes
274 *
275 * @since 2.0.0
276 */
277 public function set_slider_options() {
278 global $ewd_us_controller;
279
280 $this->timer_bar = $this->timer_bar == 'No' ? false : $ewd_us_controller->settings->get_setting( 'timer-bar' );
281 $this->carousel = $this->carousel == 'Yes' ? true : $ewd_us_controller->settings->get_setting( 'carousel' );
282 $this->slide_indicators = $this->slide_indicators ? strtolower( $this->slide_indicators ) : $ewd_us_controller->settings->get_setting( 'slide-indicators' );
283 }
284
285 /**
286 * Get the initial slider css classes
287 * @since 2.0.0
288 */
289 public function slider_classes( $classes = array() ) {
290 global $ewd_us_controller;
291
292 $classes = array_merge(
293 $classes,
294 array(
295 'ewd-us-slider',
296 'ewd-us-slider-slide-indicators-' . $ewd_us_controller->settings->get_setting( 'slide-indicators' ),
297 )
298 );
299
300 foreach ( $ewd_us_controller->settings->get_setting( 'hide-from-slider' ) as $slider_item ) { $classes[] = 'ewd-us-slider-hide-' . $slider_item; }
301 foreach ( $ewd_us_controller->settings->get_setting( 'hide-on-mobile' ) as $slider_item ) { $classes[] = 'ewd-us-slider-mobile-hide-' . $slider_item; }
302
303 if ( $this->carousel ) { $classes[] = 'ewd-us-carousel'; }
304
305 return apply_filters( 'ewd_us_slider_classes', $classes, $this );
306 }
307
308 /**
309 * Enqueue the necessary CSS and JS files
310 * @since 2.0.0
311 */
312 public function enqueue_assets() {
313 global $ewd_us_controller;
314
315 wp_enqueue_script( 'jquery-ui-core' );
316 wp_enqueue_script( 'jquery-effects-slide' );
317 wp_enqueue_script( 'ewd-us-js' );
318 wp_enqueue_script( 'iframe-clicks' );
319
320 $aspect_fraction = ewd_us_get_aspect_fraction( $ewd_us_controller->settings->get_setting( 'aspect-ratio' ) );
321 $mobile_aspect_fraction = ewd_us_get_aspect_fraction( $ewd_us_controller->settings->get_setting( 'mobile-aspect-ratio' ) );
322
323 $slider_data = array(
324 'autoplay_slideshow' => $ewd_us_controller->settings->get_setting( 'autoplay-slideshow' ),
325 'autoplay_delay' => substr( $ewd_us_controller->settings->get_setting( 'autoplay-delay' ), 0, strpos( $ewd_us_controller->settings->get_setting( 'autoplay-delay' ), '_' ) ),
326 'autoplay_interval' => substr( $ewd_us_controller->settings->get_setting( 'autoplay-interval' ), 0, strpos( $ewd_us_controller->settings->get_setting( 'autoplay-delay' ), '_' ) ),
327 'slide_transition_effect' => $ewd_us_controller->settings->get_setting( 'slide-transition-effect' ),
328 'transition_time' => substr( $ewd_us_controller->settings->get_setting( 'transition-time' ), 0, strpos( $ewd_us_controller->settings->get_setting( 'autoplay-delay' ), '_' ) ),
329 'aspect_ratio' => $aspect_fraction,
330 'mobile_aspect_ratio' => $mobile_aspect_fraction,
331 'slider_carousel' => $ewd_us_controller->settings->get_setting( 'carousel' ),
332 'carousel_columns' => $ewd_us_controller->settings->get_setting( 'carousel-columns' ),
333 'carousel_link_to_full' => $ewd_us_controller->settings->get_setting( 'carousel-link-to-full' ),
334 'carousel_advance' => $ewd_us_controller->settings->get_setting( 'carousel-advance' ),
335 'title_animate' => $ewd_us_controller->settings->get_setting( 'title-animate' ),
336 'lightbox' => $ewd_us_controller->settings->get_setting( 'lightbox' ),
337 'timer_bar' => $ewd_us_controller->settings->get_setting( 'timer-bar' ),
338 'force_full_width' => $ewd_us_controller->settings->get_setting( 'force-full-width' ),
339 'autoplay_pause_hover' => $ewd_us_controller->settings->get_setting( 'autoplay-pause-hover' )
340 );
341
342 $ewd_us_controller->add_front_end_php_data( 'ewd-us-js', 'ewd_us_php_data', $slider_data );
343
344 wp_enqueue_style( 'ewd-us-css' );
345
346 if ( $ewd_us_controller->settings->get_setting( 'lightbox' ) ) {
347
348 wp_enqueue_script( 'ultimate-lightbox' );
349
350 wp_enqueue_style( 'ewd-ulb-main' );
351 }
352 }
353
354 }
355