PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / 2.6.0
Responsive Lightbox & Gallery v2.6.0
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 / class-settings.php
responsive-lightbox / includes Last commit date
providers 1 year ago class-fast-image.php 2 years ago class-folders.php 6 months ago class-frontend.php 6 months ago class-galleries.php 6 months ago class-multilang.php 2 years ago class-remote-library-api.php 1 year ago class-remote-library.php 6 months ago class-settings.php 6 months ago class-tour.php 2 years ago class-welcome.php 2 years ago class-widgets.php 2 years ago functions.php 3 years ago
class-settings.php
2551 lines
1 <?php
2 // exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) )
4 exit;
5
6 new Responsive_Lightbox_Settings();
7
8 /**
9 * Responsive Lightbox settings class.
10 *
11 * @class Responsive_Lightbox_Settings
12 */
13 class Responsive_Lightbox_Settings {
14
15 public $settings = [];
16 private $tabs = [];
17 public $scripts = [];
18 public $image_titles = [];
19
20 /**
21 * Class constructor.
22 *
23 * @return void
24 */
25 public function __construct() {
26 // set instance
27 Responsive_Lightbox()->settings = $this;
28
29 // actions
30 add_action( 'after_setup_theme', [ $this, 'load_defaults' ] );
31 add_action( 'admin_init', [ $this, 'init_builder' ] );
32 add_action( 'admin_init', [ $this, 'register_settings' ] );
33 add_action( 'admin_menu', [ $this, 'admin_menu_options' ] );
34 }
35
36 /**
37 * Get class data.
38 *
39 * @param string $attr
40 * @return mixed
41 */
42 public function get_data( $attr ) {
43 return property_exists( $this, $attr ) ? $this->{$attr} : null;
44 }
45
46 /**
47 * Initialize additional stuff for builder.
48 *
49 * @return void
50 */
51 public function init_builder() {
52 // get main instance
53 $rl = Responsive_Lightbox();
54
55 // add categories
56 if ( $rl->options['builder']['gallery_builder'] && $rl->options['builder']['categories'] && $rl->options['builder']['archives'] ) {
57 $terms = get_terms( [ 'taxonomy' => 'rl_category', 'hide_empty' => false ] );
58
59 if ( ! empty( $terms ) ) {
60 foreach ( $terms as $term ) {
61 $this->settings['builder']['fields']['archives_category']['options'][$term->slug] = $term->name;
62 }
63 }
64 }
65
66 // flush rewrite rules if needed
67 if ( current_user_can( apply_filters( 'rl_lightbox_settings_capability', $rl->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' ) ) && isset( $_POST['flush_rules'] ) && isset( $_POST['option_page'], $_POST['action'], $_POST['responsive_lightbox_builder'], $_POST['_wpnonce'] ) && $_POST['option_page'] === 'responsive_lightbox_builder' && $_POST['action'] === 'update' && ( isset( $_POST['save_rl_builder'] ) || isset( $_POST['reset_rl_builder'] ) ) && check_admin_referer( 'responsive_lightbox_builder-options', '_wpnonce' ) !== false )
68 flush_rewrite_rules();
69 }
70
71 /**
72 * Load default settings.
73 *
74 * @global string $pagenow
75 *
76 * @return void
77 */
78 public function load_defaults() {
79 // get main instance
80 $rl = Responsive_Lightbox();
81
82 $this->scripts = apply_filters(
83 'rl_settings_scripts',
84 [
85 'featherlight' => [
86 'name' => __( 'Featherlight', 'responsive-lightbox' ),
87 'supports' => [ 'inline', 'iframe', 'ajax' ]
88 ],
89 'glightbox' => [
90 'name' => __( 'GLightbox', 'responsive-lightbox' ),
91 'supports' => [ 'title', 'caption', 'html_caption' ]
92 ],
93 'imagelightbox' => [
94 'name' => __( 'Image Lightbox', 'responsive-lightbox' ),
95 'supports' => []
96 ],
97 'magnific' => [
98 'name' => __( 'Magnific Popup', 'responsive-lightbox' ),
99 'supports' => [ 'inline', 'iframe', 'ajax', 'title', 'caption' ]
100 ],
101 'nivo' => [
102 'name' => __( 'Nivo Lightbox', 'responsive-lightbox' ),
103 'effects' => [
104 'fade' => __( 'fade', 'responsive-lightbox' ),
105 'fadeScale' => __( 'fade scale', 'responsive-lightbox' ),
106 'slideLeft' => __( 'slide left', 'responsive-lightbox' ),
107 'slideRight' => __( 'slide right', 'responsive-lightbox' ),
108 'slideUp' => __( 'slide up', 'responsive-lightbox' ),
109 'slideDown' => __( 'slide down', 'responsive-lightbox' ),
110 'fall' => __( 'fall', 'responsive-lightbox' )
111 ],
112 'supports' => [ 'inline', 'iframe', 'ajax', 'title' ]
113 ],
114 'prettyphoto' => [
115 'name' => __( 'prettyPhoto', 'responsive-lightbox' ),
116 'animation_speeds' => [
117 'slow' => __( 'slow', 'responsive-lightbox' ),
118 'normal' => __( 'normal', 'responsive-lightbox' ),
119 'fast' => __( 'fast', 'responsive-lightbox' )
120 ],
121 'themes' => [
122 'pp_default' => __( 'default', 'responsive-lightbox' ),
123 'light_rounded' => __( 'light rounded', 'responsive-lightbox' ),
124 'dark_rounded' => __( 'dark rounded', 'responsive-lightbox' ),
125 'light_square' => __( 'light square', 'responsive-lightbox' ),
126 'dark_square' => __( 'dark square', 'responsive-lightbox' ),
127 'facebook' => __( 'facebook', 'responsive-lightbox' )
128 ],
129 'wmodes' => [
130 'window' => __( 'window', 'responsive-lightbox' ),
131 'transparent' => __( 'transparent', 'responsive-lightbox' ),
132 'opaque' => __( 'opaque', 'responsive-lightbox' ),
133 'direct' => __( 'direct', 'responsive-lightbox' ),
134 'gpu' => __( 'gpu', 'responsive-lightbox' )
135 ],
136 'supports' => [ 'inline', 'iframe', 'ajax', 'title', 'caption' ]
137 ],
138 'swipebox' => [
139 'name' => __( 'SwipeBox', 'responsive-lightbox' ),
140 'animations' => [
141 'css' => __( 'CSS', 'responsive-lightbox' ),
142 'jquery' => __( 'jQuery', 'responsive-lightbox' )
143 ],
144 'supports' => [ 'title' ]
145 ],
146 'tosrus' => [
147 'name' => __( 'TosRUs', 'responsive-lightbox' ),
148 'supports' => [ 'inline', 'title' ]
149 ]
150 ]
151 );
152
153 $this->image_titles = [
154 'default' => __( 'None', 'responsive-lightbox' ),
155 'title' => __( 'Image Title', 'responsive-lightbox' ),
156 'caption' => __( 'Image Caption', 'responsive-lightbox' ),
157 'alt' => __( 'Image Alt Text', 'responsive-lightbox' ),
158 'description' => __( 'Image Description', 'responsive-lightbox' )
159 ];
160
161 // get scripts
162 foreach ( $this->scripts as $key => $value ) {
163 $scripts[$key] = $value['name'];
164 }
165
166 // get image sizes
167 $sizes = apply_filters(
168 'image_size_names_choose',
169 [
170 'thumbnail' => __( 'Thumbnail', 'responsive-lightbox' ),
171 'medium' => __( 'Medium', 'responsive-lightbox' ),
172 'large' => __( 'Large', 'responsive-lightbox' ),
173 'full' => __( 'Full Size', 'responsive-lightbox' )
174 ]
175 );
176
177 // get default gallery types
178 $gallery_types = $rl->get_data( 'gallery_types' );
179
180 // prepare galeries
181 $galleries = $builder_galleries = wp_parse_args( apply_filters( 'rl_gallery_types', [] ), $gallery_types );
182
183 unset( $builder_galleries['default'] );
184
185 $this->settings = [
186 'settings' => [
187 'option_group' => 'responsive_lightbox_settings',
188 'option_name' => 'responsive_lightbox_settings',
189 'sections' => [
190 'responsive_lightbox_settings' => [
191 'title' => __( 'General Settings', 'responsive-lightbox' )
192 ]
193 ],
194 'prefix' => 'rl',
195 'fields' => [
196 'tour' => [
197 'title' => __( 'Introduction Tour', 'responsive-lightbox' ),
198 'section' => 'responsive_lightbox_settings',
199 'type' => 'button',
200 'label' => __( 'Start Tour', 'responsive-lightbox' ),
201 'description' => __( 'Take this tour to quickly learn about the use of this plugin.', 'responsive-lightbox' ),
202 'classname' => 'button-primary button-hero',
203 ],
204 'script' => [
205 'title' => __( 'Default lightbox', 'responsive-lightbox' ),
206 'section' => 'responsive_lightbox_settings',
207 'type' => 'select',
208 'label' => '',
209 'description' => sprintf( __( 'Select your preferred ligthbox effect script or get our <a href="%s">premium extensions</a>.', 'responsive-lightbox' ), wp_nonce_url( add_query_arg( [ 'action' => 'rl-hide-notice' ], admin_url( 'admin.php?page=responsive-lightbox-addons' ) ), 'rl_action', 'rl_nonce' ) ),
210 'options' => $scripts
211 ],
212 'selector' => [
213 'title' => __( 'Selector', 'responsive-lightbox' ),
214 'section' => 'responsive_lightbox_settings',
215 'type' => 'text',
216 'description' => __( 'Enter the rel selector lightbox effect will be applied to.', 'responsive-lightbox' )
217 ],
218 'image_links' => [
219 'title' => __( 'Images', 'responsive-lightbox' ),
220 'section' => 'responsive_lightbox_settings',
221 'type' => 'boolean',
222 'label' => __( 'Enable lightbox for WordPress image links.', 'responsive-lightbox' )
223 ],
224 'image_title' => [
225 'title' => __( 'Single image title', 'responsive-lightbox' ),
226 'section' => 'responsive_lightbox_settings',
227 'type' => 'select',
228 'description' => __( 'Select title for single images.', 'responsive-lightbox' ),
229 'options' => $this->image_titles
230 ],
231 'image_caption' => [
232 'title' => __( 'Single image caption', 'responsive-lightbox' ),
233 'section' => 'responsive_lightbox_settings',
234 'type' => 'select',
235 'description' => __( 'Select caption for single images (if supported by selected lightbox and/or gallery).', 'responsive-lightbox' ),
236 'options' => $this->image_titles
237 ],
238 'images_as_gallery' => [
239 'title' => __( 'Single images as gallery', 'responsive-lightbox' ),
240 'section' => 'responsive_lightbox_settings',
241 'type' => 'boolean',
242 'label' => __( 'Display single post images as a gallery.', 'responsive-lightbox' )
243 ],
244 'galleries' => [
245 'title' => __( 'Galleries', 'responsive-lightbox' ),
246 'section' => 'responsive_lightbox_settings',
247 'type' => 'boolean',
248 'label' => __( 'Enable lightbox for WordPress image galleries.', 'responsive-lightbox' )
249 ],
250 'default_gallery' => [
251 'title' => __( 'WordPress gallery', 'responsive-lightbox' ),
252 'section' => 'responsive_lightbox_settings',
253 'type' => 'select',
254 'description' => __( 'Select your preferred default WordPress gallery style.', 'responsive-lightbox' ),
255 'options' => $galleries
256 ],
257 'builder_gallery' => [
258 'title' => __( 'Builder gallery', 'responsive-lightbox' ),
259 'section' => 'responsive_lightbox_settings',
260 'type' => 'select',
261 'description' => __( 'Select your preferred default builder gallery style.', 'responsive-lightbox' ),
262 'options' => $builder_galleries
263 ],
264 'default_woocommerce_gallery' => [
265 'title' => __( 'WooCommerce gallery', 'responsive-lightbox' ),
266 'section' => 'responsive_lightbox_settings',
267 'type' => 'select',
268 'disabled' => ! class_exists( 'WooCommerce' ),
269 'description' => __( 'Select your preferred gallery style for WooCommerce product gallery.', 'responsive-lightbox' ),
270 'options' => $galleries
271 ],
272 'gallery_image_size' => [
273 'title' => __( 'Gallery image size', 'responsive-lightbox' ),
274 'section' => 'responsive_lightbox_settings',
275 'type' => 'select',
276 'description' => __( 'Select image size for gallery image links.', 'responsive-lightbox' ),
277 'options' => $sizes
278 ],
279 'gallery_image_title' => [
280 'title' => __( 'Gallery image title', 'responsive-lightbox' ),
281 'section' => 'responsive_lightbox_settings',
282 'type' => 'select',
283 'description' => __( 'Select title for the gallery images.', 'responsive-lightbox' ),
284 'options' => $this->image_titles
285 ],
286 'gallery_image_caption' => [
287 'title' => __( 'Gallery image caption', 'responsive-lightbox' ),
288 'section' => 'responsive_lightbox_settings',
289 'type' => 'select',
290 'description' => __( 'Select caption for the gallery images (if supported by selected lightbox and/or gallery).', 'responsive-lightbox' ),
291 'options' => $this->image_titles
292 ],
293 'videos' => [
294 'title' => __( 'Videos', 'responsive-lightbox' ),
295 'section' => 'responsive_lightbox_settings',
296 'type' => 'boolean',
297 'label' => __( 'Enable lightbox for YouTube and Vimeo video links.', 'responsive-lightbox' )
298 ],
299 'widgets' => [
300 'title' => __( 'Widgets', 'responsive-lightbox' ),
301 'section' => 'responsive_lightbox_settings',
302 'type' => 'boolean',
303 'label' => __( 'Enable lightbox for widgets content.', 'responsive-lightbox' )
304 ],
305 'comments' => [
306 'title' => __( 'Comments', 'responsive-lightbox' ),
307 'section' => 'responsive_lightbox_settings',
308 'type' => 'boolean',
309 'label' => __( 'Enable lightbox for comments content.', 'responsive-lightbox' )
310 ],
311 'force_custom_gallery' => [
312 'title' => __( 'Force lightbox', 'responsive-lightbox' ),
313 'section' => 'responsive_lightbox_settings',
314 'type' => 'boolean',
315 'label' => __( 'Try to force lightbox for custom WP gallery replacements, like Jetpack or Visual Composer galleries.', 'responsive-lightbox' )
316 ],
317 'woocommerce_gallery_lightbox' => [
318 'title' => __( 'WooCommerce lightbox', 'responsive-lightbox' ),
319 'section' => 'responsive_lightbox_settings',
320 'type' => 'boolean',
321 'label' => __( 'Replace WooCommerce product gallery lightbox.', 'responsive-lightbox' ),
322 'disabled' => ! class_exists( 'WooCommerce' ) || Responsive_Lightbox()->options['settings']['default_woocommerce_gallery'] !== 'default'
323 ],
324 'enable_custom_events' => [
325 'title' => __( 'Custom events', 'responsive-lightbox' ),
326 'section' => 'responsive_lightbox_settings',
327 'type' => 'multiple',
328 'fields' => [
329 'enable_custom_events' => [
330 'type' => 'boolean',
331 'label' => __( 'Enable triggering lightbox on custom jQuery events.', 'responsive-lightbox' )
332 ],
333 'custom_events' => [
334 'type' => 'text',
335 'description' => __( 'Enter a space separated list of events.', 'responsive-lightbox' )
336 ]
337 ]
338 ],
339 'loading_place' => [
340 'title' => __( 'Loading place', 'responsive-lightbox' ),
341 'section' => 'responsive_lightbox_settings',
342 'type' => 'radio',
343 'description' => __( 'Select where all the lightbox scripts should be placed.', 'responsive-lightbox' ),
344 'options' => [
345 'header' => __( 'Header', 'responsive-lightbox' ),
346 'footer' => __( 'Footer', 'responsive-lightbox' )
347 ]
348 ],
349 'conditional_loading' => [
350 'title' => __( 'Conditional loading', 'responsive-lightbox' ),
351 'section' => 'responsive_lightbox_settings',
352 'type' => 'boolean',
353 'label' => __( 'Enable to load scripts and styles only on pages that have images or galleries in post content.', 'responsive-lightbox' )
354 ],
355 'deactivation_delete' => [
356 'title' => __( 'Delete data', 'responsive-lightbox' ),
357 'section' => 'responsive_lightbox_settings',
358 'type' => 'boolean',
359 'label' => __( 'Delete all plugin settings on deactivation.', 'responsive-lightbox' ),
360 'description' => __( 'Enable this to delete all plugin settings and also delete all plugin capabilities from all users on deactivation.', 'responsive-lightbox' )
361 ]
362 ]
363 ],
364 'builder' => [
365 'option_group' => 'responsive_lightbox_builder',
366 'option_name' => 'responsive_lightbox_builder',
367 'sections' => [
368 'responsive_lightbox_builder' => [
369 'title' => __( 'Gallery Builder Settings', 'responsive-lightbox' )
370 ]
371 ],
372 'prefix' => 'rl',
373 'fields' => [
374 'gallery_builder' => [
375 'title' => __( 'Gallery Builder', 'responsive-lightbox' ),
376 'section' => 'responsive_lightbox_builder',
377 'type' => 'boolean',
378 'label' => __( 'Enable advanced gallery builder.', 'responsive-lightbox' )
379 ],
380 'categories' => [
381 'title' => __( 'Categories', 'responsive-lightbox' ),
382 'section' => 'responsive_lightbox_builder',
383 'type' => 'boolean',
384 'label' => __( 'Enable Gallery Categories.', 'responsive-lightbox' ),
385 'description' => __( 'Enable if you want to use Gallery Categories.', 'responsive-lightbox' )
386 ],
387 'tags' => [
388 'title' => __( 'Tags', 'responsive-lightbox' ),
389 'section' => 'responsive_lightbox_builder',
390 'type' => 'boolean',
391 'label' => __( 'Enable Gallery Tags.', 'responsive-lightbox' ),
392 'description' => __( 'Enable if you want to use Gallery Tags.', 'responsive-lightbox' )
393 ],
394 'permalink' => [
395 'title' => __( 'Gallery Permalink', 'responsive-lightbox' ),
396 'section' => 'responsive_lightbox_builder',
397 'type' => 'text',
398 'description' => '<code>' . site_url() . '/<strong>' . untrailingslashit( esc_html( $rl->options['builder']['permalink'] ) ) . '</strong>/</code><br />' . esc_html__( 'Enter gallery page slug.', 'responsive-lightbox' )
399 ],
400 'permalink_categories' => [
401 'title' => __( 'Categories Permalink', 'responsive-lightbox' ),
402 'section' => 'responsive_lightbox_builder',
403 'type' => 'text',
404 'description' => '<code>' . site_url() . '/<strong>' . untrailingslashit( esc_html( $rl->options['builder']['permalink_categories'] ) ) . '</strong>/</code><br />' . esc_html__( 'Enter gallery categories archive page slug.', 'responsive-lightbox' )
405 ],
406 'permalink_tags' => [
407 'title' => __( 'Tags Permalink', 'responsive-lightbox' ),
408 'section' => 'responsive_lightbox_builder',
409 'type' => 'text',
410 'description' => '<code>' . site_url() . '/<strong>' . untrailingslashit( esc_html( $rl->options['builder']['permalink_tags'] ) ) . '</strong>/</code><br />' . esc_html__( 'Enter gallery tags archive page slug.', 'responsive-lightbox' )
411 ],
412 'archives' => [
413 'title' => __( 'Archives', 'responsive-lightbox' ),
414 'section' => 'responsive_lightbox_builder',
415 'type' => 'boolean',
416 'label' => __( 'Enable gallery archives.', 'responsive-lightbox' )
417 ],
418 'archives_category' => [
419 'title' => __( 'Archives category', 'responsive-lightbox' ),
420 'section' => 'responsive_lightbox_builder',
421 'type' => 'select',
422 'description' => __( 'Select category for gallery archives.', 'responsive-lightbox' ),
423 'options' => [
424 'all' => __( 'All', 'responsive-lightbox' )
425 ]
426 ]
427 ]
428 ],
429 'folders' => [
430 'option_group' => 'responsive_lightbox_folders',
431 'option_name' => 'responsive_lightbox_folders',
432 'sections' => [
433 'responsive_lightbox_folders' => [
434 'title' => __( 'Folders Settings', 'responsive-lightbox' )
435 ]
436 ],
437 'prefix' => 'rl',
438 'fields' => [
439 'active' => [
440 'title' => __( 'Folders', 'responsive-lightbox' ),
441 'section' => 'responsive_lightbox_folders',
442 'type' => 'boolean',
443 'label' => __( 'Enable media folders.', 'responsive-lightbox' )
444 ],
445 'media_taxonomy' => [
446 'title' => __( 'Media taxonomy', 'responsive-lightbox' ),
447 'section' => 'responsive_lightbox_folders',
448 'type' => 'select',
449 'description' => __( 'Select media taxonomy.', 'responsive-lightbox' ) . '<br />' . __( 'If you have ever used custom media taxonomies you may try to <a id="rl_folders_load_old_taxonomies" href="#">load and use them.</a>', 'responsive-lightbox' ),
450 'after_field' => '<span class="spinner rl-spinner"></span>',
451 'options' => [ $rl->options['folders']['media_taxonomy'] => $rl->options['folders']['media_taxonomy'] . ' (' . __( 'Folders', 'responsive-lightbox' ) . ')' ]
452 ],
453 'media_tags' => [
454 'title' => __( 'Media tags', 'responsive-lightbox' ),
455 'section' => 'responsive_lightbox_folders',
456 'type' => 'boolean',
457 'label' => __( 'Enable media tags.', 'responsive-lightbox' ),
458 'description' => __( 'Enable if you want to use media tags.', 'responsive-lightbox' )
459 ],
460 'show_in_menu' => [
461 'title' => __( 'Show in menu', 'responsive-lightbox' ),
462 'section' => 'responsive_lightbox_folders',
463 'type' => 'boolean',
464 'label' => __( 'Enable to show the taxonomy in the admin menu.', 'responsive-lightbox' )
465 ],
466 'folders_removal' => [
467 'title' => __( 'Subfolder removal', 'responsive-lightbox' ),
468 'section' => 'responsive_lightbox_folders',
469 'type' => 'boolean',
470 'label' => __( 'Select to remove subfolders when parent folder is deleted.', 'responsive-lightbox' )
471 ],
472 'jstree_wholerow' => [
473 'title' => __( 'Whole row', 'responsive-lightbox' ),
474 'section' => 'responsive_lightbox_folders',
475 'type' => 'boolean',
476 'label' => __( 'Enable to highlight folder\'s row as a clickable area.', 'responsive-lightbox' )
477 ]
478 ]
479 ],
480 'remote_library' => [
481 'option_group' => 'responsive_lightbox_remote_library',
482 'option_name' => 'responsive_lightbox_remote_library',
483 'sections' => [
484 'responsive_lightbox_remote_library' => [
485 'title' => __( 'Remote Library Settings', 'responsive-lightbox' )
486 ],
487 'responsive_lightbox_remote_library_providers' => [
488 'title' => __( 'Media Providers', 'responsive-lightbox' ),
489 'page' => 'responsive_lightbox_remote_library',
490 'callback' => [ $this, 'remote_library_providers_description' ]
491 ]
492 ],
493 'prefix' => 'rl',
494 'fields' => [
495 'active' => [
496 'title' => __( 'Remote Library', 'responsive-lightbox' ),
497 'section' => 'responsive_lightbox_remote_library',
498 'type' => 'boolean',
499 'label' => __( 'Enable remote libraries.', 'responsive-lightbox' ),
500 'description' => __( 'Check this to enable remote access to the following image libraries.', 'responsive-lightbox' )
501 ],
502 'max_image_size' => [
503 'title' => __( 'Max Image Size', 'responsive-lightbox' ),
504 'section' => 'responsive_lightbox_remote_library',
505 'type' => 'number',
506 'min' => 1,
507 'description' => __( 'Maximum allowed image size for remote downloads.', 'responsive-lightbox' ),
508 'append' => __( 'MB', 'responsive-lightbox' )
509 ],
510 'caching' => [
511 'title' => __( 'Caching', 'responsive-lightbox' ),
512 'section' => 'responsive_lightbox_remote_library',
513 'type' => 'boolean',
514 'label' => __( 'Enable remote library requests caching.', 'responsive-lightbox' )
515 ],
516 'cache_expiry' => [
517 'title' => __( 'Cache expiry', 'responsive-lightbox' ),
518 'section' => 'responsive_lightbox_remote_library',
519 'type' => 'number',
520 'min' => 1,
521 'description' => __( 'Enter the cache expiry time.', 'responsive-lightbox' ),
522 'append' => __( 'hour(s)', 'responsive-lightbox' )
523 ]
524 ]
525 ],
526 'configuration' => [
527 'option_group' => 'responsive_lightbox_configuration',
528 'option_name' => 'responsive_lightbox_configuration',
529 'sections' => [
530 'responsive_lightbox_configuration' => [
531 'title' => sprintf( __( '%s Settings', 'responsive-lightbox' ), ( isset( $this->scripts[$rl->options['settings']['script']]['name'] ) ? $this->scripts[$rl->options['settings']['script']]['name'] : $this->scripts[$rl->defaults['settings']['script']]['name'] ) )
532 ],
533 ],
534 'prefix' => 'rl',
535 'fields' => []
536 ],
537 'capabilities' => [
538 'option_group' => 'responsive_lightbox_capabilities',
539 'option_name' => 'responsive_lightbox_capabilities',
540 'callback' => [ $this, 'validate_capabilities' ],
541 'sections' => [
542 'responsive_lightbox_capabilities_fields' => [
543 'title' => __( 'Capabilities Settings', 'responsive-lightbox' ),
544 'page' => 'responsive_lightbox_capabilities'
545 ],
546 'responsive_lightbox_capabilities' => [
547 'callback' => [ $this, 'capabilities_table' ]
548 ]
549 ],
550 'prefix' => 'rl',
551 'fields' => [
552 'active' => [
553 'title' => __( 'Capabilities', 'responsive-lightbox' ),
554 'section' => 'responsive_lightbox_capabilities_fields',
555 'type' => 'boolean',
556 'label' => __( 'Enable advanced capability management.', 'responsive-lightbox' ),
557 'description' => __( 'Check this to enable access to plugin features for selected user roles.', 'responsive-lightbox' )
558 ]
559 ]
560 ],
561 'basicgrid_gallery' => [
562 'option_group' => 'responsive_lightbox_basicgrid_gallery',
563 'option_name' => 'responsive_lightbox_basicgrid_gallery',
564 'sections' => [
565 'responsive_lightbox_basicgrid_gallery' => [
566 'title' => __( 'Basic Grid Gallery Settings', 'responsive-lightbox' )
567 ]
568 ],
569 'prefix' => 'rl',
570 'fields' => [
571 'screen_size_columns' => [
572 'title' => __( 'Screen sizes', 'responsive-lightbox' ),
573 'section' => 'responsive_lightbox_basicgrid_gallery',
574 'type' => 'multiple',
575 'description' => __( 'Number of columns in a gallery depending on the device screen size. (if greater than 0 overrides the Columns option)', 'responsive-lightbox' ),
576 'fields' => [
577 'columns_lg' => [
578 'type' => 'number',
579 'min' => 0,
580 'max' => 6,
581 'append' => __( 'large devices / desktops (&ge;1200px)', 'responsive-lightbox' )
582 ],
583 'columns_md' => [
584 'type' => 'number',
585 'min' => 0,
586 'max' => 6,
587 'append' => __( 'medium devices / desktops (&ge;992px)', 'responsive-lightbox' )
588 ],
589 'columns_sm' => [
590 'type' => 'number',
591 'min' => 0,
592 'max' => 6,
593 'append' => __( 'small devices / tablets (&ge;768px)', 'responsive-lightbox' )
594 ],
595 'columns_xs' => [
596 'type' => 'number',
597 'min' => 0,
598 'max' => 6,
599 'append' => __( 'extra small devices / phones (<768px)', 'responsive-lightbox' )
600 ]
601 ]
602 ],
603 'gutter' => [
604 'title' => __( 'Gutter', 'responsive-lightbox' ),
605 'section' => 'responsive_lightbox_basicgrid_gallery',
606 'type' => 'number',
607 'min' => 0,
608 'description' => __( 'Set the pixel width between the columns and rows.', 'responsive-lightbox' ),
609 'append' => 'px'
610 ],
611 'force_height' => [
612 'title' => __( 'Force height', 'responsive-lightbox' ),
613 'section' => 'responsive_lightbox_basicgrid_gallery',
614 'type' => 'boolean',
615 'label' => __( 'Enable to force the thumbnail row height.', 'responsive-lightbox' )
616 ],
617 'row_height' => [
618 'title' => __( 'Row height', 'responsive-lightbox' ),
619 'section' => 'responsive_lightbox_basicgrid_gallery',
620 'type' => 'number',
621 'min' => 50,
622 'description' => __( 'Enter the thumbnail row height in pixels (used if Force height is enabled). Defaults to 150px.', 'responsive-lightbox' ),
623 'append' => 'px'
624 ]
625 ]
626 ],
627 'basicslider_gallery' => [
628 'option_group' => 'responsive_lightbox_basicslider_gallery',
629 'option_name' => 'responsive_lightbox_basicslider_gallery',
630 'sections' => [
631 'responsive_lightbox_basicslider_gallery' => [
632 'title' => __( 'Basic Slider Gallery Settings', 'responsive-lightbox' )
633 ]
634 ],
635 'prefix' => 'rl',
636 'fields' => [
637 'slider_type' => [
638 'title' => __( 'Slider Type', 'responsive-lightbox' ),
639 'section' => 'responsive_lightbox_basicslider_gallery',
640 'type' => 'select',
641 'label' => __( 'The type of the slider.', 'responsive-lightbox' ),
642 'options' => [
643 'slide' => __( 'Slide', 'responsive-lightbox' ),
644 'loop' => __( 'Loop', 'responsive-lightbox' ),
645 'fade' => __( 'Fade', 'responsive-lightbox' )
646 ]
647 ],
648 'height' => [
649 'title' => __( 'Height', 'responsive-lightbox' ),
650 'section' => 'responsive_lightbox_basicslider_gallery',
651 'type' => 'number',
652 'min' => 0,
653 'description' => __( 'Defines the carousel max width in percentage. If set to 0 slider will adapt to slides width.', 'responsive-lightbox' ),
654 'append' => 'px'
655 ],
656 'width' => [
657 'title' => __( 'Width', 'responsive-lightbox' ),
658 'section' => 'responsive_lightbox_basicslider_gallery',
659 'type' => 'number',
660 'min' => 0,
661 'description' => __( 'Defines the slide height in pixels. If set to 0, slider height will adapt to slides height.', 'responsive-lightbox' ),
662 'append' => '%'
663 ],
664 'speed' => [
665 'title' => __( 'Animation Speed', 'responsive-lightbox' ),
666 'section' => 'responsive_lightbox_basicslider_gallery',
667 'type' => 'number',
668 'min' => 400,
669 'description' => __( 'The transition speed in milliseconds.', 'responsive-lightbox' ),
670 'append' => 'ms'
671 ],
672 'gap' => [
673 'title' => __( 'Slides Gap', 'responsive-lightbox' ),
674 'section' => 'responsive_lightbox_basicslider_gallery',
675 'type' => 'number',
676 'min' => 20,
677 'description' => __( 'The gap between slides.', 'responsive-lightbox' ),
678 'append' => 'px'
679 ],
680 'arrows_navigation' => [
681 'title' => __( 'Arrows Navigtion', 'responsive-lightbox' ),
682 'section' => 'responsive_lightbox_basicslider_gallery',
683 'type' => 'boolean',
684 'label' => __( 'Determines whether to create arrows or not.', 'responsive-lightbox' )
685 ],
686 'dots_navigation' => [
687 'title' => __( 'Dots Navigtion', 'responsive-lightbox' ),
688 'section' => 'responsive_lightbox_basicslider_gallery',
689 'type' => 'boolean',
690 'label' => __( 'Determines whether to create pagination (indicator dots) or not.', 'responsive-lightbox' )
691 ],
692 'drag' => [
693 'title' => __( 'Drag', 'responsive-lightbox' ),
694 'section' => 'responsive_lightbox_basicslider_gallery',
695 'type' => 'boolean',
696 'label' => __( 'Determines whether to allow the user to drag the carousel or not.', 'responsive-lightbox' )
697 ],
698 'autoplay' => [
699 'title' => __( 'Autoplay', 'responsive-lightbox' ),
700 'section' => 'responsive_lightbox_basicslider_gallery',
701 'type' => 'boolean',
702 'label' => __( 'Determines whether to enable autoplay or not.', 'responsive-lightbox' )
703 ],
704 'interval' => [
705 'title' => __( 'Interval', 'responsive-lightbox' ),
706 'section' => 'responsive_lightbox_basicslider_gallery',
707 'type' => 'number',
708 'min' => 1000,
709 'description' => __( 'The autoplay interval duration in milliseconds.', 'responsive-lightbox' ),
710 'append' => 'ms'
711 ],
712 'wheel' => [
713 'title' => __( 'Mouse wheel', 'responsive-lightbox' ),
714 'section' => 'responsive_lightbox_basicslider_gallery',
715 'type' => 'boolean',
716 'label' => __( 'Determines whether to enable navigation by the mouse wheel.', 'responsive-lightbox' )
717 ],
718 'slides_per_page' => [
719 'title' => __( 'Per Page', 'responsive-lightbox' ),
720 'section' => 'responsive_lightbox_basicslider_gallery',
721 'type' => 'number',
722 'min' => 1,
723 'description' => __( 'Determines the number of slides to display in a page.', 'responsive-lightbox' )
724 ],
725 'slides_per_move' => [
726 'title' => __( 'Per Move', 'responsive-lightbox' ),
727 'section' => 'responsive_lightbox_basicslider_gallery',
728 'type' => 'number',
729 'min' => 1,
730 'description' => __( 'Determines the number of slides to move at once.', 'responsive-lightbox' )
731 ],
732 'slides_start' => [
733 'title' => __( 'Start', 'responsive-lightbox' ),
734 'section' => 'responsive_lightbox_basicslider_gallery',
735 'type' => 'number',
736 'min' => 0,
737 'description' => __( 'Defines the start index.', 'responsive-lightbox' )
738 ]
739 ]
740 ],
741 'basicmasonry_gallery' => [
742 'option_group' => 'responsive_lightbox_basicmasonry_gallery',
743 'option_name' => 'responsive_lightbox_basicmasonry_gallery',
744 'sections' => [
745 'responsive_lightbox_basicmasonry_gallery' => [
746 'title' => __( 'Basic Masonry Gallery Settings', 'responsive-lightbox' )
747 ]
748 ],
749 'prefix' => 'rl',
750 'fields' => [
751 'screen_size_columns' => [
752 'title' => __( 'Screen sizes', 'responsive-lightbox' ),
753 'section' => 'responsive_lightbox_basicmasonry_gallery',
754 'type' => 'multiple',
755 'description' => __( 'Number of columns in a gallery depending on the device screen size. (if greater than 0 overrides the Columns option)', 'responsive-lightbox' ),
756 'fields' => [
757 'columns_lg' => [
758 'type' => 'number',
759 'min' => 0,
760 'max' => 6,
761 'default' => 4,
762 'append' => __( 'large devices / desktops (&ge;1200px)', 'responsive-lightbox' )
763 ],
764 'columns_md' => [
765 'type' => 'number',
766 'min' => 0,
767 'max' => 6,
768 'default' => 3,
769 'append' => __( 'medium devices / desktops (&ge;992px)', 'responsive-lightbox' )
770 ],
771 'columns_sm' => [
772 'type' => 'number',
773 'min' => 0,
774 'max' => 6,
775 'default' => 2,
776 'append' => __( 'small devices / tablets (&ge;768px)', 'responsive-lightbox' )
777 ],
778 'columns_xs' => [
779 'type' => 'number',
780 'min' => 0,
781 'max' => 6,
782 'default' => 2,
783 'append' => __( 'extra small devices / phones (<768px)', 'responsive-lightbox' )
784 ]
785 ]
786 ],
787 'gutter' => [
788 'title' => __( 'Gutter', 'responsive-lightbox' ),
789 'section' => 'responsive_lightbox_basicmasonry_gallery',
790 'type' => 'number',
791 'description' => __( 'Horizontal space between gallery items.', 'responsive-lightbox' ),
792 'append' => 'px'
793 ],
794 'margin' => [
795 'title' => __( 'Margin', 'responsive-lightbox' ),
796 'section' => 'responsive_lightbox_basicmasonry_gallery',
797 'type' => 'number',
798 'description' => __( 'Vertical space between gallery items.', 'responsive-lightbox' ),
799 'append' => 'px'
800 ],
801 'origin_left' => [
802 'title' => __( 'Origin Left', 'responsive-lightbox' ),
803 'section' => 'responsive_lightbox_basicmasonry_gallery',
804 'type' => 'boolean',
805 'label' => __( 'Enable left-to-right layouts.', 'responsive-lightbox' ),
806 'description' => __( 'Controls the horizontal flow of the layout. By default, item elements start positioning at the left. Uncheck it for right-to-left layouts.', 'responsive-lightbox' )
807 ],
808 'origin_top' => [
809 'title' => __( 'Origin Top', 'responsive-lightbox' ),
810 'section' => 'responsive_lightbox_basicmasonry_gallery',
811 'type' => 'boolean',
812 'label' => __( 'Enable top-to-bottom layouts.', 'responsive-lightbox' ),
813 'description' => __( 'Controls the vertical flow of the layout. By default, item elements start positioning at the top. Uncheck it for bottom-up layouts.', 'responsive-lightbox' )
814 ]
815 ]
816 ]
817 ];
818
819 $this->tabs = apply_filters(
820 'rl_settings_tabs',
821 [
822 'settings' => [
823 'name' => __( 'General', 'responsive-lightbox' ),
824 'key' => 'responsive_lightbox_settings',
825 'submit' => 'save_rl_settings',
826 'reset' => 'reset_rl_settings'
827 ],
828 'configuration' => [
829 'name' => __( 'Lightboxes', 'responsive-lightbox' ),
830 'key' => 'responsive_lightbox_configuration',
831 'submit' => 'save_' . $this->settings['configuration']['prefix'] . '_configuration',
832 'reset' => 'reset_' . $this->settings['configuration']['prefix'] . '_configuration',
833 'sections' => $scripts,
834 'default_section' => $rl->options['settings']['script']
835 ],
836 'basicgrid_gallery' => [
837 'name' => __( 'Basic Grid', 'responsive-lightbox' ),
838 'key' => 'responsive_lightbox_basicgrid_gallery',
839 'submit' => 'save_rl_basicgrid_gallery',
840 'reset' => 'reset_rl_basicgrid_gallery'
841 ],
842 'basicslider_gallery' => [
843 'name' => __( 'Basic Slider', 'responsive-lightbox' ),
844 'key' => 'responsive_lightbox_basiclider_gallery',
845 'submit' => 'save_rl_basiclider_gallery',
846 'reset' => 'reset_rl_basiclider_gallery'
847 ],
848 'basicmasonry_gallery' => [
849 'name' => __( 'Basic Masonry', 'responsive-lightbox' ),
850 'key' => 'responsive_lightbox_basicmasonry_gallery',
851 'submit' => 'save_rl_basicmasonry_gallery',
852 'reset' => 'reset_rl_basicmasonry_gallery'
853 ]
854 ]
855 );
856
857 $tabs_copy = $this->tabs;
858 $tab_key = '';
859 $section_key = isset( $_REQUEST['section'] ) ? sanitize_key( $_REQUEST['section'] ) : '';
860
861 // set current tab and section
862 if ( is_admin() && ! wp_doing_ajax() ) {
863 global $pagenow;
864
865 // check page
866 $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : '';
867
868 // check settings page
869 if ( $pagenow === 'options.php' || ( $pagenow == 'admin.php' && $page && preg_match( '/^responsive-lightbox-(' . implode( '|', array_keys( $this->tabs + [ 'gallery' => '', 'addons' => '' ] ) ) . ')$/', $page, $tabs ) === 1 ) ) {
870 // set tab key
871 $tab_key = isset( $tabs[1] ) ? $tabs[1] : 'settings';
872
873 // set section key
874 if ( ! $section_key )
875 $section_key = ! empty( $this->tabs[$tab_key]['default_section'] ) ? $this->tabs[$tab_key]['default_section'] : '';
876 }
877 }
878
879 // remove default gallery
880 if ( isset( $gallery_types['default'] ) )
881 unset( $gallery_types['default'] );
882
883 // get available galleries
884 $gallery_types = apply_filters( 'rl_gallery_types', $gallery_types );
885
886 if ( $gallery_types ) {
887 foreach ( $gallery_types as $key => $name ) {
888 unset( $gallery_types[$key] );
889
890 $gallery_types[$key . '_gallery'] = $name;
891 }
892 }
893
894 // backward compatibility, remove from tabs
895 $gallery_tabs = array_intersect( array_keys( $this->tabs ), array_keys( $gallery_types ) );
896 $galleries = [];
897
898 if ( ! empty( $gallery_tabs ) ) {
899 // unset tabs if exist
900 foreach ( $gallery_tabs as $gallery_tab ) {
901 $galleries[$gallery_tab] = $this->tabs[$gallery_tab];
902
903 unset( $this->tabs[$gallery_tab] );
904 }
905
906 foreach ( $galleries as $key => $gallery ) {
907 $gallery_sections[$key] = $gallery['name'];
908 }
909
910 if ( $tab_key == 'gallery' ) {
911 if ( ! $section_key ) {
912 $section_key = in_array( $rl->options['settings']['default_gallery'] . '_gallery', array_keys( $gallery_sections ) ) ? $rl->options['settings']['default_gallery'] . '_gallery' : key( $gallery_sections );
913 }
914 }
915
916 $this->tabs['gallery'] = [
917 'name' => __( 'Galleries', 'responsive-lightbox' ),
918 'key' => 'responsive_lightbox_' . $section_key,
919 'submit' => array_key_exists( $section_key, $tabs_copy ) ? $tabs_copy[$section_key]['submit'] : 'save_' . $section_key . '_configuration',
920 'reset' => array_key_exists( $section_key, $tabs_copy ) ? $tabs_copy[$section_key]['reset'] : 'reset_rl_' . $section_key,
921 'sections' => $gallery_sections,
922 'default_section' => $section_key
923 ];
924 }
925
926 $this->tabs['builder'] = [
927 'name' => __( 'Builder', 'responsive-lightbox' ),
928 'key' => 'responsive_lightbox_builder',
929 'submit' => 'save_rl_builder',
930 'reset' => 'reset_rl_builder'
931 ];
932
933 $this->tabs['folders'] = [
934 'name' => __( 'Folders', 'responsive-lightbox' ),
935 'key' => 'responsive_lightbox_folders',
936 'submit' => 'save_rl_folders',
937 'reset' => 'reset_rl_folders'
938 ];
939
940 $this->tabs['capabilities'] = [
941 'name' => __( 'Capabilities', 'responsive-lightbox' ),
942 'key' => 'responsive_lightbox_capabilities',
943 'submit' => 'save_rl_capabilities',
944 'reset' => 'reset_rl_capabilities'
945 ];
946
947 $this->tabs['remote_library'] = [
948 'name' => __( 'Remote Library', 'responsive-lightbox' ),
949 'key' => 'responsive_lightbox_remote_library',
950 'submit' => 'save_rl_remote_library',
951 'reset' => 'reset_rl_remote_library'
952 ];
953
954 $this->tabs = apply_filters( 'rl_settings_tabs_extra', $this->tabs );
955
956 // push licenses just before the addons
957 if ( isset( $this->tabs['licenses'] ) ) {
958 unset( $this->tabs['licenses'] );
959
960 $this->tabs['licenses'] = [
961 'name' => __( 'Licenses', 'responsive-lightbox' ),
962 'key' => 'responsive_lightbox_licenses',
963 'submit' => 'save_rl_licenses',
964 'reset' => 'reset_rl_licenses'
965 ];
966 }
967
968 $this->tabs['addons'] = [
969 'name' => __( 'Add-ons', 'responsive-lightbox' ),
970 'key' => 'responsive_lightbox_configuration',
971 'callback' => [ $this, 'addons_tab_cb' ]
972 ];
973
974 if ( isset( $this->tabs[$tab_key]['sections'][$section_key] ) && empty( $this->tabs[$tab_key]['sections']['responsive_lightbox_' . $tab_key]['title'] ) )
975 $this->settings[$tab_key]['sections']['responsive_lightbox_' . $tab_key]['title'] = sprintf( __( '%s Settings', 'responsive-lightbox' ), $this->tabs[$tab_key]['sections'][$section_key] );
976
977 switch ( ! empty( $section_key ) ? $section_key : $rl->options['settings']['script'] ) {
978 case 'swipebox':
979 $this->settings['configuration']['prefix'] = 'rl_sb';
980 $this->settings['configuration']['fields'] = [
981 'animation' => [
982 'title' => __( 'Animation type', 'responsive-lightbox' ),
983 'section' => 'responsive_lightbox_configuration',
984 'type' => 'radio',
985 'label' => '',
986 'description' => __( 'Select a method of applying a lightbox effect.', 'responsive-lightbox' ),
987 'options' => $this->scripts['swipebox']['animations'],
988 'parent' => 'swipebox'
989 ],
990 'force_png_icons' => [
991 'title' => __( 'Force PNG icons', 'responsive-lightbox' ),
992 'section' => 'responsive_lightbox_configuration',
993 'type' => 'boolean',
994 'label' => __( 'Enable this if you\'re having problems with navigation icons not visible on some devices.', 'responsive-lightbox' ),
995 'parent' => 'swipebox'
996 ],
997 'hide_close_mobile' => [
998 'title' => __( 'Hide close on mobile', 'responsive-lightbox' ),
999 'section' => 'responsive_lightbox_configuration',
1000 'type' => 'boolean',
1001 'label' => __( 'Hide the close button on mobile devices.', 'responsive-lightbox' ),
1002 'parent' => 'swipebox'
1003 ],
1004 'remove_bars_mobile' => [
1005 'title' => __( 'Remove bars on mobile', 'responsive-lightbox' ),
1006 'section' => 'responsive_lightbox_configuration',
1007 'type' => 'boolean',
1008 'label' => __( 'Hide the top and bottom bars on mobile devices.', 'responsive-lightbox' ),
1009 'parent' => 'swipebox'
1010 ],
1011 'hide_bars' => [
1012 'title' => __( 'Top and bottom bars', 'responsive-lightbox' ),
1013 'section' => 'responsive_lightbox_configuration',
1014 'type' => 'multiple',
1015 'fields' => [
1016 'hide_bars' => [
1017 'type' => 'boolean',
1018 'label' => __( 'Hide top and bottom bars after a period of time.', 'responsive-lightbox' ),
1019 'parent' => 'swipebox'
1020 ],
1021 'hide_bars_delay' => [
1022 'type' => 'number',
1023 'description' => __( 'Enter the time after which the top and bottom bars will be hidden (when hiding is enabled).', 'responsive-lightbox' ),
1024 'append' => 'ms',
1025 'parent' => 'swipebox'
1026 ]
1027 ]
1028 ],
1029 'video_max_width' => [
1030 'title' => __( 'Video max width', 'responsive-lightbox' ),
1031 'section' => 'responsive_lightbox_configuration',
1032 'type' => 'number',
1033 'description' => __( 'Enter the max video width in a lightbox.', 'responsive-lightbox' ),
1034 'append' => 'px',
1035 'parent' => 'swipebox'
1036 ],
1037 'loop_at_end' => [
1038 'title' => __( 'Loop at end', 'responsive-lightbox' ),
1039 'section' => 'responsive_lightbox_configuration',
1040 'type' => 'boolean',
1041 'label' => __( 'True will return to the first image after the last image is reached.', 'responsive-lightbox' ),
1042 'parent' => 'swipebox'
1043 ]
1044 ];
1045 break;
1046
1047 case 'prettyphoto':
1048 $this->settings['configuration']['prefix'] = 'rl_pp';
1049 $this->settings['configuration']['fields'] = [
1050 'animation_speed' => [
1051 'title' => __( 'Animation speed', 'responsive-lightbox' ),
1052 'section' => 'responsive_lightbox_configuration',
1053 'type' => 'radio',
1054 'label' => '',
1055 'description' => __( 'Select animation speed for lightbox effect.', 'responsive-lightbox' ),
1056 'options' => $this->scripts['prettyphoto']['animation_speeds'],
1057 'parent' => 'prettyphoto'
1058 ],
1059 'slideshow' => [
1060 'title' => __( 'Slideshow', 'responsive-lightbox' ),
1061 'section' => 'responsive_lightbox_configuration',
1062 'type' => 'multiple',
1063 'fields' => [
1064 'slideshow' => [
1065 'type' => 'boolean',
1066 'label' => __( 'Display images as slideshow', 'responsive-lightbox' ),
1067 'parent' => 'prettyphoto'
1068 ],
1069 'slideshow_delay' => [
1070 'type' => 'number',
1071 'description' => __( 'Enter time (in miliseconds).', 'responsive-lightbox' ),
1072 'append' => 'ms',
1073 'parent' => 'prettyphoto'
1074 ]
1075 ]
1076 ],
1077 'slideshow_autoplay' => [
1078 'title' => __( 'Slideshow autoplay', 'responsive-lightbox' ),
1079 'section' => 'responsive_lightbox_configuration',
1080 'type' => 'boolean',
1081 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ),
1082 'parent' => 'prettyphoto'
1083 ],
1084 'opacity' => [
1085 'title' => __( 'Opacity', 'responsive-lightbox' ),
1086 'section' => 'responsive_lightbox_configuration',
1087 'type' => 'range',
1088 'description' => __( 'Value between 0 and 100, 100 for no opacity.', 'responsive-lightbox' ),
1089 'min' => 0,
1090 'max' => 100,
1091 'parent' => 'prettyphoto'
1092 ],
1093 'show_title' => [
1094 'title' => __( 'Show title', 'responsive-lightbox' ),
1095 'section' => 'responsive_lightbox_configuration',
1096 'type' => 'boolean',
1097 'label' => __( 'Display image title.', 'responsive-lightbox' ),
1098 'parent' => 'prettyphoto'
1099 ],
1100 'allow_resize' => [
1101 'title' => __( 'Allow resize big images', 'responsive-lightbox' ),
1102 'section' => 'responsive_lightbox_configuration',
1103 'type' => 'boolean',
1104 'label' => __( 'Resize the photos bigger than viewport.', 'responsive-lightbox' ),
1105 'parent' => 'prettyphoto'
1106 ],
1107 'allow_expand' => [
1108 'title' => __( 'Allow expand', 'responsive-lightbox' ),
1109 'section' => 'responsive_lightbox_configuration',
1110 'type' => 'boolean',
1111 'label' => __( 'Allow expanding images.', 'responsive-lightbox' ),
1112 'parent' => 'prettyphoto'
1113 ],
1114 'width' => [
1115 'title' => __( 'Video width', 'responsive-lightbox' ),
1116 'section' => 'responsive_lightbox_configuration',
1117 'type' => 'number',
1118 'append' => 'px',
1119 'parent' => 'prettyphoto'
1120 ],
1121 'height' => [
1122 'title' => __( 'Video height', 'responsive-lightbox' ),
1123 'section' => 'responsive_lightbox_configuration',
1124 'type' => 'number',
1125 'append' => 'px',
1126 'parent' => 'prettyphoto'
1127 ],
1128 'theme' => [
1129 'title' => __( 'Theme', 'responsive-lightbox' ),
1130 'section' => 'responsive_lightbox_configuration',
1131 'type' => 'radio',
1132 'description' => __( 'Select the theme for lightbox effect.', 'responsive-lightbox' ),
1133 'options' => $this->scripts['prettyphoto']['themes'],
1134 'parent' => 'prettyphoto'
1135 ],
1136 'horizontal_padding' => [
1137 'title' => __( 'Horizontal padding', 'responsive-lightbox' ),
1138 'section' => 'responsive_lightbox_configuration',
1139 'type' => 'number',
1140 'append' => 'px',
1141 'parent' => 'prettyphoto'
1142 ],
1143 'hide_flash' => [
1144 'title' => __( 'Hide Flash', 'responsive-lightbox' ),
1145 'section' => 'responsive_lightbox_configuration',
1146 'type' => 'boolean',
1147 'label' => __( 'Hide all the flash objects on a page. Enable this if flash appears over prettyPhoto.', 'responsive-lightbox' ),
1148 'parent' => 'prettyphoto'
1149 ],
1150 'wmode' => [
1151 'title' => __( 'Flash Window Mode (wmode)', 'responsive-lightbox' ),
1152 'section' => 'responsive_lightbox_configuration',
1153 'type' => 'radio',
1154 'description' => __( 'Select flash window mode.', 'responsive-lightbox' ),
1155 'options' => $this->scripts['prettyphoto']['wmodes'],
1156 'parent' => 'prettyphoto'
1157 ],
1158 'video_autoplay' => [
1159 'title' => __( 'Video autoplay', 'responsive-lightbox' ),
1160 'section' => 'responsive_lightbox_configuration',
1161 'type' => 'boolean',
1162 'label' => __( 'Automatically start videos.', 'responsive-lightbox' ),
1163 'parent' => 'prettyphoto'
1164 ],
1165 'modal' => [
1166 'title' => __( 'Modal', 'responsive-lightbox' ),
1167 'section' => 'responsive_lightbox_configuration',
1168 'type' => 'boolean',
1169 'label' => __( 'If set to true, only the close button will close the window.', 'responsive-lightbox' ),
1170 'parent' => 'prettyphoto'
1171 ],
1172 'deeplinking' => [
1173 'title' => __( 'Deeplinking', 'responsive-lightbox' ),
1174 'section' => 'responsive_lightbox_configuration',
1175 'type' => 'boolean',
1176 'label' => __( 'Allow prettyPhoto to update the url to enable deeplinking.', 'responsive-lightbox' ),
1177 'parent' => 'prettyphoto'
1178 ],
1179 'overlay_gallery' => [
1180 'title' => __( 'Overlay gallery', 'responsive-lightbox' ),
1181 'section' => 'responsive_lightbox_configuration',
1182 'type' => 'boolean',
1183 'label' => __( 'If enabled, a gallery will overlay the fullscreen image on mouse over.', 'responsive-lightbox' ),
1184 'parent' => 'prettyphoto'
1185 ],
1186 'keyboard_shortcuts' => [
1187 'title' => __( 'Keyboard shortcuts', 'responsive-lightbox' ),
1188 'section' => 'responsive_lightbox_configuration',
1189 'type' => 'boolean',
1190 'label' => __( 'Set to false if you open forms inside prettyPhoto.', 'responsive-lightbox' ),
1191 'parent' => 'prettyphoto'
1192 ],
1193 'social' => [
1194 'title' => __( 'Social (Twitter, Facebook)', 'responsive-lightbox' ),
1195 'section' => 'responsive_lightbox_configuration',
1196 'type' => 'boolean',
1197 'label' => __( 'Display links to Facebook and Twitter.', 'responsive-lightbox' ),
1198 'parent' => 'prettyphoto'
1199 ]
1200 ];
1201 break;
1202
1203 case 'nivo':
1204 $this->settings['configuration']['prefix'] = 'rl_nv';
1205 $this->settings['configuration']['fields'] = [
1206 'effect' => [
1207 'title' => __( 'Effect', 'responsive-lightbox' ),
1208 'section' => 'responsive_lightbox_configuration',
1209 'type' => 'radio',
1210 'description' => __( 'The effect to use when showing the lightbox.', 'responsive-lightbox' ),
1211 'options' => $this->scripts['nivo']['effects'],
1212 'parent' => 'nivo'
1213 ],
1214 'keyboard_nav' => [
1215 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ),
1216 'section' => 'responsive_lightbox_configuration',
1217 'type' => 'boolean',
1218 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ),
1219 'parent' => 'nivo'
1220 ],
1221 'click_overlay_to_close' => [
1222 'title' => __( 'Click overlay to close', 'responsive-lightbox' ),
1223 'section' => 'responsive_lightbox_configuration',
1224 'type' => 'boolean',
1225 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ),
1226 'parent' => 'nivo'
1227 ],
1228 'error_message' => [
1229 'title' => __( 'Error message', 'responsive-lightbox' ),
1230 'section' => 'responsive_lightbox_configuration',
1231 'type' => 'text',
1232 'class' => 'large-text',
1233 'label' => __( 'Error message if the content cannot be loaded.', 'responsive-lightbox' ),
1234 'parent' => 'nivo'
1235 ],
1236 ];
1237 break;
1238
1239 case 'imagelightbox':
1240 $this->settings['configuration']['prefix'] = 'rl_il';
1241 $this->settings['configuration']['fields'] = [
1242 'animation_speed' => [
1243 'title' => __( 'Animation speed', 'responsive-lightbox' ),
1244 'section' => 'responsive_lightbox_configuration',
1245 'type' => 'number',
1246 'description' => __( 'Animation speed.', 'responsive-lightbox' ),
1247 'append' => 'ms',
1248 'parent' => 'imagelightbox'
1249 ],
1250 'preload_next' => [
1251 'title' => __( 'Preload next image', 'responsive-lightbox' ),
1252 'section' => 'responsive_lightbox_configuration',
1253 'type' => 'boolean',
1254 'label' => __( 'Silently preload the next image.', 'responsive-lightbox' ),
1255 'parent' => 'imagelightbox'
1256 ],
1257 'enable_keyboard' => [
1258 'title' => __( 'Enable keyboard keys', 'responsive-lightbox' ),
1259 'section' => 'responsive_lightbox_configuration',
1260 'type' => 'boolean',
1261 'label' => __( 'Enable keyboard shortcuts (arrows Left/Right and Esc).', 'responsive-lightbox' ),
1262 'parent' => 'imagelightbox'
1263 ],
1264 'quit_on_end' => [
1265 'title' => __( 'Quit after last image', 'responsive-lightbox' ),
1266 'section' => 'responsive_lightbox_configuration',
1267 'type' => 'boolean',
1268 'label' => __( 'Quit after viewing the last image.', 'responsive-lightbox' ),
1269 'parent' => 'imagelightbox'
1270 ],
1271 'quit_on_image_click' => [
1272 'title' => __( 'Quit on image click', 'responsive-lightbox' ),
1273 'section' => 'responsive_lightbox_configuration',
1274 'type' => 'boolean',
1275 'label' => __( 'Quit when the viewed image is clicked.', 'responsive-lightbox' ),
1276 'parent' => 'imagelightbox'
1277 ],
1278 'quit_on_document_click' => [
1279 'title' => __( 'Quit on anything click', 'responsive-lightbox' ),
1280 'section' => 'responsive_lightbox_configuration',
1281 'type' => 'boolean',
1282 'label' => __( 'Quit when anything but the viewed image is clicked.', 'responsive-lightbox' ),
1283 'parent' => 'imagelightbox'
1284 ],
1285 ];
1286 break;
1287
1288 case 'tosrus':
1289 $this->settings['configuration']['prefix'] = 'rl_tr';
1290 $this->settings['configuration']['fields'] = [
1291 'effect' => [
1292 'title' => __( 'Transition effect', 'responsive-lightbox' ),
1293 'section' => 'responsive_lightbox_configuration',
1294 'type' => 'radio',
1295 'description' => __( 'What effect to use for the transition.', 'responsive-lightbox' ),
1296 'options' => [
1297 'slide' => __( 'slide', 'responsive-lightbox' ),
1298 'fade' => __( 'fade', 'responsive-lightbox' )
1299 ],
1300 'parent' => 'tosrus'
1301 ],
1302 'infinite' => [
1303 'title' => __( 'Infinite loop', 'responsive-lightbox' ),
1304 'section' => 'responsive_lightbox_configuration',
1305 'type' => 'boolean',
1306 'label' => __( 'Whether or not to slide back to the first slide when the last has been reached.', 'responsive-lightbox' ),
1307 'parent' => 'tosrus'
1308 ],
1309 'keys' => [
1310 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ),
1311 'section' => 'responsive_lightbox_configuration',
1312 'type' => 'boolean',
1313 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ),
1314 'parent' => 'tosrus'
1315 ],
1316 'autoplay' => [
1317 'title' => __( 'Autoplay', 'responsive-lightbox' ),
1318 'section' => 'responsive_lightbox_configuration',
1319 'type' => 'multiple',
1320 'fields' => [
1321 'autoplay' => [
1322 'type' => 'boolean',
1323 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ),
1324 'parent' => 'tosrus'
1325 ],
1326 'timeout' => [
1327 'type' => 'number',
1328 'description' => __( 'The timeout between sliding to the next slide in milliseconds.', 'responsive-lightbox' ),
1329 'append' => 'ms',
1330 'parent' => 'tosrus'
1331 ]
1332 ]
1333 ],
1334 'pause_on_hover' => [
1335 'title' => __( 'Pause on hover', 'responsive-lightbox' ),
1336 'section' => 'responsive_lightbox_configuration',
1337 'type' => 'boolean',
1338 'label' => __( 'Whether or not to pause on hover.', 'responsive-lightbox' ),
1339 'parent' => 'tosrus'
1340 ],
1341 'pagination' => [
1342 'title' => __( 'Pagination', 'responsive-lightbox' ),
1343 'section' => 'responsive_lightbox_configuration',
1344 'type' => 'multiple',
1345 'fields' => [
1346 'pagination' => [
1347 'type' => 'boolean',
1348 'label' => __( 'Whether or not to add a pagination.', 'responsive-lightbox' ),
1349 'parent' => 'tosrus'
1350 ],
1351 'pagination_type' => [
1352 'type' => 'radio',
1353 'description' => __( 'What type of pagination to use.', 'responsive-lightbox' ),
1354 'options' => [
1355 'bullets' => __( 'Bullets', 'responsive-lightbox' ),
1356 'thumbnails' => __( 'Thumbnails', 'responsive-lightbox' )
1357 ],
1358 'parent' => 'tosrus'
1359 ]
1360 ]
1361 ],
1362 'close_on_click' => [
1363 'title' => __( 'Overlay close', 'responsive-lightbox' ),
1364 'section' => 'responsive_lightbox_configuration',
1365 'type' => 'boolean',
1366 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ),
1367 'parent' => 'tosrus'
1368 ]
1369 ];
1370 break;
1371
1372 case 'featherlight':
1373 $this->settings['configuration']['prefix'] = 'rl_fl';
1374 $this->settings['configuration']['fields'] = [
1375 'open_speed' => [
1376 'title' => __( 'Opening speed', 'responsive-lightbox' ),
1377 'section' => 'responsive_lightbox_configuration',
1378 'type' => 'number',
1379 'description' => __( 'Duration of opening animation.', 'responsive-lightbox' ),
1380 'append' => 'ms',
1381 'parent' => 'featherlight'
1382 ],
1383 'close_speed' => [
1384 'title' => __( 'Closing speed', 'responsive-lightbox' ),
1385 'section' => 'responsive_lightbox_configuration',
1386 'type' => 'number',
1387 'description' => __( 'Duration of closing animation.', 'responsive-lightbox' ),
1388 'append' => 'ms',
1389 'parent' => 'featherlight'
1390 ],
1391 'close_on_click' => [
1392 'title' => __( 'Close on click', 'responsive-lightbox' ),
1393 'section' => 'responsive_lightbox_configuration',
1394 'type' => 'radio',
1395 'label' => __( 'Select how to close lightbox.', 'responsive-lightbox' ),
1396 'options' => [
1397 'background' => __( 'background', 'responsive-lightbox' ),
1398 'anywhere' => __( 'anywhere', 'responsive-lightbox' ),
1399 'false' => __( 'false', 'responsive-lightbox' )
1400 ],
1401 'parent' => 'featherlight'
1402 ],
1403 'close_on_esc' => [
1404 'title' => __( 'Close on Esc', 'responsive-lightbox' ),
1405 'section' => 'responsive_lightbox_configuration',
1406 'type' => 'boolean',
1407 'label' => __( 'Toggle if pressing Esc button closes lightbox.', 'responsive-lightbox' ),
1408 'parent' => 'featherlight'
1409 ],
1410 'gallery_fade_in' => [
1411 'title' => __( 'Gallery fade in', 'responsive-lightbox' ),
1412 'section' => 'responsive_lightbox_configuration',
1413 'type' => 'number',
1414 'description' => __( 'Animation speed when image is loaded.', 'responsive-lightbox' ),
1415 'append' => 'ms',
1416 'parent' => 'featherlight'
1417 ],
1418 'gallery_fade_out' => [
1419 'title' => __( 'Gallery fade out', 'responsive-lightbox' ),
1420 'section' => 'responsive_lightbox_configuration',
1421 'type' => 'number',
1422 'description' => __( 'Animation speed before image is loaded.', 'responsive-lightbox' ),
1423 'append' => 'ms',
1424 'parent' => 'featherlight'
1425 ]
1426 ];
1427 break;
1428
1429 case 'magnific':
1430 $this->settings['configuration']['prefix'] = 'rl_mp';
1431 $this->settings['configuration']['fields'] = [
1432 'disable_on' => [
1433 'title' => __( 'Disable on', 'responsive-lightbox' ),
1434 'section' => 'responsive_lightbox_configuration',
1435 'type' => 'number',
1436 'description' => __( 'If window width is less than the number in this option lightbox will not be opened and the default behavior of the element will be triggered. Set to 0 to disable behavior.', 'responsive-lightbox' ),
1437 'append' => 'px',
1438 'parent' => 'magnific'
1439 ],
1440 'mid_click' => [
1441 'title' => __( 'Middle click', 'responsive-lightbox' ),
1442 'section' => 'responsive_lightbox_configuration',
1443 'type' => 'boolean',
1444 'label' => __( 'If option enabled, lightbox is opened if the user clicked on the middle mouse button, or click with Command/Ctrl key.', 'responsive-lightbox' ),
1445 'parent' => 'magnific'
1446 ],
1447 'preloader' => [
1448 'title' => __( 'Preloader', 'responsive-lightbox' ),
1449 'section' => 'responsive_lightbox_configuration',
1450 'type' => 'boolean',
1451 'label' => __( 'If option enabled, it\'s always present in DOM only text inside of it changes.', 'responsive-lightbox' ),
1452 'parent' => 'magnific'
1453 ],
1454 'close_on_content_click' => [
1455 'title' => __( 'Close on content click', 'responsive-lightbox' ),
1456 'section' => 'responsive_lightbox_configuration',
1457 'type' => 'boolean',
1458 'label' => __( 'Close popup when user clicks on content of it. It\'s recommended to enable this option when you have only image in popup.', 'responsive-lightbox' ),
1459 'parent' => 'magnific'
1460 ],
1461 'close_on_background_click' => [
1462 'title' => __( 'Close on background click', 'responsive-lightbox' ),
1463 'section' => 'responsive_lightbox_configuration',
1464 'type' => 'boolean',
1465 'label' => __( 'Close the popup when user clicks on the dark overlay.', 'responsive-lightbox' ),
1466 'parent' => 'magnific'
1467 ],
1468 'close_button_inside' => [
1469 'title' => __( 'Close button inside', 'responsive-lightbox' ),
1470 'section' => 'responsive_lightbox_configuration',
1471 'type' => 'boolean',
1472 'label' => __( 'If enabled, Magnific Popup will put close button inside content of popup.', 'responsive-lightbox' ),
1473 'parent' => 'magnific'
1474 ],
1475 'show_close_button' => [
1476 'title' => __( 'Show close button', 'responsive-lightbox' ),
1477 'section' => 'responsive_lightbox_configuration',
1478 'type' => 'boolean',
1479 'label' => __( 'Controls whether the close button will be displayed or not.', 'responsive-lightbox' ),
1480 'parent' => 'magnific'
1481 ],
1482 'enable_escape_key' => [
1483 'title' => __( 'Enable escape key', 'responsive-lightbox' ),
1484 'section' => 'responsive_lightbox_configuration',
1485 'type' => 'boolean',
1486 'label' => __( 'Controls whether pressing the escape key will dismiss the active popup or not.', 'responsive-lightbox' ),
1487 'parent' => 'magnific'
1488 ],
1489 'align_top' => [
1490 'title' => __( 'Align top', 'responsive-lightbox' ),
1491 'section' => 'responsive_lightbox_configuration',
1492 'type' => 'boolean',
1493 'label' => __( 'If set to true popup is aligned to top instead of to center.', 'responsive-lightbox' ),
1494 'parent' => 'magnific'
1495 ],
1496 'fixed_content_position' => [
1497 'title' => __( 'Content position type', 'responsive-lightbox' ),
1498 'section' => 'responsive_lightbox_configuration',
1499 'type' => 'select',
1500 'description' => __( 'Popup content position. If set to "auto" popup will automatically disable this option when browser doesn\'t support fixed position properly.', 'responsive-lightbox' ),
1501 'options' => [
1502 'auto' => __( 'Auto', 'responsive-lightbox' ),
1503 'true' => __( 'Fixed', 'responsive-lightbox' ),
1504 'false' => __( 'Absolute', 'responsive-lightbox' )
1505 ],
1506 'parent' => 'magnific'
1507 ],
1508 'fixed_background_position' => [
1509 'title' => __( 'Fixed background position', 'responsive-lightbox' ),
1510 'section' => 'responsive_lightbox_configuration',
1511 'type' => 'select',
1512 'description' => __( 'Dark transluscent overlay content position.', 'responsive-lightbox' ),
1513 'options' => [
1514 'auto' => __( 'Auto', 'responsive-lightbox' ),
1515 'true' => __( 'Fixed', 'responsive-lightbox' ),
1516 'false' => __( 'Absolute', 'responsive-lightbox' )
1517 ],
1518 'parent' => 'magnific'
1519 ],
1520 'auto_focus_last' => [
1521 'title' => __( 'Auto focus last', 'responsive-lightbox' ),
1522 'section' => 'responsive_lightbox_configuration',
1523 'type' => 'boolean',
1524 'label' => __( 'If set to true last focused element before popup showup will be focused after popup close.', 'responsive-lightbox' ),
1525 'parent' => 'magnific'
1526 ]
1527 ];
1528 break;
1529
1530 case 'glightbox':
1531 $this->settings['configuration']['prefix'] = 'rl_gl';
1532 $this->settings['configuration']['fields'] = [
1533 'slide_effect' => [
1534 'title' => __( 'Slide effect', 'responsive-lightbox' ),
1535 'section' => 'responsive_lightbox_configuration',
1536 'type' => 'select',
1537 'description' => __( 'Select the slide effect.', 'responsive-lightbox' ),
1538 'options' => [
1539 'slide' => __( 'Slide', 'responsive-lightbox' ),
1540 'fade' => __( 'Fade', 'responsive-lightbox' ),
1541 'zoom' => __( 'Zoom', 'responsive-lightbox' ),
1542 'none' => __( 'None', 'responsive-lightbox' )
1543 ],
1544 'parent' => 'glightbox'
1545 ],
1546 'close_button' => [
1547 'title' => __( 'Close button', 'responsive-lightbox' ),
1548 'section' => 'responsive_lightbox_configuration',
1549 'type' => 'boolean',
1550 'label' => __( 'Display the close button.', 'responsive-lightbox' ),
1551 'parent' => 'glightbox'
1552 ],
1553 'touch_navigation' => [
1554 'title' => __( 'Touch navigation', 'responsive-lightbox' ),
1555 'section' => 'responsive_lightbox_configuration',
1556 'type' => 'boolean',
1557 'label' => __( 'Enable touch navigation.', 'responsive-lightbox' ),
1558 'parent' => 'glightbox'
1559 ],
1560 'keyboard_navigation' => [
1561 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ),
1562 'section' => 'responsive_lightbox_configuration',
1563 'type' => 'boolean',
1564 'label' => __( 'Enable keyboard navigation.', 'responsive-lightbox' ),
1565 'parent' => 'glightbox'
1566 ],
1567 'close_on_outside_click' => [
1568 'title' => __( 'Close on outside click', 'responsive-lightbox' ),
1569 'section' => 'responsive_lightbox_configuration',
1570 'type' => 'boolean',
1571 'label' => __( 'Close the lightbox when clicking outside of the content.', 'responsive-lightbox' ),
1572 'parent' => 'glightbox'
1573 ],
1574 'loop' => [
1575 'title' => __( 'Loop', 'responsive-lightbox' ),
1576 'section' => 'responsive_lightbox_configuration',
1577 'type' => 'boolean',
1578 'label' => __( 'Enable loop.', 'responsive-lightbox' ),
1579 'parent' => 'glightbox'
1580 ],
1581 'zoomable' => [
1582 'title' => __( 'Zoomable', 'responsive-lightbox' ),
1583 'section' => 'responsive_lightbox_configuration',
1584 'type' => 'boolean',
1585 'label' => __( 'Enable zoomable images.', 'responsive-lightbox' ),
1586 'parent' => 'glightbox'
1587 ]
1588 ];
1589 break;
1590
1591 default:
1592 $this->settings['configuration'] = apply_filters( 'rl_settings_' . ( ! empty( $section_key ) ? $section_key : $rl->options['settings']['script'] ) . '_script_configuration', $this->settings['configuration'] );
1593 }
1594
1595 if ( isset( $this->tabs[$tab_key]['submit'], $this->tabs[$tab_key]['reset'] ) && ! empty( $this->settings[$tab_key]['prefix'] ) ) {
1596 $this->tabs[$tab_key]['submit'] = 'save_' . $this->settings[$tab_key]['prefix'] . '_' . $tab_key;
1597 $this->tabs[$tab_key]['reset'] = 'reset_' . $this->settings[$tab_key]['prefix'] . '_' . $tab_key;
1598 }
1599 }
1600
1601 /**
1602 * Remote Library Media Providers description
1603 *
1604 * @return void
1605 */
1606 public function remote_library_providers_description() {
1607 echo '<p class="description">' . sprintf( esc_html__( 'Below you\'ll find a list of available remote media libraries. If you\'re looking for Pixabay, Pexels, Instagram and other integrations please check the %s addon.', 'responsive-lightbox' ), '<a href="http://www.dfactory.co/products/remote-library-pro/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=addon" target="_blank">Remote Library Pro</a>' ) . '</p>';
1608 }
1609
1610 /**
1611 * Register options page
1612 *
1613 * @return void
1614 */
1615 public function admin_menu_options() {
1616 // get master capability
1617 $capability = apply_filters( 'rl_lightbox_settings_capability', Responsive_Lightbox()->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' );
1618
1619 add_menu_page( __( 'General', 'responsive-lightbox' ), __( 'Lightbox', 'responsive-lightbox' ), $capability, 'responsive-lightbox-settings', '', 'dashicons-format-image', '57.1' );
1620
1621 foreach ( $this->tabs as $key => $options ) {
1622 add_submenu_page( 'responsive-lightbox-settings', $options['name'], $options['name'], $capability, 'responsive-lightbox-' . $key , [ $this, 'options_page' ] );
1623 }
1624 }
1625
1626 /**
1627 * Render options page
1628 *
1629 * @return void
1630 */
1631 public function options_page() {
1632 // check page
1633 $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : '';
1634
1635 // check settings page
1636 if ( $page && preg_match( '/^responsive-lightbox-(' . implode( '|', array_keys( $this->tabs ) ) . ')$/', $page, $tabs ) !== 1 )
1637 return;
1638
1639 $tab_key = isset( $tabs[1] ) ? $tabs[1] : 'settings';
1640
1641 // check section
1642 $section_key = isset( $_GET['section'] ) ? sanitize_key( $_GET['section'] ) : '';
1643
1644 if ( ! $section_key )
1645 $section_key = ! empty( $this->tabs[$tab_key]['default_section'] ) ? $this->tabs[$tab_key]['default_section'] : '';
1646
1647 // get main instance
1648 $rl = Responsive_Lightbox();
1649
1650 // no valid lightbox script?
1651 if ( $tab_key === 'configuration' && ! array_key_exists( $section_key, $rl->options['configuration'] ) )
1652 return;
1653
1654 // no valid gallery?
1655 if ( $tab_key === 'gallery' && ! array_key_exists( $section_key, $this->tabs['gallery']['sections'] ) )
1656 return;
1657
1658 echo '
1659 <div class="wrap">';
1660
1661 settings_errors();
1662
1663 // hidden h2 tag is needed to display info box properly when saving or resetting settings
1664 echo '
1665 <h2 class="hidden">' . esc_html__( 'Responsive Lightbox & Gallery', 'responsive-lightbox' ) . ' - ' . esc_html( $this->tabs[$tab_key]['name'] ) . '</h2>' . '
1666 <h2 class="nav-tab-wrapper">';
1667
1668 foreach ( $this->tabs as $key => $options ) {
1669 echo '
1670 <a class="nav-tab ' . ( $tab_key === $key ? 'nav-tab-active' : '' ) . '" href="' . esc_url( admin_url( 'admin.php?page=responsive-lightbox-' . $key ) ) . '">' . esc_html( $options['name'] ) . '</a>';
1671 }
1672
1673 echo '
1674 </h2>
1675 <div class="responsive-lightbox-settings">
1676 <div class="df-credits">
1677 <h3 class="hndle">' . esc_html__( 'Responsive Lightbox & Gallery', 'responsive-lightbox' ) . ' ' . esc_html( $rl->defaults['version'] ) . '</h3>
1678 <div class="inside">
1679 <h4 class="inner">' . esc_html__( 'Need support?', 'responsive-lightbox' ) . '</h4>
1680 <p class="inner">' . sprintf( esc_html__( 'If you are having problems with this plugin, please browse it\'s %s or talk about them in the %s.', 'responsive-lightbox' ), '<a href="http://www.dfactory.co/docs/responsive-lightbox/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=docs" target="_blank">' . esc_html__( 'Documentation', 'responsive-lightbox' ) . '</a>', '<a href="http://www.dfactory.co/support/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=support" target="_blank">' . esc_html__( 'Support forum', 'responsive-lightbox' ) . '</a>' ) . '</p>
1681 <hr />
1682 <h4 class="inner">' . esc_html__( 'Do you like this plugin?', 'responsive-lightbox' ) . '</h4>
1683 <p class="inner">' . sprintf( esc_html__( '%s on WordPress.org', 'responsive-lightbox' ), '<a href="https://wordpress.org/support/plugin/responsive-lightbox/reviews/?filter=5" target="_blank">' . esc_html__( 'Rate it 5', 'responsive-lightbox' ) . '</a>' ) . '<br />' .
1684 sprintf( esc_html__( 'Blog about it & link to the %s.', 'responsive-lightbox' ), '<a href="http://www.dfactory.co/products/responsive-lightbox/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=blog-about" target="_blank">' . esc_html__( 'plugin page', 'responsive-lightbox' ) . '</a>' ) . '<br />' .
1685 sprintf( esc_html__( 'Check out our other %s.', 'responsive-lightbox' ), '<a href="http://www.dfactory.co/products/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=other-plugins" target="_blank">' . esc_html__( 'WordPress plugins', 'responsive-lightbox' ) . '</a>' ) . '
1686 </p>
1687 <hr />
1688 <p class="df-link inner"><a href="http://www.dfactory.co/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=created-by" target="_blank" title="Digital Factory"><img src="//rlg-53eb.kxcdn.com/df-black-sm.png' . '" alt="Digital Factory" /></a></p>
1689 </div>
1690 </div>
1691 <form action="options.php" method="post">';
1692
1693 // views
1694 if ( ! empty( $this->tabs[$tab_key]['sections'] ) ) {
1695 $list = [];
1696
1697 echo '
1698 <ul class="subsubsub">';
1699
1700 // get number of sections
1701 $nos = count( $this->tabs[$tab_key]['sections'] );
1702
1703 $i = 0;
1704
1705 foreach ( $this->tabs[$tab_key]['sections'] as $key => $name ) {
1706 echo '
1707 <li class="' . esc_attr( $key ) . '"><a href="' . esc_url( admin_url( 'admin.php?page=responsive-lightbox-' . $tab_key . '&section=' . $key ) ) . '" class="' . ( $key === $section_key ? 'current' : '' ) . '">' . esc_html( $name ) . '</a>' . ( $nos === ++$i ? '' : ' |' ) . '</li>';
1708 }
1709
1710 echo '
1711 </ul>
1712 <input type="hidden" name="section" value="' . esc_attr( $section_key ) . '" />
1713 <br class="clear">';
1714 }
1715
1716 // tab content callback
1717 if ( ! empty( $this->tabs[$tab_key]['callback'] ) )
1718 call_user_func( $this->tabs[$tab_key]['callback'] );
1719 else {
1720 settings_fields( $this->tabs[$tab_key]['key'] );
1721 do_settings_sections( $this->tabs[$tab_key]['key'] );
1722
1723 if ( $tab_key === 'builder' )
1724 echo '
1725 <input type="hidden" name="flush_rules" value="1" />';
1726 }
1727
1728 if ( ! empty( $this->tabs[$tab_key]['submit'] ) || ! empty( $this->tabs[$tab_key]['reset'] ) ) {
1729 echo '
1730 <p class="submit">';
1731
1732 if ( ! empty( $this->tabs[$tab_key]['submit'] ) ) {
1733 submit_button( '', [ 'primary', 'save-' . $tab_key ], $this->tabs[$tab_key]['submit'], false );
1734 echo ' ';
1735 }
1736
1737 if ( ! empty( $this->tabs[$tab_key]['reset'] ) )
1738 submit_button( __( 'Reset to defaults', 'responsive-lightbox' ), [ 'secondary', 'reset-responsive-lightbox-settings reset-' . $tab_key ], $this->tabs[$tab_key]['reset'], false );
1739
1740 echo '
1741 </p>';
1742 }
1743
1744 echo '
1745 </form>
1746 </div>
1747 <div class="clear"></div>
1748 </div>';
1749 }
1750
1751 /**
1752 * Add new capability to manage options.
1753 *
1754 * @return string
1755 */
1756 public function manage_options_capability() {
1757 return Responsive_Lightbox()->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options';
1758 }
1759
1760 /**
1761 * Render settings function.
1762 *
1763 * @return void
1764 */
1765 public function register_settings() {
1766 // get main instance
1767 $rl = Responsive_Lightbox();
1768
1769 foreach ( $this->settings as $_setting_id => $setting ) {
1770 $setting_id = sanitize_key( $_setting_id );
1771
1772 if ( ! empty( $setting['option_name'] ) )
1773 $option_name = sanitize_key( $setting['option_name'] );
1774 else
1775 $option_name = $setting_id;
1776
1777 // set key
1778 $setting_key = $setting_id;
1779 $setting_id = 'responsive_lightbox_' . $setting_id;
1780
1781 // add new capability to manage options
1782 add_filter( 'option_page_capability_' . $setting_id, [ $this, 'manage_options_capability' ] );
1783
1784 // register setting
1785 register_setting( $setting_id, $option_name, ! empty( $setting['callback'] ) ? $setting['callback'] : [ $this, 'validate_settings' ] );
1786
1787 // register sections
1788 if ( ! empty( $setting['sections'] ) && is_array( $setting['sections'] ) ) {
1789 foreach ( $setting['sections'] as $_section_id => $section ) {
1790 $section_id = sanitize_key( $_section_id );
1791
1792 add_settings_section(
1793 $section_id,
1794 ! empty( $section['title'] ) ? esc_html( $section['title'] ) : '',
1795 ! empty( $section['callback'] ) ? $section['callback'] : '',
1796 ! empty( $section['page'] ) ? sanitize_key( $section['page'] ) : $section_id
1797 );
1798 }
1799 }
1800
1801 // register fields
1802 if ( ! empty( $setting['fields'] ) && is_array( $setting['fields'] ) ) {
1803 foreach ( $setting['fields'] as $_field_id => $field ) {
1804 $field_id = sanitize_key( $_field_id );
1805
1806 // prefix field id?
1807 $field_key = $field_id;
1808 $field_id = ( ! empty( $setting['prefix'] ) ? $setting['prefix'] . '_' : '' ) . $field_id;
1809
1810 // field args
1811 $args = [
1812 'id' => ! empty( $field['id'] ) ? $field['id'] : $field_id,
1813 'class' => ! empty( $field['class'] ) ? $field['class'] : '',
1814 'name' => $option_name . ( ! empty( $field['parent'] ) ? '[' . $field['parent'] . ']' : '' ) . '[' . $field_key . ']',
1815 'type' => ! empty( $field['type'] ) ? $field['type'] : 'text',
1816 'label' => ! empty( $field['label'] ) ? $field['label'] : '',
1817 'description' => ! empty( $field['description'] ) ? $field['description'] : '',
1818 'disabled' => isset( $field['disabled'] ) ? (bool) $field['disabled'] : false,
1819 'append' => ! empty( $field['append'] ) ? $field['append'] : '',
1820 'prepend' => ! empty( $field['prepend'] ) ? $field['prepend'] : '',
1821 'min' => isset( $field['min'] ) ? (int) $field['min'] : '',
1822 'max' => isset( $field['max'] ) ? (int) $field['max'] : '',
1823 'options' => ! empty( $field['options'] ) ? $field['options'] : '',
1824 'fields' => ! empty( $field['fields'] ) ? $field['fields'] : '',
1825 'after_field' => ! empty( $field['after_field'] ) ? $field['after_field'] : '',
1826 'default' => $field['type'] === 'multiple' ? '' : ( $this->sanitize_field( ! empty( $field['parent'] ) ? $rl->defaults[$setting_key][$field['parent']][$field_key] : $rl->defaults[$setting_key][$field_key], $field['type'] ) ),
1827 'value' => $field['type'] === 'multiple' ? '' : ( $this->sanitize_field( ! empty( $field['parent'] ) ? $rl->options[$setting_key][$field['parent']][$field_key] : ( isset( $rl->options[$setting_key][$field_key] ) ? $rl->options[$setting_key][$field_key] : $rl->defaults[$setting_key][$field_key] ), $field['type'] ) ),
1828 'label_for' => $field_id,
1829 'classname' => ! empty( $field['classname'] ) ? $field['classname'] : '',
1830 'callback' => ! empty( $field['callback'] ) ? $field['callback'] : '',
1831 'return' => false
1832 ];
1833
1834 if ( $args['type'] === 'multiple' ) {
1835 foreach ( $args['fields'] as $subfield_id => $subfield ) {
1836 $args['fields'][$subfield_id] = wp_parse_args(
1837 $subfield,
1838 [
1839 'id' => $field_id . '-' . $subfield_id,
1840 'class' => ! empty( $subfield['class'] ) ? $subfield['class'] : '',
1841 'name' => $option_name . ( ! empty( $subfield['parent'] ) ? '[' . $subfield['parent'] . ']' : '' ) . '[' . $subfield_id . ']',
1842 'default' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? $rl->defaults[$setting_key][$subfield['parent']][$subfield_id] : $rl->defaults[$setting_key][$subfield_id], $subfield['type'] ),
1843 'value' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? $rl->options[$setting_key][$subfield['parent']][$subfield_id] : $rl->options[$setting_key][$subfield_id], $subfield['type'] ),
1844 'return' => true
1845 ]
1846 );
1847 }
1848 }
1849
1850 add_settings_field(
1851 $field_id,
1852 ! empty( $field['title'] ) ? esc_html( $field['title'] ) : '',
1853 [ $this, 'render_field' ],
1854 ! empty( $field['page'] ) ? sanitize_key( $field['page'] ) : $setting_id,
1855 ! empty( $field['section'] ) ? sanitize_key( $field['section'] ) : '',
1856 $args
1857 );
1858 }
1859 }
1860 }
1861
1862 // licenses
1863 $extensions = apply_filters( 'rl_settings_licenses', [] );
1864
1865 if ( $extensions ) {
1866 // add new capability to manage licenses
1867 add_filter( 'option_page_capability_responsive_lightbox_licenses', [ $this, 'manage_options_capability' ] );
1868
1869 // register setting
1870 register_setting( 'responsive_lightbox_licenses', 'responsive_lightbox_licenses', [ $this, 'validate_licenses' ] );
1871
1872 add_settings_section( 'responsive_lightbox_licenses', esc_html__( 'Licenses', 'responsive-lightbox' ), [ $this, 'licenses_section_cb' ], 'responsive_lightbox_licenses' );
1873
1874 foreach ( $extensions as $id => $extension ) {
1875 add_settings_field( sanitize_key( $id ), esc_html( $extension['name'] ), [ $this, 'license_field_cb' ], 'responsive_lightbox_licenses', 'responsive_lightbox_licenses', $extension );
1876 }
1877 }
1878 }
1879
1880 /**
1881 * Render settings field function.
1882 *
1883 * @param array $args
1884 * @return void|string
1885 */
1886 public function render_field( $args ) {
1887 if ( empty( $args ) || ! is_array( $args ) )
1888 return '';
1889
1890 $html = '';
1891
1892 switch ( $args['type'] ) {
1893 case 'boolean':
1894 $html .= '<label><input id="' . esc_attr( $args['id'] ) . '" type="checkbox" name="' . esc_attr( $args['name'] ) . '" value="1" ' . checked( (bool) $args['value'], true, false ) . ( isset( $args['disabled'] ) && $args['disabled'] == true ? ' disabled="disabled"' : '' ) . ' />' . esc_html( $args['label'] ) . '</label>';
1895 break;
1896
1897 case 'radio':
1898 foreach ( $args['options'] as $key => $name ) {
1899 $html .= '<label><input id="' . esc_attr( $args['id'] . '-' . $key ) . '" type="radio" name="' . esc_attr( $args['name'] ) . '" value="' . esc_attr( $key ) . '" ' . checked( $key, $args['value'], false ) . ( isset( $args['disabled'] ) && $args['disabled'] == true ? ' disabled="disabled"' : '' ) . ' />' . esc_html( $name ) . '</label> ';
1900 }
1901 break;
1902
1903 case 'checkbox':
1904 foreach ( $args['options'] as $key => $name ) {
1905 $html .= '<label><input id="' . esc_attr( $args['id'] . '-' . $key ) . '" type="checkbox" name="' . esc_attr( $args['name'] ) . '[' . esc_attr( $key ) . ']" value="1" ' . checked( in_array( $key, $args['value'] ), true, false ) . ( isset( $args['disabled'] ) && $args['disabled'] == true ? ' disabled="disabled"' : '' ) . ' />' . esc_html( $name ) . '</label> ';
1906 }
1907 break;
1908
1909 case 'select':
1910 $html .= '<select id="' . esc_attr( $args['id'] ) . '" name="' . esc_attr( $args['name'] ) . '" value="' . esc_attr( $args['value'] ) . '" ' . ( isset( $args['disabled'] ) && $args['disabled'] == true ? ' disabled="disabled"' : '' ) . '/>';
1911
1912 foreach ( $args['options'] as $key => $name ) {
1913 $html .= '<option value="' . esc_attr( $key ) . '" ' . selected( $args['value'], $key, false ) . '>' . esc_html( $name ) . '</option>';
1914 }
1915
1916 $html .= '</select>';
1917 break;
1918
1919 case 'multiple':
1920 $html .= '<fieldset>';
1921
1922 if ( $args['fields'] ) {
1923 $count = 1;
1924 $count_fields = count( $args['fields'] );
1925
1926 foreach ( $args['fields'] as $subfield_id => $subfield_args ) {
1927 $html .= $this->render_field( $subfield_args ) . ( $count < $count_fields ? '<br />' : '' );
1928
1929 $count++;
1930 }
1931 }
1932
1933 $html .= '</fieldset>';
1934 break;
1935
1936 case 'range':
1937 $html .= '<input id="' . esc_attr( $args['id'] ) . '" type="range" name="' . esc_attr( $args['name'] ) . '" value="' . (int) $args['value'] . '" min="' . (int) $args['min'] . '" max="' . (int) $args['max'] . '" oninput="this.form.' . esc_attr( $args['id'] ) . '_range.value=this.value" />';
1938 $html .= '<output name="' . esc_attr( $args['id'] ) . '_range">' . (int) $args['value'] . '</output>';
1939 break;
1940
1941 case 'color_picker':
1942 $html .= '<input id="' . esc_attr( $args['id'] ) . '" class="color-picker" type="text" value="' . esc_attr( $args['value'] ) . '" name="' . esc_attr( $args['name'] ) . '" data-default-color="' . esc_attr( $args['default'] ) . '" />';
1943 break;
1944
1945 case 'number':
1946 $html .= ( ! empty( $args['prepend'] ) ? '<span>' . esc_html( $args['prepend'] ) . '</span> ' : '' );
1947 $html .= '<input id="' . esc_attr( $args['id'] ) . '" type="number" value="' . (int) $args['value'] . '" name="' . esc_attr( $args['name'] ) . '" />';
1948 $html .= ( ! empty( $args['append'] ) ? ' <span>' . esc_html( $args['append'] ) . '</span>' : '' );
1949 break;
1950
1951 case 'button':
1952 $html .= ( ! empty( $args['prepend'] ) ? '<span>' . esc_html( $args['prepend'] ) . '</span> ' : '' );
1953 $html .= '<a href="' . esc_url( admin_url( 'admin.php?page=responsive-lightbox-tour' ) ) . '" id="' . esc_attr( $args['id'] ) . '" class="button ' . ( ! empty( $args['classname'] ) ? esc_attr( $args['classname'] ) : 'button-secondary' ) . '">' . esc_html( $args['label'] ) . '</a>';
1954 $html .= ( ! empty( $args['append'] ) ? ' <span>' . esc_html( $args['append'] ) . '</span>' : '' );
1955 break;
1956
1957 case 'custom':
1958 // get allowed html
1959 $allowed_html = wp_kses_allowed_html( 'post' );
1960
1961 $allowed_html['select'] = [
1962 'name' => [],
1963 'id' => [],
1964 'class' => []
1965 ];
1966 $allowed_html['option'] = [
1967 'value' => [],
1968 'selected' => []
1969 ];
1970 $allowed_html['input'] = [
1971 'id' => [],
1972 'class' => [],
1973 'name' => [],
1974 'placeholder' => [],
1975 'checked' => [],
1976 'type' => [],
1977 'value' => []
1978 ];
1979
1980 add_filter( 'safe_style_css', [ $this, 'allow_display_attr' ] );
1981
1982 $html .= wp_kses( call_user_func( $args['callback'], $args ), $allowed_html );
1983
1984 remove_filter( 'safe_style_css', [ $this, 'allow_display_attr' ] );
1985 break;
1986
1987 case 'text':
1988 default :
1989 $html .= ( ! empty( $args['prepend'] ) ? '<span>' . esc_html( $args['prepend'] ) . '</span> ' : '' );
1990 $html .= '<input id="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( $args['class'] ) . '" type="text" value="' . esc_attr( $args['value'] ) . '" name="' . esc_attr( $args['name'] ) . '" />';
1991 $html .= ( ! empty( $args['append'] ) ? ' <span>' . esc_html( $args['append'] ) . '</span>' : '' );
1992 }
1993
1994 if ( ! empty ( $args['after_field'] ) )
1995 $html .= wp_kses_post( $args['after_field'] );
1996
1997 if ( ! empty ( $args['description'] ) )
1998 $html .= '<p class="description">' . wp_kses_post( $args['description'] ) . '</p>';
1999
2000 // $html is already escaped
2001 if ( ! empty( $args['return'] ) )
2002 return $html;
2003 else
2004 echo $html;
2005 }
2006
2007 /**
2008 * Add display property to style safe list.
2009 *
2010 * @param array $styles
2011 * @return array
2012 */
2013 public function allow_display_attr( $styles ) {
2014 $styles[] = 'display';
2015
2016 return $styles;
2017 }
2018
2019 /**
2020 * Sanitize field function
2021 *
2022 * @param mixed $value
2023 * @param string $type
2024 * @param array $args
2025 * @return mixed
2026 */
2027 public function sanitize_field( $value = null, $type = '', $args = [] ) {
2028 if ( is_null( $value ) )
2029 return null;
2030
2031 switch ( $type ) {
2032 case 'button':
2033 case 'boolean':
2034 $value = empty( $value ) ? false : true;
2035 break;
2036
2037 case 'checkbox':
2038 $value = is_array( $value ) && ! empty( $value ) ? array_map( 'sanitize_key', $value ) : [];
2039 break;
2040
2041 case 'radio':
2042 $value = is_array( $value ) ? false : sanitize_key( $value );
2043 break;
2044
2045 case 'textarea':
2046 case 'wysiwyg':
2047 $value = wp_kses_post( $value );
2048 break;
2049
2050 case 'color_picker':
2051 $value = sanitize_hex_color( $value );
2052
2053 if ( empty( $value ) )
2054 $value = '#666666';
2055 break;
2056
2057 case 'number':
2058 $value = (int) $value;
2059
2060 // is value lower than?
2061 if ( isset( $args['min'] ) && $value < $args['min'] )
2062 $value = $args['min'];
2063
2064 // is value greater than?
2065 if ( isset( $args['max'] ) && $value > $args['max'] )
2066 $value = $args['max'];
2067 break;
2068
2069 case 'custom':
2070 // do nothing
2071 break;
2072
2073 case 'text':
2074 if ( ! empty( $args ) ) {
2075 // validate custom events
2076 if ( $args['setting_id'] === 'settings' ) {
2077 if ( $args['field_id'] === 'enable_custom_events' && $args['subfield_id'] === 'custom_events' )
2078 $value = preg_replace( '/[^a-z0-9\s.-]/i', '', $value );
2079 } elseif ( $args['setting_id'] === 'builder' ) {
2080 if ( $args['field_id'] === 'permalink' || $args['field_id'] === 'permalink_categories' || $args['field_id'] === 'permalink_tags' )
2081 $value = sanitize_title( $value );
2082 }
2083 }
2084 case 'select':
2085 default:
2086 $value = is_array( $value ) ? array_map( 'sanitize_text_field', $value ) : sanitize_text_field( $value );
2087 break;
2088 }
2089
2090 return stripslashes_deep( $value );
2091 }
2092
2093 /**
2094 * Validate settings function
2095 *
2096 * @param array $input
2097 * @return array
2098 */
2099 public function validate_settings( $input ) {
2100 // get main instance
2101 $rl = Responsive_Lightbox();
2102
2103 // check capability
2104 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', $rl->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' ) ) )
2105 return $input;
2106
2107 // check option page
2108 $option_page = isset( $_POST['option_page'] ) ? sanitize_key( $_POST['option_page'] ) : '';
2109
2110 // check page
2111 if ( ! $option_page )
2112 return $input;
2113
2114 foreach ( $this->settings as $id => $setting ) {
2115 $key = array_search( $option_page, $setting );
2116
2117 if ( $key ) {
2118 // set key
2119 $setting_id = sanitize_key( $id );
2120 break;
2121 }
2122 }
2123
2124 // check setting id
2125 if ( ! $setting_id )
2126 return $input;
2127
2128 // save settings
2129 if ( isset( $_POST['save' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) {
2130 if ( $this->settings[$setting_id]['fields'] ) {
2131 foreach ( $this->settings[$setting_id]['fields'] as $field_id => $field ) {
2132 if ( $field['type'] === 'multiple' ) {
2133 if ( $field['fields'] ) {
2134 foreach ( $field['fields'] as $subfield_id => $subfield ) {
2135 $args = $subfield;
2136 $args['setting_id'] = $setting_id;
2137 $args['field_id'] = $field_id;
2138 $args['subfield_id'] = $subfield_id;
2139
2140 // if subfield has parent
2141 if ( ! empty( $this->settings[$setting_id]['fields'][$field_id]['fields'][$subfield_id]['parent'] ) ) {
2142 $field_parent = $this->settings[$setting_id]['fields'][$field_id]['fields'][$subfield_id]['parent'];
2143
2144 $input[$field_parent][$subfield_id] = isset( $input[$field_parent][$subfield_id] ) ? $this->sanitize_field( $input[$field_parent][$subfield_id], $subfield['type'], $args ) : ( $subfield['type'] === 'boolean' ? false : $rl->defaults[$setting_id][$field_parent][$subfield_id] );
2145 } else {
2146 $input[$subfield_id] = isset( $input[$subfield_id] ) ? $this->sanitize_field( $input[$subfield_id], $subfield['type'], $args ) : ( $subfield['type'] === 'boolean' ? false : $rl->defaults[$setting_id][$field_id][$subfield_id] );
2147 }
2148 }
2149 }
2150 } else {
2151 $args = $field;
2152 $args['setting_id'] = $setting_id;
2153 $args['field_id'] = $field_id;
2154
2155 // if field has parent
2156 if ( ! empty( $this->settings[$setting_id]['fields'][$field_id]['parent'] ) ) {
2157 $field_parent = $this->settings[$setting_id]['fields'][$field_id]['parent'];
2158
2159 $input[$field_parent][$field_id] = isset( $input[$field_parent][$field_id] ) ? ( $field['type'] === 'checkbox' ? array_keys( $this->sanitize_field( $input[$field_parent][$field_id], $field['type'], $args ) ) : $this->sanitize_field( $input[$field_parent][$field_id], $field['type'], $args ) ) : ( in_array( $field['type'], [ 'boolean', 'checkbox' ] ) ? false : $rl->defaults[$setting_id][$field_parent][$field_id] );
2160 } else {
2161 $input[$field_id] = isset( $input[$field_id] ) ? ( $field['type'] === 'checkbox' ? array_keys( $this->sanitize_field( $input[$field_id], $field['type'], $args ) ) : $this->sanitize_field( $input[$field_id], $field['type'], $args ) ) : ( in_array( $field['type'], [ 'boolean', 'checkbox' ] ) ? false : $rl->defaults[$setting_id][$field_id] );
2162 }
2163 }
2164 }
2165 }
2166
2167 if ( $setting_id === 'settings' ) {
2168 // merge scripts settings
2169 $input = array_merge( $rl->options['settings'], $input );
2170
2171 $input['update_notice'] = $rl->options['settings']['update_notice'];
2172
2173 // woocommerce lightbox has to be enabled when using rl gallery
2174 if ( $input['default_woocommerce_gallery'] !== 'default' )
2175 $input['woocommerce_gallery_lightbox'] = true;
2176 }
2177
2178 if ( $setting_id === 'configuration' ) {
2179 // merge scripts settings
2180 $input = array_merge( $rl->options['configuration'], $input );
2181 }
2182
2183 if ( $setting_id === 'remote_library' )
2184 $input = apply_filters( 'rl_remote_library_settings', $input );
2185 } elseif ( isset( $_POST['reset' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) {
2186 if ( $setting_id === 'configuration' ) {
2187 $script = key( $input );
2188
2189 // merge scripts settings
2190 $input[$script] = $rl->defaults['configuration'][$script];
2191 $input = array_merge( $rl->options['configuration'], $input );
2192 } elseif ( $setting_id === 'settings' ) {
2193 $input = $rl->defaults[$setting_id];
2194 $input['update_version'] = $rl->options['settings']['update_version'];
2195 $input['update_notice'] = $rl->options['settings']['update_notice'];
2196 } else
2197 $input = $rl->defaults[$setting_id];
2198
2199 add_settings_error( 'reset_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id, 'settings_restored', esc_html__( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' );
2200 }
2201
2202 return $input;
2203 }
2204
2205 /**
2206 * Validate capabilities.
2207 *
2208 * @global object $wp_roles
2209 *
2210 * @param array $input
2211 * @return array
2212 */
2213 public function validate_capabilities( $input ) {
2214 // get main instance
2215 $rl = Responsive_Lightbox();
2216
2217 // check capability
2218 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', $rl->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' ) ) )
2219 return $input;
2220
2221 global $wp_roles;
2222
2223 // validate normal fields
2224 $input = $this->validate_settings( $input );
2225
2226 // save capabilities?
2227 if ( isset( $_POST['save_rl_capabilities'] ) ) {
2228 foreach ( $wp_roles->roles as $role_name => $role_label ) {
2229 // get user role
2230 $role = $wp_roles->get_role( $role_name );
2231
2232 // manage new capabilities only for non-admins
2233 if ( $role_name !== 'administrator' ) {
2234 foreach ( $rl->get_data( 'capabilities' ) as $capability => $label ) {
2235 if ( isset( $input['roles'][$role_name][$capability] ) && $input['roles'][$role_name][$capability] === 'true' )
2236 $role->add_cap( $capability );
2237 else
2238 $role->remove_cap( $capability );
2239 }
2240 }
2241 }
2242 // reset capabilities?
2243 } elseif ( isset( $_POST['reset_rl_capabilities'] ) ) {
2244 foreach ( $wp_roles->roles as $role_name => $display_name ) {
2245 // get user role
2246 $role = $wp_roles->get_role( $role_name );
2247
2248 foreach ( $rl->get_data( 'capabilities' ) as $capability => $label ) {
2249 if ( array_key_exists( $role_name, $rl->defaults['capabilities']['roles'] ) && in_array( $capability, $rl->defaults['capabilities']['roles'][$role_name], true ) )
2250 $role->add_cap( $capability );
2251 else
2252 $role->remove_cap( $capability );
2253 }
2254 }
2255
2256 add_settings_error( 'reset_rl_capabilities', 'settings_restored', esc_html__( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' );
2257 }
2258
2259 return $input;
2260 }
2261
2262 /**
2263 * Render capabilities section.
2264 *
2265 * @global object $wp_roles
2266 *
2267 * @return void
2268 */
2269 public function capabilities_table() {
2270 global $wp_roles;
2271
2272 // get available user roles
2273 $editable_roles = get_editable_roles();
2274
2275 echo '
2276 <br class="clear" />
2277 <table class="widefat fixed posts">
2278 <thead>
2279 <tr>
2280 <th>' . esc_html__( 'Role', 'responsive-lightbox' ) . '</th>';
2281
2282 foreach ( $editable_roles as $role_name => $role_info ) {
2283 echo '<th>' . esc_html( isset( $wp_roles->role_names[$role_name] ) ? translate_user_role( $wp_roles->role_names[$role_name] ) : $role_name ) . '</th>';
2284 }
2285
2286 echo '
2287 </tr>
2288 </thead>
2289 <tbody id="the-list">';
2290
2291 $i = 0;
2292
2293 foreach ( Responsive_Lightbox()->get_data( 'capabilities' ) as $cap_role => $cap_label ) {
2294 echo '
2295 <tr' . ( ( $i++ % 2 === 0 ) ? ' class="alternate"' : '' ) . '>
2296 <td>' . esc_html__( $cap_label, 'responsive-lightbox' ) . '</td>';
2297
2298 foreach ( $editable_roles as $role_name => $role_info ) {
2299 // get user role
2300 $role = $wp_roles->get_role( $role_name );
2301
2302 echo '
2303 <td>
2304 <input type="checkbox" name="responsive_lightbox_capabilities[roles][' . esc_attr( $role->name ) . '][' . esc_attr( $cap_role ) . ']" value="true" ' . checked( true, ( $role->has_cap( $cap_role ) || $role_name === 'administrator' ), false ) . ' ' . disabled( $role_name, 'administrator', false ) . ' />
2305 </td>';
2306 }
2307
2308 echo '
2309 </tr>';
2310 }
2311
2312 echo '
2313 </tbody>
2314 </table>';
2315 }
2316
2317 /**
2318 * Add-ons tab callback
2319 *
2320 * @return void
2321 */
2322 private function addons_tab_cb() {
2323 ?>
2324 <h3><?php esc_html_e( 'Add-ons / Extensions', 'responsive-lightbox' ); ?></h3>
2325 <p class="description"><?php esc_html_e( 'Enhance your website with these beautiful, easy to use extensions, designed with Responsive Lightbox & Gallery integration in mind.', 'responsive-lightbox' ); ?></p>
2326 <br />
2327 <?php
2328 $addons_html = get_transient( 'responsive_lightbox_addons_feed' );
2329
2330 if ( $addons_html === false ) {
2331 $feed = wp_remote_get( 'http://www.dfactory.co/?feed=addons&product=responsive-lightbox', [ 'sslverify' => false ] );
2332
2333 if ( ! is_wp_error( $feed ) ) {
2334 if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 )
2335 $addons_html = wp_remote_retrieve_body( $feed );
2336 } else
2337 $addons_html = '<div class="error"><p>' . esc_html__( 'There was an error retrieving the extensions list from the server. Please try again later.', 'responsive-lightbox' ) . '</p></div>';
2338 }
2339
2340 $allowed_html = wp_kses_allowed_html( 'post' );
2341
2342 $allowed_html['img']['srcset'] = [];
2343 $allowed_html['img']['sizes'] = [];
2344
2345 echo wp_kses( $addons_html, $allowed_html );
2346 }
2347
2348 /**
2349 * Licenses section callback.
2350 *
2351 * @return void
2352 */
2353 public function licenses_section_cb() {
2354 ?><p class="description"><?php esc_html_e( 'A list of licenses for your Responsive Lightbox & Gallery extensions.', 'responsive-lightbox' ); ?></p><?php
2355 }
2356
2357 /**
2358 * License field callback.
2359 *
2360 * @param array $args
2361 * @return void
2362 */
2363 public function license_field_cb( $args ) {
2364 $licenses = get_option( 'responsive_lightbox_licenses' );
2365
2366 if ( ! empty( $licenses ) ) {
2367 $license = isset( $licenses[$args['id']]['license'] ) ? $licenses[$args['id']]['license'] : '';
2368 $status = ! empty( $licenses[$args['id']]['status'] );
2369 } else {
2370 $license = '';
2371 $status = false;
2372 } ?>
2373 <fieldset class="rl_license rl_license-<?php echo esc_attr( $args['id'] ); ?>">
2374 <input type="text" class="regular-text" name="responsive_lightbox_licenses[<?php echo esc_attr( $args['id'] ); ?>][license]" value="<?php echo esc_attr( $license ); ?>"><span class="dashicons <?php echo ( $status ? 'dashicons-yes' : 'dashicons-no' ); ?>"></span>
2375 <p class="description"><?php echo esc_html( sprintf( __( 'Enter your license key to activate %s extension and enable automatic upgrade notices.', 'responsive-lightbox' ), $args['name'] ) ); ?></p>
2376 </fieldset>
2377 <?php
2378 }
2379
2380 /**
2381 * Validate licenses function.
2382 *
2383 * @param array $input
2384 * @return array
2385 */
2386 public function validate_licenses( $input ) {
2387 // check cap
2388 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', Responsive_Lightbox()->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' ) ) )
2389 return $input;
2390
2391 // check option page
2392 $option_page = isset( $_POST['option_page'] ) ? sanitize_key( $_POST['option_page'] ) : '';
2393
2394 // check page
2395 if ( ! $option_page )
2396 return $input;
2397
2398 $rl_licenses = [];
2399
2400 if ( isset( $_POST['responsive_lightbox_licenses'] ) && is_array( $_POST['responsive_lightbox_licenses'] ) && ! empty( $_POST['responsive_lightbox_licenses'] ) ) {
2401 foreach ( $_POST['responsive_lightbox_licenses'] as $extension => $data ) {
2402 $ext = sanitize_key( $extension );
2403
2404 if ( is_array( $data ) && ! empty( $data['license'] ) )
2405 $rl_licenses[$ext]['license'] = preg_replace( '/[^a-z0-9]/i', '', $data['license'] );
2406 else
2407 $rl_licenses[$ext]['license'] = '';
2408 }
2409 }
2410
2411 // check data
2412 if ( ! $rl_licenses )
2413 return $input;
2414
2415 // get extension licenses
2416 $extensions = apply_filters( 'rl_settings_licenses', [] );
2417
2418 if ( empty( $extensions ) )
2419 return $input;
2420
2421 // save settings
2422 if ( isset( $_POST['save_rl_licenses'] ) ) {
2423 $licenses = get_option( 'responsive_lightbox_licenses' );
2424 $statuses = [ 'updated' => 0, 'error' => 0 ];
2425
2426 foreach ( $extensions as $extension ) {
2427 if ( ! isset( $rl_licenses[$extension['id']] ) )
2428 continue;
2429
2430 $license = $rl_licenses[$extension['id']]['license'];
2431 $status = ! empty( $licenses ) && ! empty( $licenses[$extension['id']]['status'] );
2432
2433 // update license
2434 $input[$extension['id']]['license'] = $license;
2435
2436 // request data
2437 $request_args = [
2438 'action' => 'activate_license',
2439 'license' => $license,
2440 'item_name' => $extension['item_name']
2441 ];
2442
2443 // request
2444 $response = $this->license_request( $request_args );
2445
2446 // validate request
2447 if ( is_wp_error( $response ) ) {
2448 $input[$extension['id']]['status'] = false;
2449 $statuses['error']++;
2450 } else {
2451 // decode the license data
2452 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
2453
2454 // assign the data
2455 if ( $license_data->license === 'valid' ) {
2456 $input[$extension['id']]['status'] = true;
2457
2458 if ( $status === false )
2459 $statuses['updated']++;
2460 } else {
2461 $input[$extension['id']]['status'] = false;
2462 $statuses['error']++;
2463 }
2464 }
2465 }
2466
2467 // success notice
2468 if ( $statuses['updated'] > 0 )
2469 add_settings_error( 'rl_licenses_settings', 'license_activated', esc_html( sprintf( _n( '%s license successfully activated.', '%s licenses successfully activated.', (int) $statuses['updated'], 'responsive-lightbox' ), (int) $statuses['updated'] ) ), 'updated' );
2470
2471 // failed notice
2472 if ( $statuses['error'] > 0 )
2473 add_settings_error( 'rl_licenses_settings', 'license_activation_failed', esc_html( sprintf( _n( '%s license activation failed.', '%s licenses activation failed.', (int) $statuses['error'], 'responsive-lightbox' ), (int) $statuses['error'] ) ), 'error' );
2474 } elseif ( isset( $_POST['reset_rl_licenses'] ) ) {
2475 $licenses = get_option( 'responsive_lightbox_licenses' );
2476 $statuses = [
2477 'updated' => 0,
2478 'error' => 0
2479 ];
2480
2481 foreach ( $extensions as $extension ) {
2482 $license = ! empty( $licenses ) && isset( $licenses[$extension['id']]['license'] ) ? $licenses[$extension['id']]['license'] : '';
2483 $status = ! empty( $licenses ) && ! empty( $licenses[$extension['id']]['status'] );
2484
2485 if ( $status === true || ( $status === false && ! empty( $license ) ) ) {
2486 // request data
2487 $request_args = [
2488 'action' => 'deactivate_license',
2489 'license' => trim( $license ),
2490 'item_name' => $extension['item_name']
2491 ];
2492
2493 // request
2494 $response = $this->license_request( $request_args );
2495
2496 // validate request
2497 if ( is_wp_error( $response ) )
2498 $statuses['error']++;
2499 else {
2500 // decode the license data
2501 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
2502
2503 // assign the data
2504 if ( $license_data->license == 'deactivated' ) {
2505 $input[$extension['id']]['license'] = '';
2506 $input[$extension['id']]['status'] = false;
2507
2508 $statuses['updated']++;
2509 } else
2510 $statuses['error']++;
2511 }
2512 }
2513 }
2514
2515 // success notice
2516 if ( $statuses['updated'] > 0 )
2517 add_settings_error( 'rl_licenses_settings', 'license_deactivated', esc_html( sprintf( _n( '%s license successfully deactivated.', '%s licenses successfully deactivated.', (int) $statuses['updated'], 'responsive-lightbox' ), (int) $statuses['updated'] ) ), 'updated' );
2518
2519 // failed notice
2520 if ( $statuses['error'] > 0 )
2521 add_settings_error( 'rl_licenses_settings', 'license_deactivation_failed', esc_html( sprintf( _n( '%s license deactivation failed.', '%s licenses deactivation failed.', (int) $statuses['error'], 'responsive-lightbox' ), (int) $statuses['error'] ) ), 'error' );
2522 }
2523
2524 return $input;
2525 }
2526
2527 /**
2528 * License request function.
2529 *
2530 * @param array $args
2531 * @return mixed
2532 */
2533 private function license_request( $args ) {
2534 // data to send in our API request
2535 $api_params = [
2536 'edd_action' => $args['action'],
2537 'license' => sanitize_key( $args['license'] ),
2538 'item_name' => urlencode( $args['item_name'] ),
2539 // 'item_id' => $args['item_id'],
2540 'url' => home_url(),
2541 'timeout' => 60,
2542 'sslverify' => false
2543 ];
2544
2545 // call the custom API
2546 $response = wp_remote_get( add_query_arg( $api_params, 'https://www.dfactory.co' ) );
2547
2548 return $response;
2549 }
2550 }
2551