PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / 2.4.3
Responsive Lightbox & Gallery v2.4.3
2.7.8 trunk 1.0.0 1.0.1 1.0.1.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.0.1 1.4.1 1.4.11 1.4.12 1.4.13 1.4.14 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3.1 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7
responsive-lightbox / includes / functions.php
responsive-lightbox / includes Last commit date
providers 3 years ago class-fast-image.php 3 years ago class-folders-walker.php 7 years ago class-folders.php 3 years ago class-frontend.php 3 years ago class-galleries.php 3 years ago class-multilang.php 3 years ago class-remote-library-api.php 3 years ago class-remote-library.php 3 years ago class-settings.php 3 years ago class-tour.php 3 years ago class-welcome.php 3 years ago class-widgets.php 3 years ago functions.php 3 years ago
functions.php
182 lines
1 <?php
2 /**
3 * Responsive Lightbox public functions
4 *
5 * Functions available for users and developers. May not be replaced.
6 *
7 * @since 2.0
8 */
9 if ( ! defined( 'ABSPATH' ) )
10 exit;
11
12 /**
13 * Display gallery using shortcode.
14 *
15 * @param array $args Shortcode arguments
16 * @return void
17 */
18 function rl_gallery( $args = [] ) {
19 $defaults = [
20 'id' => 0
21 ];
22
23 // merge defaults with arguments
24 $args = array_merge( $defaults, $args );
25
26 // parse id
27 $args['id'] = (int) $args['id'];
28
29 // is it gallery?
30 if ( get_post_type( $args['id'] ) === 'rl_gallery' )
31 echo do_shortcode( '[rl_gallery id="' . $args['id'] . '"]' );
32 else
33 echo '[rl_gallery id="' . $args['id'] . '"]';
34 }
35
36 /**
37 * Get gallery shortcode images - wrapper.
38 *
39 * @param array $args Gallery arguments
40 * @return array
41 */
42 function rl_get_gallery_shortcode_images( $args ) {
43 return Responsive_Lightbox()->frontend->get_gallery_shortcode_images( $args );
44 }
45
46 /**
47 * Get gallery fields - wrapper.
48 *
49 * @param string $type Gallery type
50 * @return array
51 */
52 function rl_get_gallery_fields( $type ) {
53 return Responsive_Lightbox()->frontend->get_gallery_fields( $type );
54 }
55
56 /**
57 * Get gallery fields combined with shortcode attributes - wrapper.
58 *
59 * @param array $fields Gallery fields
60 * @param array $shortcode_atts Gallery shortcode attributes
61 * @param bool $gallery Whether is it rl_gallery shortcode
62 * @return array
63 */
64 function rl_get_gallery_fields_atts( $fields, $shortcode_atts, $gallery = true ) {
65 return Responsive_Lightbox()->frontend->get_gallery_fields_atts( $fields, $shortcode_atts, $gallery );
66 }
67
68 /**
69 * Get gallery images - wrapper.
70 *
71 * @param int $gallery_id Gallery ID
72 * @param array $args Gellery args
73 * @return array
74 */
75 function rl_get_gallery_images( $gallery_id, $args ) {
76 if ( did_action( 'init' ) )
77 return Responsive_Lightbox()->galleries->get_gallery_images( $gallery_id, $args );
78 else
79 return [];
80 }
81
82 /**
83 * Add lightbox to images, galleries and videos.
84 *
85 * @param string $content HTML content
86 * @return string
87 */
88 function rl_add_lightbox( $content ) {
89 return Responsive_Lightbox()->frontend->add_lightbox( $content );
90 }
91
92 /**
93 * Get attachment id by URL.
94 *
95 * @param string $url Image URL
96 * @return int
97 */
98 function rl_get_attachment_id_by_url( $url ) {
99 return Responsive_Lightbox()->frontend->get_attachment_id_by_url( $url );
100 }
101
102 /**
103 * Get image size by URL.
104 *
105 * @param string $url Image URL
106 * @return array
107 */
108 function rl_get_image_size_by_url( $url ) {
109 return Responsive_Lightbox()->frontend->get_image_size_by_url( $url );
110 }
111
112 /**
113 * Get current lightbox script.
114 *
115 * @return string
116 */
117 function rl_get_lightbox_script() {
118 return Responsive_Lightbox()->get_lightbox_script();
119 }
120
121 /**
122 * Set current lightbox script.
123 *
124 * @return bool
125 */
126 function rl_set_lightbox_script( $script ) {
127 return Responsive_Lightbox()->set_lightbox_script( $script );
128 }
129
130 /**
131 * Check whether lightbox supports specified type.
132 *
133 * @param string|array $type Lightbox support type(s), leave empty to get all supported features
134 * @param string $compare_mode
135 * @return bool|array
136 */
137 function rl_current_lightbox_supports( $type = '', $compare_mode = 'AND' ) {
138 // get main instance
139 $rl = Responsive_Lightbox();
140
141 // get current script
142 $script = $rl->get_lightbox_script();
143
144 // get scripts
145 $scripts = $rl->settings->scripts;
146
147 // valid script?
148 if ( array_key_exists( $script, $scripts ) && array_key_exists( 'supports', $scripts[$script] ) ) {
149 if ( ! empty( $type ) ) {
150 // multitype?
151 if ( is_array( $type ) ) {
152 // filter types
153 $type = array_filter( $type );
154
155 if ( empty( $type ) )
156 return false;
157
158 $supports = ( $compare_mode === 'AND' );
159
160 foreach ( $type as $_type ) {
161 // single type required
162 if ( $compare_mode === 'OR' ) {
163 if ( in_array( $_type, $scripts[$script]['supports'], true ) )
164 return true;
165 // all types required
166 } else {
167 if ( ! in_array( $_type, $scripts[$script]['supports'], true ) )
168 return false;
169 }
170 }
171
172 return $supports;
173 // single type
174 } else
175 return in_array( $type, $scripts[$script]['supports'], true );
176 // return all supported features
177 } else
178 return $scripts[$script]['supports'];
179 }
180
181 return false;
182 }