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