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