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