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