PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / 2.5.5
Responsive Lightbox & Gallery v2.5.5
2.7.8 trunk 1.0.0 1.0.1 1.0.1.1 1.0.2 1.0.3 1.0.4 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.0.1 1.4.1 1.4.11 1.4.12 1.4.13 1.4.14 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3.1 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7
responsive-lightbox / includes / class-settings.php
responsive-lightbox / includes Last commit date
providers 1 year ago class-fast-image.php 2 years ago class-folders.php 6 months ago class-frontend.php 6 months ago class-galleries.php 6 months ago class-multilang.php 2 years ago class-remote-library-api.php 1 year ago class-remote-library.php 6 months ago class-settings.php 6 months ago class-tour.php 2 years ago class-welcome.php 2 years ago class-widgets.php 2 years ago functions.php 3 years ago
class-settings.php
2486 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 'max_image_size' => [
499 'title' => __( 'Max Image Size', 'responsive-lightbox' ),
500 'section' => 'responsive_lightbox_remote_library',
501 'type' => 'number',
502 'min' => 1,
503 'description' => __( 'Maximum allowed image size for remote downloads.', 'responsive-lightbox' ),
504 'append' => __( 'MB', 'responsive-lightbox' )
505 ],
506 'caching' => [
507 'title' => __( 'Caching', 'responsive-lightbox' ),
508 'section' => 'responsive_lightbox_remote_library',
509 'type' => 'boolean',
510 'label' => __( 'Enable remote library requests caching.', 'responsive-lightbox' )
511 ],
512 'cache_expiry' => [
513 'title' => __( 'Cache expiry', 'responsive-lightbox' ),
514 'section' => 'responsive_lightbox_remote_library',
515 'type' => 'number',
516 'min' => 1,
517 'description' => __( 'Enter the cache expiry time.', 'responsive-lightbox' ),
518 'append' => __( 'hour(s)', 'responsive-lightbox' )
519 ]
520 ]
521 ],
522 'configuration' => [
523 'option_group' => 'responsive_lightbox_configuration',
524 'option_name' => 'responsive_lightbox_configuration',
525 'sections' => [
526 'responsive_lightbox_configuration' => [
527 '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'] ) )
528 ],
529 ],
530 'prefix' => 'rl',
531 'fields' => []
532 ],
533 'capabilities' => [
534 'option_group' => 'responsive_lightbox_capabilities',
535 'option_name' => 'responsive_lightbox_capabilities',
536 'callback' => [ $this, 'validate_capabilities' ],
537 'sections' => [
538 'responsive_lightbox_capabilities_fields' => [
539 'title' => __( 'Capabilities Settings', 'responsive-lightbox' ),
540 'page' => 'responsive_lightbox_capabilities'
541 ],
542 'responsive_lightbox_capabilities' => [
543 'callback' => [ $this, 'capabilities_table' ]
544 ]
545 ],
546 'prefix' => 'rl',
547 'fields' => [
548 'active' => [
549 'title' => __( 'Capabilities', 'responsive-lightbox' ),
550 'section' => 'responsive_lightbox_capabilities_fields',
551 'type' => 'boolean',
552 'label' => __( 'Enable advanced capability management.', 'responsive-lightbox' ),
553 'description' => __( 'Check this to enable access to plugin features for selected user roles.', 'responsive-lightbox' )
554 ]
555 ]
556 ],
557 'basicgrid_gallery' => [
558 'option_group' => 'responsive_lightbox_basicgrid_gallery',
559 'option_name' => 'responsive_lightbox_basicgrid_gallery',
560 'sections' => [
561 'responsive_lightbox_basicgrid_gallery' => [
562 'title' => __( 'Basic Grid Gallery Settings', 'responsive-lightbox' )
563 ]
564 ],
565 'prefix' => 'rl',
566 'fields' => [
567 'screen_size_columns' => [
568 'title' => __( 'Screen sizes', 'responsive-lightbox' ),
569 'section' => 'responsive_lightbox_basicgrid_gallery',
570 'type' => 'multiple',
571 'description' => __( 'Number of columns in a gallery depending on the device screen size. (if greater than 0 overrides the Columns option)', 'responsive-lightbox' ),
572 'fields' => [
573 'columns_lg' => [
574 'type' => 'number',
575 'min' => 0,
576 'max' => 6,
577 'append' => __( 'large devices / desktops (&ge;1200px)', 'responsive-lightbox' )
578 ],
579 'columns_md' => [
580 'type' => 'number',
581 'min' => 0,
582 'max' => 6,
583 'append' => __( 'medium devices / desktops (&ge;992px)', 'responsive-lightbox' )
584 ],
585 'columns_sm' => [
586 'type' => 'number',
587 'min' => 0,
588 'max' => 6,
589 'append' => __( 'small devices / tablets (&ge;768px)', 'responsive-lightbox' )
590 ],
591 'columns_xs' => [
592 'type' => 'number',
593 'min' => 0,
594 'max' => 6,
595 'append' => __( 'extra small devices / phones (<768px)', 'responsive-lightbox' )
596 ]
597 ]
598 ],
599 'gutter' => [
600 'title' => __( 'Gutter', 'responsive-lightbox' ),
601 'section' => 'responsive_lightbox_basicgrid_gallery',
602 'type' => 'number',
603 'min' => 0,
604 'description' => __( 'Set the pixel width between the columns and rows.', 'responsive-lightbox' ),
605 'append' => 'px'
606 ],
607 'force_height' => [
608 'title' => __( 'Force height', 'responsive-lightbox' ),
609 'section' => 'responsive_lightbox_basicgrid_gallery',
610 'type' => 'boolean',
611 'label' => __( 'Enable to force the thumbnail row height.', 'responsive-lightbox' )
612 ],
613 'row_height' => [
614 'title' => __( 'Row height', 'responsive-lightbox' ),
615 'section' => 'responsive_lightbox_basicgrid_gallery',
616 'type' => 'number',
617 'min' => 50,
618 'description' => __( 'Enter the thumbnail row height in pixels (used if Force height is enabled). Defaults to 150px.', 'responsive-lightbox' ),
619 'append' => 'px'
620 ]
621 ]
622 ],
623 'basicslider_gallery' => [
624 'option_group' => 'responsive_lightbox_basicslider_gallery',
625 'option_name' => 'responsive_lightbox_basicslider_gallery',
626 'sections' => [
627 'responsive_lightbox_basicslider_gallery' => [
628 'title' => __( 'Basic Slider Gallery Settings', 'responsive-lightbox' )
629 ]
630 ],
631 'prefix' => 'rl',
632 'fields' => [
633 'slider_type' => [
634 'title' => __( 'Slider Type', 'responsive-lightbox' ),
635 'section' => 'responsive_lightbox_basicslider_gallery',
636 'type' => 'select',
637 'label' => __( 'The type of the slider.', 'responsive-lightbox' ),
638 'options' => [
639 'slide' => __( 'Slide', 'responsive-lightbox' ),
640 'loop' => __( 'Loop', 'responsive-lightbox' ),
641 'fade' => __( 'Fade', 'responsive-lightbox' )
642 ]
643 ],
644 'height' => [
645 'title' => __( 'Height', 'responsive-lightbox' ),
646 'section' => 'responsive_lightbox_basicslider_gallery',
647 'type' => 'number',
648 'min' => 0,
649 'description' => __( 'Defines the carousel max width in percentage. If set to 0 slider will adapt to slides width.', 'responsive-lightbox' ),
650 'append' => 'px'
651 ],
652 'width' => [
653 'title' => __( 'Width', 'responsive-lightbox' ),
654 'section' => 'responsive_lightbox_basicslider_gallery',
655 'type' => 'number',
656 'min' => 0,
657 'description' => __( 'Defines the slide height in pixels. If set to 0, slider height will adapt to slides height.', 'responsive-lightbox' ),
658 'append' => '%'
659 ],
660 'speed' => [
661 'title' => __( 'Animation Speed', 'responsive-lightbox' ),
662 'section' => 'responsive_lightbox_basicslider_gallery',
663 'type' => 'number',
664 'min' => 400,
665 'description' => __( 'The transition speed in milliseconds.', 'responsive-lightbox' ),
666 'append' => 'ms'
667 ],
668 'gap' => [
669 'title' => __( 'Slides Gap', 'responsive-lightbox' ),
670 'section' => 'responsive_lightbox_basicslider_gallery',
671 'type' => 'number',
672 'min' => 20,
673 'description' => __( 'The gap between slides.', 'responsive-lightbox' ),
674 'append' => 'px'
675 ],
676 'arrows_navigation' => [
677 'title' => __( 'Arrows Navigtion', 'responsive-lightbox' ),
678 'section' => 'responsive_lightbox_basicslider_gallery',
679 'type' => 'boolean',
680 'label' => __( 'Determines whether to create arrows or not.', 'responsive-lightbox' )
681 ],
682 'dots_navigation' => [
683 'title' => __( 'Dots Navigtion', 'responsive-lightbox' ),
684 'section' => 'responsive_lightbox_basicslider_gallery',
685 'type' => 'boolean',
686 'label' => __( 'Determines whether to create pagination (indicator dots) or not.', 'responsive-lightbox' )
687 ],
688 'drag' => [
689 'title' => __( 'Drag', 'responsive-lightbox' ),
690 'section' => 'responsive_lightbox_basicslider_gallery',
691 'type' => 'boolean',
692 'label' => __( 'Determines whether to allow the user to drag the carousel or not.', 'responsive-lightbox' )
693 ],
694 'autoplay' => [
695 'title' => __( 'Autoplay', 'responsive-lightbox' ),
696 'section' => 'responsive_lightbox_basicslider_gallery',
697 'type' => 'boolean',
698 'label' => __( 'Determines whether to enable autoplay or not.', 'responsive-lightbox' )
699 ],
700 'interval' => [
701 'title' => __( 'Interval', 'responsive-lightbox' ),
702 'section' => 'responsive_lightbox_basicslider_gallery',
703 'type' => 'number',
704 'min' => 1000,
705 'description' => __( 'The autoplay interval duration in milliseconds.', 'responsive-lightbox' ),
706 'append' => 'ms'
707 ],
708 'wheel' => [
709 'title' => __( 'Mouse wheel', 'responsive-lightbox' ),
710 'section' => 'responsive_lightbox_basicslider_gallery',
711 'type' => 'boolean',
712 'label' => __( 'Determines whether to enable navigation by the mouse wheel.', 'responsive-lightbox' )
713 ],
714 'slides_per_page' => [
715 'title' => __( 'Per Page', 'responsive-lightbox' ),
716 'section' => 'responsive_lightbox_basicslider_gallery',
717 'type' => 'number',
718 'min' => 1,
719 'description' => __( 'Determines the number of slides to display in a page.', 'responsive-lightbox' )
720 ],
721 'slides_per_move' => [
722 'title' => __( 'Per Move', 'responsive-lightbox' ),
723 'section' => 'responsive_lightbox_basicslider_gallery',
724 'type' => 'number',
725 'min' => 1,
726 'description' => __( 'Determines the number of slides to move at once.', 'responsive-lightbox' )
727 ],
728 'slides_start' => [
729 'title' => __( 'Start', 'responsive-lightbox' ),
730 'section' => 'responsive_lightbox_basicslider_gallery',
731 'type' => 'number',
732 'min' => 0,
733 'description' => __( 'Defines the start index.', 'responsive-lightbox' )
734 ]
735 ]
736 ],
737 'basicmasonry_gallery' => [
738 'option_group' => 'responsive_lightbox_basicmasonry_gallery',
739 'option_name' => 'responsive_lightbox_basicmasonry_gallery',
740 'sections' => [
741 'responsive_lightbox_basicmasonry_gallery' => [
742 'title' => __( 'Basic Masonry Gallery Settings', 'responsive-lightbox' )
743 ]
744 ],
745 'prefix' => 'rl',
746 'fields' => [
747 'screen_size_columns' => [
748 'title' => __( 'Screen sizes', 'responsive-lightbox' ),
749 'section' => 'responsive_lightbox_basicmasonry_gallery',
750 'type' => 'multiple',
751 'description' => __( 'Number of columns in a gallery depending on the device screen size. (if greater than 0 overrides the Columns option)', 'responsive-lightbox' ),
752 'fields' => [
753 'columns_lg' => [
754 'type' => 'number',
755 'min' => 0,
756 'max' => 6,
757 'default' => 4,
758 'append' => __( 'large devices / desktops (&ge;1200px)', 'responsive-lightbox' )
759 ],
760 'columns_md' => [
761 'type' => 'number',
762 'min' => 0,
763 'max' => 6,
764 'default' => 3,
765 'append' => __( 'medium devices / desktops (&ge;992px)', 'responsive-lightbox' )
766 ],
767 'columns_sm' => [
768 'type' => 'number',
769 'min' => 0,
770 'max' => 6,
771 'default' => 2,
772 'append' => __( 'small devices / tablets (&ge;768px)', 'responsive-lightbox' )
773 ],
774 'columns_xs' => [
775 'type' => 'number',
776 'min' => 0,
777 'max' => 6,
778 'default' => 2,
779 'append' => __( 'extra small devices / phones (<768px)', 'responsive-lightbox' )
780 ]
781 ]
782 ],
783 'gutter' => [
784 'title' => __( 'Gutter', 'responsive-lightbox' ),
785 'section' => 'responsive_lightbox_basicmasonry_gallery',
786 'type' => 'number',
787 'description' => __( 'Horizontal space between gallery items.', 'responsive-lightbox' ),
788 'append' => 'px'
789 ],
790 'margin' => [
791 'title' => __( 'Margin', 'responsive-lightbox' ),
792 'section' => 'responsive_lightbox_basicmasonry_gallery',
793 'type' => 'number',
794 'description' => __( 'Vertical space between gallery items.', 'responsive-lightbox' ),
795 'append' => 'px'
796 ],
797 'origin_left' => [
798 'title' => __( 'Origin Left', 'responsive-lightbox' ),
799 'section' => 'responsive_lightbox_basicmasonry_gallery',
800 'type' => 'boolean',
801 'label' => __( 'Enable left-to-right layouts.', 'responsive-lightbox' ),
802 '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' )
803 ],
804 'origin_top' => [
805 'title' => __( 'Origin Top', 'responsive-lightbox' ),
806 'section' => 'responsive_lightbox_basicmasonry_gallery',
807 'type' => 'boolean',
808 'label' => __( 'Enable top-to-bottom layouts.', 'responsive-lightbox' ),
809 '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' )
810 ]
811 ]
812 ]
813 ];
814
815 $this->tabs = apply_filters(
816 'rl_settings_tabs',
817 [
818 'settings' => [
819 'name' => __( 'General', 'responsive-lightbox' ),
820 'key' => 'responsive_lightbox_settings',
821 'submit' => 'save_rl_settings',
822 'reset' => 'reset_rl_settings'
823 ],
824 'configuration' => [
825 'name' => __( 'Lightboxes', 'responsive-lightbox' ),
826 'key' => 'responsive_lightbox_configuration',
827 'submit' => 'save_' . $this->settings['configuration']['prefix'] . '_configuration',
828 'reset' => 'reset_' . $this->settings['configuration']['prefix'] . '_configuration',
829 'sections' => $scripts,
830 'default_section' => $rl->options['settings']['script']
831 ],
832 'basicgrid_gallery' => [
833 'name' => __( 'Basic Grid', 'responsive-lightbox' ),
834 'key' => 'responsive_lightbox_basicgrid_gallery',
835 'submit' => 'save_rl_basicgrid_gallery',
836 'reset' => 'reset_rl_basicgrid_gallery'
837 ],
838 'basicslider_gallery' => [
839 'name' => __( 'Basic Slider', 'responsive-lightbox' ),
840 'key' => 'responsive_lightbox_basiclider_gallery',
841 'submit' => 'save_rl_basiclider_gallery',
842 'reset' => 'reset_rl_basiclider_gallery'
843 ],
844 'basicmasonry_gallery' => [
845 'name' => __( 'Basic Masonry', 'responsive-lightbox' ),
846 'key' => 'responsive_lightbox_basicmasonry_gallery',
847 'submit' => 'save_rl_basicmasonry_gallery',
848 'reset' => 'reset_rl_basicmasonry_gallery'
849 ]
850 ]
851 );
852
853 $tabs_copy = $this->tabs;
854 $tab_key = '';
855 $section_key = isset( $_REQUEST['section'] ) ? sanitize_key( $_REQUEST['section'] ) : '';
856
857 // set current tab and section
858 if ( is_admin() && ! wp_doing_ajax() ) {
859 global $pagenow;
860
861 // check page
862 $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : '';
863
864 // check settings page
865 if ( $pagenow === 'options.php' || ( $pagenow == 'admin.php' && $page && preg_match( '/^responsive-lightbox-(' . implode( '|', array_keys( $this->tabs + [ 'gallery' => '', 'addons' => '' ] ) ) . ')$/', $page, $tabs ) === 1 ) ) {
866 // set tab key
867 $tab_key = isset( $tabs[1] ) ? $tabs[1] : 'settings';
868
869 // set section key
870 if ( ! $section_key )
871 $section_key = ! empty( $this->tabs[$tab_key]['default_section'] ) ? $this->tabs[$tab_key]['default_section'] : '';
872 }
873 }
874
875 // remove default gallery
876 if ( isset( $gallery_types['default'] ) )
877 unset( $gallery_types['default'] );
878
879 // get available galleries
880 $gallery_types = apply_filters( 'rl_gallery_types', $gallery_types );
881
882 if ( $gallery_types ) {
883 foreach ( $gallery_types as $key => $name ) {
884 unset( $gallery_types[$key] );
885
886 $gallery_types[$key . '_gallery'] = $name;
887 }
888 }
889
890 // backward compatibility, remove from tabs
891 $gallery_tabs = array_intersect( array_keys( $this->tabs ), array_keys( $gallery_types ) );
892 $galleries = [];
893
894 if ( ! empty( $gallery_tabs ) ) {
895 // unset tabs if exist
896 foreach ( $gallery_tabs as $gallery_tab ) {
897 $galleries[$gallery_tab] = $this->tabs[$gallery_tab];
898
899 unset( $this->tabs[$gallery_tab] );
900 }
901
902 foreach ( $galleries as $key => $gallery ) {
903 $gallery_sections[$key] = $gallery['name'];
904 }
905
906 if ( $tab_key == 'gallery' ) {
907 if ( ! $section_key ) {
908 $section_key = in_array( $rl->options['settings']['default_gallery'] . '_gallery', array_keys( $gallery_sections ) ) ? $rl->options['settings']['default_gallery'] . '_gallery' : key( $gallery_sections );
909 }
910 }
911
912 $this->tabs['gallery'] = [
913 'name' => __( 'Galleries', 'responsive-lightbox' ),
914 'key' => 'responsive_lightbox_' . $section_key,
915 'submit' => array_key_exists( $section_key, $tabs_copy ) ? $tabs_copy[$section_key]['submit'] : 'save_' . $section_key . '_configuration',
916 'reset' => array_key_exists( $section_key, $tabs_copy ) ? $tabs_copy[$section_key]['reset'] : 'reset_rl_' . $section_key,
917 'sections' => $gallery_sections,
918 'default_section' => $section_key
919 ];
920 }
921
922 $this->tabs['builder'] = [
923 'name' => __( 'Builder', 'responsive-lightbox' ),
924 'key' => 'responsive_lightbox_builder',
925 'submit' => 'save_rl_builder',
926 'reset' => 'reset_rl_builder'
927 ];
928
929 $this->tabs['folders'] = [
930 'name' => __( 'Folders', 'responsive-lightbox' ),
931 'key' => 'responsive_lightbox_folders',
932 'submit' => 'save_rl_folders',
933 'reset' => 'reset_rl_folders'
934 ];
935
936 $this->tabs['capabilities'] = [
937 'name' => __( 'Capabilities', 'responsive-lightbox' ),
938 'key' => 'responsive_lightbox_capabilities',
939 'submit' => 'save_rl_capabilities',
940 'reset' => 'reset_rl_capabilities'
941 ];
942
943 $this->tabs['remote_library'] = [
944 'name' => __( 'Remote Library', 'responsive-lightbox' ),
945 'key' => 'responsive_lightbox_remote_library',
946 'submit' => 'save_rl_remote_library',
947 'reset' => 'reset_rl_remote_library'
948 ];
949
950 $this->tabs = apply_filters( 'rl_settings_tabs_extra', $this->tabs );
951
952 // push licenses just before the addons
953 if ( isset( $this->tabs['licenses'] ) ) {
954 unset( $this->tabs['licenses'] );
955
956 $this->tabs['licenses'] = [
957 'name' => __( 'Licenses', 'responsive-lightbox' ),
958 'key' => 'responsive_lightbox_licenses',
959 'submit' => 'save_rl_licenses',
960 'reset' => 'reset_rl_licenses'
961 ];
962 }
963
964 $this->tabs['addons'] = [
965 'name' => __( 'Add-ons', 'responsive-lightbox' ),
966 'key' => 'responsive_lightbox_configuration',
967 'callback' => [ $this, 'addons_tab_cb' ]
968 ];
969
970 if ( isset( $this->tabs[$tab_key]['sections'][$section_key] ) && empty( $this->tabs[$tab_key]['sections']['responsive_lightbox_' . $tab_key]['title'] ) )
971 $this->settings[$tab_key]['sections']['responsive_lightbox_' . $tab_key]['title'] = sprintf( __( '%s Settings', 'responsive-lightbox' ), $this->tabs[$tab_key]['sections'][$section_key] );
972
973 switch ( ! empty( $section_key ) ? $section_key : $rl->options['settings']['script'] ) {
974 case 'swipebox':
975 $this->settings['configuration']['prefix'] = 'rl_sb';
976 $this->settings['configuration']['fields'] = [
977 'animation' => [
978 'title' => __( 'Animation type', 'responsive-lightbox' ),
979 'section' => 'responsive_lightbox_configuration',
980 'type' => 'radio',
981 'label' => '',
982 'description' => __( 'Select a method of applying a lightbox effect.', 'responsive-lightbox' ),
983 'options' => $this->scripts['swipebox']['animations'],
984 'parent' => 'swipebox'
985 ],
986 'force_png_icons' => [
987 'title' => __( 'Force PNG icons', 'responsive-lightbox' ),
988 'section' => 'responsive_lightbox_configuration',
989 'type' => 'boolean',
990 'label' => __( 'Enable this if you\'re having problems with navigation icons not visible on some devices.', 'responsive-lightbox' ),
991 'parent' => 'swipebox'
992 ],
993 'hide_close_mobile' => [
994 'title' => __( 'Hide close on mobile', 'responsive-lightbox' ),
995 'section' => 'responsive_lightbox_configuration',
996 'type' => 'boolean',
997 'label' => __( 'Hide the close button on mobile devices.', 'responsive-lightbox' ),
998 'parent' => 'swipebox'
999 ],
1000 'remove_bars_mobile' => [
1001 'title' => __( 'Remove bars on mobile', 'responsive-lightbox' ),
1002 'section' => 'responsive_lightbox_configuration',
1003 'type' => 'boolean',
1004 'label' => __( 'Hide the top and bottom bars on mobile devices.', 'responsive-lightbox' ),
1005 'parent' => 'swipebox'
1006 ],
1007 'hide_bars' => [
1008 'title' => __( 'Top and bottom bars', 'responsive-lightbox' ),
1009 'section' => 'responsive_lightbox_configuration',
1010 'type' => 'multiple',
1011 'fields' => [
1012 'hide_bars' => [
1013 'type' => 'boolean',
1014 'label' => __( 'Hide top and bottom bars after a period of time.', 'responsive-lightbox' ),
1015 'parent' => 'swipebox'
1016 ],
1017 'hide_bars_delay' => [
1018 'type' => 'number',
1019 'description' => __( 'Enter the time after which the top and bottom bars will be hidden (when hiding is enabled).', 'responsive-lightbox' ),
1020 'append' => 'ms',
1021 'parent' => 'swipebox'
1022 ]
1023 ]
1024 ],
1025 'video_max_width' => [
1026 'title' => __( 'Video max width', 'responsive-lightbox' ),
1027 'section' => 'responsive_lightbox_configuration',
1028 'type' => 'number',
1029 'description' => __( 'Enter the max video width in a lightbox.', 'responsive-lightbox' ),
1030 'append' => 'px',
1031 'parent' => 'swipebox'
1032 ],
1033 'loop_at_end' => [
1034 'title' => __( 'Loop at end', 'responsive-lightbox' ),
1035 'section' => 'responsive_lightbox_configuration',
1036 'type' => 'boolean',
1037 'label' => __( 'True will return to the first image after the last image is reached.', 'responsive-lightbox' ),
1038 'parent' => 'swipebox'
1039 ]
1040 ];
1041 break;
1042
1043 case 'prettyphoto':
1044 $this->settings['configuration']['prefix'] = 'rl_pp';
1045 $this->settings['configuration']['fields'] = [
1046 'animation_speed' => [
1047 'title' => __( 'Animation speed', 'responsive-lightbox' ),
1048 'section' => 'responsive_lightbox_configuration',
1049 'type' => 'radio',
1050 'label' => '',
1051 'description' => __( 'Select animation speed for lightbox effect.', 'responsive-lightbox' ),
1052 'options' => $this->scripts['prettyphoto']['animation_speeds'],
1053 'parent' => 'prettyphoto'
1054 ],
1055 'slideshow' => [
1056 'title' => __( 'Slideshow', 'responsive-lightbox' ),
1057 'section' => 'responsive_lightbox_configuration',
1058 'type' => 'multiple',
1059 'fields' => [
1060 'slideshow' => [
1061 'type' => 'boolean',
1062 'label' => __( 'Display images as slideshow', 'responsive-lightbox' ),
1063 'parent' => 'prettyphoto'
1064 ],
1065 'slideshow_delay' => [
1066 'type' => 'number',
1067 'description' => __( 'Enter time (in miliseconds).', 'responsive-lightbox' ),
1068 'append' => 'ms',
1069 'parent' => 'prettyphoto'
1070 ]
1071 ]
1072 ],
1073 'slideshow_autoplay' => [
1074 'title' => __( 'Slideshow autoplay', 'responsive-lightbox' ),
1075 'section' => 'responsive_lightbox_configuration',
1076 'type' => 'boolean',
1077 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ),
1078 'parent' => 'prettyphoto'
1079 ],
1080 'opacity' => [
1081 'title' => __( 'Opacity', 'responsive-lightbox' ),
1082 'section' => 'responsive_lightbox_configuration',
1083 'type' => 'range',
1084 'description' => __( 'Value between 0 and 100, 100 for no opacity.', 'responsive-lightbox' ),
1085 'min' => 0,
1086 'max' => 100,
1087 'parent' => 'prettyphoto'
1088 ],
1089 'show_title' => [
1090 'title' => __( 'Show title', 'responsive-lightbox' ),
1091 'section' => 'responsive_lightbox_configuration',
1092 'type' => 'boolean',
1093 'label' => __( 'Display image title.', 'responsive-lightbox' ),
1094 'parent' => 'prettyphoto'
1095 ],
1096 'allow_resize' => [
1097 'title' => __( 'Allow resize big images', 'responsive-lightbox' ),
1098 'section' => 'responsive_lightbox_configuration',
1099 'type' => 'boolean',
1100 'label' => __( 'Resize the photos bigger than viewport.', 'responsive-lightbox' ),
1101 'parent' => 'prettyphoto'
1102 ],
1103 'allow_expand' => [
1104 'title' => __( 'Allow expand', 'responsive-lightbox' ),
1105 'section' => 'responsive_lightbox_configuration',
1106 'type' => 'boolean',
1107 'label' => __( 'Allow expanding images.', 'responsive-lightbox' ),
1108 'parent' => 'prettyphoto'
1109 ],
1110 'width' => [
1111 'title' => __( 'Video width', 'responsive-lightbox' ),
1112 'section' => 'responsive_lightbox_configuration',
1113 'type' => 'number',
1114 'append' => 'px',
1115 'parent' => 'prettyphoto'
1116 ],
1117 'height' => [
1118 'title' => __( 'Video height', 'responsive-lightbox' ),
1119 'section' => 'responsive_lightbox_configuration',
1120 'type' => 'number',
1121 'append' => 'px',
1122 'parent' => 'prettyphoto'
1123 ],
1124 'theme' => [
1125 'title' => __( 'Theme', 'responsive-lightbox' ),
1126 'section' => 'responsive_lightbox_configuration',
1127 'type' => 'radio',
1128 'description' => __( 'Select the theme for lightbox effect.', 'responsive-lightbox' ),
1129 'options' => $this->scripts['prettyphoto']['themes'],
1130 'parent' => 'prettyphoto'
1131 ],
1132 'horizontal_padding' => [
1133 'title' => __( 'Horizontal padding', 'responsive-lightbox' ),
1134 'section' => 'responsive_lightbox_configuration',
1135 'type' => 'number',
1136 'append' => 'px',
1137 'parent' => 'prettyphoto'
1138 ],
1139 'hide_flash' => [
1140 'title' => __( 'Hide Flash', 'responsive-lightbox' ),
1141 'section' => 'responsive_lightbox_configuration',
1142 'type' => 'boolean',
1143 'label' => __( 'Hide all the flash objects on a page. Enable this if flash appears over prettyPhoto.', 'responsive-lightbox' ),
1144 'parent' => 'prettyphoto'
1145 ],
1146 'wmode' => [
1147 'title' => __( 'Flash Window Mode (wmode)', 'responsive-lightbox' ),
1148 'section' => 'responsive_lightbox_configuration',
1149 'type' => 'radio',
1150 'description' => __( 'Select flash window mode.', 'responsive-lightbox' ),
1151 'options' => $this->scripts['prettyphoto']['wmodes'],
1152 'parent' => 'prettyphoto'
1153 ],
1154 'video_autoplay' => [
1155 'title' => __( 'Video autoplay', 'responsive-lightbox' ),
1156 'section' => 'responsive_lightbox_configuration',
1157 'type' => 'boolean',
1158 'label' => __( 'Automatically start videos.', 'responsive-lightbox' ),
1159 'parent' => 'prettyphoto'
1160 ],
1161 'modal' => [
1162 'title' => __( 'Modal', 'responsive-lightbox' ),
1163 'section' => 'responsive_lightbox_configuration',
1164 'type' => 'boolean',
1165 'label' => __( 'If set to true, only the close button will close the window.', 'responsive-lightbox' ),
1166 'parent' => 'prettyphoto'
1167 ],
1168 'deeplinking' => [
1169 'title' => __( 'Deeplinking', 'responsive-lightbox' ),
1170 'section' => 'responsive_lightbox_configuration',
1171 'type' => 'boolean',
1172 'label' => __( 'Allow prettyPhoto to update the url to enable deeplinking.', 'responsive-lightbox' ),
1173 'parent' => 'prettyphoto'
1174 ],
1175 'overlay_gallery' => [
1176 'title' => __( 'Overlay gallery', 'responsive-lightbox' ),
1177 'section' => 'responsive_lightbox_configuration',
1178 'type' => 'boolean',
1179 'label' => __( 'If enabled, a gallery will overlay the fullscreen image on mouse over.', 'responsive-lightbox' ),
1180 'parent' => 'prettyphoto'
1181 ],
1182 'keyboard_shortcuts' => [
1183 'title' => __( 'Keyboard shortcuts', 'responsive-lightbox' ),
1184 'section' => 'responsive_lightbox_configuration',
1185 'type' => 'boolean',
1186 'label' => __( 'Set to false if you open forms inside prettyPhoto.', 'responsive-lightbox' ),
1187 'parent' => 'prettyphoto'
1188 ],
1189 'social' => [
1190 'title' => __( 'Social (Twitter, Facebook)', 'responsive-lightbox' ),
1191 'section' => 'responsive_lightbox_configuration',
1192 'type' => 'boolean',
1193 'label' => __( 'Display links to Facebook and Twitter.', 'responsive-lightbox' ),
1194 'parent' => 'prettyphoto'
1195 ]
1196 ];
1197 break;
1198
1199 case 'nivo':
1200 $this->settings['configuration']['prefix'] = 'rl_nv';
1201 $this->settings['configuration']['fields'] = [
1202 'effect' => [
1203 'title' => __( 'Effect', 'responsive-lightbox' ),
1204 'section' => 'responsive_lightbox_configuration',
1205 'type' => 'radio',
1206 'description' => __( 'The effect to use when showing the lightbox.', 'responsive-lightbox' ),
1207 'options' => $this->scripts['nivo']['effects'],
1208 'parent' => 'nivo'
1209 ],
1210 'keyboard_nav' => [
1211 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ),
1212 'section' => 'responsive_lightbox_configuration',
1213 'type' => 'boolean',
1214 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ),
1215 'parent' => 'nivo'
1216 ],
1217 'click_overlay_to_close' => [
1218 'title' => __( 'Click overlay to close', 'responsive-lightbox' ),
1219 'section' => 'responsive_lightbox_configuration',
1220 'type' => 'boolean',
1221 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ),
1222 'parent' => 'nivo'
1223 ],
1224 'error_message' => [
1225 'title' => __( 'Error message', 'responsive-lightbox' ),
1226 'section' => 'responsive_lightbox_configuration',
1227 'type' => 'text',
1228 'class' => 'large-text',
1229 'label' => __( 'Error message if the content cannot be loaded.', 'responsive-lightbox' ),
1230 'parent' => 'nivo'
1231 ],
1232 ];
1233 break;
1234
1235 case 'imagelightbox':
1236 $this->settings['configuration']['prefix'] = 'rl_il';
1237 $this->settings['configuration']['fields'] = [
1238 'animation_speed' => [
1239 'title' => __( 'Animation speed', 'responsive-lightbox' ),
1240 'section' => 'responsive_lightbox_configuration',
1241 'type' => 'number',
1242 'description' => __( 'Animation speed.', 'responsive-lightbox' ),
1243 'append' => 'ms',
1244 'parent' => 'imagelightbox'
1245 ],
1246 'preload_next' => [
1247 'title' => __( 'Preload next image', 'responsive-lightbox' ),
1248 'section' => 'responsive_lightbox_configuration',
1249 'type' => 'boolean',
1250 'label' => __( 'Silently preload the next image.', 'responsive-lightbox' ),
1251 'parent' => 'imagelightbox'
1252 ],
1253 'enable_keyboard' => [
1254 'title' => __( 'Enable keyboard keys', 'responsive-lightbox' ),
1255 'section' => 'responsive_lightbox_configuration',
1256 'type' => 'boolean',
1257 'label' => __( 'Enable keyboard shortcuts (arrows Left/Right and Esc).', 'responsive-lightbox' ),
1258 'parent' => 'imagelightbox'
1259 ],
1260 'quit_on_end' => [
1261 'title' => __( 'Quit after last image', 'responsive-lightbox' ),
1262 'section' => 'responsive_lightbox_configuration',
1263 'type' => 'boolean',
1264 'label' => __( 'Quit after viewing the last image.', 'responsive-lightbox' ),
1265 'parent' => 'imagelightbox'
1266 ],
1267 'quit_on_image_click' => [
1268 'title' => __( 'Quit on image click', 'responsive-lightbox' ),
1269 'section' => 'responsive_lightbox_configuration',
1270 'type' => 'boolean',
1271 'label' => __( 'Quit when the viewed image is clicked.', 'responsive-lightbox' ),
1272 'parent' => 'imagelightbox'
1273 ],
1274 'quit_on_document_click' => [
1275 'title' => __( 'Quit on anything click', 'responsive-lightbox' ),
1276 'section' => 'responsive_lightbox_configuration',
1277 'type' => 'boolean',
1278 'label' => __( 'Quit when anything but the viewed image is clicked.', 'responsive-lightbox' ),
1279 'parent' => 'imagelightbox'
1280 ],
1281 ];
1282 break;
1283
1284 case 'tosrus':
1285 $this->settings['configuration']['prefix'] = 'rl_tr';
1286 $this->settings['configuration']['fields'] = [
1287 'effect' => [
1288 'title' => __( 'Transition effect', 'responsive-lightbox' ),
1289 'section' => 'responsive_lightbox_configuration',
1290 'type' => 'radio',
1291 'description' => __( 'What effect to use for the transition.', 'responsive-lightbox' ),
1292 'options' => [
1293 'slide' => __( 'slide', 'responsive-lightbox' ),
1294 'fade' => __( 'fade', 'responsive-lightbox' )
1295 ],
1296 'parent' => 'tosrus'
1297 ],
1298 'infinite' => [
1299 'title' => __( 'Infinite loop', 'responsive-lightbox' ),
1300 'section' => 'responsive_lightbox_configuration',
1301 'type' => 'boolean',
1302 'label' => __( 'Whether or not to slide back to the first slide when the last has been reached.', 'responsive-lightbox' ),
1303 'parent' => 'tosrus'
1304 ],
1305 'keys' => [
1306 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ),
1307 'section' => 'responsive_lightbox_configuration',
1308 'type' => 'boolean',
1309 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ),
1310 'parent' => 'tosrus'
1311 ],
1312 'autoplay' => [
1313 'title' => __( 'Autoplay', 'responsive-lightbox' ),
1314 'section' => 'responsive_lightbox_configuration',
1315 'type' => 'multiple',
1316 'fields' => [
1317 'autoplay' => [
1318 'type' => 'boolean',
1319 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ),
1320 'parent' => 'tosrus'
1321 ],
1322 'timeout' => [
1323 'type' => 'number',
1324 'description' => __( 'The timeout between sliding to the next slide in milliseconds.', 'responsive-lightbox' ),
1325 'append' => 'ms',
1326 'parent' => 'tosrus'
1327 ]
1328 ]
1329 ],
1330 'pause_on_hover' => [
1331 'title' => __( 'Pause on hover', 'responsive-lightbox' ),
1332 'section' => 'responsive_lightbox_configuration',
1333 'type' => 'boolean',
1334 'label' => __( 'Whether or not to pause on hover.', 'responsive-lightbox' ),
1335 'parent' => 'tosrus'
1336 ],
1337 'pagination' => [
1338 'title' => __( 'Pagination', 'responsive-lightbox' ),
1339 'section' => 'responsive_lightbox_configuration',
1340 'type' => 'multiple',
1341 'fields' => [
1342 'pagination' => [
1343 'type' => 'boolean',
1344 'label' => __( 'Whether or not to add a pagination.', 'responsive-lightbox' ),
1345 'parent' => 'tosrus'
1346 ],
1347 'pagination_type' => [
1348 'type' => 'radio',
1349 'description' => __( 'What type of pagination to use.', 'responsive-lightbox' ),
1350 'options' => [
1351 'bullets' => __( 'Bullets', 'responsive-lightbox' ),
1352 'thumbnails' => __( 'Thumbnails', 'responsive-lightbox' )
1353 ],
1354 'parent' => 'tosrus'
1355 ]
1356 ]
1357 ],
1358 'close_on_click' => [
1359 'title' => __( 'Overlay close', 'responsive-lightbox' ),
1360 'section' => 'responsive_lightbox_configuration',
1361 'type' => 'boolean',
1362 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ),
1363 'parent' => 'tosrus'
1364 ]
1365 ];
1366 break;
1367
1368 case 'featherlight':
1369 $this->settings['configuration']['prefix'] = 'rl_fl';
1370 $this->settings['configuration']['fields'] = [
1371 'open_speed' => [
1372 'title' => __( 'Opening speed', 'responsive-lightbox' ),
1373 'section' => 'responsive_lightbox_configuration',
1374 'type' => 'number',
1375 'description' => __( 'Duration of opening animation.', 'responsive-lightbox' ),
1376 'append' => 'ms',
1377 'parent' => 'featherlight'
1378 ],
1379 'close_speed' => [
1380 'title' => __( 'Closing speed', 'responsive-lightbox' ),
1381 'section' => 'responsive_lightbox_configuration',
1382 'type' => 'number',
1383 'description' => __( 'Duration of closing animation.', 'responsive-lightbox' ),
1384 'append' => 'ms',
1385 'parent' => 'featherlight'
1386 ],
1387 'close_on_click' => [
1388 'title' => __( 'Close on click', 'responsive-lightbox' ),
1389 'section' => 'responsive_lightbox_configuration',
1390 'type' => 'radio',
1391 'label' => __( 'Select how to close lightbox.', 'responsive-lightbox' ),
1392 'options' => [
1393 'background' => __( 'background', 'responsive-lightbox' ),
1394 'anywhere' => __( 'anywhere', 'responsive-lightbox' ),
1395 'false' => __( 'false', 'responsive-lightbox' )
1396 ],
1397 'parent' => 'featherlight'
1398 ],
1399 'close_on_esc' => [
1400 'title' => __( 'Close on Esc', 'responsive-lightbox' ),
1401 'section' => 'responsive_lightbox_configuration',
1402 'type' => 'boolean',
1403 'label' => __( 'Toggle if pressing Esc button closes lightbox.', 'responsive-lightbox' ),
1404 'parent' => 'featherlight'
1405 ],
1406 'gallery_fade_in' => [
1407 'title' => __( 'Gallery fade in', 'responsive-lightbox' ),
1408 'section' => 'responsive_lightbox_configuration',
1409 'type' => 'number',
1410 'description' => __( 'Animation speed when image is loaded.', 'responsive-lightbox' ),
1411 'append' => 'ms',
1412 'parent' => 'featherlight'
1413 ],
1414 'gallery_fade_out' => [
1415 'title' => __( 'Gallery fade out', 'responsive-lightbox' ),
1416 'section' => 'responsive_lightbox_configuration',
1417 'type' => 'number',
1418 'description' => __( 'Animation speed before image is loaded.', 'responsive-lightbox' ),
1419 'append' => 'ms',
1420 'parent' => 'featherlight'
1421 ]
1422 ];
1423 break;
1424
1425 case 'magnific':
1426 $this->settings['configuration']['prefix'] = 'rl_mp';
1427 $this->settings['configuration']['fields'] = [
1428 'disable_on' => [
1429 'title' => __( 'Disable on', 'responsive-lightbox' ),
1430 'section' => 'responsive_lightbox_configuration',
1431 'type' => 'number',
1432 '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' ),
1433 'append' => 'px',
1434 'parent' => 'magnific'
1435 ],
1436 'mid_click' => [
1437 'title' => __( 'Middle click', 'responsive-lightbox' ),
1438 'section' => 'responsive_lightbox_configuration',
1439 'type' => 'boolean',
1440 'label' => __( 'If option enabled, lightbox is opened if the user clicked on the middle mouse button, or click with Command/Ctrl key.', 'responsive-lightbox' ),
1441 'parent' => 'magnific'
1442 ],
1443 'preloader' => [
1444 'title' => __( 'Preloader', 'responsive-lightbox' ),
1445 'section' => 'responsive_lightbox_configuration',
1446 'type' => 'boolean',
1447 'label' => __( 'If option enabled, it\'s always present in DOM only text inside of it changes.', 'responsive-lightbox' ),
1448 'parent' => 'magnific'
1449 ],
1450 'close_on_content_click' => [
1451 'title' => __( 'Close on content click', 'responsive-lightbox' ),
1452 'section' => 'responsive_lightbox_configuration',
1453 'type' => 'boolean',
1454 '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' ),
1455 'parent' => 'magnific'
1456 ],
1457 'close_on_background_click' => [
1458 'title' => __( 'Close on background click', 'responsive-lightbox' ),
1459 'section' => 'responsive_lightbox_configuration',
1460 'type' => 'boolean',
1461 'label' => __( 'Close the popup when user clicks on the dark overlay.', 'responsive-lightbox' ),
1462 'parent' => 'magnific'
1463 ],
1464 'close_button_inside' => [
1465 'title' => __( 'Close button inside', 'responsive-lightbox' ),
1466 'section' => 'responsive_lightbox_configuration',
1467 'type' => 'boolean',
1468 'label' => __( 'If enabled, Magnific Popup will put close button inside content of popup.', 'responsive-lightbox' ),
1469 'parent' => 'magnific'
1470 ],
1471 'show_close_button' => [
1472 'title' => __( 'Show close button', 'responsive-lightbox' ),
1473 'section' => 'responsive_lightbox_configuration',
1474 'type' => 'boolean',
1475 'label' => __( 'Controls whether the close button will be displayed or not.', 'responsive-lightbox' ),
1476 'parent' => 'magnific'
1477 ],
1478 'enable_escape_key' => [
1479 'title' => __( 'Enable escape key', 'responsive-lightbox' ),
1480 'section' => 'responsive_lightbox_configuration',
1481 'type' => 'boolean',
1482 'label' => __( 'Controls whether pressing the escape key will dismiss the active popup or not.', 'responsive-lightbox' ),
1483 'parent' => 'magnific'
1484 ],
1485 'align_top' => [
1486 'title' => __( 'Align top', 'responsive-lightbox' ),
1487 'section' => 'responsive_lightbox_configuration',
1488 'type' => 'boolean',
1489 'label' => __( 'If set to true popup is aligned to top instead of to center.', 'responsive-lightbox' ),
1490 'parent' => 'magnific'
1491 ],
1492 'fixed_content_position' => [
1493 'title' => __( 'Content position type', 'responsive-lightbox' ),
1494 'section' => 'responsive_lightbox_configuration',
1495 'type' => 'select',
1496 'description' => __( 'Popup content position. If set to "auto" popup will automatically disable this option when browser doesn\'t support fixed position properly.', 'responsive-lightbox' ),
1497 'options' => [
1498 'auto' => __( 'Auto', 'responsive-lightbox' ),
1499 'true' => __( 'Fixed', 'responsive-lightbox' ),
1500 'false' => __( 'Absolute', 'responsive-lightbox' )
1501 ],
1502 'parent' => 'magnific'
1503 ],
1504 'fixed_background_position' => [
1505 'title' => __( 'Fixed background position', 'responsive-lightbox' ),
1506 'section' => 'responsive_lightbox_configuration',
1507 'type' => 'select',
1508 'description' => __( 'Dark transluscent overlay content position.', 'responsive-lightbox' ),
1509 'options' => [
1510 'auto' => __( 'Auto', 'responsive-lightbox' ),
1511 'true' => __( 'Fixed', 'responsive-lightbox' ),
1512 'false' => __( 'Absolute', 'responsive-lightbox' )
1513 ],
1514 'parent' => 'magnific'
1515 ],
1516 'auto_focus_last' => [
1517 'title' => __( 'Auto focus last', 'responsive-lightbox' ),
1518 'section' => 'responsive_lightbox_configuration',
1519 'type' => 'boolean',
1520 'label' => __( 'If set to true last focused element before popup showup will be focused after popup close.', 'responsive-lightbox' ),
1521 'parent' => 'magnific'
1522 ]
1523 ];
1524 break;
1525
1526 default:
1527 $this->settings['configuration'] = apply_filters( 'rl_settings_' . ( ! empty( $section_key ) ? $section_key : $rl->options['settings']['script'] ) . '_script_configuration', $this->settings['configuration'] );
1528 }
1529
1530 if ( isset( $this->tabs[$tab_key]['submit'], $this->tabs[$tab_key]['reset'] ) && ! empty( $this->settings[$tab_key]['prefix'] ) ) {
1531 $this->tabs[$tab_key]['submit'] = 'save_' . $this->settings[$tab_key]['prefix'] . '_' . $tab_key;
1532 $this->tabs[$tab_key]['reset'] = 'reset_' . $this->settings[$tab_key]['prefix'] . '_' . $tab_key;
1533 }
1534 }
1535
1536 /**
1537 * Remote Library Media Providers description
1538 *
1539 * @return void
1540 */
1541 public function remote_library_providers_description() {
1542 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>';
1543 }
1544
1545 /**
1546 * Register options page
1547 *
1548 * @return void
1549 */
1550 public function admin_menu_options() {
1551 // get master capability
1552 $capability = apply_filters( 'rl_lightbox_settings_capability', Responsive_Lightbox()->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' );
1553
1554 add_menu_page( __( 'General', 'responsive-lightbox' ), __( 'Lightbox', 'responsive-lightbox' ), $capability, 'responsive-lightbox-settings', '', 'dashicons-format-image', '57.1' );
1555
1556 foreach ( $this->tabs as $key => $options ) {
1557 add_submenu_page( 'responsive-lightbox-settings', $options['name'], $options['name'], $capability, 'responsive-lightbox-' . $key , [ $this, 'options_page' ] );
1558 }
1559 }
1560
1561 /**
1562 * Render options page
1563 *
1564 * @return void
1565 */
1566 public function options_page() {
1567 // check page
1568 $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : '';
1569
1570 // check settings page
1571 if ( $page && preg_match( '/^responsive-lightbox-(' . implode( '|', array_keys( $this->tabs ) ) . ')$/', $page, $tabs ) !== 1 )
1572 return;
1573
1574 $tab_key = isset( $tabs[1] ) ? $tabs[1] : 'settings';
1575
1576 // check section
1577 $section_key = isset( $_GET['section'] ) ? sanitize_key( $_GET['section'] ) : '';
1578
1579 if ( ! $section_key )
1580 $section_key = ! empty( $this->tabs[$tab_key]['default_section'] ) ? $this->tabs[$tab_key]['default_section'] : '';
1581
1582 // get main instance
1583 $rl = Responsive_Lightbox();
1584
1585 // no valid lightbox script?
1586 if ( $tab_key === 'configuration' && ! array_key_exists( $section_key, $rl->options['configuration'] ) )
1587 return;
1588
1589 // no valid gallery?
1590 if ( $tab_key === 'gallery' && ! array_key_exists( $section_key, $this->tabs['gallery']['sections'] ) )
1591 return;
1592
1593 echo '
1594 <div class="wrap">';
1595
1596 settings_errors();
1597
1598 // hidden h2 tag is needed to display info box properly when saving or resetting settings
1599 echo '
1600 <h2 class="hidden">' . esc_html__( 'Responsive Lightbox & Gallery', 'responsive-lightbox' ) . ' - ' . esc_html( $this->tabs[$tab_key]['name'] ) . '</h2>' . '
1601 <h2 class="nav-tab-wrapper">';
1602
1603 foreach ( $this->tabs as $key => $options ) {
1604 echo '
1605 <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>';
1606 }
1607
1608 echo '
1609 </h2>
1610 <div class="responsive-lightbox-settings">
1611 <div class="df-credits">
1612 <h3 class="hndle">' . esc_html__( 'Responsive Lightbox & Gallery', 'responsive-lightbox' ) . ' ' . esc_html( $rl->defaults['version'] ) . '</h3>
1613 <div class="inside">
1614 <h4 class="inner">' . esc_html__( 'Need support?', 'responsive-lightbox' ) . '</h4>
1615 <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>
1616 <hr />
1617 <h4 class="inner">' . esc_html__( 'Do you like this plugin?', 'responsive-lightbox' ) . '</h4>
1618 <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 />' .
1619 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 />' .
1620 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>' ) . '
1621 </p>
1622 <hr />
1623 <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>
1624 </div>
1625 </div>
1626 <form action="options.php" method="post">';
1627
1628 // views
1629 if ( ! empty( $this->tabs[$tab_key]['sections'] ) ) {
1630 $list = [];
1631
1632 echo '
1633 <ul class="subsubsub">';
1634
1635 // get number of sections
1636 $nos = count( $this->tabs[$tab_key]['sections'] );
1637
1638 $i = 0;
1639
1640 foreach ( $this->tabs[$tab_key]['sections'] as $key => $name ) {
1641 echo '
1642 <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>';
1643 }
1644
1645 echo '
1646 </ul>
1647 <input type="hidden" name="section" value="' . esc_attr( $section_key ) . '" />
1648 <br class="clear">';
1649 }
1650
1651 // tab content callback
1652 if ( ! empty( $this->tabs[$tab_key]['callback'] ) )
1653 call_user_func( $this->tabs[$tab_key]['callback'] );
1654 else {
1655 settings_fields( $this->tabs[$tab_key]['key'] );
1656 do_settings_sections( $this->tabs[$tab_key]['key'] );
1657
1658 if ( $tab_key === 'builder' )
1659 echo '
1660 <input type="hidden" name="flush_rules" value="1" />';
1661 }
1662
1663 if ( ! empty( $this->tabs[$tab_key]['submit'] ) || ! empty( $this->tabs[$tab_key]['reset'] ) ) {
1664 echo '
1665 <p class="submit">';
1666
1667 if ( ! empty( $this->tabs[$tab_key]['submit'] ) ) {
1668 submit_button( '', [ 'primary', 'save-' . $tab_key ], $this->tabs[$tab_key]['submit'], false );
1669 echo ' ';
1670 }
1671
1672 if ( ! empty( $this->tabs[$tab_key]['reset'] ) )
1673 submit_button( __( 'Reset to defaults', 'responsive-lightbox' ), [ 'secondary', 'reset-responsive-lightbox-settings reset-' . $tab_key ], $this->tabs[$tab_key]['reset'], false );
1674
1675 echo '
1676 </p>';
1677 }
1678
1679 echo '
1680 </form>
1681 </div>
1682 <div class="clear"></div>
1683 </div>';
1684 }
1685
1686 /**
1687 * Add new capability to manage options.
1688 *
1689 * @return string
1690 */
1691 public function manage_options_capability() {
1692 return Responsive_Lightbox()->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options';
1693 }
1694
1695 /**
1696 * Render settings function.
1697 *
1698 * @return void
1699 */
1700 public function register_settings() {
1701 // get main instance
1702 $rl = Responsive_Lightbox();
1703
1704 foreach ( $this->settings as $_setting_id => $setting ) {
1705 $setting_id = sanitize_key( $_setting_id );
1706
1707 if ( ! empty( $setting['option_name'] ) )
1708 $option_name = sanitize_key( $setting['option_name'] );
1709 else
1710 $option_name = $setting_id;
1711
1712 // set key
1713 $setting_key = $setting_id;
1714 $setting_id = 'responsive_lightbox_' . $setting_id;
1715
1716 // add new capability to manage options
1717 add_filter( 'option_page_capability_' . $setting_id, [ $this, 'manage_options_capability' ] );
1718
1719 // register setting
1720 register_setting( $setting_id, $option_name, ! empty( $setting['callback'] ) ? $setting['callback'] : [ $this, 'validate_settings' ] );
1721
1722 // register sections
1723 if ( ! empty( $setting['sections'] ) && is_array( $setting['sections'] ) ) {
1724 foreach ( $setting['sections'] as $_section_id => $section ) {
1725 $section_id = sanitize_key( $_section_id );
1726
1727 add_settings_section(
1728 $section_id,
1729 ! empty( $section['title'] ) ? esc_html( $section['title'] ) : '',
1730 ! empty( $section['callback'] ) ? $section['callback'] : '',
1731 ! empty( $section['page'] ) ? sanitize_key( $section['page'] ) : $section_id
1732 );
1733 }
1734 }
1735
1736 // register fields
1737 if ( ! empty( $setting['fields'] ) && is_array( $setting['fields'] ) ) {
1738 foreach ( $setting['fields'] as $_field_id => $field ) {
1739 $field_id = sanitize_key( $_field_id );
1740
1741 // prefix field id?
1742 $field_key = $field_id;
1743 $field_id = ( ! empty( $setting['prefix'] ) ? $setting['prefix'] . '_' : '' ) . $field_id;
1744
1745 // field args
1746 $args = [
1747 'id' => ! empty( $field['id'] ) ? $field['id'] : $field_id,
1748 'class' => ! empty( $field['class'] ) ? $field['class'] : '',
1749 'name' => $option_name . ( ! empty( $field['parent'] ) ? '[' . $field['parent'] . ']' : '' ) . '[' . $field_key . ']',
1750 'type' => ! empty( $field['type'] ) ? $field['type'] : 'text',
1751 'label' => ! empty( $field['label'] ) ? $field['label'] : '',
1752 'description' => ! empty( $field['description'] ) ? $field['description'] : '',
1753 'disabled' => isset( $field['disabled'] ) ? (bool) $field['disabled'] : false,
1754 'append' => ! empty( $field['append'] ) ? $field['append'] : '',
1755 'prepend' => ! empty( $field['prepend'] ) ? $field['prepend'] : '',
1756 'min' => isset( $field['min'] ) ? (int) $field['min'] : '',
1757 'max' => isset( $field['max'] ) ? (int) $field['max'] : '',
1758 'options' => ! empty( $field['options'] ) ? $field['options'] : '',
1759 'fields' => ! empty( $field['fields'] ) ? $field['fields'] : '',
1760 'after_field' => ! empty( $field['after_field'] ) ? $field['after_field'] : '',
1761 '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'] ) ),
1762 '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'] ) ),
1763 'label_for' => $field_id,
1764 'classname' => ! empty( $field['classname'] ) ? $field['classname'] : '',
1765 'callback' => ! empty( $field['callback'] ) ? $field['callback'] : '',
1766 'return' => false
1767 ];
1768
1769 if ( $args['type'] === 'multiple' ) {
1770 foreach ( $args['fields'] as $subfield_id => $subfield ) {
1771 $args['fields'][$subfield_id] = wp_parse_args(
1772 $subfield,
1773 [
1774 'id' => $field_id . '-' . $subfield_id,
1775 'class' => ! empty( $subfield['class'] ) ? $subfield['class'] : '',
1776 'name' => $option_name . ( ! empty( $subfield['parent'] ) ? '[' . $subfield['parent'] . ']' : '' ) . '[' . $subfield_id . ']',
1777 'default' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? $rl->defaults[$setting_key][$subfield['parent']][$subfield_id] : $rl->defaults[$setting_key][$subfield_id], $subfield['type'] ),
1778 'value' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? $rl->options[$setting_key][$subfield['parent']][$subfield_id] : $rl->options[$setting_key][$subfield_id], $subfield['type'] ),
1779 'return' => true
1780 ]
1781 );
1782 }
1783 }
1784
1785 add_settings_field(
1786 $field_id,
1787 ! empty( $field['title'] ) ? esc_html( $field['title'] ) : '',
1788 [ $this, 'render_field' ],
1789 ! empty( $field['page'] ) ? sanitize_key( $field['page'] ) : $setting_id,
1790 ! empty( $field['section'] ) ? sanitize_key( $field['section'] ) : '',
1791 $args
1792 );
1793 }
1794 }
1795 }
1796
1797 // licenses
1798 $extensions = apply_filters( 'rl_settings_licenses', [] );
1799
1800 if ( $extensions ) {
1801 // add new capability to manage licenses
1802 add_filter( 'option_page_capability_responsive_lightbox_licenses', [ $this, 'manage_options_capability' ] );
1803
1804 // register setting
1805 register_setting( 'responsive_lightbox_licenses', 'responsive_lightbox_licenses', [ $this, 'validate_licenses' ] );
1806
1807 add_settings_section( 'responsive_lightbox_licenses', esc_html__( 'Licenses', 'responsive-lightbox' ), [ $this, 'licenses_section_cb' ], 'responsive_lightbox_licenses' );
1808
1809 foreach ( $extensions as $id => $extension ) {
1810 add_settings_field( sanitize_key( $id ), esc_html( $extension['name'] ), [ $this, 'license_field_cb' ], 'responsive_lightbox_licenses', 'responsive_lightbox_licenses', $extension );
1811 }
1812 }
1813 }
1814
1815 /**
1816 * Render settings field function.
1817 *
1818 * @param array $args
1819 * @return void|string
1820 */
1821 public function render_field( $args ) {
1822 if ( empty( $args ) || ! is_array( $args ) )
1823 return '';
1824
1825 $html = '';
1826
1827 switch ( $args['type'] ) {
1828 case 'boolean':
1829 $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>';
1830 break;
1831
1832 case 'radio':
1833 foreach ( $args['options'] as $key => $name ) {
1834 $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> ';
1835 }
1836 break;
1837
1838 case 'checkbox':
1839 foreach ( $args['options'] as $key => $name ) {
1840 $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> ';
1841 }
1842 break;
1843
1844 case 'select':
1845 $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"' : '' ) . '/>';
1846
1847 foreach ( $args['options'] as $key => $name ) {
1848 $html .= '<option value="' . esc_attr( $key ) . '" ' . selected( $args['value'], $key, false ) . '>' . esc_html( $name ) . '</option>';
1849 }
1850
1851 $html .= '</select>';
1852 break;
1853
1854 case 'multiple':
1855 $html .= '<fieldset>';
1856
1857 if ( $args['fields'] ) {
1858 $count = 1;
1859 $count_fields = count( $args['fields'] );
1860
1861 foreach ( $args['fields'] as $subfield_id => $subfield_args ) {
1862 $html .= $this->render_field( $subfield_args ) . ( $count < $count_fields ? '<br />' : '' );
1863
1864 $count++;
1865 }
1866 }
1867
1868 $html .= '</fieldset>';
1869 break;
1870
1871 case 'range':
1872 $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" />';
1873 $html .= '<output name="' . esc_attr( $args['id'] ) . '_range">' . (int) $args['value'] . '</output>';
1874 break;
1875
1876 case 'color_picker':
1877 $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'] ) . '" />';
1878 break;
1879
1880 case 'number':
1881 $html .= ( ! empty( $args['prepend'] ) ? '<span>' . esc_html( $args['prepend'] ) . '</span> ' : '' );
1882 $html .= '<input id="' . esc_attr( $args['id'] ) . '" type="number" value="' . (int) $args['value'] . '" name="' . esc_attr( $args['name'] ) . '" />';
1883 $html .= ( ! empty( $args['append'] ) ? ' <span>' . esc_html( $args['append'] ) . '</span>' : '' );
1884 break;
1885
1886 case 'button':
1887 $html .= ( ! empty( $args['prepend'] ) ? '<span>' . esc_html( $args['prepend'] ) . '</span> ' : '' );
1888 $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>';
1889 $html .= ( ! empty( $args['append'] ) ? ' <span>' . esc_html( $args['append'] ) . '</span>' : '' );
1890 break;
1891
1892 case 'custom':
1893 // get allowed html
1894 $allowed_html = wp_kses_allowed_html( 'post' );
1895
1896 $allowed_html['select'] = [
1897 'name' => [],
1898 'id' => [],
1899 'class' => []
1900 ];
1901 $allowed_html['option'] = [
1902 'value' => [],
1903 'selected' => []
1904 ];
1905 $allowed_html['input'] = [
1906 'id' => [],
1907 'class' => [],
1908 'name' => [],
1909 'placeholder' => [],
1910 'checked' => [],
1911 'type' => [],
1912 'value' => []
1913 ];
1914
1915 add_filter( 'safe_style_css', [ $this, 'allow_display_attr' ] );
1916
1917 $html .= wp_kses( call_user_func( $args['callback'], $args ), $allowed_html );
1918
1919 remove_filter( 'safe_style_css', [ $this, 'allow_display_attr' ] );
1920 break;
1921
1922 case 'text':
1923 default :
1924 $html .= ( ! empty( $args['prepend'] ) ? '<span>' . esc_html( $args['prepend'] ) . '</span> ' : '' );
1925 $html .= '<input id="' . esc_attr( $args['id'] ) . '" class="' . esc_attr( $args['class'] ) . '" type="text" value="' . esc_attr( $args['value'] ) . '" name="' . esc_attr( $args['name'] ) . '" />';
1926 $html .= ( ! empty( $args['append'] ) ? ' <span>' . esc_html( $args['append'] ) . '</span>' : '' );
1927 }
1928
1929 if ( ! empty ( $args['after_field'] ) )
1930 $html .= wp_kses_post( $args['after_field'] );
1931
1932 if ( ! empty ( $args['description'] ) )
1933 $html .= '<p class="description">' . wp_kses_post( $args['description'] ) . '</p>';
1934
1935 // $html is already escaped
1936 if ( ! empty( $args['return'] ) )
1937 return $html;
1938 else
1939 echo $html;
1940 }
1941
1942 /**
1943 * Add display property to style safe list.
1944 *
1945 * @param array $styles
1946 * @return array
1947 */
1948 public function allow_display_attr( $styles ) {
1949 $styles[] = 'display';
1950
1951 return $styles;
1952 }
1953
1954 /**
1955 * Sanitize field function
1956 *
1957 * @param mixed $value
1958 * @param string $type
1959 * @param array $args
1960 * @return mixed
1961 */
1962 public function sanitize_field( $value = null, $type = '', $args = [] ) {
1963 if ( is_null( $value ) )
1964 return null;
1965
1966 switch ( $type ) {
1967 case 'button':
1968 case 'boolean':
1969 $value = empty( $value ) ? false : true;
1970 break;
1971
1972 case 'checkbox':
1973 $value = is_array( $value ) && ! empty( $value ) ? array_map( 'sanitize_key', $value ) : [];
1974 break;
1975
1976 case 'radio':
1977 $value = is_array( $value ) ? false : sanitize_key( $value );
1978 break;
1979
1980 case 'textarea':
1981 case 'wysiwyg':
1982 $value = wp_kses_post( $value );
1983 break;
1984
1985 case 'color_picker':
1986 $value = sanitize_hex_color( $value );
1987
1988 if ( empty( $value ) )
1989 $value = '#666666';
1990 break;
1991
1992 case 'number':
1993 $value = (int) $value;
1994
1995 // is value lower than?
1996 if ( isset( $args['min'] ) && $value < $args['min'] )
1997 $value = $args['min'];
1998
1999 // is value greater than?
2000 if ( isset( $args['max'] ) && $value > $args['max'] )
2001 $value = $args['max'];
2002 break;
2003
2004 case 'custom':
2005 // do nothing
2006 break;
2007
2008 case 'text':
2009 if ( ! empty( $args ) ) {
2010 // validate custom events
2011 if ( $args['setting_id'] === 'settings' ) {
2012 if ( $args['field_id'] === 'enable_custom_events' && $args['subfield_id'] === 'custom_events' )
2013 $value = preg_replace( '/[^a-z0-9\s.-]/i', '', $value );
2014 } elseif ( $args['setting_id'] === 'builder' ) {
2015 if ( $args['field_id'] === 'permalink' || $args['field_id'] === 'permalink_categories' || $args['field_id'] === 'permalink_tags' )
2016 $value = sanitize_title( $value );
2017 }
2018 }
2019 case 'select':
2020 default:
2021 $value = is_array( $value ) ? array_map( 'sanitize_text_field', $value ) : sanitize_text_field( $value );
2022 break;
2023 }
2024
2025 return stripslashes_deep( $value );
2026 }
2027
2028 /**
2029 * Validate settings function
2030 *
2031 * @param array $input
2032 * @return array
2033 */
2034 public function validate_settings( $input ) {
2035 // get main instance
2036 $rl = Responsive_Lightbox();
2037
2038 // check capability
2039 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', $rl->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' ) ) )
2040 return $input;
2041
2042 // check option page
2043 $option_page = isset( $_POST['option_page'] ) ? sanitize_key( $_POST['option_page'] ) : '';
2044
2045 // check page
2046 if ( ! $option_page )
2047 return $input;
2048
2049 foreach ( $this->settings as $id => $setting ) {
2050 $key = array_search( $option_page, $setting );
2051
2052 if ( $key ) {
2053 // set key
2054 $setting_id = sanitize_key( $id );
2055 break;
2056 }
2057 }
2058
2059 // check setting id
2060 if ( ! $setting_id )
2061 return $input;
2062
2063 // save settings
2064 if ( isset( $_POST['save' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) {
2065 if ( $this->settings[$setting_id]['fields'] ) {
2066 foreach ( $this->settings[$setting_id]['fields'] as $field_id => $field ) {
2067 if ( $field['type'] === 'multiple' ) {
2068 if ( $field['fields'] ) {
2069 foreach ( $field['fields'] as $subfield_id => $subfield ) {
2070 $args = $subfield;
2071 $args['setting_id'] = $setting_id;
2072 $args['field_id'] = $field_id;
2073 $args['subfield_id'] = $subfield_id;
2074
2075 // if subfield has parent
2076 if ( ! empty( $this->settings[$setting_id]['fields'][$field_id]['fields'][$subfield_id]['parent'] ) ) {
2077 $field_parent = $this->settings[$setting_id]['fields'][$field_id]['fields'][$subfield_id]['parent'];
2078
2079 $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] );
2080 } else {
2081 $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] );
2082 }
2083 }
2084 }
2085 } else {
2086 $args = $field;
2087 $args['setting_id'] = $setting_id;
2088 $args['field_id'] = $field_id;
2089
2090 // if field has parent
2091 if ( ! empty( $this->settings[$setting_id]['fields'][$field_id]['parent'] ) ) {
2092 $field_parent = $this->settings[$setting_id]['fields'][$field_id]['parent'];
2093
2094 $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] );
2095 } else {
2096 $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] );
2097 }
2098 }
2099 }
2100 }
2101
2102 if ( $setting_id === 'settings' ) {
2103 // merge scripts settings
2104 $input = array_merge( $rl->options['settings'], $input );
2105
2106 $input['update_notice'] = $rl->options['settings']['update_notice'];
2107
2108 // woocommerce lightbox has to be enabled when using rl gallery
2109 if ( $input['default_woocommerce_gallery'] !== 'default' )
2110 $input['woocommerce_gallery_lightbox'] = true;
2111 }
2112
2113 if ( $setting_id === 'configuration' ) {
2114 // merge scripts settings
2115 $input = array_merge( $rl->options['configuration'], $input );
2116 }
2117
2118 if ( $setting_id === 'remote_library' )
2119 $input = apply_filters( 'rl_remote_library_settings', $input );
2120 } elseif ( isset( $_POST['reset' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) {
2121 if ( $setting_id === 'configuration' ) {
2122 $script = key( $input );
2123
2124 // merge scripts settings
2125 $input[$script] = $rl->defaults['configuration'][$script];
2126 $input = array_merge( $rl->options['configuration'], $input );
2127 } elseif ( $setting_id === 'settings' ) {
2128 $input = $rl->defaults[$setting_id];
2129 $input['update_version'] = $rl->options['settings']['update_version'];
2130 $input['update_notice'] = $rl->options['settings']['update_notice'];
2131 } else
2132 $input = $rl->defaults[$setting_id];
2133
2134 add_settings_error( 'reset_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id, 'settings_restored', esc_html__( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' );
2135 }
2136
2137 return $input;
2138 }
2139
2140 /**
2141 * Validate capabilities.
2142 *
2143 * @global object $wp_roles
2144 *
2145 * @param array $input
2146 * @return array
2147 */
2148 public function validate_capabilities( $input ) {
2149 // get main instance
2150 $rl = Responsive_Lightbox();
2151
2152 // check capability
2153 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', $rl->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' ) ) )
2154 return $input;
2155
2156 global $wp_roles;
2157
2158 // validate normal fields
2159 $input = $this->validate_settings( $input );
2160
2161 // save capabilities?
2162 if ( isset( $_POST['save_rl_capabilities'] ) ) {
2163 foreach ( $wp_roles->roles as $role_name => $role_label ) {
2164 // get user role
2165 $role = $wp_roles->get_role( $role_name );
2166
2167 // manage new capabilities only for non-admins
2168 if ( $role_name !== 'administrator' ) {
2169 foreach ( $rl->get_data( 'capabilities' ) as $capability => $label ) {
2170 if ( isset( $input['roles'][$role_name][$capability] ) && $input['roles'][$role_name][$capability] === 'true' )
2171 $role->add_cap( $capability );
2172 else
2173 $role->remove_cap( $capability );
2174 }
2175 }
2176 }
2177 // reset capabilities?
2178 } elseif ( isset( $_POST['reset_rl_capabilities'] ) ) {
2179 foreach ( $wp_roles->roles as $role_name => $display_name ) {
2180 // get user role
2181 $role = $wp_roles->get_role( $role_name );
2182
2183 foreach ( $rl->get_data( 'capabilities' ) as $capability => $label ) {
2184 if ( array_key_exists( $role_name, $rl->defaults['capabilities']['roles'] ) && in_array( $capability, $rl->defaults['capabilities']['roles'][$role_name], true ) )
2185 $role->add_cap( $capability );
2186 else
2187 $role->remove_cap( $capability );
2188 }
2189 }
2190
2191 add_settings_error( 'reset_rl_capabilities', 'settings_restored', esc_html__( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' );
2192 }
2193
2194 return $input;
2195 }
2196
2197 /**
2198 * Render capabilities section.
2199 *
2200 * @global object $wp_roles
2201 *
2202 * @return void
2203 */
2204 public function capabilities_table() {
2205 global $wp_roles;
2206
2207 // get available user roles
2208 $editable_roles = get_editable_roles();
2209
2210 echo '
2211 <br class="clear" />
2212 <table class="widefat fixed posts">
2213 <thead>
2214 <tr>
2215 <th>' . esc_html__( 'Role', 'responsive-lightbox' ) . '</th>';
2216
2217 foreach ( $editable_roles as $role_name => $role_info ) {
2218 echo '<th>' . esc_html( isset( $wp_roles->role_names[$role_name] ) ? translate_user_role( $wp_roles->role_names[$role_name] ) : $role_name ) . '</th>';
2219 }
2220
2221 echo '
2222 </tr>
2223 </thead>
2224 <tbody id="the-list">';
2225
2226 $i = 0;
2227
2228 foreach ( Responsive_Lightbox()->get_data( 'capabilities' ) as $cap_role => $cap_label ) {
2229 echo '
2230 <tr' . ( ( $i++ % 2 === 0 ) ? ' class="alternate"' : '' ) . '>
2231 <td>' . esc_html__( $cap_label, 'responsive-lightbox' ) . '</td>';
2232
2233 foreach ( $editable_roles as $role_name => $role_info ) {
2234 // get user role
2235 $role = $wp_roles->get_role( $role_name );
2236
2237 echo '
2238 <td>
2239 <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 ) . ' />
2240 </td>';
2241 }
2242
2243 echo '
2244 </tr>';
2245 }
2246
2247 echo '
2248 </tbody>
2249 </table>';
2250 }
2251
2252 /**
2253 * Add-ons tab callback
2254 *
2255 * @return void
2256 */
2257 private function addons_tab_cb() {
2258 ?>
2259 <h3><?php esc_html_e( 'Add-ons / Extensions', 'responsive-lightbox' ); ?></h3>
2260 <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>
2261 <br />
2262 <?php
2263 $addons_html = get_transient( 'responsive_lightbox_addons_feed' );
2264
2265 if ( $addons_html === false ) {
2266 $feed = wp_remote_get( 'http://www.dfactory.co/?feed=addons&product=responsive-lightbox', [ 'sslverify' => false ] );
2267
2268 if ( ! is_wp_error( $feed ) ) {
2269 if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 )
2270 $addons_html = wp_remote_retrieve_body( $feed );
2271 } else
2272 $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>';
2273 }
2274
2275 $allowed_html = wp_kses_allowed_html( 'post' );
2276
2277 $allowed_html['img']['srcset'] = [];
2278 $allowed_html['img']['sizes'] = [];
2279
2280 echo wp_kses( $addons_html, $allowed_html );
2281 }
2282
2283 /**
2284 * Licenses section callback.
2285 *
2286 * @return void
2287 */
2288 public function licenses_section_cb() {
2289 ?><p class="description"><?php esc_html_e( 'A list of licenses for your Responsive Lightbox & Gallery extensions.', 'responsive-lightbox' ); ?></p><?php
2290 }
2291
2292 /**
2293 * License field callback.
2294 *
2295 * @param array $args
2296 * @return void
2297 */
2298 public function license_field_cb( $args ) {
2299 $licenses = get_option( 'responsive_lightbox_licenses' );
2300
2301 if ( ! empty( $licenses ) ) {
2302 $license = isset( $licenses[$args['id']]['license'] ) ? $licenses[$args['id']]['license'] : '';
2303 $status = ! empty( $licenses[$args['id']]['status'] );
2304 } else {
2305 $license = '';
2306 $status = false;
2307 } ?>
2308 <fieldset class="rl_license rl_license-<?php echo esc_attr( $args['id'] ); ?>">
2309 <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>
2310 <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>
2311 </fieldset>
2312 <?php
2313 }
2314
2315 /**
2316 * Validate licenses function.
2317 *
2318 * @param array $input
2319 * @return array
2320 */
2321 public function validate_licenses( $input ) {
2322 // check cap
2323 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', Responsive_Lightbox()->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' ) ) )
2324 return $input;
2325
2326 // check option page
2327 $option_page = isset( $_POST['option_page'] ) ? sanitize_key( $_POST['option_page'] ) : '';
2328
2329 // check page
2330 if ( ! $option_page )
2331 return $input;
2332
2333 $rl_licenses = [];
2334
2335 if ( isset( $_POST['responsive_lightbox_licenses'] ) && is_array( $_POST['responsive_lightbox_licenses'] ) && ! empty( $_POST['responsive_lightbox_licenses'] ) ) {
2336 foreach ( $_POST['responsive_lightbox_licenses'] as $extension => $data ) {
2337 $ext = sanitize_key( $extension );
2338
2339 if ( is_array( $data ) && ! empty( $data['license'] ) )
2340 $rl_licenses[$ext]['license'] = preg_replace( '/[^a-z0-9]/i', '', $data['license'] );
2341 else
2342 $rl_licenses[$ext]['license'] = '';
2343 }
2344 }
2345
2346 // check data
2347 if ( ! $rl_licenses )
2348 return $input;
2349
2350 // get extension licenses
2351 $extensions = apply_filters( 'rl_settings_licenses', [] );
2352
2353 if ( empty( $extensions ) )
2354 return $input;
2355
2356 // save settings
2357 if ( isset( $_POST['save_rl_licenses'] ) ) {
2358 $licenses = get_option( 'responsive_lightbox_licenses' );
2359 $statuses = [ 'updated' => 0, 'error' => 0 ];
2360
2361 foreach ( $extensions as $extension ) {
2362 if ( ! isset( $rl_licenses[$extension['id']] ) )
2363 continue;
2364
2365 $license = $rl_licenses[$extension['id']]['license'];
2366 $status = ! empty( $licenses ) && ! empty( $licenses[$extension['id']]['status'] );
2367
2368 // update license
2369 $input[$extension['id']]['license'] = $license;
2370
2371 // request data
2372 $request_args = [
2373 'action' => 'activate_license',
2374 'license' => $license,
2375 'item_name' => $extension['item_name']
2376 ];
2377
2378 // request
2379 $response = $this->license_request( $request_args );
2380
2381 // validate request
2382 if ( is_wp_error( $response ) ) {
2383 $input[$extension['id']]['status'] = false;
2384 $statuses['error']++;
2385 } else {
2386 // decode the license data
2387 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
2388
2389 // assign the data
2390 if ( $license_data->license === 'valid' ) {
2391 $input[$extension['id']]['status'] = true;
2392
2393 if ( $status === false )
2394 $statuses['updated']++;
2395 } else {
2396 $input[$extension['id']]['status'] = false;
2397 $statuses['error']++;
2398 }
2399 }
2400 }
2401
2402 // success notice
2403 if ( $statuses['updated'] > 0 )
2404 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' );
2405
2406 // failed notice
2407 if ( $statuses['error'] > 0 )
2408 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' );
2409 } elseif ( isset( $_POST['reset_rl_licenses'] ) ) {
2410 $licenses = get_option( 'responsive_lightbox_licenses' );
2411 $statuses = [
2412 'updated' => 0,
2413 'error' => 0
2414 ];
2415
2416 foreach ( $extensions as $extension ) {
2417 $license = ! empty( $licenses ) && isset( $licenses[$extension['id']]['license'] ) ? $licenses[$extension['id']]['license'] : '';
2418 $status = ! empty( $licenses ) && ! empty( $licenses[$extension['id']]['status'] );
2419
2420 if ( $status === true || ( $status === false && ! empty( $license ) ) ) {
2421 // request data
2422 $request_args = [
2423 'action' => 'deactivate_license',
2424 'license' => trim( $license ),
2425 'item_name' => $extension['item_name']
2426 ];
2427
2428 // request
2429 $response = $this->license_request( $request_args );
2430
2431 // validate request
2432 if ( is_wp_error( $response ) )
2433 $statuses['error']++;
2434 else {
2435 // decode the license data
2436 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
2437
2438 // assign the data
2439 if ( $license_data->license == 'deactivated' ) {
2440 $input[$extension['id']]['license'] = '';
2441 $input[$extension['id']]['status'] = false;
2442
2443 $statuses['updated']++;
2444 } else
2445 $statuses['error']++;
2446 }
2447 }
2448 }
2449
2450 // success notice
2451 if ( $statuses['updated'] > 0 )
2452 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' );
2453
2454 // failed notice
2455 if ( $statuses['error'] > 0 )
2456 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' );
2457 }
2458
2459 return $input;
2460 }
2461
2462 /**
2463 * License request function.
2464 *
2465 * @param array $args
2466 * @return mixed
2467 */
2468 private function license_request( $args ) {
2469 // data to send in our API request
2470 $api_params = [
2471 'edd_action' => $args['action'],
2472 'license' => sanitize_key( $args['license'] ),
2473 'item_name' => urlencode( $args['item_name'] ),
2474 // 'item_id' => $args['item_id'],
2475 'url' => home_url(),
2476 'timeout' => 60,
2477 'sslverify' => false
2478 ];
2479
2480 // call the custom API
2481 $response = wp_remote_get( add_query_arg( $api_params, 'https://www.dfactory.co' ) );
2482
2483 return $response;
2484 }
2485 }
2486