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