PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.9
JetFormBuilder — Dynamic Blocks Form Builder v3.1.9
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 2 years ago arrayable 2 years ago filters 2 years ago http 2 years ago macro-constants 2 years ago post 2 years ago resources 2 years ago theme 2 years ago attributes-trait.php 2 years ago base-attributes-trait.php 2 years ago builder-helper.php 2 years ago compatibility.php 2 years ago date-tools.php 2 years ago gallery.php 2 years ago get-icon-trait.php 2 years ago get-template-trait.php 2 years ago html-attributes-trait.php 2 years ago instance-trait.php 2 years ago macros-parser.php 2 years ago regexp-tools.php 2 years ago tools.php 2 years ago
gallery.php
210 lines
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 }
210