PluginProbe ʕ •ᴥ•ʔ
Responsive Lightbox & Gallery / 2.4.2
Responsive Lightbox & Gallery v2.4.2
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 3 years ago class-fast-image.php 8 years ago class-folders-walker.php 7 years ago class-folders.php 3 years ago class-frontend.php 3 years ago class-galleries.php 3 years ago class-multilang.php 3 years ago class-remote-library-api.php 3 years ago class-remote-library.php 3 years ago class-settings.php 3 years ago class-tour.php 3 years ago class-welcome.php 3 years ago class-widgets.php 3 years ago functions.php 3 years ago
class-settings.php
2672 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 $this->tabs = apply_filters( 'rl_settings_tabs_extra', $this->tabs );
1028
1029 // push licenses just before the addons
1030 if ( isset( $this->tabs['licenses'] ) ) {
1031 unset( $this->tabs['licenses'] );
1032
1033 $this->tabs['licenses'] = array(
1034 'name' => __( 'Licenses', 'responsive-lightbox' ),
1035 'key' => 'responsive_lightbox_licenses',
1036 'submit' => 'save_rl_licenses',
1037 'reset' => 'reset_rl_licenses'
1038 );
1039 }
1040
1041 $this->tabs['addons'] = array(
1042 'name' => __( 'Add-ons', 'responsive-lightbox' ),
1043 'key' => 'responsive_lightbox_configuration',
1044 'callback' => array( $this, 'addons_tab_cb' )
1045 );
1046
1047 if ( isset( $this->tabs[$tab_key]['sections'][$section_key] ) && empty( $this->tabs[$tab_key]['sections']['responsive_lightbox_' . $tab_key]['title'] ) ) {
1048 $this->settings[$tab_key]['sections']['responsive_lightbox_' . $tab_key]['title'] = sprintf( __( '%s Settings', 'responsive-lightbox' ), $this->tabs[$tab_key]['sections'][$section_key] );
1049 }
1050
1051 switch ( ! empty( $section_key ) ? $section_key : $rl->options['settings']['script'] ) {
1052 case 'swipebox':
1053 $this->settings['configuration']['prefix'] = 'rl_sb';
1054 $this->settings['configuration']['fields'] = array(
1055 'animation' => array(
1056 'title' => __( 'Animation type', 'responsive-lightbox' ),
1057 'section' => 'responsive_lightbox_configuration',
1058 'type' => 'radio',
1059 'label' => '',
1060 'description' => __( 'Select a method of applying a lightbox effect.', 'responsive-lightbox' ),
1061 'options' => $this->scripts['swipebox']['animations'],
1062 'parent' => 'swipebox'
1063 ),
1064 'force_png_icons' => array(
1065 'title' => __( 'Force PNG icons', 'responsive-lightbox' ),
1066 'section' => 'responsive_lightbox_configuration',
1067 'type' => 'boolean',
1068 'label' => __( 'Enable this if you\'re having problems with navigation icons not visible on some devices.', 'responsive-lightbox' ),
1069 'parent' => 'swipebox'
1070 ),
1071 'hide_close_mobile' => array(
1072 'title' => __( 'Hide close on mobile', 'responsive-lightbox' ),
1073 'section' => 'responsive_lightbox_configuration',
1074 'type' => 'boolean',
1075 'label' => __( 'Hide the close button on mobile devices.', 'responsive-lightbox' ),
1076 'parent' => 'swipebox'
1077 ),
1078 'remove_bars_mobile' => array(
1079 'title' => __( 'Remove bars on mobile', 'responsive-lightbox' ),
1080 'section' => 'responsive_lightbox_configuration',
1081 'type' => 'boolean',
1082 'label' => __( 'Hide the top and bottom bars on mobile devices.', 'responsive-lightbox' ),
1083 'parent' => 'swipebox'
1084 ),
1085 'hide_bars' => array(
1086 'title' => __( 'Top and bottom bars', 'responsive-lightbox' ),
1087 'section' => 'responsive_lightbox_configuration',
1088 'type' => 'multiple',
1089 'fields' => array(
1090 'hide_bars' => array(
1091 'type' => 'boolean',
1092 'label' => __( 'Hide top and bottom bars after a period of time.', 'responsive-lightbox' ),
1093 'parent' => 'swipebox'
1094 ),
1095 'hide_bars_delay' => array(
1096 'type' => 'number',
1097 'description' => __( 'Enter the time after which the top and bottom bars will be hidden (when hiding is enabled).', 'responsive-lightbox' ),
1098 'append' => 'ms',
1099 'parent' => 'swipebox'
1100 )
1101 )
1102 ),
1103 'video_max_width' => array(
1104 'title' => __( 'Video max width', 'responsive-lightbox' ),
1105 'section' => 'responsive_lightbox_configuration',
1106 'type' => 'number',
1107 'description' => __( 'Enter the max video width in a lightbox.', 'responsive-lightbox' ),
1108 'append' => 'px',
1109 'parent' => 'swipebox'
1110 ),
1111 'loop_at_end' => array(
1112 'title' => __( 'Loop at end', 'responsive-lightbox' ),
1113 'section' => 'responsive_lightbox_configuration',
1114 'type' => 'boolean',
1115 'label' => __( 'True will return to the first image after the last image is reached.', 'responsive-lightbox' ),
1116 'parent' => 'swipebox'
1117 ),
1118 );
1119 break;
1120
1121 case 'prettyphoto':
1122 $this->settings['configuration']['prefix'] = 'rl_pp';
1123 $this->settings['configuration']['fields'] = array(
1124 'animation_speed' => array(
1125 'title' => __( 'Animation speed', 'responsive-lightbox' ),
1126 'section' => 'responsive_lightbox_configuration',
1127 'type' => 'radio',
1128 'label' => '',
1129 'description' => __( 'Select animation speed for lightbox effect.', 'responsive-lightbox' ),
1130 'options' => $this->scripts['prettyphoto']['animation_speeds'],
1131 'parent' => 'prettyphoto'
1132 ),
1133 'slideshow' => array(
1134 'title' => __( 'Slideshow', 'responsive-lightbox' ),
1135 'section' => 'responsive_lightbox_configuration',
1136 'type' => 'multiple',
1137 'fields' => array(
1138 'slideshow' => array(
1139 'type' => 'boolean',
1140 'label' => __( 'Display images as slideshow', 'responsive-lightbox' ),
1141 'parent' => 'prettyphoto'
1142 ),
1143 'slideshow_delay' => array(
1144 'type' => 'number',
1145 'description' => __( 'Enter time (in miliseconds).', 'responsive-lightbox' ),
1146 'append' => 'ms',
1147 'parent' => 'prettyphoto'
1148 )
1149 )
1150 ),
1151 'slideshow_autoplay' => array(
1152 'title' => __( 'Slideshow autoplay', 'responsive-lightbox' ),
1153 'section' => 'responsive_lightbox_configuration',
1154 'type' => 'boolean',
1155 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ),
1156 'parent' => 'prettyphoto'
1157 ),
1158 'opacity' => array(
1159 'title' => __( 'Opacity', 'responsive-lightbox' ),
1160 'section' => 'responsive_lightbox_configuration',
1161 'type' => 'range',
1162 'description' => __( 'Value between 0 and 100, 100 for no opacity.', 'responsive-lightbox' ),
1163 'min' => 0,
1164 'max' => 100,
1165 'parent' => 'prettyphoto'
1166 ),
1167 'show_title' => array(
1168 'title' => __( 'Show title', 'responsive-lightbox' ),
1169 'section' => 'responsive_lightbox_configuration',
1170 'type' => 'boolean',
1171 'label' => __( 'Display image title.', 'responsive-lightbox' ),
1172 'parent' => 'prettyphoto'
1173 ),
1174 'allow_resize' => array(
1175 'title' => __( 'Allow resize big images', 'responsive-lightbox' ),
1176 'section' => 'responsive_lightbox_configuration',
1177 'type' => 'boolean',
1178 'label' => __( 'Resize the photos bigger than viewport.', 'responsive-lightbox' ),
1179 'parent' => 'prettyphoto'
1180 ),
1181 'allow_expand' => array(
1182 'title' => __( 'Allow expand', 'responsive-lightbox' ),
1183 'section' => 'responsive_lightbox_configuration',
1184 'type' => 'boolean',
1185 'label' => __( 'Allow expanding images.', 'responsive-lightbox' ),
1186 'parent' => 'prettyphoto'
1187 ),
1188 'width' => array(
1189 'title' => __( 'Video width', 'responsive-lightbox' ),
1190 'section' => 'responsive_lightbox_configuration',
1191 'type' => 'number',
1192 'append' => 'px',
1193 'parent' => 'prettyphoto'
1194 ),
1195 'height' => array(
1196 'title' => __( 'Video height', 'responsive-lightbox' ),
1197 'section' => 'responsive_lightbox_configuration',
1198 'type' => 'number',
1199 'append' => 'px',
1200 'parent' => 'prettyphoto'
1201 ),
1202 'theme' => array(
1203 'title' => __( 'Theme', 'responsive-lightbox' ),
1204 'section' => 'responsive_lightbox_configuration',
1205 'type' => 'radio',
1206 'description' => __( 'Select the theme for lightbox effect.', 'responsive-lightbox' ),
1207 'options' => $this->scripts['prettyphoto']['themes'],
1208 'parent' => 'prettyphoto'
1209 ),
1210 'horizontal_padding' => array(
1211 'title' => __( 'Horizontal padding', 'responsive-lightbox' ),
1212 'section' => 'responsive_lightbox_configuration',
1213 'type' => 'number',
1214 'append' => 'px',
1215 'parent' => 'prettyphoto'
1216 ),
1217 'hide_flash' => array(
1218 'title' => __( 'Hide Flash', 'responsive-lightbox' ),
1219 'section' => 'responsive_lightbox_configuration',
1220 'type' => 'boolean',
1221 'label' => __( 'Hide all the flash objects on a page. Enable this if flash appears over prettyPhoto.', 'responsive-lightbox' ),
1222 'parent' => 'prettyphoto'
1223 ),
1224 'wmode' => array(
1225 'title' => __( 'Flash Window Mode (wmode)', 'responsive-lightbox' ),
1226 'section' => 'responsive_lightbox_configuration',
1227 'type' => 'radio',
1228 'description' => __( 'Select flash window mode.', 'responsive-lightbox' ),
1229 'options' => $this->scripts['prettyphoto']['wmodes'],
1230 'parent' => 'prettyphoto'
1231 ),
1232 'video_autoplay' => array(
1233 'title' => __( 'Video autoplay', 'responsive-lightbox' ),
1234 'section' => 'responsive_lightbox_configuration',
1235 'type' => 'boolean',
1236 'label' => __( 'Automatically start videos.', 'responsive-lightbox' ),
1237 'parent' => 'prettyphoto'
1238 ),
1239 'modal' => array(
1240 'title' => __( 'Modal', 'responsive-lightbox' ),
1241 'section' => 'responsive_lightbox_configuration',
1242 'type' => 'boolean',
1243 'label' => __( 'If set to true, only the close button will close the window.', 'responsive-lightbox' ),
1244 'parent' => 'prettyphoto'
1245 ),
1246 'deeplinking' => array(
1247 'title' => __( 'Deeplinking', 'responsive-lightbox' ),
1248 'section' => 'responsive_lightbox_configuration',
1249 'type' => 'boolean',
1250 'label' => __( 'Allow prettyPhoto to update the url to enable deeplinking.', 'responsive-lightbox' ),
1251 'parent' => 'prettyphoto'
1252 ),
1253 'overlay_gallery' => array(
1254 'title' => __( 'Overlay gallery', 'responsive-lightbox' ),
1255 'section' => 'responsive_lightbox_configuration',
1256 'type' => 'boolean',
1257 'label' => __( 'If enabled, a gallery will overlay the fullscreen image on mouse over.', 'responsive-lightbox' ),
1258 'parent' => 'prettyphoto'
1259 ),
1260 'keyboard_shortcuts' => array(
1261 'title' => __( 'Keyboard shortcuts', 'responsive-lightbox' ),
1262 'section' => 'responsive_lightbox_configuration',
1263 'type' => 'boolean',
1264 'label' => __( 'Set to false if you open forms inside prettyPhoto.', 'responsive-lightbox' ),
1265 'parent' => 'prettyphoto'
1266 ),
1267 'social' => array(
1268 'title' => __( 'Social (Twitter, Facebook)', 'responsive-lightbox' ),
1269 'section' => 'responsive_lightbox_configuration',
1270 'type' => 'boolean',
1271 'label' => __( 'Display links to Facebook and Twitter.', 'responsive-lightbox' ),
1272 'parent' => 'prettyphoto'
1273 ),
1274 );
1275 break;
1276
1277 case 'fancybox':
1278 $this->settings['configuration']['prefix'] = 'rl_fb';
1279 $this->settings['configuration']['fields'] = array(
1280 'modal' => array(
1281 'title' => __( 'Modal', 'responsive-lightbox' ),
1282 'section' => 'responsive_lightbox_configuration',
1283 'type' => 'boolean',
1284 'label' => __( 'When true, "overlayShow" is set to true and "hideOnOverlayClick", "hideOnContentClick", "enableEscapeButton", "showCloseButton" are set to false.', 'responsive-lightbox' ),
1285 'parent' => 'fancybox'
1286 ),
1287 'show_overlay' => array(
1288 'title' => __( 'Show overlay', 'responsive-lightbox' ),
1289 'section' => 'responsive_lightbox_configuration',
1290 'type' => 'boolean',
1291 'label' => __( 'Toggle overlay.', 'responsive-lightbox' ),
1292 'parent' => 'fancybox'
1293 ),
1294 'show_close_button' => array(
1295 'title' => __( 'Show close button', 'responsive-lightbox' ),
1296 'section' => 'responsive_lightbox_configuration',
1297 'type' => 'boolean',
1298 'label' => __( 'Toggle close button.', 'responsive-lightbox' ),
1299 'parent' => 'fancybox'
1300 ),
1301 'enable_escape_button' => array(
1302 'title' => __( 'Enable escape button', 'responsive-lightbox' ),
1303 'section' => 'responsive_lightbox_configuration',
1304 'type' => 'boolean',
1305 'label' => __( 'Toggle if pressing Esc button closes lightbox.', 'responsive-lightbox' ),
1306 'parent' => 'fancybox'
1307 ),
1308 'hide_on_overlay_click' => array(
1309 'title' => __( 'Hide on overlay click', 'responsive-lightbox' ),
1310 'section' => 'responsive_lightbox_configuration',
1311 'type' => 'boolean',
1312 'label' => __( 'Toggle if clicking the overlay should close FancyBox.', 'responsive-lightbox' ),
1313 'parent' => 'fancybox'
1314 ),
1315 'hide_on_content_click' => array(
1316 'title' => __( 'Hide on content click', 'responsive-lightbox' ),
1317 'section' => 'responsive_lightbox_configuration',
1318 'type' => 'boolean',
1319 'label' => __( 'Toggle if clicking the content should close FancyBox.', 'responsive-lightbox' ),
1320 'parent' => 'fancybox'
1321 ),
1322 'cyclic' => array(
1323 'title' => __( 'Cyclic', 'responsive-lightbox' ),
1324 'section' => 'responsive_lightbox_configuration',
1325 'type' => 'boolean',
1326 'label' => __( 'When true, galleries will be cyclic, allowing you to keep pressing next/back.', 'responsive-lightbox' ),
1327 'parent' => 'fancybox'
1328 ),
1329 'show_nav_arrows' => array(
1330 'title' => __( 'Show nav arrows', 'responsive-lightbox' ),
1331 'section' => 'responsive_lightbox_configuration',
1332 'type' => 'boolean',
1333 'label' => __( 'Toggle navigation arrows.', 'responsive-lightbox' ),
1334 'parent' => 'fancybox'
1335 ),
1336 'auto_scale' => array(
1337 'title' => __( 'Auto scale', 'responsive-lightbox' ),
1338 'section' => 'responsive_lightbox_configuration',
1339 'type' => 'boolean',
1340 'label' => __( 'If true, FancyBox is scaled to fit in viewport.', 'responsive-lightbox' ),
1341 'parent' => 'fancybox'
1342 ),
1343 'scrolling' => array(
1344 'title' => __( 'Scrolling (in/out)', 'responsive-lightbox' ),
1345 'section' => 'responsive_lightbox_configuration',
1346 'type' => 'radio',
1347 'description' => __( 'Set the overflow CSS property to create or hide scrollbars.', 'responsive-lightbox' ),
1348 'options' => $this->scripts['fancybox']['scrollings'],
1349 'parent' => 'fancybox'
1350 ),
1351 'center_on_scroll' => array(
1352 'title' => __( 'Center on scroll', 'responsive-lightbox' ),
1353 'section' => 'responsive_lightbox_configuration',
1354 'type' => 'boolean',
1355 'label' => __( 'When true, FancyBox is centered while scrolling page.', 'responsive-lightbox' ),
1356 'parent' => 'fancybox'
1357 ),
1358 'opacity' => array(
1359 'title' => __( 'Opacity', 'responsive-lightbox' ),
1360 'section' => 'responsive_lightbox_configuration',
1361 'type' => 'boolean',
1362 'label' => __( 'When true, transparency of content is changed for elastic transitions.', 'responsive-lightbox' ),
1363 'parent' => 'fancybox'
1364 ),
1365 'overlay_opacity' => array(
1366 'title' => __( 'Overlay opacity', 'responsive-lightbox' ),
1367 'section' => 'responsive_lightbox_configuration',
1368 'type' => 'range',
1369 'description' => __( 'Opacity of the overlay.', 'responsive-lightbox' ),
1370 'min' => 0,
1371 'max' => 100,
1372 'parent' => 'fancybox'
1373 ),
1374 'overlay_color' => array(
1375 'title' => __( 'Overlay color', 'responsive-lightbox' ),
1376 'section' => 'responsive_lightbox_configuration',
1377 'type' => 'color_picker',
1378 'label' => __( 'Color of the overlay.', 'responsive-lightbox' ),
1379 'parent' => 'fancybox'
1380 ),
1381 'title_show' => array(
1382 'title' => __( 'Title show', 'responsive-lightbox' ),
1383 'section' => 'responsive_lightbox_configuration',
1384 'type' => 'boolean',
1385 'label' => __( 'Toggle title.', 'responsive-lightbox' ),
1386 'parent' => 'fancybox'
1387 ),
1388 'title_position' => array(
1389 'title' => __( 'Title position', 'responsive-lightbox' ),
1390 'section' => 'responsive_lightbox_configuration',
1391 'type' => 'radio',
1392 'description' => __( 'The position of title.', 'responsive-lightbox' ),
1393 'options' => $this->scripts['fancybox']['positions'],
1394 'parent' => 'fancybox'
1395 ),
1396 'transitions' => array(
1397 'title' => __( 'Transition (in/out)', 'responsive-lightbox' ),
1398 'section' => 'responsive_lightbox_configuration',
1399 'type' => 'radio',
1400 'description' => __( 'The transition type.', 'responsive-lightbox' ),
1401 'options' => $this->scripts['fancybox']['transitions'],
1402 'parent' => 'fancybox'
1403 ),
1404 'easings' => array(
1405 'title' => __( 'Easings (in/out)', 'responsive-lightbox' ),
1406 'section' => 'responsive_lightbox_configuration',
1407 'type' => 'radio',
1408 'description' => __( 'Easing used for elastic animations.', 'responsive-lightbox' ),
1409 'options' => $this->scripts['fancybox']['easings'],
1410 'parent' => 'fancybox'
1411 ),
1412 'speeds' => array(
1413 'title' => __( 'Speed (in/out)', 'responsive-lightbox' ),
1414 'section' => 'responsive_lightbox_configuration',
1415 'type' => 'number',
1416 'description' => __( 'Speed of the fade and elastic transitions, in milliseconds.', 'responsive-lightbox' ),
1417 'append' => 'ms',
1418 'parent' => 'fancybox'
1419 ),
1420 'change_speed' => array(
1421 'title' => __( 'Change speed', 'responsive-lightbox' ),
1422 'section' => 'responsive_lightbox_configuration',
1423 'type' => 'number',
1424 'description' => __( 'Speed of resizing when changing gallery items, in milliseconds.', 'responsive-lightbox' ),
1425 'append' => 'ms',
1426 'parent' => 'fancybox'
1427 ),
1428 'change_fade' => array(
1429 'title' => __( 'Change fade', 'responsive-lightbox' ),
1430 'section' => 'responsive_lightbox_configuration',
1431 'type' => 'number',
1432 'description' => __( 'Speed of the content fading while changing gallery items.', 'responsive-lightbox' ),
1433 'append' => 'ms',
1434 'parent' => 'fancybox'
1435 ),
1436 'padding' => array(
1437 'title' => __( 'Padding', 'responsive-lightbox' ),
1438 'section' => 'responsive_lightbox_configuration',
1439 'type' => 'number',
1440 'description' => __( 'Space between FancyBox wrapper and content.', 'responsive-lightbox' ),
1441 'append' => 'px',
1442 'parent' => 'fancybox'
1443 ),
1444 'margin' => array(
1445 'title' => __( 'Margin', 'responsive-lightbox' ),
1446 'section' => 'responsive_lightbox_configuration',
1447 'type' => 'number',
1448 'description' => __( 'Space between viewport and FancyBox wrapper.', 'responsive-lightbox' ),
1449 'append' => 'px',
1450 'parent' => 'fancybox'
1451 ),
1452 'video_width' => array(
1453 'title' => __( 'Video width', 'responsive-lightbox' ),
1454 'section' => 'responsive_lightbox_configuration',
1455 'type' => 'number',
1456 'description' => __( 'Width of the video.', 'responsive-lightbox' ),
1457 'append' => 'px',
1458 'parent' => 'fancybox'
1459 ),
1460 'video_height' => array(
1461 'title' => __( 'Video height', 'responsive-lightbox' ),
1462 'section' => 'responsive_lightbox_configuration',
1463 'type' => 'number',
1464 'description' => __( 'Height of the video.', 'responsive-lightbox' ),
1465 'append' => 'px',
1466 'parent' => 'fancybox'
1467 ),
1468 );
1469 break;
1470
1471 case 'nivo':
1472 $this->settings['configuration']['prefix'] = 'rl_nv';
1473 $this->settings['configuration']['fields'] = array(
1474 'effect' => array(
1475 'title' => __( 'Effect', 'responsive-lightbox' ),
1476 'section' => 'responsive_lightbox_configuration',
1477 'type' => 'radio',
1478 'description' => __( 'The effect to use when showing the lightbox.', 'responsive-lightbox' ),
1479 'options' => $this->scripts['nivo']['effects'],
1480 'parent' => 'nivo'
1481 ),
1482 'keyboard_nav' => array(
1483 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ),
1484 'section' => 'responsive_lightbox_configuration',
1485 'type' => 'boolean',
1486 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ),
1487 'parent' => 'nivo'
1488 ),
1489 'click_overlay_to_close' => array(
1490 'title' => __( 'Click overlay to close', 'responsive-lightbox' ),
1491 'section' => 'responsive_lightbox_configuration',
1492 'type' => 'boolean',
1493 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ),
1494 'parent' => 'nivo'
1495 ),
1496 'error_message' => array(
1497 'title' => __( 'Error message', 'responsive-lightbox' ),
1498 'section' => 'responsive_lightbox_configuration',
1499 'type' => 'text',
1500 'class' => 'large-text',
1501 'label' => __( 'Error message if the content cannot be loaded.', 'responsive-lightbox' ),
1502 'parent' => 'nivo'
1503 ),
1504 );
1505 break;
1506
1507 case 'imagelightbox':
1508 $this->settings['configuration']['prefix'] = 'rl_il';
1509 $this->settings['configuration']['fields'] = array(
1510 'animation_speed' => array(
1511 'title' => __( 'Animation speed', 'responsive-lightbox' ),
1512 'section' => 'responsive_lightbox_configuration',
1513 'type' => 'number',
1514 'description' => __( 'Animation speed.', 'responsive-lightbox' ),
1515 'append' => 'ms',
1516 'parent' => 'imagelightbox'
1517 ),
1518 'preload_next' => array(
1519 'title' => __( 'Preload next image', 'responsive-lightbox' ),
1520 'section' => 'responsive_lightbox_configuration',
1521 'type' => 'boolean',
1522 'label' => __( 'Silently preload the next image.', 'responsive-lightbox' ),
1523 'parent' => 'imagelightbox'
1524 ),
1525 'enable_keyboard' => array(
1526 'title' => __( 'Enable keyboard keys', 'responsive-lightbox' ),
1527 'section' => 'responsive_lightbox_configuration',
1528 'type' => 'boolean',
1529 'label' => __( 'Enable keyboard shortcuts (arrows Left/Right and Esc).', 'responsive-lightbox' ),
1530 'parent' => 'imagelightbox'
1531 ),
1532 'quit_on_end' => array(
1533 'title' => __( 'Quit after last image', 'responsive-lightbox' ),
1534 'section' => 'responsive_lightbox_configuration',
1535 'type' => 'boolean',
1536 'label' => __( 'Quit after viewing the last image.', 'responsive-lightbox' ),
1537 'parent' => 'imagelightbox'
1538 ),
1539 'quit_on_image_click' => array(
1540 'title' => __( 'Quit on image click', 'responsive-lightbox' ),
1541 'section' => 'responsive_lightbox_configuration',
1542 'type' => 'boolean',
1543 'label' => __( 'Quit when the viewed image is clicked.', 'responsive-lightbox' ),
1544 'parent' => 'imagelightbox'
1545 ),
1546 'quit_on_document_click' => array(
1547 'title' => __( 'Quit on anything click', 'responsive-lightbox' ),
1548 'section' => 'responsive_lightbox_configuration',
1549 'type' => 'boolean',
1550 'label' => __( 'Quit when anything but the viewed image is clicked.', 'responsive-lightbox' ),
1551 'parent' => 'imagelightbox'
1552 ),
1553 );
1554 break;
1555
1556 case 'tosrus':
1557 $this->settings['configuration']['prefix'] = 'rl_tr';
1558 $this->settings['configuration']['fields'] = array(
1559 'effect' => array(
1560 'title' => __( 'Transition effect', 'responsive-lightbox' ),
1561 'section' => 'responsive_lightbox_configuration',
1562 'type' => 'radio',
1563 'description' => __( 'What effect to use for the transition.', 'responsive-lightbox' ),
1564 'options' => array(
1565 'slide' => __( 'slide', 'responsive-lightbox' ),
1566 'fade' => __( 'fade', 'responsive-lightbox' )
1567 ),
1568 'parent' => 'tosrus'
1569 ),
1570 'infinite' => array(
1571 'title' => __( 'Infinite loop', 'responsive-lightbox' ),
1572 'section' => 'responsive_lightbox_configuration',
1573 'type' => 'boolean',
1574 'label' => __( 'Whether or not to slide back to the first slide when the last has been reached.', 'responsive-lightbox' ),
1575 'parent' => 'tosrus'
1576 ),
1577 'keys' => array(
1578 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ),
1579 'section' => 'responsive_lightbox_configuration',
1580 'type' => 'boolean',
1581 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ),
1582 'parent' => 'tosrus'
1583 ),
1584 'autoplay' => array(
1585 'title' => __( 'Autoplay', 'responsive-lightbox' ),
1586 'section' => 'responsive_lightbox_configuration',
1587 'type' => 'multiple',
1588 'fields' => array(
1589 'autoplay' => array(
1590 'type' => 'boolean',
1591 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ),
1592 'parent' => 'tosrus'
1593 ),
1594 'timeout' => array(
1595 'type' => 'number',
1596 'description' => __( 'The timeout between sliding to the next slide in milliseconds.', 'responsive-lightbox' ),
1597 'append' => 'ms',
1598 'parent' => 'tosrus'
1599 )
1600 )
1601 ),
1602 'pause_on_hover' => array(
1603 'title' => __( 'Pause on hover', 'responsive-lightbox' ),
1604 'section' => 'responsive_lightbox_configuration',
1605 'type' => 'boolean',
1606 'label' => __( 'Whether or not to pause on hover.', 'responsive-lightbox' ),
1607 'parent' => 'tosrus'
1608 ),
1609 'pagination' => array(
1610 'title' => __( 'Pagination', 'responsive-lightbox' ),
1611 'section' => 'responsive_lightbox_configuration',
1612 'type' => 'multiple',
1613 'fields' => array(
1614 'pagination' => array(
1615 'type' => 'boolean',
1616 'label' => __( 'Whether or not to add a pagination.', 'responsive-lightbox' ),
1617 'parent' => 'tosrus'
1618 ),
1619 'pagination_type' => array(
1620 'type' => 'radio',
1621 'description' => __( 'What type of pagination to use.', 'responsive-lightbox' ),
1622 'options' => array(
1623 'bullets' => __( 'Bullets', 'responsive-lightbox' ),
1624 'thumbnails' => __( 'Thumbnails', 'responsive-lightbox' )
1625 ),
1626 'parent' => 'tosrus'
1627 )
1628 )
1629 ),
1630 'close_on_click' => array(
1631 'title' => __( 'Overlay close', 'responsive-lightbox' ),
1632 'section' => 'responsive_lightbox_configuration',
1633 'type' => 'boolean',
1634 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ),
1635 'parent' => 'tosrus'
1636 )
1637 );
1638 break;
1639
1640 case 'featherlight':
1641 $this->settings['configuration']['prefix'] = 'rl_fl';
1642 $this->settings['configuration']['fields'] = array(
1643 'open_speed' => array(
1644 'title' => __( 'Opening speed', 'responsive-lightbox' ),
1645 'section' => 'responsive_lightbox_configuration',
1646 'type' => 'number',
1647 'description' => __( 'Duration of opening animation.', 'responsive-lightbox' ),
1648 'append' => 'ms',
1649 'parent' => 'featherlight'
1650 ),
1651 'close_speed' => array(
1652 'title' => __( 'Closing speed', 'responsive-lightbox' ),
1653 'section' => 'responsive_lightbox_configuration',
1654 'type' => 'number',
1655 'description' => __( 'Duration of closing animation.', 'responsive-lightbox' ),
1656 'append' => 'ms',
1657 'parent' => 'featherlight'
1658 ),
1659 'close_on_click' => array(
1660 'title' => __( 'Close on click', 'responsive-lightbox' ),
1661 'section' => 'responsive_lightbox_configuration',
1662 'type' => 'radio',
1663 'label' => __( 'Select how to close lightbox.', 'responsive-lightbox' ),
1664 'options' => array(
1665 'background' => __( 'background', 'responsive-lightbox' ),
1666 'anywhere' => __( 'anywhere', 'responsive-lightbox' ),
1667 'false' => __( 'false', 'responsive-lightbox' )
1668 ),
1669 'parent' => 'featherlight'
1670 ),
1671 'close_on_esc' => array(
1672 'title' => __( 'Close on Esc', 'responsive-lightbox' ),
1673 'section' => 'responsive_lightbox_configuration',
1674 'type' => 'boolean',
1675 'label' => __( 'Toggle if pressing Esc button closes lightbox.', 'responsive-lightbox' ),
1676 'parent' => 'featherlight'
1677 ),
1678 'gallery_fade_in' => array(
1679 'title' => __( 'Gallery fade in', 'responsive-lightbox' ),
1680 'section' => 'responsive_lightbox_configuration',
1681 'type' => 'number',
1682 'description' => __( 'Animation speed when image is loaded.', 'responsive-lightbox' ),
1683 'append' => 'ms',
1684 'parent' => 'featherlight'
1685 ),
1686 'gallery_fade_out' => array(
1687 'title' => __( 'Gallery fade out', 'responsive-lightbox' ),
1688 'section' => 'responsive_lightbox_configuration',
1689 'type' => 'number',
1690 'description' => __( 'Animation speed before image is loaded.', 'responsive-lightbox' ),
1691 'append' => 'ms',
1692 'parent' => 'featherlight'
1693 )
1694 );
1695 break;
1696
1697 case 'magnific':
1698 $this->settings['configuration']['prefix'] = 'rl_mp';
1699 $this->settings['configuration']['fields'] = array(
1700 'disable_on' => array(
1701 'title' => __( 'Disable on', 'responsive-lightbox' ),
1702 'section' => 'responsive_lightbox_configuration',
1703 'type' => 'number',
1704 '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' ),
1705 'append' => 'px',
1706 'parent' => 'magnific'
1707 ),
1708 'mid_click' => array(
1709 'title' => __( 'Middle click', 'responsive-lightbox' ),
1710 'section' => 'responsive_lightbox_configuration',
1711 'type' => 'boolean',
1712 'label' => __( 'If option enabled, lightbox is opened if the user clicked on the middle mouse button, or click with Command/Ctrl key.', 'responsive-lightbox' ),
1713 'parent' => 'magnific'
1714 ),
1715 'preloader' => array(
1716 'title' => __( 'Preloader', 'responsive-lightbox' ),
1717 'section' => 'responsive_lightbox_configuration',
1718 'type' => 'boolean',
1719 'label' => __( 'If option enabled, it\'s always present in DOM only text inside of it changes.', 'responsive-lightbox' ),
1720 'parent' => 'magnific'
1721 ),
1722 'close_on_content_click' => array(
1723 'title' => __( 'Close on content click', 'responsive-lightbox' ),
1724 'section' => 'responsive_lightbox_configuration',
1725 'type' => 'boolean',
1726 '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' ),
1727 'parent' => 'magnific'
1728 ),
1729 'close_on_background_click' => array(
1730 'title' => __( 'Close on background click', 'responsive-lightbox' ),
1731 'section' => 'responsive_lightbox_configuration',
1732 'type' => 'boolean',
1733 'label' => __( 'Close the popup when user clicks on the dark overlay.', 'responsive-lightbox' ),
1734 'parent' => 'magnific'
1735 ),
1736 'close_button_inside' => array(
1737 'title' => __( 'Close button inside', 'responsive-lightbox' ),
1738 'section' => 'responsive_lightbox_configuration',
1739 'type' => 'boolean',
1740 'label' => __( 'If enabled, Magnific Popup will put close button inside content of popup.', 'responsive-lightbox' ),
1741 'parent' => 'magnific'
1742 ),
1743 'show_close_button' => array(
1744 'title' => __( 'Show close button', 'responsive-lightbox' ),
1745 'section' => 'responsive_lightbox_configuration',
1746 'type' => 'boolean',
1747 'label' => __( 'Controls whether the close button will be displayed or not.', 'responsive-lightbox' ),
1748 'parent' => 'magnific'
1749 ),
1750 'enable_escape_key' => array(
1751 'title' => __( 'Enable escape key', 'responsive-lightbox' ),
1752 'section' => 'responsive_lightbox_configuration',
1753 'type' => 'boolean',
1754 'label' => __( 'Controls whether pressing the escape key will dismiss the active popup or not.', 'responsive-lightbox' ),
1755 'parent' => 'magnific'
1756 ),
1757 'align_top' => array(
1758 'title' => __( 'Align top', 'responsive-lightbox' ),
1759 'section' => 'responsive_lightbox_configuration',
1760 'type' => 'boolean',
1761 'label' => __( 'If set to true popup is aligned to top instead of to center.', 'responsive-lightbox' ),
1762 'parent' => 'magnific'
1763 ),
1764 'fixed_content_position' => array(
1765 'title' => __( 'Content position type', 'responsive-lightbox' ),
1766 'section' => 'responsive_lightbox_configuration',
1767 'type' => 'select',
1768 'description' => __( 'Popup content position. If set to "auto" popup will automatically disable this option when browser doesn\'t support fixed position properly.', 'responsive-lightbox' ),
1769 'options' => array(
1770 'auto' => __( 'Auto', 'responsive-lightbox' ),
1771 'true' => __( 'Fixed', 'responsive-lightbox' ),
1772 'false' => __( 'Absolute', 'responsive-lightbox' )
1773 ),
1774 'parent' => 'magnific'
1775 ),
1776 'fixed_background_position' => array(
1777 'title' => __( 'Fixed background position', 'responsive-lightbox' ),
1778 'section' => 'responsive_lightbox_configuration',
1779 'type' => 'select',
1780 'description' => __( 'Dark transluscent overlay content position.', 'responsive-lightbox' ),
1781 'options' => array(
1782 'auto' => __( 'Auto', 'responsive-lightbox' ),
1783 'true' => __( 'Fixed', 'responsive-lightbox' ),
1784 'false' => __( 'Absolute', 'responsive-lightbox' )
1785 ),
1786 'parent' => 'magnific'
1787 ),
1788 'auto_focus_last' => array(
1789 'title' => __( 'Auto focus last', 'responsive-lightbox' ),
1790 'section' => 'responsive_lightbox_configuration',
1791 'type' => 'boolean',
1792 'label' => __( 'If set to true last focused element before popup showup will be focused after popup close.', 'responsive-lightbox' ),
1793 'parent' => 'magnific'
1794 )
1795 );
1796 break;
1797
1798 default:
1799 $this->settings['configuration'] = apply_filters( 'rl_settings_' . ( ! empty( $section_key ) ? $section_key : $rl->options['settings']['script'] ) . '_script_configuration', $this->settings['configuration'] );
1800 }
1801
1802 if ( isset( $this->tabs[$tab_key]['submit'], $this->tabs[$tab_key]['reset'] ) && ! empty( $this->settings[$tab_key]['prefix'] ) ) {
1803 $this->tabs[$tab_key]['submit'] = 'save_' . $this->settings[$tab_key]['prefix'] . '_' . $tab_key;
1804 $this->tabs[$tab_key]['reset'] = 'reset_' . $this->settings[$tab_key]['prefix'] . '_' . $tab_key;
1805 }
1806 }
1807
1808 /**
1809 * Remote Library Media Providers description
1810 *
1811 * @return void
1812 */
1813 public function remote_library_providers_description() {
1814 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>';
1815 }
1816
1817 /**
1818 * Register options page
1819 *
1820 * @return void
1821 */
1822 public function admin_menu_options() {
1823 // get master capability
1824 $capability = apply_filters( 'rl_lightbox_settings_capability', Responsive_Lightbox()->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' );
1825
1826 add_menu_page( __( 'General', 'responsive-lightbox' ), __( 'Lightbox', 'responsive-lightbox' ), $capability, 'responsive-lightbox-settings', '', 'dashicons-format-image', '57.1' );
1827
1828 foreach ( $this->tabs as $key => $options ) {
1829 add_submenu_page( 'responsive-lightbox-settings', $options['name'], $options['name'], $capability, 'responsive-lightbox-' . $key , array( $this, 'options_page' ) );
1830 }
1831 }
1832
1833 /**
1834 * Render options page
1835 *
1836 * @return void
1837 */
1838 public function options_page() {
1839 // check settings page
1840 if ( isset( $_GET['page'] ) && preg_match( '/^responsive-lightbox-(' . implode( '|', array_keys( $this->tabs ) ) . ')$/', $_GET['page'], $tabs ) !== 1 )
1841 return;
1842
1843 $tab_key = isset( $tabs[1] ) ? $tabs[1] : 'settings';
1844 $section_key = isset( $_GET['section'] ) ? esc_attr( $_GET['section'] ) : ( ! empty( $this->tabs[$tab_key]['default_section'] ) ? $this->tabs[$tab_key]['default_section'] : '' );
1845
1846 // assign main instance
1847 $rl = Responsive_Lightbox();
1848
1849 // no valid lightbox script?
1850 if ( $tab_key === 'configuration' && ! array_key_exists( $section_key, $rl->options['configuration'] ) )
1851 return;
1852
1853 // no valid gallery?
1854 if ( $tab_key === 'gallery' && ! array_key_exists( $section_key, $rl->settings->tabs['gallery']['sections'] ) )
1855 return;
1856
1857 echo '
1858 <div class="wrap">';
1859
1860 settings_errors();
1861
1862 // hidden h2 tag is needed to display info box properly when saving or resetting settings
1863 echo '
1864 <h2 class="hidden">' . __( 'Responsive Lightbox & Gallery', 'responsive-lightbox' ) . ' - ' . $this->tabs[$tab_key]['name'] . '</h2>' . '
1865 <h2 class="nav-tab-wrapper">';
1866
1867 foreach ( $this->tabs as $key => $options ) {
1868 echo '
1869 <a class="nav-tab ' . ( $tab_key == $key ? 'nav-tab-active' : '' ) . '" href="' . esc_url( admin_url( 'admin.php?page=responsive-lightbox-' . $key ) ) . '">' . $options['name'] . '</a>';
1870 }
1871
1872 echo '
1873 </h2>
1874 <div class="responsive-lightbox-settings">
1875 <div class="df-credits">
1876 <h3 class="hndle">' . __( 'Responsive Lightbox & Gallery', 'responsive-lightbox' ) . ' ' . $rl->defaults['version'] . '</h3>
1877 <div class="inside">
1878 <h4 class="inner">' . __( 'Need support?', 'responsive-lightbox' ) . '</h4>
1879 <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>
1880 <hr />
1881 <h4 class="inner">' . __( 'Do you like this plugin?', 'responsive-lightbox' ) . '</h4>
1882 <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 />' .
1883 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 />' .
1884 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' ) . '
1885 </p>
1886 <hr />
1887 <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>
1888 </div>
1889 </div>
1890 <form action="options.php" method="post">';
1891
1892 // views
1893 if ( ! empty( $this->tabs[$tab_key]['sections'] ) ) {
1894 $views = $this->tabs[$tab_key]['sections'];
1895
1896 echo '<ul class="subsubsub">';
1897
1898 foreach ( $views as $key => $name ) {
1899 $view = '<a href="' . esc_url( admin_url( 'admin.php?page=responsive-lightbox-' . $tab_key . '&section=' . $key ) ) . '" class="' . ( $key == $section_key ? 'current' : '' ) . '">' . $name . '</a>';
1900 $views[$key] = "\t<li class='$key'>$view";
1901 }
1902
1903 echo implode( " |</li>\n", $views ) . "</li>\n";
1904 echo '</ul><input type="hidden" name="section" value="' . $section_key . '" /><br class="clear">';
1905 }
1906
1907 // tab content callback
1908 if ( ! empty( $this->tabs[$tab_key]['callback'] ) )
1909 call_user_func( $this->tabs[$tab_key]['callback'] );
1910 else {
1911 settings_fields( $this->tabs[$tab_key]['key'] );
1912 do_settings_sections( $this->tabs[$tab_key]['key'] );
1913
1914 if ( $tab_key === 'builder' )
1915 echo '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( add_query_arg( 'flush_rules', 1, $_SERVER['REQUEST_URI'] ) ) ) . '" />';
1916 }
1917
1918 if ( ! empty( $this->tabs[$tab_key]['submit'] ) || ! empty( $this->tabs[$tab_key]['reset'] ) ) {
1919 echo '<p class="submit">';
1920
1921 if ( ! empty( $this->tabs[$tab_key]['submit'] ) ) {
1922 submit_button( '', array( 'primary', 'save-' . $tab_key ), $this->tabs[$tab_key]['submit'], false );
1923 echo ' ';
1924 }
1925
1926 if ( ! empty( $this->tabs[$tab_key]['reset'] ) )
1927 submit_button( __( 'Reset to defaults', 'responsive-lightbox' ), array( 'secondary', 'reset-responsive-lightbox-settings reset-' . $tab_key ), $this->tabs[$tab_key]['reset'], false );
1928
1929 echo '</p>';
1930 }
1931
1932 echo '
1933 </form>
1934 </div>
1935 <div class="clear"></div>
1936 </div>';
1937 }
1938
1939 /**
1940 * Add new capability to manage options.
1941 *
1942 * @return string
1943 */
1944 public function manage_options_capability() {
1945 return Responsive_Lightbox()->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options';
1946 }
1947
1948 /**
1949 * Render settings function.
1950 *
1951 * @return void
1952 */
1953 public function register_settings() {
1954 // assign main instance
1955 $rl = Responsive_Lightbox();
1956
1957 foreach ( $this->settings as $setting_id => $setting ) {
1958 // set key
1959 $setting_key = $setting_id;
1960 $setting_id = 'responsive_lightbox_' . $setting_id;
1961
1962 // add new capability to manage options
1963 add_filter( 'option_page_capability_' . $setting_id, array( $this, 'manage_options_capability' ) );
1964
1965 // register setting
1966 register_setting(
1967 esc_attr( $setting_id ),
1968 ! empty( $setting['option_name'] ) ? esc_attr( $setting['option_name'] ) : $setting_id,
1969 ! empty( $setting['callback'] ) ? $setting['callback'] : array( $this, 'validate_settings' )
1970 );
1971
1972 // register sections
1973 if ( ! empty( $setting['sections'] ) && is_array( $setting['sections'] ) ) {
1974 foreach ( $setting['sections'] as $section_id => $section ) {
1975 add_settings_section(
1976 esc_attr( $section_id ),
1977 ! empty( $section['title'] ) ? esc_html( $section['title'] ) : '',
1978 ! empty( $section['callback'] ) ? $section['callback'] : '',
1979 ! empty( $section['page'] ) ? esc_attr( $section['page'] ) : $section_id
1980 );
1981 }
1982 }
1983
1984 // register fields
1985 if ( ! empty( $setting['fields'] ) && is_array( $setting['fields'] ) ) {
1986 foreach ( $setting['fields'] as $field_id => $field ) {
1987 // prefix field id?
1988 $field_key = $field_id;
1989 $field_id = ( ! empty( $setting['prefix'] ) ? $setting['prefix'] . '_' : '' ) . $field_id;
1990
1991 // field args
1992 $args = array(
1993 'id' => ! empty( $field['id'] ) ? $field['id'] : $field_id,
1994 'class' => ! empty( $field['class'] ) ? $field['class'] : '',
1995 'name' => $setting['option_name'] . ( ! empty( $field['parent'] ) ? '[' . $field['parent'] . ']' : '' ) . '[' . $field_key . ']',
1996 'type' => ! empty( $field['type'] ) ? $field['type'] : 'text',
1997 'label' => ! empty( $field['label'] ) ? $field['label'] : '',
1998 'description' => ! empty( $field['description'] ) ? $field['description'] : '',
1999 'disabled' => isset( $field['disabled'] ) ? (bool) $field['disabled'] : false,
2000 'append' => ! empty( $field['append'] ) ? esc_html( $field['append'] ) : '',
2001 'prepend' => ! empty( $field['prepend'] ) ? esc_html( $field['prepend'] ) : '',
2002 'min' => isset( $field['min'] ) ? (int) $field['min'] : '',
2003 'max' => isset( $field['max'] ) ? (int) $field['max'] : '',
2004 'options' => ! empty( $field['options'] ) ? $field['options'] : '',
2005 'fields' => ! empty( $field['fields'] ) ? $field['fields'] : '',
2006 'after_field' => ! empty( $field['after_field'] ) ? $field['after_field'] : '',
2007 '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'] ) ),
2008 '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'] ) ),
2009 'label_for' => $field_id,
2010 'classname' => ! empty( $field['classname'] ) ? $field['classname'] : '',
2011 'callback' => ! empty( $field['callback'] ) ? $field['callback'] : '',
2012 'return' => false
2013 );
2014
2015 if ( $args['type'] === 'multiple' ) {
2016 foreach ( $args['fields'] as $subfield_id => $subfield ) {
2017 $args['fields'][$subfield_id] = wp_parse_args( $subfield, array(
2018 'id' => $field_id . '-' . $subfield_id,
2019 'class' => ! empty( $subfield['class'] ) ? $subfield['class'] : '',
2020 'name' => $setting['option_name'] . ( ! empty( $subfield['parent'] ) ? '[' . $subfield['parent'] . ']' : '' ) . '[' . $subfield_id . ']',
2021 'default' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? $rl->defaults[$setting_key][$subfield['parent']][$subfield_id] : $rl->defaults[$setting_key][$subfield_id], $subfield['type'] ),
2022 'value' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? $rl->options[$setting_key][$subfield['parent']][$subfield_id] : $rl->options[$setting_key][$subfield_id], $subfield['type'] ),
2023 'return' => true
2024 ) );
2025 }
2026 }
2027
2028 add_settings_field(
2029 esc_attr( $field_id ),
2030 ! empty( $field['title'] ) ? esc_html( $field['title'] ) : '',
2031 array( $this, 'render_field' ),
2032 ! empty( $field['page'] ) ? esc_attr( $field['page'] ) : $setting_id,
2033 ! empty( $field['section'] ) ? esc_attr( $field['section'] ) : '',
2034 $args
2035 );
2036 }
2037 }
2038 }
2039
2040 // licenses
2041 $extensions = apply_filters( 'rl_settings_licenses', array() );
2042
2043 if ( $extensions ) {
2044 // add new capability to manage licenses
2045 add_filter( 'option_page_capability_responsive_lightbox_licenses', array( $this, 'manage_options_capability' ) );
2046
2047 // register setting
2048 register_setting(
2049 'responsive_lightbox_licenses',
2050 'responsive_lightbox_licenses',
2051 array( $this, 'validate_licenses' )
2052 );
2053
2054 add_settings_section(
2055 'responsive_lightbox_licenses',
2056 __( 'Licenses', 'responsive-lightbox' ),
2057 array( $this, 'licenses_section_cb' ),
2058 'responsive_lightbox_licenses'
2059 );
2060
2061 foreach ( $extensions as $id => $extension ) {
2062 add_settings_field(
2063 esc_attr( $id ),
2064 $extension['name'],
2065 array( $this, 'license_field_cb' ),
2066 'responsive_lightbox_licenses',
2067 'responsive_lightbox_licenses',
2068 $extension
2069 );
2070 }
2071 }
2072 }
2073
2074 /**
2075 * Render settings field function.
2076 *
2077 * @param array $args
2078 * @return void|string
2079 */
2080 public function render_field( $args ) {
2081 if ( empty( $args ) || ! is_array( $args ) )
2082 return;
2083
2084 $html = '';
2085
2086 switch ( $args['type'] ) {
2087 case 'boolean':
2088 $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>';
2089 break;
2090
2091 case 'radio':
2092 foreach ( $args['options'] as $key => $name ) {
2093 $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> ';
2094 }
2095 break;
2096
2097 case 'checkbox':
2098 foreach ( $args['options'] as $key => $name ) {
2099 $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> ';
2100 }
2101 break;
2102
2103 case 'select':
2104 $html .= '<select id="' . $args['id'] . '" name="' . $args['name'] . '" value="' . esc_attr( $args['value'] ) . '" ' . ( isset( $args['disabled'] ) && $args['disabled'] == true ? ' disabled="disabled"' : '' ) . '/>';
2105
2106 foreach ( $args['options'] as $key => $name ) {
2107 $html .= '<option value="' . $key . '" ' . selected( $args['value'], $key, false ) . '>' . $name . '</option>';
2108 }
2109
2110 $html .= '</select>';
2111 break;
2112
2113 case 'multiple':
2114 $html .= '<fieldset>';
2115
2116 if ( $args['fields'] ) {
2117 $count = 1;
2118 $count_fields = count( $args['fields'] );
2119
2120 foreach ( $args['fields'] as $subfield_id => $subfield_args ) {
2121 $html .= $this->render_field( $subfield_args ) . ( $count < $count_fields ? '<br />' : '' );
2122 $count++;
2123 }
2124 }
2125
2126 $html .= '</fieldset>';
2127 break;
2128
2129 case 'range':
2130 $html .= '<input id="' . $args['id'] . '" type="range" name="' . $args['name'] . '" value="' . (int) $args['value'] . '" min="' . $args['min'] . '" max="' . $args['max'] . '" oninput="this.form.' . $args['id'] . '_range.value=this.value" />';
2131 $html .= '<output name="' . $args['id'] . '_range">' . (int) $args['value'] . '</output>';
2132 break;
2133
2134 case 'color_picker':
2135 $html .= '<input id="' . $args['id'] . '" class="color-picker" type="text" value="' . esc_attr( $args['value'] ) . '" name="' . $args['name'] . '" data-default-color="' . $args['default'] . '" />';
2136 break;
2137
2138 case 'number':
2139 $html .= ( ! empty( $args['prepend'] ) ? '<span>' . $args['prepend'] . '</span> ' : '' );
2140 $html .= '<input id="' . $args['id'] . '" type="number" value="' . (int) $args['value'] . '" name="' . $args['name'] . '" />';
2141 $html .= ( ! empty( $args['append'] ) ? ' <span>' . $args['append'] . '</span>' : '' );
2142 break;
2143
2144 case 'button':
2145 $html .= ( ! empty( $args['prepend'] ) ? '<span>' . $args['prepend'] . '</span> ' : '' );
2146 $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>';
2147 $html .= ( ! empty( $args['append'] ) ? ' <span>' . $args['append'] . '</span>' : '' );
2148 break;
2149
2150 case 'custom':
2151 $html .= call_user_func( $args['callback'], $args );
2152 break;
2153
2154 case 'text':
2155 default :
2156 $html .= ( ! empty( $args['prepend'] ) ? '<span>' . $args['prepend'] . '</span> ' : '' );
2157 $html .= '<input id="' . $args['id'] . '" class="' . $args['class'] . '" type="text" value="' . esc_attr( $args['value'] ) . '" name="' . $args['name'] . '" />';
2158 $html .= ( ! empty( $args['append'] ) ? ' <span>' . $args['append'] . '</span>' : '' );
2159 }
2160
2161 if ( ! empty ( $args['after_field'] ) )
2162 $html .= $args['after_field'];
2163
2164 if ( ! empty ( $args['description'] ) )
2165 $html .= '<p class="description">' . $args['description'] . '</p>';
2166
2167 if ( ! empty( $args['return'] ) )
2168 return $html;
2169 else
2170 echo $html;
2171 }
2172
2173 /**
2174 * Sanitize field function
2175 *
2176 * @param mixed $value
2177 * @param string $type
2178 * @param array $args
2179 * @return mixed
2180 */
2181 public function sanitize_field( $value = null, $type = '', $args = array() ) {
2182 if ( is_null( $value ) )
2183 return null;
2184
2185 switch ( $type ) {
2186 case 'button':
2187 case 'boolean':
2188 $value = empty( $value ) ? false : true;
2189 break;
2190
2191 case 'checkbox':
2192 $value = is_array( $value ) && ! empty( $value ) ? array_map( 'sanitize_text_field', $value ) : array();
2193 break;
2194
2195 case 'radio':
2196 $value = is_array( $value ) ? false : sanitize_text_field( $value );
2197 break;
2198
2199 case 'textarea':
2200 case 'wysiwyg':
2201 $value = wp_kses_post( $value );
2202 break;
2203
2204 case 'color_picker':
2205 if ( empty( $value ) || preg_match( '/^#[a-f0-9]{6}$/i', $value ) !== 1 )
2206 $value = '#666666';
2207 break;
2208
2209 case 'number':
2210 $value = (int) $value;
2211
2212 // is value lower than?
2213 if ( isset( $args['min'] ) && $value < $args['min'] )
2214 $value = $args['min'];
2215
2216 // is value greater than?
2217 if ( isset( $args['max'] ) && $value > $args['max'] )
2218 $value = $args['max'];
2219 break;
2220
2221 case 'custom':
2222 // do nothing
2223 break;
2224
2225 case 'text':
2226 if ( ! empty( $args ) ) {
2227 // validate custom events
2228 if ( $args['setting_id'] === 'settings' ) {
2229 if ( $args['field_id'] === 'enable_custom_events' && $args['subfield_id'] === 'custom_events' )
2230 $value = preg_replace( '/[^a-z0-9 ]/i', '', $value );
2231 } elseif ( $args['setting_id'] === 'builder' ) {
2232 if ( $args['field_id'] === 'permalink' || $args['field_id'] === 'permalink_categories' || $args['field_id'] === 'permalink_tags' )
2233 $value = sanitize_title( $value );
2234 }
2235
2236 }
2237 case 'select':
2238 default:
2239 $value = is_array( $value ) ? array_map( 'sanitize_text_field', $value ) : sanitize_text_field( $value );
2240 break;
2241 }
2242
2243 return stripslashes_deep( $value );
2244 }
2245
2246 /**
2247 * Validate settings function
2248 *
2249 * @param array $input
2250 * @return array
2251 */
2252 public function validate_settings( $input ) {
2253 // assign main instance
2254 $rl = Responsive_Lightbox();
2255
2256 // check capability
2257 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', $rl->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' ) ) )
2258 return $input;
2259
2260 // check page
2261 if ( ! isset( $_POST['option_page'] ) || ! ( $option_page = esc_attr( $_POST['option_page'] ) ) )
2262 return $input;
2263
2264 foreach ( $this->settings as $id => $setting ) {
2265 $key = array_search( $option_page, $setting );
2266
2267 if ( $key ) {
2268 // set key
2269 $setting_id = $id;
2270 break;
2271 }
2272 }
2273
2274 // check setting id
2275 if ( ! $setting_id )
2276 return $input;
2277
2278 // save settings
2279 if ( isset( $_POST['save' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) {
2280 if ( $this->settings[$setting_id]['fields'] ) {
2281 foreach ( $this->settings[$setting_id]['fields'] as $field_id => $field ) {
2282 if ( $field['type'] === 'multiple' ) {
2283 if ( $field['fields'] ) {
2284 foreach ( $field['fields'] as $subfield_id => $subfield ) {
2285 $args = $subfield;
2286 $args['setting_id'] = $setting_id;
2287 $args['field_id'] = $field_id;
2288 $args['subfield_id'] = $subfield_id;
2289
2290 // if subfield has parent
2291 if ( ! empty( $this->settings[$setting_id]['fields'][$field_id]['fields'][$subfield_id]['parent'] ) ) {
2292 $field_parent = $this->settings[$setting_id]['fields'][$field_id]['fields'][$subfield_id]['parent'];
2293
2294 $input[$field_parent][$subfield_id] = isset( $input[$field_parent][$subfield_id] ) ? $this->sanitize_field( $input[$field_parent][$subfield_id], $subfield['type'], $args ) : ( $subfield['type'] === 'boolean' ? false : $rl->defaults[$setting_id][$field_parent][$subfield_id] );
2295 } else {
2296 $input[$subfield_id] = isset( $input[$subfield_id] ) ? $this->sanitize_field( $input[$subfield_id], $subfield['type'], $args ) : ( $subfield['type'] === 'boolean' ? false : $rl->defaults[$setting_id][$field_id][$subfield_id] );
2297 }
2298 }
2299 }
2300 } else {
2301 $args = $field;
2302 $args['setting_id'] = $setting_id;
2303 $args['field_id'] = $field_id;
2304
2305 // if field has parent
2306 if ( ! empty( $this->settings[$setting_id]['fields'][$field_id]['parent'] ) ) {
2307 $field_parent = $this->settings[$setting_id]['fields'][$field_id]['parent'];
2308
2309 $input[$field_parent][$field_id] = isset( $input[$field_parent][$field_id] ) ? ( $field['type'] === 'checkbox' ? array_keys( $this->sanitize_field( $input[$field_parent][$field_id], $field['type'], $args ) ) : $this->sanitize_field( $input[$field_parent][$field_id], $field['type'], $args ) ) : ( in_array( $field['type'], array( 'boolean', 'checkbox' ) ) ? false : $rl->defaults[$setting_id][$field_parent][$field_id] );
2310 } else {
2311 $input[$field_id] = isset( $input[$field_id] ) ? ( $field['type'] === 'checkbox' ? array_keys( $this->sanitize_field( $input[$field_id], $field['type'], $args ) ) : $this->sanitize_field( $input[$field_id], $field['type'], $args ) ) : ( in_array( $field['type'], array( 'boolean', 'checkbox' ) ) ? false : $rl->defaults[$setting_id][$field_id] );
2312 }
2313 }
2314 }
2315 }
2316
2317 if ( $setting_id === 'settings' ) {
2318 // merge scripts settings
2319 $input = array_merge( $rl->options['settings'], $input );
2320
2321 // woocommerce lightbox has to be enabled when using rl gallery
2322 if ( $input['default_woocommerce_gallery'] !== 'default' )
2323 $input['woocommerce_gallery_lightbox'] = true;
2324 }
2325
2326 if ( $setting_id === 'configuration' ) {
2327 // merge scripts settings
2328 $input = array_merge( $rl->options['configuration'], $input );
2329 }
2330
2331 if ( $setting_id === 'remote_library' )
2332 $input = apply_filters( 'rl_remote_library_settings', $input );
2333 } elseif ( isset( $_POST['reset' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) {
2334 if ( $setting_id === 'configuration' ) {
2335 $script = key( $input );
2336
2337 // merge scripts settings
2338 $input[$script] = $rl->defaults['configuration'][$script];
2339 $input = array_merge( $rl->options['configuration'], $input );
2340 } elseif ( $setting_id === 'settings' ) {
2341 $input = $rl->defaults[$setting_id];
2342 $input['update_version'] = $rl->options['settings']['update_version'];
2343 $input['update_notice'] = $rl->options['settings']['update_notice'];
2344 } else
2345 $input = $rl->defaults[$setting_id];
2346
2347 add_settings_error( 'reset_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id, 'settings_restored', __( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' );
2348 }
2349
2350 return $input;
2351 }
2352
2353 /**
2354 * Validate capabilities.
2355 *
2356 * @global object $wp_roles
2357 *
2358 * @param array $input
2359 * @return array
2360 */
2361 public function validate_capabilities( $input ) {
2362 // assign main instance
2363 $rl = Responsive_Lightbox();
2364
2365 // check capability
2366 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', $rl->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' ) ) )
2367 return $input;
2368
2369 // validate normal fields
2370 $input = $this->validate_settings( $input );
2371
2372 global $wp_roles;
2373
2374 // save capabilities?
2375 if ( isset( $_POST['save_rl_capabilities'] ) ) {
2376 foreach ( $wp_roles->roles as $role_name => $role_label ) {
2377 // get user role
2378 $role = $wp_roles->get_role( $role_name );
2379
2380 // manage new capabilities only for non-admins
2381 if ( $role_name !== 'administrator' ) {
2382 foreach ( $rl->capabilities as $capability => $label ) {
2383 if ( isset( $input['roles'][$role_name][$capability] ) && $input['roles'][$role_name][$capability] === 'true' )
2384 $role->add_cap( $capability );
2385 else
2386 $role->remove_cap( $capability );
2387 }
2388 }
2389 }
2390 // reset capabilities?
2391 } elseif ( isset( $_POST['reset_rl_capabilities'] ) ) {
2392 foreach ( $wp_roles->roles as $role_name => $display_name ) {
2393 // get user role
2394 $role = $wp_roles->get_role( $role_name );
2395
2396 foreach ( $rl->capabilities as $capability => $label ) {
2397 if ( array_key_exists( $role_name, $rl->defaults['capabilities']['roles'] ) && in_array( $capability, $rl->defaults['capabilities']['roles'][$role_name], true ) )
2398 $role->add_cap( $capability );
2399 else
2400 $role->remove_cap( $capability );
2401 }
2402 }
2403
2404 add_settings_error( 'reset_rl_capabilities', 'settings_restored', __( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' );
2405 }
2406
2407 return $input;
2408 }
2409
2410 /**
2411 * Render capabilities section.
2412 *
2413 * @global object $wp_roles
2414 *
2415 * @return void
2416 */
2417 public function capabilities_table() {
2418 global $wp_roles;
2419
2420 // get available user roles
2421 $editable_roles = get_editable_roles();
2422
2423 $html = '
2424 <br class="clear" />
2425 <table class="widefat fixed posts">
2426 <thead>
2427 <tr>
2428 <th>' . __( 'Role', 'responsive-lightbox' ) . '</th>';
2429
2430 foreach ( $editable_roles as $role_name => $role_info ) {
2431 $html .= '<th>' . esc_html( isset( $wp_roles->role_names[$role_name] ) ? translate_user_role( $wp_roles->role_names[$role_name] ) : $role_name ) . '</th>';
2432 }
2433
2434 $html .= '
2435 </tr>
2436 </thead>
2437 <tbody id="the-list">';
2438
2439 $i = 0;
2440
2441 foreach ( Responsive_Lightbox()->capabilities as $cap_role => $cap_label ) {
2442 $html .= '
2443 <tr' . ( ( $i++ % 2 === 0 ) ? ' class="alternate"' : '' ) . '>
2444 <td>' . esc_html( __( $cap_label, 'responsive-lightbox' ) ) . '</td>';
2445
2446 foreach ( $editable_roles as $role_name => $role_info ) {
2447 // get user role
2448 $role = $wp_roles->get_role( $role_name );
2449
2450 $html .= '
2451 <td>
2452 <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 ) . ' />
2453 </td>';
2454 }
2455
2456 $html .= '
2457 </tr>';
2458 }
2459
2460 $html .= '
2461 </tbody>
2462 </table>';
2463
2464 echo $html;
2465 }
2466
2467 /**
2468 * Add-ons tab callback
2469 *
2470 * @return void
2471 */
2472 private function addons_tab_cb() {
2473 ?>
2474 <h3><?php _e( 'Add-ons / Extensions', 'responsive-lightbox' ); ?></h3>
2475 <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>
2476 <br />
2477 <?php
2478 if ( ( $cache = get_transient( 'responsive_lightbox_addons_feed' ) ) === false ) {
2479 $url = 'https://dfactory.eu/?feed=addons&product=responsive-lightbox';
2480
2481 $feed = wp_remote_get( esc_url_raw( $url ), array( 'sslverify' => false ) );
2482
2483 if ( ! is_wp_error( $feed ) ) {
2484 if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 )
2485 $cache = wp_remote_retrieve_body( $feed );
2486 } else
2487 $cache = '<div class="error"><p>' . __( 'There was an error retrieving the extensions list from the server. Please try again later.', 'responsive-lightbox' ) . '</div>';
2488 }
2489
2490 echo $cache;
2491 }
2492
2493 /**
2494 * Licenses section callback.
2495 *
2496 * @return void
2497 */
2498 public function licenses_section_cb() {
2499 ?><p class="description"><?php _e( 'A list of licenses for your Responsive Lightbox & Gallery extensions.', 'responsive-lightbox' ); ?></p><?php
2500 }
2501
2502 /**
2503 * License field callback.
2504 *
2505 * @param array $args
2506 * @return void
2507 */
2508 public function license_field_cb( $args ) {
2509 $licenses = get_option( 'responsive_lightbox_licenses' );
2510
2511 if ( ! empty( $licenses ) ) {
2512 $license = isset( $licenses[$args['id']]['license'] ) ? esc_attr( $licenses[$args['id']]['license'] ) : '';
2513 $status = ! empty( $licenses[$args['id']]['status'] );
2514 } else {
2515 $license = '';
2516 $status = false;
2517 } ?>
2518 <fieldset class="rl_license rl_license-<?php echo esc_attr( $args['id'] ); ?>">
2519 <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>
2520 <p class="description"><?php printf( __( 'Enter your license key to activate %s extension and enable automatic upgrade notices.', 'responsive-lightbox' ), $args['name'] ); ?></p>
2521 </fieldset>
2522 <?php
2523 }
2524
2525 /**
2526 * Validate licenses function.
2527 *
2528 * @param array $input
2529 * @return array
2530 */
2531 public function validate_licenses( $input ) {
2532 // check cap
2533 if ( ! current_user_can( apply_filters( 'rl_lightbox_settings_capability', Responsive_Lightbox()->options['capabilities']['active'] ? 'edit_lightbox_settings' : 'manage_options' ) ) )
2534 return $input;
2535
2536 // check page
2537 if ( ! isset( $_POST['option_page'] ) || ! ( $option_page = esc_attr( $_POST['option_page'] ) ) )
2538 return $input;
2539
2540 // check data
2541 if ( ! isset( $_POST['responsive_lightbox_licenses'] ) || ! is_array( $_POST['responsive_lightbox_licenses'] ) )
2542 return $input;
2543
2544 // get extension licenses
2545 $extensions = apply_filters( 'rl_settings_licenses', array() );
2546
2547 if ( empty( $extensions ) )
2548 return $input;
2549
2550 // save settings
2551 if ( isset( $_POST['save_rl_licenses'] ) ) {
2552 $licenses = get_option( 'responsive_lightbox_licenses' );
2553 $statuses = array( 'updated' => 0, 'error' => 0 );
2554
2555 foreach ( $extensions as $extension ) {
2556 if ( ! isset( $_POST['responsive_lightbox_licenses'][$extension['id']] ) )
2557 continue;
2558
2559 $license = preg_replace('/[^a-zA-Z0-9]/', '', $_POST['responsive_lightbox_licenses'][$extension['id']]['license'] );
2560 $status = ! empty( $licenses ) && ! empty( $licenses[$extension['id']]['status'] ) ? true : false;
2561
2562 // request data
2563 $request_args = array(
2564 'action' => 'activate_license',
2565 'license' => trim( $license ),
2566 'item_name' => $extension['item_name']
2567 );
2568
2569 // request
2570 $response = $this->license_request( $request_args );
2571
2572 // validate request
2573 if ( is_wp_error( $response ) ) {
2574 $input[$extension['id']['status']] = false;
2575 $statuses['error']++;
2576 } else {
2577 // decode the license data
2578 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
2579
2580 // assign the data
2581 if ( $license_data->license == 'valid' ) {
2582 $input[$extension['id']]['status'] = true;
2583
2584 if ( $status === false )
2585 $statuses['updated']++;
2586 } else {
2587 $input[$extension['id']]['status'] = false;
2588 $statuses['error']++;
2589 }
2590 }
2591 }
2592
2593 // success notice
2594 if ( $statuses['updated'] > 0 )
2595 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' );
2596
2597 // failed notice
2598 if ( $statuses['error'] > 0 )
2599 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' );
2600 } elseif ( isset( $_POST['reset_rl_licenses'] ) ) {
2601 $licenses = get_option( 'responsive_lightbox_licenses' );
2602 $statuses = array( 'updated' => 0, 'error' => 0 );
2603
2604 foreach ( $extensions as $extension ) {
2605 $license = ! empty( $licenses ) && isset( $licenses[$extension['id']]['license'] ) ? $licenses[$extension['id']]['license'] : '';
2606 $status = ! empty( $licenses ) && ! empty( $licenses[$extension['id']]['status'] ) ? true : false;
2607
2608 if ( $status === true || ( $status === false && ! empty( $license ) ) ) {
2609 // request data
2610 $request_args = array(
2611 'action' => 'deactivate_license',
2612 'license' => trim( $license ),
2613 'item_name' => $extension['item_name']
2614 );
2615
2616 // request
2617 $response = $this->license_request( $request_args );
2618
2619 // validate request
2620 if ( is_wp_error( $response ) )
2621 $statuses['error']++;
2622 else {
2623 // decode the license data
2624 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
2625
2626 // assign the data
2627 if ( $license_data->license == 'deactivated' ) {
2628 $input[$extension['id']]['license'] = '';
2629 $input[$extension['id']]['status'] = false;
2630 $statuses['updated']++;
2631 } else
2632 $statuses['error']++;
2633 }
2634 }
2635 }
2636
2637 // success notice
2638 if ( $statuses['updated'] > 0 )
2639 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' );
2640
2641 // failed notice
2642 if ( $statuses['error'] > 0 )
2643 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' );
2644 }
2645
2646 return $input;
2647 }
2648
2649 /**
2650 * License request function.
2651 *
2652 * @param array $args
2653 * @return mixed
2654 */
2655 private function license_request( $args ) {
2656 // data to send in our API request
2657 $api_params = array(
2658 'edd_action' => $args['action'],
2659 'license' => $args['license'],
2660 'item_name' => urlencode( $args['item_name'] ),
2661 // 'item_id' => $args['item_id'],
2662 'url' => home_url(),
2663 'timeout' => 60,
2664 'sslverify' => false
2665 );
2666
2667 // call the custom API
2668 $response = wp_remote_get( add_query_arg( $api_params, 'http://dfactory.eu' ) );
2669
2670 return $response;
2671 }
2672 }