PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 1.2.0
JetFormBuilder — Dynamic Blocks Form Builder v1.2.0
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 All 130 releases
← All changes | includes/classes/gallery.php +192 -209 trunk1.2.0 View file →
@@ -1,209 +1,192 @@
1 -<?php
2 -
3 -
4 -namespace Jet_Form_Builder\Classes;
5 -
6 -// If this file is called directly, abort.
7 -if ( ! defined( 'WPINC' ) ) {
8 - die;
9 -}
10 -
11 -class Gallery {
12 -
13 - /**
14 - * Render images gallery as slider
15 - *
16 - * @param array $images [description]
17 - * @param array $args [description]
18 - *
19 - * @return string
20 - */
21 - public static function slider( $images = array(), $args = array() ) {
22 -
23 - if ( empty( $images ) ) {
24 - return '';
25 - }
26 -
27 - ob_start();
28 -
29 - wp_enqueue_script( 'jquery-slick' );
30 - wp_enqueue_script( 'imagesloaded' );
31 - wp_enqueue_script( 'jet-engine-frontend' );
32 -
33 - $args = wp_parse_args(
34 - $args,
35 - array(
36 - 'size' => 'full',
37 - 'lightbox' => false,
38 - 'slides_to_show' => 1,
39 - 'slides_to_show_t' => false,
40 - 'slides_to_show_m' => false,
41 - )
42 - );
43 -
44 - $slider_atts = array(
45 - 'slidesToShow' => $args['slides_to_show'],
46 - 'dots' => false,
47 - 'slidesToScroll' => 1,
48 - 'adaptiveHeight' => true,
49 - 'prevArrow' => '<i class="fa fa-angle-left prev-arrow jet-engine-arrow"></i>',
50 - 'nextArrow' => '<i class="fa fa-angle-right next-arrow jet-engine-arrow"></i>',
51 - 'rtl' => is_rtl(),
52 - );
53 -
54 - $mobile_settings = apply_filters(
55 - 'jet-form-builder/gallery/slider/mobile-settings',
56 - array(
57 - 'slides_to_show_t' => 1025,
58 - 'slides_to_show_m' => 768,
59 - )
60 - );
61 -
62 - foreach ( $mobile_settings as $key => $breakpoint ) {
63 -
64 - if ( ! empty( $args[ $key ] ) ) {
65 -
66 - if ( ! isset( $slider_atts['responsive'] ) ) {
67 - $slider_atts['responsive'] = array();
68 - }
69 -
70 - $slider_atts['responsive'][] = array(
71 - 'breakpoint' => $breakpoint,
72 - 'settings' => array(
73 - 'slidesToShow' => $args[ $key ],
74 - ),
75 - );
76 -
77 - }
78 - }
79 -
80 - $slider_atts = apply_filters( 'jet-form-builder/gallery/slider/atts', $slider_atts );
81 - $slider_atts = htmlspecialchars( wp_json_encode( $slider_atts ) );
82 -
83 - echo '<div class="jet-engine-gallery-slider" data-atts="' . esc_attr( $slider_atts ) . '">';
84 -
85 - $gallery_id = self::get_gallery_id();
86 -
87 - foreach ( $images as $img_id ) {
88 -
89 - if ( 'full' === $args['size'] ) {
90 - $img_url = wp_get_attachment_image_url( $img_id, $args['size'] );
91 - $img_full = $img_url;
92 - } else {
93 - $img_url = wp_get_attachment_image_url( $img_id, $args['size'] );
94 - $img_full = wp_get_attachment_image_url( $img_id, 'full' );
95 - }
96 -
97 - echo '<div class="jet-engine-gallery-slider__item">';
98 -
99 - if ( $args['lightbox'] ) {
100 - echo '<a href="' . esc_attr( $img_full ) . '" class="jet-engine-gallery-slider__item-wrap jet-engine-gallery-item-wrap is-lightbox" data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="' . esc_attr( $gallery_id ) . '">';
101 - } else {
102 - echo '<span class="jet-engine-gallery-slider__item-wrap jet-engine-gallery-item-wrap">';
103 - }
104 -
105 - $alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true );
106 -
107 - echo '<img src="' . esc_attr( $img_url ) . '" alt="' . esc_attr( $alt ) . '" class="jet-engine-gallery-slider__item-img">';
108 -
109 - if ( $args['lightbox'] ) {
110 - echo '</a>';
111 - } else {
112 - echo '</span>';
113 - }
114 -
115 - echo '</div>';
116 -
117 - }
118 -
119 - echo '</div>';
120 -
121 - return ob_get_clean();
122 - }
123 -
124 - /**
125 - * Render images gallery as grid
126 - *
127 - * @param array $images [description]
128 - * @param string $size [description]
129 - * @param boolean $lightbox [description]
130 - *
131 - * @return string
132 - */
133 - public static function grid( $images = array(), $args = array() ) {
134 -
135 - if ( empty( $images ) ) {
136 - return '';
137 - }
138 -
139 - $args = wp_parse_args(
140 - $args,
141 - array(
142 - 'size' => 'full',
143 - 'lightbox' => false,
144 - 'cols_desk' => 3,
145 - 'cols_tablet' => 3,
146 - 'cols_mobile' => 1,
147 - )
148 - );
149 -
150 - ob_start();
151 -
152 - $classes = array(
153 - 'grid-col-desk-' . $args['cols_desk'],
154 - 'grid-col-tablet-' . $args['cols_tablet'],
155 - 'grid-col-mobile-' . $args['cols_mobile'],
156 - );
157 - $classes = sprintf( ' %s', implode( ' ', $classes ) );
158 -
159 - echo '<div class="jet-engine-gallery-grid' . esc_attr( $classes ) . '">';
160 -
161 - $gallery_id = self::get_gallery_id();
162 -
163 - foreach ( $images as $img_id ) {
164 -
165 - if ( 'full' === $args['size'] ) {
166 - $img_url = wp_get_attachment_image_url( $img_id, $args['size'] );
167 - $img_full = $img_url;
168 - } else {
169 - $img_url = wp_get_attachment_image_url( $img_id, $args['size'] );
170 - $img_full = wp_get_attachment_image_url( $img_id, 'full' );
171 - }
172 -
173 - echo '<div class="jet-engine-gallery-grid__item">';
174 -
175 - if ( $args['lightbox'] ) {
176 - echo '<a href="' . esc_attr( $img_full ) . '" class="jet-engine-gallery-grid__item-wrap jet-engine-gallery-item-wrap is-lightbox" data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="' . esc_attr( $gallery_id ) . '">';
177 - } else {
178 - echo '<span class="jet-engine-gallery-grid__item-wrap jet-engine-gallery-item-wrap">';
179 - }
180 -
181 - $alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true );
182 -
183 - echo '<img src="' . esc_attr( $img_url ) . '" alt="' . esc_attr( $alt ) . '" class="jet-engine-gallery-grid__item-img">';
184 -
185 - if ( $args['lightbox'] ) {
186 - echo '</a>';
187 - } else {
188 - echo '</span>';
189 - }
190 -
191 - echo '</div>';
192 -
193 - }
194 -
195 - echo '</div>';
196 -
197 - return ob_get_clean();
198 - }
199 -
200 - /**
201 - * Returns random ID for gallery
202 - *
203 - * @return [type] [description]
204 - */
205 - public static function get_gallery_id() {
206 - return 'gallery_' . wp_rand( 1000, 9999 );
207 - }
208 -
209 -}
1 +<?php
2 +
3 +
4 +namespace Jet_Form_Builder\Classes;
5 +
6 +
7 +class Gallery {
8 +
9 + /**
10 + * Render images gallery as slider
11 + *
12 + * @param array $images [description]
13 + * @param array $args [description]
14 + *
15 + * @return [type] [description]
16 + */
17 + public static function slider( $images = array(), $args = array() ) {
18 +
19 + if ( empty( $images ) ) {
20 + return '';
21 + }
22 +
23 + wp_enqueue_script( 'jquery-slick' );
24 + wp_enqueue_script( 'imagesloaded' );
25 + wp_enqueue_script( 'jet-engine-frontend' );
26 +
27 + $args = wp_parse_args( $args, array(
28 + 'size' => 'full',
29 + 'lightbox' => false,
30 + 'slides_to_show' => 1,
31 + 'slides_to_show_t' => false,
32 + 'slides_to_show_m' => false,
33 + ) );
34 +
35 + $slider_atts = array(
36 + 'slidesToShow' => $args['slides_to_show'],
37 + 'dots' => false,
38 + 'slidesToScroll' => 1,
39 + 'adaptiveHeight' => true,
40 + 'prevArrow' => '<i class="fa fa-angle-left prev-arrow jet-engine-arrow"></i>',
41 + 'nextArrow' => '<i class="fa fa-angle-right next-arrow jet-engine-arrow"></i>',
42 + 'rtl' => is_rtl(),
43 + );
44 +
45 + $mobile_settings = apply_filters( 'jet-form-builder/gallery/slider/mobile-settings', array(
46 + 'slides_to_show_t' => 1025,
47 + 'slides_to_show_m' => 768,
48 + ) );
49 +
50 + foreach ( $mobile_settings as $key => $breakpoint ) {
51 +
52 + if ( ! empty( $args[ $key ] ) ) {
53 +
54 + if ( ! isset( $slider_atts['responsive'] ) ) {
55 + $slider_atts['responsive'] = array();
56 + }
57 +
58 + $slider_atts['responsive'][] = array(
59 + 'breakpoint' => $breakpoint,
60 + 'settings' => array(
61 + 'slidesToShow' => $args[ $key ],
62 + ),
63 + );
64 +
65 + }
66 + }
67 +
68 + $slider_atts = apply_filters( 'jet-form-builder/gallery/slider/atts', $slider_atts );
69 + $slider_atts = htmlspecialchars( json_encode( $slider_atts ) );
70 +
71 + echo '<div class="jet-engine-gallery-slider" data-atts="' . $slider_atts . '">';
72 +
73 + $gallery_id = self::get_gallery_id();
74 +
75 + foreach ( $images as $img_id ) {
76 +
77 + if ( 'full' === $args['size'] ) {
78 + $img_url = $img_full = wp_get_attachment_image_url( $img_id, $args['size'] );
79 + } else {
80 + $img_url = wp_get_attachment_image_url( $img_id, $args['size'] );
81 + $img_full = wp_get_attachment_image_url( $img_id, 'full' );
82 + }
83 +
84 + echo '<div class="jet-engine-gallery-slider__item">';
85 +
86 + if ( $args['lightbox'] ) {
87 + echo '<a href="' . $img_full . '" class="jet-engine-gallery-slider__item-wrap jet-engine-gallery-item-wrap is-lightbox" data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="' . $gallery_id . '">';
88 + } else {
89 + echo '<span class="jet-engine-gallery-slider__item-wrap jet-engine-gallery-item-wrap">';
90 + }
91 +
92 + $alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true );
93 +
94 + echo '<img src="' . $img_url . '" alt="' . $alt . '" class="jet-engine-gallery-slider__item-img">';
95 +
96 + if ( $args['lightbox'] ) {
97 + echo '</a>';
98 + } else {
99 + echo '</span>';
100 + }
101 +
102 + echo '</div>';
103 +
104 + }
105 +
106 + echo '</div>';
107 +
108 + }
109 +
110 + /**
111 + * Render images gallery as grid
112 + *
113 + * @param array $images [description]
114 + * @param string $size [description]
115 + * @param boolean $lightbox [description]
116 + *
117 + * @return string
118 + */
119 + public static function grid( $images = array(), $args = array() ) {
120 +
121 + if ( empty( $images ) ) {
122 + return '';
123 + }
124 +
125 + $args = wp_parse_args( $args, array(
126 + 'size' => 'full',
127 + 'lightbox' => false,
128 + 'cols_desk' => 3,
129 + 'cols_tablet' => 3,
130 + 'cols_mobile' => 1,
131 + ) );
132 +
133 + ob_start();
134 +
135 + $classes = array(
136 + 'grid-col-desk-' . $args['cols_desk'],
137 + 'grid-col-tablet-' . $args['cols_tablet'],
138 + 'grid-col-mobile-' . $args['cols_mobile'],
139 + );
140 + $classes = sprintf( ' %s', implode( ' ', $classes ) );
141 +
142 + echo '<div class="jet-engine-gallery-grid' . $classes . '">';
143 +
144 + $gallery_id = self::get_gallery_id();
145 +
146 + foreach ( $images as $img_id ) {
147 +
148 + if ( 'full' === $args['size'] ) {
149 + $img_url = $img_full = wp_get_attachment_image_url( $img_id, $args['size'] );
150 + } else {
151 + $img_url = wp_get_attachment_image_url( $img_id, $args['size'] );
152 + $img_full = wp_get_attachment_image_url( $img_id, 'full' );
153 + }
154 +
155 + echo '<div class="jet-engine-gallery-grid__item">';
156 +
157 + if ( $args['lightbox'] ) {
158 + echo '<a href="' . $img_full . '" class="jet-engine-gallery-grid__item-wrap jet-engine-gallery-item-wrap is-lightbox" data-elementor-open-lightbox="yes" data-elementor-lightbox-slideshow="' . $gallery_id . '">';
159 + } else {
160 + echo '<span class="jet-engine-gallery-grid__item-wrap jet-engine-gallery-item-wrap">';
161 + }
162 +
163 + $alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true );
164 +
165 + echo '<img src="' . $img_url . '" alt="' . $alt . '" class="jet-engine-gallery-grid__item-img">';
166 +
167 + if ( $args['lightbox'] ) {
168 + echo '</a>';
169 + } else {
170 + echo '</span>';
171 + }
172 +
173 + echo '</div>';
174 +
175 + }
176 +
177 + echo '</div>';
178 +
179 + return ob_get_clean();
180 +
181 + }
182 +
183 + /**
184 + * Returns random ID for gallery
185 + *
186 + * @return [type] [description]
187 + */
188 + public static function get_gallery_id() {
189 + return 'gallery_' . rand( 1000, 9999 );
190 + }
191 +
192 +}