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