PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.5
JetFormBuilder — Dynamic Blocks Form Builder v2.1.5
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 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / classes / gallery.php
jetformbuilder / includes / classes Last commit date
arguments 3 years ago arrayable 3 years ago filters 3 years ago http 3 years ago post 3 years ago repository 3 years ago resources 3 years ago security 3 years ago theme 3 years ago attributes-trait.php 3 years ago base-attributes-trait.php 3 years ago builder-helper.php 3 years ago compatibility.php 3 years ago gallery.php 3 years ago get-icon-trait.php 3 years ago get-template-trait.php 3 years ago html-attributes-trait.php 3 years ago instance-trait.php 3 years ago macros-parser.php 3 years ago messages-helper-trait.php 3 years ago tools.php 3 years ago
gallery.php
201 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Classes;
5
6 class Gallery {
7
8 /**
9 * Render images gallery as slider
10 *
11 * @param array $images [description]
12 * @param array $args [description]
13 *
14 * @return [type] [description]
15 */
16 public static function slider( $images = array(), $args = array() ) {
17
18 if ( empty( $images ) ) {
19 return '';
20 }
21
22 wp_enqueue_script( 'jquery-slick' );
23 wp_enqueue_script( 'imagesloaded' );
24 wp_enqueue_script( 'jet-engine-frontend' );
25
26 $args = wp_parse_args(
27 $args,
28 array(
29 'size' => 'full',
30 'lightbox' => false,
31 'slides_to_show' => 1,
32 'slides_to_show_t' => false,
33 'slides_to_show_m' => false,
34 )
35 );
36
37 $slider_atts = array(
38 'slidesToShow' => $args['slides_to_show'],
39 'dots' => false,
40 'slidesToScroll' => 1,
41 'adaptiveHeight' => true,
42 'prevArrow' => '<i class="fa fa-angle-left prev-arrow jet-engine-arrow"></i>',
43 'nextArrow' => '<i class="fa fa-angle-right next-arrow jet-engine-arrow"></i>',
44 'rtl' => is_rtl(),
45 );
46
47 $mobile_settings = apply_filters(
48 'jet-form-builder/gallery/slider/mobile-settings',
49 array(
50 'slides_to_show_t' => 1025,
51 'slides_to_show_m' => 768,
52 )
53 );
54
55 foreach ( $mobile_settings as $key => $breakpoint ) {
56
57 if ( ! empty( $args[ $key ] ) ) {
58
59 if ( ! isset( $slider_atts['responsive'] ) ) {
60 $slider_atts['responsive'] = array();
61 }
62
63 $slider_atts['responsive'][] = array(
64 'breakpoint' => $breakpoint,
65 'settings' => array(
66 'slidesToShow' => $args[ $key ],
67 ),
68 );
69
70 }
71 }
72
73 $slider_atts = apply_filters( 'jet-form-builder/gallery/slider/atts', $slider_atts );
74 $slider_atts = htmlspecialchars( wp_json_encode( $slider_atts ) );
75
76 echo '<div class="jet-engine-gallery-slider" data-atts="' . esc_attr( $slider_atts ) . '">';
77
78 $gallery_id = self::get_gallery_id();
79
80 foreach ( $images as $img_id ) {
81
82 if ( 'full' === $args['size'] ) {
83 $img_url = $img_full = wp_get_attachment_image_url( $img_id, $args['size'] );
84 } else {
85 $img_url = wp_get_attachment_image_url( $img_id, $args['size'] );
86 $img_full = wp_get_attachment_image_url( $img_id, 'full' );
87 }
88
89 echo '<div class="jet-engine-gallery-slider__item">';
90
91 if ( $args['lightbox'] ) {
92 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 ) . '">';
93 } else {
94 echo '<span class="jet-engine-gallery-slider__item-wrap jet-engine-gallery-item-wrap">';
95 }
96
97 $alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true );
98
99 echo '<img src="' . esc_attr( $img_url ) . '" alt="' . esc_attr( $alt ) . '" class="jet-engine-gallery-slider__item-img">';
100
101 if ( $args['lightbox'] ) {
102 echo '</a>';
103 } else {
104 echo '</span>';
105 }
106
107 echo '</div>';
108
109 }
110
111 echo '</div>';
112
113 }
114
115 /**
116 * Render images gallery as grid
117 *
118 * @param array $images [description]
119 * @param string $size [description]
120 * @param boolean $lightbox [description]
121 *
122 * @return string
123 */
124 public static function grid( $images = array(), $args = array() ) {
125
126 if ( empty( $images ) ) {
127 return '';
128 }
129
130 $args = wp_parse_args(
131 $args,
132 array(
133 'size' => 'full',
134 'lightbox' => false,
135 'cols_desk' => 3,
136 'cols_tablet' => 3,
137 'cols_mobile' => 1,
138 )
139 );
140
141 ob_start();
142
143 $classes = array(
144 'grid-col-desk-' . $args['cols_desk'],
145 'grid-col-tablet-' . $args['cols_tablet'],
146 'grid-col-mobile-' . $args['cols_mobile'],
147 );
148 $classes = sprintf( ' %s', implode( ' ', $classes ) );
149
150 echo '<div class="jet-engine-gallery-grid' . esc_attr( $classes ) . '">';
151
152 $gallery_id = self::get_gallery_id();
153
154 foreach ( $images as $img_id ) {
155
156 if ( 'full' === $args['size'] ) {
157 $img_url = $img_full = wp_get_attachment_image_url( $img_id, $args['size'] );
158 } else {
159 $img_url = wp_get_attachment_image_url( $img_id, $args['size'] );
160 $img_full = wp_get_attachment_image_url( $img_id, 'full' );
161 }
162
163 echo '<div class="jet-engine-gallery-grid__item">';
164
165 if ( $args['lightbox'] ) {
166 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 ) . '">';
167 } else {
168 echo '<span class="jet-engine-gallery-grid__item-wrap jet-engine-gallery-item-wrap">';
169 }
170
171 $alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true );
172
173 echo '<img src="' . esc_attr( $img_url ) . '" alt="' . esc_attr( $alt ) . '" class="jet-engine-gallery-grid__item-img">';
174
175 if ( $args['lightbox'] ) {
176 echo '</a>';
177 } else {
178 echo '</span>';
179 }
180
181 echo '</div>';
182
183 }
184
185 echo '</div>';
186
187 return ob_get_clean();
188
189 }
190
191 /**
192 * Returns random ID for gallery
193 *
194 * @return [type] [description]
195 */
196 public static function get_gallery_id() {
197 return 'gallery_' . wp_rand( 1000, 9999 );
198 }
199
200 }
201