Responsive Lightbox & Gallery - Version 1.5.0

Version Description

  • New: Revamped User Interface
  • New: Option to force lightbox for custom WP gallery replacements like Jetpack tiled galleries
Download this release

Release Info

Developer dfactory
Plugin Icon 128x128 Responsive Lightbox & Gallery
Version 1.5.0
Comparing to
See all releases

Code changes from version 1.4.14 to 1.5.0

css/admin.css CHANGED
@@ -38,6 +38,9 @@
38
.responsive-lightbox-settings {
39
margin-right: 300px;
40
}
41
.responsive-lightbox-settings hr, .df-credits hr {
42
border: solid #eee;
43
border-width: 1px 0 0;
@@ -54,6 +57,15 @@
54
margin-top: 4px;
55
display: block;
56
}
57
58
.wplike-slider span.middle {
59
width: 150px;
@@ -75,4 +87,385 @@
75
.responsive-lightbox-settings {
76
margin-right: 0;
77
}
78
- }
38
.responsive-lightbox-settings {
39
margin-right: 300px;
40
}
41
+ .responsive-lightbox-settings td > label {
42
+ margin-right: 5px;
43
+ }
44
.responsive-lightbox-settings hr, .df-credits hr {
45
border: solid #eee;
46
border-width: 1px 0 0;
57
margin-top: 4px;
58
display: block;
59
}
60
+ .responsive-lightbox-settings output {
61
+ display: inline-block;
62
+ font-size: inherit;
63
+ margin: 0;
64
+ text-align: left;
65
+ }
66
+ .rtl .responsive-lightbox-settings output {
67
+ text-align: right;
68
+ }
69
70
.wplike-slider span.middle {
71
width: 150px;
87
.responsive-lightbox-settings {
88
margin-right: 0;
89
}
90
+ }
91
+
92
+ /*
93
+ * checkBo lightweight jQuery plugin v0.1.4 by @ElmahdiMahmoud
94
+ * Licensed under the MIT license - https://github.com/elmahdim/checkbo/blob/master/LICENSE
95
+ *
96
+ * Custom checkbox and radio
97
+ * Author URL: elmahdim.com
98
+ */
99
+ .cb-checkbox .cb-inner, .cb-checkbox i {
100
+ width:18px;
101
+ height:18px;
102
+ -moz-border-radius:3px;
103
+ -webkit-border-radius:3px;
104
+ border-radius:3px
105
+ }
106
+ .cb-checkbox.cb-sm i, .cb-checkbox.cb-sm .cb-inner {
107
+ width:14px;
108
+ height:14px
109
+ }
110
+ .cb-checkbox.cb-md i, .cb-checkbox.cb-md .cb-inner {
111
+ width:24px;
112
+ height:24px;
113
+ -moz-border-radius:4px;
114
+ -webkit-border-radius:4px;
115
+ border-radius:4px
116
+ }
117
+ .cb-checkbox.cb-lg i, .cb-checkbox.cb-lg .cb-inner {
118
+ width:30px;
119
+ height:30px;
120
+ -moz-border-radius:6px;
121
+ -webkit-border-radius:6px;
122
+ border-radius:6px
123
+ }
124
+ .cb-radio .cb-inner {
125
+ width:18px;
126
+ height:18px
127
+ }
128
+ .cb-radio.cb-sm .cb-inner {
129
+ width:14px;
130
+ height:14px
131
+ }
132
+ .cb-radio.cb-md .cb-inner {
133
+ width:24px;
134
+ height:24px
135
+ }
136
+ .cb-radio.cb-lg .cb-inner {
137
+ width:30px;
138
+ height:30px
139
+ }
140
+ .cb-checkbox, .cb-radio {
141
+ padding:3px 0;
142
+ color:inherit;
143
+ cursor:pointer;
144
+ overflow:hidden;
145
+ font-size:inherit;
146
+ font-weight:normal;
147
+ display:inline-block;
148
+ line-height:18px
149
+ }
150
+ .cb-checkbox.disabled, .cb-checkbox.disabled *, .cb-radio.disabled, .cb-radio.disabled * {
151
+ cursor:default
152
+ }
153
+ .cb-checkbox input[type="checkbox"], .cb-radio input[type="radio"], .cb-switcher input[type="checkbox"], .cb-switcher input[type="radio"] {
154
+ display:none
155
+ }
156
+ .cb-checkbox.disabled, .cb-checkbox.disabled *, .cb-radio.disabled, .cb-radio.disabled *, .cb-switcher.disabled, .cb-switcher.disabled * {
157
+ cursor:default
158
+ }
159
+ .cb-checkbox.disabled {
160
+ color:#ddd
161
+ }
162
+ .cb-checkbox.disabled .cb-inner {
163
+ color:#ddd
164
+ }
165
+ .cb-checkbox.disabled:hover .cb-inner {
166
+ border-color:#ddd
167
+ }
168
+ .cb-checkbox.disabled.checked .cb-inner {
169
+ background-color:#ddd;
170
+ border-color:#ddd
171
+ }
172
+ .cb-radio.disabled {
173
+ color:#ddd
174
+ }
175
+ .cb-radio.disabled .cb-inner {
176
+ border-color:#ddd
177
+ }
178
+ .cb-radio.disabled i {
179
+ background-color:transparent
180
+ }
181
+ .cb-radio.disabled.checked .cb-inner {
182
+ border-color:#ddd
183
+ }
184
+ .cb-radio.disabled.checked .cb-inner i {
185
+ background-color:#ddd
186
+ }
187
+ .cb-radio.disabled:hover .cb-inner {
188
+ border-color:#ddd
189
+ }
190
+ .cb-checkbox .cb-inner {
191
+ float:left;
192
+ overflow:hidden;
193
+ margin:0 5px 0 0;
194
+ position:relative;
195
+ background:#f2f2f2;
196
+ display:inline-block;
197
+ border:1px solid #d6d6d6;
198
+ -moz-transition:all 0.5s ease;
199
+ -o-transition:all 0.5s ease;
200
+ -webkit-transition:all 0.5s ease;
201
+ transition:all 0.5s ease
202
+ }
203
+ .cb-checkbox i {
204
+ top:1px;
205
+ left:2px;
206
+ display:block;
207
+ position:absolute
208
+ }
209
+ .cb-checkbox i:before, .cb-checkbox i:after {
210
+ height:0;
211
+ width:2px;
212
+ content:"";
213
+ display:block;
214
+ position:absolute;
215
+ background-color:#fff;
216
+ -moz-transition:all 0.2s ease;
217
+ -o-transition:all 0.2s ease;
218
+ -webkit-transition:all 0.2s ease;
219
+ transition:all 0.2s ease
220
+ }
221
+ .cb-checkbox i:before {
222
+ top:0;
223
+ left:0;
224
+ -moz-transform:rotate(-45deg);
225
+ -ms-transform:rotate(-45deg);
226
+ -webkit-transform:rotate(-45deg);
227
+ transform:rotate(-45deg)
228
+ }
229
+ .cb-checkbox i:after {
230
+ left:7px;
231
+ bottom:5px;
232
+ -moz-transition-delay:0.3s;
233
+ -o-transition-delay:0.3s;
234
+ -webkit-transition-delay:0.3s;
235
+ transition-delay:0.3s;
236
+ -moz-transform:rotate(30deg);
237
+ -ms-transform:rotate(30deg);
238
+ -webkit-transform:rotate(30deg);
239
+ transform:rotate(30deg)
240
+ }
241
+ .cb-radio .cb-inner {
242
+ float:left;
243
+ overflow:hidden;
244
+ margin:0 5px 0 0;
245
+ position:relative;
246
+ display:inline-block;
247
+ border:1px solid #d7d7d7;
248
+ background-color:#f2f2f2;
249
+ -moz-border-radius:100%;
250
+ -webkit-border-radius:100%;
251
+ border-radius:100%;
252
+ -moz-transition:all 0.1s ease;
253
+ -o-transition:all 0.1s ease;
254
+ -webkit-transition:all 0.1s ease;
255
+ transition:all 0.1s ease
256
+ }
257
+ .cb-radio i {
258
+ top:50%;
259
+ left:50%;
260
+ width:6px;
261
+ height:6px;
262
+ margin-top:-3px;
263
+ margin-left:-3px;
264
+ position:absolute;
265
+ background-color:transparent;
266
+ -moz-border-radius:100%;
267
+ -webkit-border-radius:100%;
268
+ border-radius:100%;
269
+ -moz-transform:scale(0.05, 5);
270
+ -ms-transform:scale(0.05, 5);
271
+ -webkit-transform:scale(0.05, 5);
272
+ transform:scale(0.05, 5);
273
+ -moz-transition:all 0.2s ease;
274
+ -o-transition:all 0.2s ease;
275
+ -webkit-transition:all 0.2s ease;
276
+ transition:all 0.2s ease
277
+ }
278
+ .cb-checkbox.cb-sm, .cb-radio.cb-sm {
279
+ line-height:14px
280
+ }
281
+ .cb-checkbox.cb-md, .cb-radio.cb-md {
282
+ line-height:24px
283
+ }
284
+ .cb-checkbox.cb-lg, .cb-radio.cb-lg {
285
+ line-height:30px
286
+ }
287
+ .cb-checkbox.cb-sm i:before {
288
+ top:4px;
289
+ left:1px
290
+ }
291
+ .cb-checkbox.cb-sm i:after {
292
+ left:5px
293
+ }
294
+ .cb-checkbox.cb-md i:before {
295
+ top:10px;
296
+ left:5px
297
+ }
298
+ .cb-checkbox.cb-md i:after {
299
+ bottom:6px;
300
+ left:11px
301
+ }
302
+ .cb-checkbox.checked .cb-inner {
303
+ border-color:#0073aa;
304
+ background-color:#00a0d2;
305
+ box-shadow: 0 1px 0 rgba(120, 200, 230, 0.5) inset, 0 1px 0 rgba(0, 0, 0, 0.15);
306
+ }
307
+ .cb-checkbox.checked:hover .cb-inner {
308
+ background-color:#0091cd
309
+ }
310
+ .cb-checkbox.checked.cb-sm i:before {
311
+ top:4px;
312
+ left:1px
313
+ }
314
+ .cb-checkbox.checked.cb-sm i:after {
315
+ height:9px
316
+ }
317
+ .cb-checkbox.checked.cb-md i:before {
318
+ top:10px;
319
+ left:4px;
320
+ height:8px
321
+ }
322
+ .cb-checkbox.checked.cb-md i:after {
323
+ bottom:6px;
324
+ left:11px;
325
+ height:16px
326
+ }
327
+ .cb-checkbox.checked.cb-lg i:before {
328
+ top:11px;
329
+ left:6px;
330
+ height:12px
331
+ }
332
+ .cb-checkbox.checked.cb-lg i:after {
333
+ left:14px;
334
+ bottom:7px;
335
+ height:20px
336
+ }
337
+ .cb-checkbox.checked i:before {
338
+ top:6px;
339
+ left:2px;
340
+ height:6px
341
+ }
342
+ .cb-checkbox.checked i:after {
343
+ height:12px
344
+ }
345
+ .cb-radio.checked .cb-inner {
346
+ background:#fff;
347
+ box-shadow:0 0 3px #efefef
348
+ }
349
+ .cb-radio.checked i {
350
+ -moz-transform:scale(1.1, 1.1);
351
+ -ms-transform:scale(1.1, 1.1);
352
+ -webkit-transform:scale(1.1, 1.1);
353
+ transform:scale(1.1, 1.1);
354
+ background-color:#00a0d2
355
+ }
356
+ .cb-checkbox:hover .cb-inner, .cb-radio:hover .cb-inner {
357
+ border-color:#0073aa
358
+ }
359
+ .cb-switcher {
360
+ display:inline-block;
361
+ border:1px solid #eee;
362
+ background-color:#fff;
363
+ width:95px;
364
+ height:35px;
365
+ position:relative;
366
+ -moz-border-radius:20px;
367
+ -webkit-border-radius:20px;
368
+ border-radius:20px;
369
+ -moz-transition:background 0.4s ease;
370
+ -o-transition:background 0.4s ease;
371
+ -webkit-transition:background 0.4s ease;
372
+ transition:background 0.4s ease
373
+ }
374
+ .cb-switcher, .cb-switcher * {
375
+ cursor:pointer
376
+ }
377
+ .cb-switcher ::-moz-selection {
378
+ background-color:transparent
379
+ }
380
+ .cb-switcher ::selection {
381
+ background-color:transparent
382
+ }
383
+ .cb-switcher .cb-state {
384
+ z-index:1;
385
+ text-align:center;
386
+ font-size:12px
387
+ }
388
+ .cb-switcher .cb-state, .cb-switcher:before {
389
+ width:34px;
390
+ height:34px;
391
+ line-height:34px;
392
+ position:absolute;
393
+ left:0;
394
+ top:-1px;
395
+ -moz-border-radius:100%;
396
+ -webkit-border-radius:100%;
397
+ border-radius:100%;
398
+ -moz-transition:all 0.4s ease;
399
+ -o-transition:all 0.4s ease;
400
+ -webkit-transition:all 0.4s ease;
401
+ transition:all 0.4s ease
402
+ }
403
+ .cb-switcher:before {
404
+ content:"";
405
+ background-color:#eee;
406
+ -moz-box-shadow:1px 1px 1px rgba(0, 0, 0, 0.1);
407
+ -webkit-box-shadow:1px 1px 1px rgba(0, 0, 0, 0.1);
408
+ box-shadow:1px 1px 1px rgba(0, 0, 0, 0.1)
409
+ }
410
+ .cb-switcher.checked {
411
+ background-color:#00a0d2
412
+ }
413
+ .cb-switcher.checked .cb-state, .cb-switcher.checked:before {
414
+ left:60px;
415
+ color:#00a0d2
416
+ }
417
+ .cb-switcher.checked:before {
418
+ background-color:#fff;
419
+ -moz-box-shadow:-1px 1px 1px rgba(0, 0, 0, 0.1);
420
+ -webkit-box-shadow:-1px 1px 1px rgba(0, 0, 0, 0.1);
421
+ box-shadow:-1px 1px 1px rgba(0, 0, 0, 0.1)
422
+ }
423
+ .cb-switcher.checked .inner-switcher:before {
424
+ border-top-color:#0073aa
425
+ }
426
+ .cb-switcher.checked .inner-switcher:after {
427
+ border-bottom-color:#0073aa
428
+ }
429
+ .cb-switcher .inner-switcher:before, .cb-switcher .inner-switcher:after {
430
+ content:"";
431
+ position:absolute;
432
+ left:50%;
433
+ width:0;
434
+ height:0;
435
+ z-index:2;
436
+ margin-left:-20px;
437
+ border-left:20px solid transparent;
438
+ border-right:20px solid transparent;
439
+ -moz-transition:border 0.4s ease;
440
+ -o-transition:border 0.4s ease;
441
+ -webkit-transition:border 0.4s ease;
442
+ transition:border 0.4s ease
443
+ }
444
+ .cb-switcher .inner-switcher:before {
445
+ border-top:17px solid #fff;
446
+ top:0
447
+ }
448
+ .cb-switcher .inner-switcher:after {
449
+ border-bottom:17px solid #fff;
450
+ bottom:0
451
+ }
452
+ .cb-state {
453
+ color:#ccc;
454
+ display:inline-block
455
+ }
456
+ .cb-switcher-group .cb-state {
457
+ position:relative;
458
+ top:7px
459
+ }
460
+ .is-hidden {
461
+ display:none !important;
462
+ visibility:hidden !important
463
+ }
464
+ output {
465
+ display: block;
466
+ font-size: 30px;
467
+ font-weight: bold;
468
+ text-align: center;
469
+ margin: 30px 0;
470
+ width: 100%;
471
+ }
includes/class-frontend.php ADDED
@@ -0,0 +1,279 @@
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) )
3
+ exit;
4
+
5
+ new Responsive_Lightbox_Frontend();
6
+
7
+ /**
8
+ * Responsive Lightbox frontend class.
9
+ *
10
+ * @class Responsive_Lightbox_Frontend
11
+ */
12
+ class Responsive_Lightbox_Frontend {
13
+
14
+ private $options = array();
15
+ private $defaults = array();
16
+ private $gallery_no = 0;
17
+
18
+ public function __construct() {
19
+ // set instance
20
+ Responsive_Lightbox()->frontend = $this;
21
+
22
+ // set vars
23
+ $this->defaults = Responsive_Lightbox()->defaults;
24
+ $this->options = Responsive_Lightbox()->options;
25
+
26
+ // filters
27
+ add_filter( 'post_gallery', array( &$this, 'gallery_attributes' ), 1000, 10, 2 );
28
+
29
+ if ( $this->options['settings']['galleries'] === true ) {
30
+ add_filter( 'wp_get_attachment_link', array( &$this, 'add_gallery_lightbox_selector' ), 1000, 6 );
31
+ }
32
+
33
+ if ( $this->options['settings']['videos'] === true ) {
34
+ add_filter( 'the_content', array( &$this, 'add_videos_lightbox_selector' ) );
35
+ }
36
+
37
+ if ( $this->options['settings']['image_links'] === true || $this->options['settings']['images_as_gallery'] === true ) {
38
+ add_filter( 'the_content', array( &$this, 'add_links_lightbox_selector' ) );
39
+ }
40
+
41
+ if ( $this->options['settings']['force_custom_gallery'] === true ) {
42
+ add_filter( 'post_gallery', array( &$this, 'add_tiled_gallery_lightbox_selector' ), 2000, 10, 2 );
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Add lightbox to videos
48
+ *
49
+ * @param mixed $content
50
+ * @return mixed
51
+ */
52
+ public function add_videos_lightbox_selector( $content ) {
53
+ preg_match_all( '/<a(.*?)href=(?:\'|")((?:(?:http|https):\/\/)?(?:www\.)?(((?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/watch\?.+&v=))([\w-]{11})(?:.+))|(vimeo\.com\/[0-9]{8,})))(?:\'|")(.*?)>/i', $content, $links );
54
+
55
+ if ( isset( $links[0] ) ) {
56
+ foreach ( $links[0] as $id => $link ) {
57
+ if ( preg_match( '/<a.*?rel=(?:\'|")(.*?)(?:\'|").*?>/', $link, $result ) === 1 ) {
58
+ if ( isset( $result[1] ) ) {
59
+ $new_rels = array();
60
+ $rels = explode( ' ', $result[1] );
61
+
62
+ if ( in_array( $this->options['settings']['selector'], $rels, true ) ) {
63
+ foreach ( $rels as $no => $rel ) {
64
+ if ( $rel !== $this->options['settings']['selector'] )
65
+ $new_rels[] = $rel;
66
+ }
67
+
68
+ $content = str_replace( $link, preg_replace( '/rel=(?:\'|")(.*?)(?:\'|")/', 'rel="' . ( ! empty( $new_rel ) ? simplode( ' ', $new_rels ) . ' ' : '') . $this->options['settings']['selector'] . '-video-' . $id . '"', $link ), $content );
69
+ } else
70
+ $content = str_replace( $link, preg_replace( '/rel=(?:\'|")(.*?)(?:\'|")/', 'rel="' . ( $result[1] !== '' ? $result[1] . ' ' : '' ) . $this->options['settings']['selector'] . '-video-' . $id . '"', $link ), $content );
71
+ }
72
+ } else
73
+ $content = str_replace( $link, '<a' . $links[1][$id] . 'href="' . $links[2][$id] . '"' . $links[6][$id] . ' rel="' . $this->options['settings']['selector'] . '-video-' . $id . '">', $content );
74
+ }
75
+ }
76
+
77
+ return $content;
78
+ }
79
+
80
+ /**
81
+ * Add lightbox to to image links
82
+ *
83
+ * @param mixed $content
84
+ * @return mixed
85
+ */
86
+ public function add_links_lightbox_selector( $content ) {
87
+ preg_match_all( '/<a(.*?)href=(?:\'|")([^<]*?).(bmp|gif|jpeg|jpg|png)(?:\'|")(.*?)>/i', $content, $links );
88
+
89
+ if ( isset( $links[0] ) ) {
90
+ if ( $this->options['settings']['images_as_gallery'] === true )
91
+ $rel_hash = '[gallery-' . $this->generate_password( 4 ) . ']';
92
+
93
+ foreach ( $links[0] as $id => $link ) {
94
+ if ( preg_match( '/<a.*?rel=(?:\'|")(.*?)(?:\'|").*?>/', $link, $result ) === 1 ) {
95
+ if ( $this->options['settings']['images_as_gallery'] === true ) {
96
+ $content = str_replace( $link, preg_replace( '/rel=(?:\'|")(.*?)(?:\'|")/', 'rel="' . $this->options['settings']['selector'] . $rel_hash . '"' . ( $this->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ), $link ), $content );
97
+ } else {
98
+ if ( isset( $result[1] ) ) {
99
+ $new_rels = array();
100
+ $rels = explode( ' ', $result[1] );
101
+
102
+ if ( in_array( $this->options['settings']['selector'], $rels, true ) ) {
103
+ foreach ( $rels as $no => $rel ) {
104
+ if ( $rel !== $this->options['settings']['selector'] )
105
+ $new_rels[] = $rel;
106
+ }
107
+
108
+ $content = str_replace( $link, preg_replace( '/rel=(?:\'|")(.*?)(?:\'|")/', 'rel="' . ( ! empty( $new_rels ) ? implode( ' ', $new_rels ) . ' ' : '' ) . $this->options['settings']['selector'] . '-' . $id . '"' . ( $this->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ), $link ), $content );
109
+ } else
110
+ $content = str_replace( $link, preg_replace( '/rel=(?:\'|")(.*?)(?:\'|")/', 'rel="' . ( $result[1] !== '' ? $result[1] . ' ' : '' ) . $this->options['settings']['selector'] . '-' . $id . '"' . ( $this->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ), $link ), $content );
111
+ }
112
+ }
113
+ } else
114
+ $content = str_replace( $link, '<a' . $links[1][$id] . 'href="' . $links[2][$id] . '.' . $links[3][$id] . '"' . $links[4][$id] . ' rel="' . $this->options['settings']['selector'] . ( $this->options['settings']['images_as_gallery'] === true ? $rel_hash : '-' . $id ) . '"' . ( $this->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ) . '>', $content );
115
+ }
116
+ }
117
+
118
+ return $content;
119
+ }
120
+
121
+ /**
122
+ * Add lightbox to gallery
123
+ */
124
+ public function add_gallery_lightbox_selector( $link, $id, $size, $permalink, $icon, $text ) {
125
+
126
+ // gallery image title
127
+ $title = '';
128
+
129
+ if ( ( $title_arg = $this->options['settings']['gallery_image_title'] ) !== 'default' ) {
130
+ $title_arg = apply_filters( 'rl_lightbox_attachment_image_title_arg', $title_arg, $link, $id );
131
+ $title = wp_strip_all_tags( trim( $this->get_attachment_title( $id, $title_arg ) ) );
132
+ }
133
+
134
+ if ( $title ) {
135
+ $link = str_replace( '<a href', '<a title="'. $title .'" href', $link );
136
+ }
137
+
138
+ $link = ( preg_match( '/<a.*? rel=("|\').*?("|\')>/', $link ) === 1 ? preg_replace( '/(<a.*? rel=(?:"|\').*?)((?:"|\').*?>)/', '$1 ' . $this->options['settings']['selector'] . '[gallery-' . $this->gallery_no . ']' . '$2', $link ) : preg_replace( '/(<a.*?)>/', '$1 rel="' . $this->options['settings']['selector'] . '[gallery-' . $this->gallery_no . ']' . '">', $link ) );
139
+
140
+ $link = ( preg_match( '/<a.*? href=("|\').*?("|\')>/', $link ) === 1 ? preg_replace( '/(<a.*? href=(?:"|\')).*?((?:"|\').*?>)/', '$1' . wp_get_attachment_url( $id ) . '$2', $link ) : preg_replace( '/(<a.*?)>/', '$1 href="' . wp_get_attachment_url( $id ) . '">', $link ) );
141
+
142
+ // gallery image size
143
+ if ( $permalink && $this->options['settings']['gallery_image_size'] !== 'full' ) {
144
+ $image = wp_get_attachment_image_src( $id, $this->options['settings']['gallery_image_size'] );
145
+ $link = preg_replace( '/href=\'(.*?)\'/', 'href=\'' . $image[0] . '\'', $link );
146
+ }
147
+
148
+ return apply_filters( 'rl_lightbox_attachment_link', $link, $id, $size, $permalink, $icon, $text );
149
+ }
150
+
151
+ /**
152
+ * Add lightbox to Jetpack tiled gallery
153
+ *
154
+ * @param mixed $content
155
+ * @param array $attr
156
+ * @return mixed
157
+ */
158
+ public function add_tiled_gallery_lightbox_selector( $content, $attr ) {
159
+ preg_match_all( '/<a(.*?)href=(?:\'|")([^<]*?).(bmp|gif|jpeg|jpg|png)(?:\'|")(.*?)>/i', $content, $links );
160
+
161
+ if ( isset( $links[0] ) ) {
162
+
163
+ foreach ( $links[0] as $id => $link ) {
164
+
165
+ // gallery image title
166
+ $title = '';
167
+
168
+ if ( ( $title_arg = $this->options['settings']['gallery_image_title'] ) !== 'default' ) {
169
+
170
+ $image_id = (int) $this->get_attachment_id_by_url( $links[2][$id] . '.' . $links[3][$id] );
171
+
172
+ if ( $image_id ) {
173
+ $title_arg = apply_filters( 'rl_lightbox_attachment_image_title_arg', $title_arg, $image_id, $links[2][$id] . '.' . $links[3][$id] );
174
+ $title = wp_strip_all_tags( trim( $this->get_attachment_title( $image_id, $title_arg ) ) );
175
+ }
176
+ }
177
+
178
+ if ( preg_match( '/<a.*?rel=(?:\'|")(.*?)(?:\'|").*?>/', $link, $result ) === 1 ) {
179
+ $content = str_replace( $link, preg_replace( '/rel=(?:\'|")(.*?)(?:\'|")/', 'rel="' . $this->options['settings']['selector'] . '"' . ( ! empty ( $title ) ? ' title="' . $title . '"' : '' ) . ( $this->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ), $link ), $content );
180
+ } else {
181
+ $content = str_replace( $link, '<a' . $links[1][$id] . 'href="' . $links[2][$id] . '.' . $links[3][$id] . '"' . $links[4][$id] . ' rel="' . $this->options['settings']['selector'] . '"' . ( $this->options['settings']['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $id . '"' : '' ) . ( ! empty ( $title ) ? ' title="' . $title . '"' : '' ) . '>', $content );
182
+ }
183
+ }
184
+ }
185
+ return $content;
186
+ }
187
+
188
+ /**
189
+ * Get attachment title function
190
+ *
191
+ * @param int $id
192
+ * @param string $title_arg
193
+ * @return string
194
+ */
195
+ private function get_attachment_title( $id, $title_arg ) {
196
+
197
+ if ( empty( $title_arg ) || empty( $id ) ) {
198
+ return false;
199
+ }
200
+
201
+ switch( $title_arg ) {
202
+ case 'title':
203
+ $title = get_the_title( $id );
204
+ break;
205
+ case 'caption':
206
+ $title = get_post_field( 'post_excerpt', $id ) ;
207
+ break;
208
+ case 'alt':
209
+ $title = get_post_meta( $id, '_wp_attachment_image_alt', true );
210
+ break;
211
+ case 'description':
212
+ $title = get_post_field( 'post_content', $id ) ;
213
+ break;
214
+ default:
215
+ $title = '';
216
+ }
217
+
218
+ return apply_filters( 'rl_get_attachment_title', $title, $id, $title_arg );
219
+
220
+ }
221
+
222
+ /**
223
+ * Get attachment id by url function, adjusted to work cropped images
224
+ *
225
+ * @param string $url
226
+ * @return int
227
+ */
228
+ private function get_attachment_id_by_url( $url ) {
229
+ $post_id = attachment_url_to_postid( $url );
230
+
231
+ if ( ! $post_id ) {
232
+ $dir = wp_upload_dir();
233
+ $path = $url;
234
+
235
+ if ( 0 === strpos( $path, $dir['baseurl'] . '/' ) ) {
236
+ $path = substr( $path, strlen( $dir['baseurl'] . '/' ) );
237
+ }
238
+
239
+ if ( preg_match( '/^(.*)(\-\d*x\d*)(\.\w{1,})/i', $path, $matches ) ){
240
+ $url = $dir['baseurl'] . '/' . $matches[1] . $matches[3];
241
+ $post_id = attachment_url_to_postid( $url );
242
+ }
243
+ }
244
+
245
+ return (int) $post_id;
246
+ }
247
+
248
+ /**
249
+ * Helper: generate password without wp_rand() and DB call it uses
250
+ *
251
+ * @param int $length
252
+ * @return string
253
+ */
254
+ private function generate_password( $length = 64 ) {
255
+ $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
256
+ $password = '';
257
+
258
+ for( $i = 0; $i < $length; $i++ ) {
259
+ $password .= substr( $chars, mt_rand( 0, strlen( $chars ) - 1 ), 1 );
260
+ }
261
+
262
+ return $password;
263
+ }
264
+
265
+ /**
266
+ * Helper: gallery number function
267
+ *
268
+ * @param mixed $content
269
+ * @param array $attr
270
+ * @return mixed
271
+ */
272
+ public function gallery_attributes( $content, $attr ) {
273
+
274
+ ++ $this->gallery_no;
275
+
276
+ return $content;
277
+ }
278
+
279
+ }
includes/class-settings.php ADDED
@@ -0,0 +1,1231 @@
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) )
3
+ exit;
4
+
5
+ new Responsive_Lightbox_Settings();
6
+
7
+ /**
8
+ * Responsive Lightbox settings class.
9
+ *
10
+ * @class Responsive_Lightbox_Settings
11
+ */
12
+ class Responsive_Lightbox_Settings {
13
+
14
+ private $settings = array();
15
+ private $scripts = array();
16
+ private $options = array();
17
+ private $defaults = array();
18
+ private $tabs = array();
19
+ private $choices = array();
20
+ private $loading_places = array();
21
+
22
+ public function __construct() {
23
+
24
+ // set instance
25
+ Responsive_Lightbox()->settings = $this;
26
+
27
+ // set vars
28
+ $this->defaults = Responsive_Lightbox()->defaults;
29
+ $this->options = Responsive_Lightbox()->options;
30
+
31
+ // actions
32
+ add_action( 'admin_init', array( &$this, 'register_settings' ) );
33
+ add_action( 'admin_menu', array( &$this, 'admin_menu_options' ) );
34
+ add_action( 'after_setup_theme', array( &$this, 'load_defaults' ) );
35
+ }
36
+
37
+ /**
38
+ * Load default settings.
39
+ *
40
+ * @return void
41
+ */
42
+ public function load_defaults() {
43
+
44
+ $this->scripts = array(
45
+ 'prettyphoto' => array(
46
+ 'name' => __( 'prettyPhoto', 'responsive-lightbox' ),
47
+ 'animation_speeds' => array(
48
+ 'slow' => __( 'slow', 'responsive-lightbox' ),
49
+ 'normal' => __( 'normal', 'responsive-lightbox' ),
50
+ 'fast' => __( 'fast', 'responsive-lightbox' )
51
+ ),
52
+ 'themes' => array(
53
+ 'pp_default' => __( 'default', 'responsive-lightbox' ),
54
+ 'light_rounded' => __( 'light rounded', 'responsive-lightbox' ),
55
+ 'dark_rounded' => __( 'dark rounded', 'responsive-lightbox' ),
56
+ 'light_square' => __( 'light square', 'responsive-lightbox' ),
57
+ 'dark_square' => __( 'dark square', 'responsive-lightbox' ),
58
+ 'facebook' => __( 'facebook', 'responsive-lightbox' )
59
+ ),
60
+ 'wmodes' => array(
61
+ 'window' => __( 'window', 'responsive-lightbox' ),
62
+ 'transparent' => __( 'transparent', 'responsive-lightbox' ),
63
+ 'opaque' => __( 'opaque', 'responsive-lightbox' ),
64
+ 'direct' => __( 'direct', 'responsive-lightbox' ),
65
+ 'gpu' => __( 'gpu', 'responsive-lightbox' )
66
+ )
67
+ ),
68
+ 'swipebox' => array(
69
+ 'name' => __( 'SwipeBox', 'responsive-lightbox' ),
70
+ 'animations' => array(
71
+ 'css' => __( 'CSS', 'responsive-lightbox' ),
72
+ 'jquery' => __( 'jQuery', 'responsive-lightbox' )
73
+ )
74
+ ),
75
+ 'fancybox' => array(
76
+ 'name' => __( 'FancyBox', 'responsive-lightbox' ),
77
+ 'transitions' => array(
78
+ 'elastic' => __( 'elastic', 'responsive-lightbox' ),
79
+ 'fade' => __( 'fade', 'responsive-lightbox' ),
80
+ 'none' => __( 'none', 'responsive-lightbox' )
81
+ ),
82
+ 'scrollings' => array(
83
+ 'auto' => __( 'auto', 'responsive-lightbox' ),
84
+ 'yes' => __( 'yes', 'responsive-lightbox' ),
85
+ 'no' => __( 'no', 'responsive-lightbox' )
86
+ ),
87
+ 'easings' => array(
88
+ 'swing' => __( 'swing', 'responsive-lightbox' ),
89
+ 'linear' => __( 'linear', 'responsive-lightbox' )
90
+ ),
91
+ 'positions' => array(
92
+ 'outside' => __( 'outside', 'responsive-lightbox' ),
93
+ 'inside' => __( 'inside', 'responsive-lightbox' ),
94
+ 'over' => __( 'over', 'responsive-lightbox' )
95
+ )
96
+ ),
97
+ 'nivo' => array(
98
+ 'name' => __( 'Nivo Lightbox', 'responsive-lightbox' ),
99
+ 'effects' => array(
100
+ 'fade' => __( 'fade', 'responsive-lightbox' ),
101
+ 'fadeScale' => __( 'fade scale', 'responsive-lightbox' ),
102
+ 'slideLeft' => __( 'slide left', 'responsive-lightbox' ),
103
+ 'slideRight' => __( 'slide right', 'responsive-lightbox' ),
104
+ 'slideUp' => __( 'slide up', 'responsive-lightbox' ),
105
+ 'slideDown' => __( 'slide down', 'responsive-lightbox' ),
106
+ 'fall' => __( 'fall', 'responsive-lightbox' )
107
+ )
108
+ ),
109
+ 'imagelightbox' => array(
110
+ 'name' => __( 'Image Lightbox', 'responsive-lightbox' )
111
+ )
112
+ );
113
+
114
+ $this->choices = array(
115
+ 'yes' => __( 'Enable', 'responsive-lightbox' ),
116
+ 'no' => __( 'Disable', 'responsive-lightbox' )
117
+ );
118
+
119
+ $this->gallery_image_titles = array(
120
+ 'default' => __( 'None (default)', 'responsive-lightbox' ),
121
+ 'title' => __( 'Image Title', 'responsive-lightbox' ),
122
+ 'caption' => __( 'Image Caption', 'responsive-lightbox' ),
123
+ 'alt' => __( 'Image Alt Text', 'responsive-lightbox' ),
124
+ 'description' => __( 'Image Description', 'responsive-lightbox' )
125
+ );
126
+
127
+ $this->loading_places = array(
128
+ 'header' => __( 'Header', 'responsive-lightbox' ),
129
+ 'footer' => __( 'Footer', 'responsive-lightbox' )
130
+ );
131
+
132
+ // get scripts
133
+ foreach ( $this->scripts as $key => $value ) {
134
+ $scripts[$key] = $value['name'];
135
+ }
136
+
137
+ // get image sizes
138
+ $sizes = apply_filters( 'image_size_names_choose', array(
139
+ 'thumbnail' => __( 'Thumbnail', 'responsive-lightbox' ),
140
+ 'medium' => __( 'Medium', 'responsive-lightbox' ),
141
+ 'large' => __( 'Large', 'responsive-lightbox' ),
142
+ 'full' => __( 'Full Size (default)', 'responsive-lightbox' ),
143
+ ) );
144
+
145
+ $this->settings = array(
146
+ 'settings' => array(
147
+ 'option_group' => 'responsive_lightbox_settings',
148
+ 'option_name' => 'responsive_lightbox_settings',
149
+ // 'callback' => array( &$this, 'validate_options' ),
150
+ 'sections' => array(
151
+ 'responsive_lightbox_settings' => array(
152
+ 'title' => __( 'General settings', 'responsive-lightbox' ),
153
+ // 'callback' => '',
154
+ // 'page' => '',
155
+ ),
156
+ ),
157
+ 'prefix' => 'rl',
158
+ 'fields' => array(
159
+ 'script' => array(
160
+ // 'name' => '',
161
+ 'title' => __( 'Lightbox script', 'responsive-lightbox' ),
162
+ // 'callback' => '',
163
+ // 'page' => '',
164
+ 'section' => 'responsive_lightbox_settings',
165
+ 'type' => 'radio',
166
+ 'label' => '',
167
+ 'description' => __( 'Select your preffered ligthbox effect script.', 'responsive-lightbox' ),
168
+ 'options' => $scripts,
169
+ // 'options_cb' => '',
170
+ // 'id' => '',
171
+ // 'class' => array(),
172
+ ),
173
+ 'selector' => array(
174
+ 'title' => __( 'Selector', 'responsive-lightbox' ),
175
+ 'section' => 'responsive_lightbox_settings',
176
+ 'type' => 'text',
177
+ 'description' => __( 'Enter the rel selector lightbox effect will be applied to.', 'responsive-lightbox' ),
178
+ ),
179
+ 'image_links' => array(
180
+ 'title' => __( 'Image links', 'responsive-lightbox' ),
181
+ 'section' => 'responsive_lightbox_settings',
182
+ 'type' => 'boolean',
183
+ 'label' => __( 'Add lightbox to WordPress image links by default.', 'responsive-lightbox' ),
184
+ ),
185
+ 'images_as_gallery' => array(
186
+ 'title' => __( 'Single images as gallery', 'responsive-lightbox' ),
187
+ 'section' => 'responsive_lightbox_settings',
188
+ 'type' => 'boolean',
189
+ 'label' => __( 'Display single post images as a gallery.', 'responsive-lightbox' ),
190
+ ),
191
+ 'galleries' => array(
192
+ 'title' => __( 'Galleries', 'responsive-lightbox' ),
193
+ 'section' => 'responsive_lightbox_settings',
194
+ 'type' => 'boolean',
195
+ 'label' => __( 'Add lightbox to WordPress image galleries by default.', 'responsive-lightbox' ),
196
+ ),
197
+ 'gallery_image_size' => array(
198
+ 'title' => __( 'Gallery image size', 'responsive-lightbox' ),
199
+ 'section' => 'responsive_lightbox_settings',
200
+ 'type' => 'select',
201
+ 'description' => __( 'Select image size for gallery image links.', 'responsive-lightbox' ),
202
+ 'options' => $sizes,
203
+ ),
204
+ 'gallery_image_title' => array(
205
+ 'title' => __( 'Gallery image title', 'responsive-lightbox' ),
206
+ 'section' => 'responsive_lightbox_settings',
207
+ 'type' => 'select',
208
+ 'description' => __( 'Select title for images in native WordPress galleries.', 'responsive-lightbox' ),
209
+ 'options' => $this->gallery_image_titles,
210
+ ),
211
+ 'force_custom_gallery' => array(
212
+ 'title' => __( 'Force gallery lightbox', 'responsive-lightbox' ),
213
+ 'section' => 'responsive_lightbox_settings',
214
+ 'type' => 'boolean',
215
+ 'label' => __( 'Try to force lightbox for custom WP gallery replacements, like Jetpack tiled galleries.', 'responsive-lightbox' ),
216
+ ),
217
+ 'videos' => array(
218
+ 'title' => __( 'Video links', 'responsive-lightbox' ),
219
+ 'section' => 'responsive_lightbox_settings',
220
+ 'type' => 'boolean',
221
+ 'label' => __( 'Add lightbox to YouTube and Vimeo video links by default.', 'responsive-lightbox' ),
222
+ ),
223
+ 'enable_custom_events' => array(
224
+ 'title' => __( 'Custom events', 'responsive-lightbox' ),
225
+ 'section' => 'responsive_lightbox_settings',
226
+ 'type' => 'multiple',
227
+ 'fields' => array(
228
+ 'enable_custom_events' => array(
229
+ 'type' => 'boolean',
230
+ 'label' => __( 'Enable triggering lightbox on custom jQuery events.', 'responsive-lightbox' ),
231
+ ),
232
+ 'custom_events' => array(
233
+ 'type' => 'text',
234
+ 'description' => __( 'Enter a space separated list of events.', 'responsive-lightbox' ),
235
+ )
236
+ ),
237
+ ),
238
+ 'loading_place' => array(
239
+ 'title' => __( 'Loading place', 'responsive-lightbox' ),
240
+ 'section' => 'responsive_lightbox_settings',
241
+ 'type' => 'radio',
242
+ 'description' => __( 'Select where all the lightbox scripts should be placed.', 'responsive-lightbox' ),
243
+ 'options' => $this->loading_places,
244
+ ),
245
+ 'deactivation_delete' => array(
246
+ 'title' => __( 'Delete data', 'responsive-lightbox' ),
247
+ 'section' => 'responsive_lightbox_settings',
248
+ 'type' => 'boolean',
249
+ 'label' => __( 'Delete all plugin settings on deactivation.', 'responsive-lightbox' ),
250
+ ),
251
+ ),
252
+ ),
253
+ 'configuration' => array(
254
+ 'option_group' => 'responsive_lightbox_configuration',
255
+ 'option_name' => 'responsive_lightbox_configuration',
256
+ // 'callback' => array( &$this, 'validate_options' ),
257
+ 'sections' => array(
258
+ 'responsive_lightbox_configuration' => array(
259
+ 'title' => __( 'Lightbox settings', 'responsive-lightbox' ) . ': ' . $this->scripts[$this->options['settings']['script']]['name'],
260
+ // 'callback' => '',
261
+ // 'page' => '',
262
+ ),
263
+ ),
264
+ 'prefix' => 'rl',
265
+ 'fields' => array(
266
+ )
267
+ )
268
+ );
269
+
270
+ switch ( $this->options['settings']['script'] ) {
271
+
272
+ case ( 'swipebox' ) :
273
+
274
+ $this->settings['configuration']['prefix'] = 'rl_sb';
275
+ $this->settings['configuration']['fields'] = array(
276
+ 'animation' => array(
277
+ 'title' => __( 'Animation type', 'responsive-lightbox' ),
278
+ 'section' => 'responsive_lightbox_configuration',
279
+ 'type' => 'radio',
280
+ 'label' => '',
281
+ 'description' => __( 'Select a method of applying a lightbox effect.', 'responsive-lightbox' ),
282
+ 'options' => $this->scripts['swipebox']['animations'],
283
+ 'parent' => 'swipebox'
284
+ ),
285
+ 'force_png_icons' => array(
286
+ 'title' => __( 'Force PNG icons', 'responsive-lightbox' ),
287
+ 'section' => 'responsive_lightbox_configuration',
288
+ 'type' => 'boolean',
289
+ 'label' => __( 'Enable this if you\'re having problems with navigation icons not visible on some devices.', 'responsive-lightbox' ),
290
+ 'parent' => 'swipebox'
291
+ ),
292
+ 'hide_close_mobile' => array(
293
+ 'title' => __( 'Hide close on mobile', 'responsive-lightbox' ),
294
+ 'section' => 'responsive_lightbox_configuration',
295
+ 'type' => 'boolean',
296
+ 'label' => __( 'Hide the close button on mobile devices.', 'responsive-lightbox' ),
297
+ 'parent' => 'swipebox'
298
+ ),
299
+ 'hide_bars' => array(
300
+ 'title' => __( 'Top and bottom bars', 'responsive-lightbox' ),
301
+ 'section' => 'responsive_lightbox_configuration',
302
+ 'type' => 'multiple',
303
+ 'fields' => array(
304
+ 'hide_bars' => array(
305
+ 'type' => 'boolean',
306
+ 'label' => __( 'Hide top and bottom bars after a period of time.', 'responsive-lightbox' ),
307
+ 'parent' => 'swipebox'
308
+ ),
309
+ 'hide_bars_delay' => array(
310
+ 'type' => 'number',
311
+ 'description' => __( 'Enter the time after which the top and bottom bars will be hidden (when hiding is enabled).', 'responsive-lightbox' ),
312
+ 'append' => 'ms',
313
+ 'parent' => 'swipebox'
314
+ )
315
+ )
316
+ ),
317
+ 'video_max_width' => array(
318
+ 'title' => __( 'Video max width', 'responsive-lightbox' ),
319
+ 'section' => 'responsive_lightbox_configuration',
320
+ 'type' => 'number',
321
+ 'description' => __( 'Enter the max video width in a lightbox.', 'responsive-lightbox' ),
322
+ 'append' => 'px',
323
+ 'parent' => 'swipebox'
324
+ ),
325
+ 'loop_at_end' => array(
326
+ 'title' => __( 'Loop at end', 'responsive-lightbox' ),
327
+ 'section' => 'responsive_lightbox_configuration',
328
+ 'type' => 'boolean',
329
+ 'label' => __( 'True will return to the first image after the last image is reached.', 'responsive-lightbox' ),
330
+ 'parent' => 'swipebox'
331
+ ),
332
+ );
333
+
334
+ break;
335
+
336
+ case ( 'prettyphoto' ) :
337
+
338
+ $this->settings['configuration']['prefix'] = 'rl_pp';
339
+ $this->settings['configuration']['fields'] = array(
340
+ 'animation_speed' => array(
341
+ 'title' => __( 'Animation speed', 'responsive-lightbox' ),
342
+ 'section' => 'responsive_lightbox_configuration',
343
+ 'type' => 'radio',
344
+ 'label' => '',
345
+ 'description' => __( 'Select animation speed for lightbox effect.', 'responsive-lightbox' ),
346
+ 'options' => $this->scripts['prettyphoto']['animation_speeds'],
347
+ 'parent' => 'prettyphoto'
348
+ ),
349
+ 'slideshow' => array(
350
+ 'title' => __( 'Slideshow', 'responsive-lightbox' ),
351
+ 'section' => 'responsive_lightbox_configuration',
352
+ 'type' => 'multiple',
353
+ 'fields' => array(
354
+ 'slideshow' => array(
355
+ 'type' => 'boolean',
356
+ 'label' => __( 'Display images as slideshow', 'responsive-lightbox' ),
357
+ 'parent' => 'prettyphoto'
358
+ ),
359
+ 'slideshow_delay' => array(
360
+ 'type' => 'number',
361
+ 'description' => __( 'Enter time (in miliseconds).', 'responsive-lightbox' ),
362
+ 'append' => 'ms',
363
+ 'parent' => 'prettyphoto'
364
+ )
365
+ )
366
+ ),
367
+ 'slideshow_autoplay' => array(
368
+ 'title' => __( 'Slideshow autoplay', 'responsive-lightbox' ),
369
+ 'section' => 'responsive_lightbox_configuration',
370
+ 'type' => 'boolean',
371
+ 'label' => __( 'Automatically start slideshow.', 'responsive-lightbox' ),
372
+ 'parent' => 'prettyphoto'
373
+ ),
374
+ 'opacity' => array(
375
+ 'title' => __( 'Opacity', 'responsive-lightbox' ),
376
+ 'section' => 'responsive_lightbox_configuration',
377
+ 'type' => 'range',
378
+ 'description' => __( 'Value between 0 and 100, 100 for no opacity.', 'responsive-lightbox' ),
379
+ 'min' => 0,
380
+ 'max' => 100,
381
+ 'parent' => 'prettyphoto'
382
+ ),
383
+ 'show_title' => array(
384
+ 'title' => __( 'Show title', 'responsive-lightbox' ),
385
+ 'section' => 'responsive_lightbox_configuration',
386
+ 'type' => 'boolean',
387
+ 'label' => __( 'Display image title.', 'responsive-lightbox' ),
388
+ 'parent' => 'prettyphoto'
389
+ ),
390
+ 'allow_resize' => array(
391
+ 'title' => __( 'Allow resize big images', 'responsive-lightbox' ),
392
+ 'section' => 'responsive_lightbox_configuration',
393
+ 'type' => 'boolean',
394
+ 'label' => __( 'Resize the photos bigger than viewport.', 'responsive-lightbox' ),
395
+ 'parent' => 'prettyphoto'
396
+ ),
397
+ 'allow_expand' => array(
398
+ 'title' => __( 'Allow expand', 'responsive-lightbox' ),
399
+ 'section' => 'responsive_lightbox_configuration',
400
+ 'type' => 'boolean',
401
+ 'label' => __( 'Allow expanding images.', 'responsive-lightbox' ),
402
+ 'parent' => 'prettyphoto'
403
+ ),
404
+ 'width' => array(
405
+ 'title' => __( 'Video width', 'responsive-lightbox' ),
406
+ 'section' => 'responsive_lightbox_configuration',
407
+ 'type' => 'number',
408
+ 'append' => 'px',
409
+ 'parent' => 'prettyphoto'
410
+ ),
411
+ 'height' => array(
412
+ 'title' => __( 'Video height', 'responsive-lightbox' ),
413
+ 'section' => 'responsive_lightbox_configuration',
414
+ 'type' => 'number',
415
+ 'append' => 'px',
416
+ 'parent' => 'prettyphoto'
417
+ ),
418
+ 'theme' => array(
419
+ 'title' => __( 'Theme', 'responsive-lightbox' ),
420
+ 'section' => 'responsive_lightbox_configuration',
421
+ 'type' => 'radio',
422
+ 'description' => __( 'Select the theme for lightbox effect.', 'responsive-lightbox' ),
423
+ 'options' => $this->scripts['prettyphoto']['themes'],
424
+ 'parent' => 'prettyphoto'
425
+ ),
426
+ 'horizontal_padding' => array(
427
+ 'title' => __( 'Horizontal padding', 'responsive-lightbox' ),
428
+ 'section' => 'responsive_lightbox_configuration',
429
+ 'type' => 'number',
430
+ 'append' => 'px',
431
+ 'parent' => 'prettyphoto'
432
+ ),
433
+ 'hide_flash' => array(
434
+ 'title' => __( 'Hide Flash', 'responsive-lightbox' ),
435
+ 'section' => 'responsive_lightbox_configuration',
436
+ 'type' => 'boolean',
437
+ 'label' => __( 'Hide all the flash objects on a page. Enable this if flash appears over prettyPhoto.', 'responsive-lightbox' ),
438
+ 'parent' => 'prettyphoto'
439
+ ),
440
+ 'wmode' => array(
441
+ 'title' => __( 'Flash Window Mode (wmode)', 'responsive-lightbox' ),
442
+ 'section' => 'responsive_lightbox_configuration',
443
+ 'type' => 'radio',
444
+ 'description' => __( 'Select flash window mode.', 'responsive-lightbox' ),
445
+ 'options' => $this->scripts['prettyphoto']['wmodes'],
446
+ 'parent' => 'prettyphoto'
447
+ ),
448
+ 'video_autoplay' => array(
449
+ 'title' => __( 'Video autoplay', 'responsive-lightbox' ),
450
+ 'section' => 'responsive_lightbox_configuration',
451
+ 'type' => 'boolean',
452
+ 'label' => __( 'Automatically start videos.', 'responsive-lightbox' ),
453
+ 'parent' => 'prettyphoto'
454
+ ),
455
+ 'modal' => array(
456
+ 'title' => __( 'Modal', 'responsive-lightbox' ),
457
+ 'section' => 'responsive_lightbox_configuration',
458
+ 'type' => 'boolean',
459
+ 'label' => __( 'If set to true, only the close button will close the window.', 'responsive-lightbox' ),
460
+ 'parent' => 'prettyphoto'
461
+ ),
462
+ 'deeplinking' => array(
463
+ 'title' => __( 'Deeplinking', 'responsive-lightbox' ),
464
+ 'section' => 'responsive_lightbox_configuration',
465
+ 'type' => 'boolean',
466
+ 'label' => __( 'Allow prettyPhoto to update the url to enable deeplinking.', 'responsive-lightbox' ),
467
+ 'parent' => 'prettyphoto'
468
+ ),
469
+ 'overlay_gallery' => array(
470
+ 'title' => __( 'Overlay gallery', 'responsive-lightbox' ),
471
+ 'section' => 'responsive_lightbox_configuration',
472
+ 'type' => 'boolean',
473
+ 'label' => __( 'If enabled, a gallery will overlay the fullscreen image on mouse over.', 'responsive-lightbox' ),
474
+ 'parent' => 'prettyphoto'
475
+ ),
476
+ 'keyboard_shortcuts' => array(
477
+ 'title' => __( 'Keyboard shortcuts', 'responsive-lightbox' ),
478
+ 'section' => 'responsive_lightbox_configuration',
479
+ 'type' => 'boolean',
480
+ 'label' => __( 'Set to false if you open forms inside prettyPhoto.', 'responsive-lightbox' ),
481
+ 'parent' => 'prettyphoto'
482
+ ),
483
+ 'social' => array(
484
+ 'title' => __( 'Social (Twitter, Facebook)', 'responsive-lightbox' ),
485
+ 'section' => 'responsive_lightbox_configuration',
486
+ 'type' => 'boolean',
487
+ 'label' => __( 'Display links to Facebook and Twitter.', 'responsive-lightbox' ),
488
+ 'parent' => 'prettyphoto'
489
+ ),
490
+ );
491
+
492
+ break;
493
+
494
+ case ( 'fancybox' ) :
495
+
496
+ $this->settings['configuration']['prefix'] = 'rl_fb';
497
+ $this->settings['configuration']['fields'] = array(
498
+ 'modal' => array(
499
+ 'title' => __( 'Modal', 'responsive-lightbox' ),
500
+ 'section' => 'responsive_lightbox_configuration',
501
+ 'type' => 'boolean',
502
+ 'label' => __( 'When true, "overlayShow" is set to true and "hideOnOverlayClick", "hideOnContentClick", "enableEscapeButton", "showCloseButton" are set to false.', 'responsive-lightbox' ),
503
+ 'parent' => 'fancybox'
504
+ ),
505
+ 'show_overlay' => array(
506
+ 'title' => __( 'Show overlay', 'responsive-lightbox' ),
507
+ 'section' => 'responsive_lightbox_configuration',
508
+ 'type' => 'boolean',
509
+ 'label' => __( 'Toggle overlay.', 'responsive-lightbox' ),
510
+ 'parent' => 'fancybox'
511
+ ),
512
+ 'show_close_button' => array(
513
+ 'title' => __( 'Show close button', 'responsive-lightbox' ),
514
+ 'section' => 'responsive_lightbox_configuration',
515
+ 'type' => 'boolean',
516
+ 'label' => __( 'Toggle close button.', 'responsive-lightbox' ),
517
+ 'parent' => 'fancybox'
518
+ ),
519
+ 'enable_escape_button' => array(
520
+ 'title' => __( 'Enable escape button', 'responsive-lightbox' ),
521
+ 'section' => 'responsive_lightbox_configuration',
522
+ 'type' => 'boolean',
523
+ 'label' => __( 'Toggle if pressing Esc button closes FancyBox.', 'responsive-lightbox' ),
524
+ 'parent' => 'fancybox'
525
+ ),
526
+ 'hide_on_overlay_click' => array(
527
+ 'title' => __( 'Hide on overlay click', 'responsive-lightbox' ),
528
+ 'section' => 'responsive_lightbox_configuration',
529
+ 'type' => 'boolean',
530
+ 'label' => __( 'Toggle if clicking the overlay should close FancyBox.', 'responsive-lightbox' ),
531
+ 'parent' => 'fancybox'
532
+ ),
533
+ 'hide_on_content_click' => array(
534
+ 'title' => __( 'Hide on content click', 'responsive-lightbox' ),
535
+ 'section' => 'responsive_lightbox_configuration',
536
+ 'type' => 'boolean',
537
+ 'label' => __( 'Toggle if clicking the content should close FancyBox.', 'responsive-lightbox' ),
538
+ 'parent' => 'fancybox'
539
+ ),
540
+ 'cyclic' => array(
541
+ 'title' => __( 'Cyclic', 'responsive-lightbox' ),
542
+ 'section' => 'responsive_lightbox_configuration',
543
+ 'type' => 'boolean',
544
+ 'label' => __( 'When true, galleries will be cyclic, allowing you to keep pressing next/back.', 'responsive-lightbox' ),
545
+ 'parent' => 'fancybox'
546
+ ),
547
+ 'show_nav_arrows' => array(
548
+ 'title' => __( 'Show nav arrows', 'responsive-lightbox' ),
549
+ 'section' => 'responsive_lightbox_configuration',
550
+ 'type' => 'boolean',
551
+ 'label' => __( 'Toggle navigation arrows.', 'responsive-lightbox' ),
552
+ 'parent' => 'fancybox'
553
+ ),
554
+ 'auto_scale' => array(
555
+ 'title' => __( 'Auto scale', 'responsive-lightbox' ),
556
+ 'section' => 'responsive_lightbox_configuration',
557
+ 'type' => 'boolean',
558
+ 'label' => __( 'If true, FancyBox is scaled to fit in viewport.', 'responsive-lightbox' ),
559
+ 'parent' => 'fancybox'
560
+ ),
561
+ 'scrolling' => array(
562
+ 'title' => __( 'Scrolling (in/out)', 'responsive-lightbox' ),
563
+ 'section' => 'responsive_lightbox_configuration',
564
+ 'type' => 'radio',
565
+ 'description' => __( 'Set the overflow CSS property to create or hide scrollbars.', 'responsive-lightbox' ),
566
+ 'options' => $this->scripts['fancybox']['scrollings'],
567
+ 'parent' => 'fancybox'
568
+ ),
569
+ 'center_on_scroll' => array(
570
+ 'title' => __( 'Center on scroll', 'responsive-lightbox' ),
571
+ 'section' => 'responsive_lightbox_configuration',
572
+ 'type' => 'boolean',
573
+ 'label' => __( 'When true, FancyBox is centered while scrolling page.', 'responsive-lightbox' ),
574
+ 'parent' => 'fancybox'
575
+ ),
576
+ 'opacity' => array(
577
+ 'title' => __( 'Opacity', 'responsive-lightbox' ),
578
+ 'section' => 'responsive_lightbox_configuration',
579
+ 'type' => 'boolean',
580
+ 'label' => __( 'When true, transparency of content is changed for elastic transitions.', 'responsive-lightbox' ),
581
+ 'parent' => 'fancybox'
582
+ ),
583
+ 'overlay_opacity' => array(
584
+ 'title' => __( 'Overlay opacity', 'responsive-lightbox' ),
585
+ 'section' => 'responsive_lightbox_configuration',
586
+ 'type' => 'range',
587
+ 'description' => __( 'Opacity of the overlay.', 'responsive-lightbox' ),
588
+ 'min' => 0,
589
+ 'max' => 100,
590
+ 'parent' => 'fancybox'
591
+ ),
592
+ 'overlay_color' => array(
593
+ 'title' => __( 'Overlay color', 'responsive-lightbox' ),
594
+ 'section' => 'responsive_lightbox_configuration',
595
+ 'type' => 'color_picker',
596
+ 'label' => __( 'Color of the overlay.', 'responsive-lightbox' ),
597
+ 'parent' => 'fancybox'
598
+ ),
599
+ 'title_show' => array(
600
+ 'title' => __( 'Title show', 'responsive-lightbox' ),
601
+ 'section' => 'responsive_lightbox_configuration',
602
+ 'type' => 'boolean',
603
+ 'label' => __( 'Toggle title.', 'responsive-lightbox' ),
604
+ 'parent' => 'fancybox'
605
+ ),
606
+ 'title_position' => array(
607
+ 'title' => __( 'Title position', 'responsive-lightbox' ),
608
+ 'section' => 'responsive_lightbox_configuration',
609
+ 'type' => 'radio',
610
+ 'description' => __( 'The position of title.', 'responsive-lightbox' ),
611
+ 'options' => $this->scripts['fancybox']['positions'],
612
+ 'parent' => 'fancybox'
613
+ ),
614
+ 'transitions' => array(
615
+ 'title' => __( 'Transition (in/out)', 'responsive-lightbox' ),
616
+ 'section' => 'responsive_lightbox_configuration',
617
+ 'type' => 'radio',
618
+ 'description' => __( 'The transition type.', 'responsive-lightbox' ),
619
+ 'options' => $this->scripts['fancybox']['transitions'],
620
+ 'parent' => 'fancybox'
621
+ ),
622
+ 'easings' => array(
623
+ 'title' => __( 'Easings (in/out)', 'responsive-lightbox' ),
624
+ 'section' => 'responsive_lightbox_configuration',
625
+ 'type' => 'radio',
626
+ 'description' => __( 'Easing used for elastic animations.', 'responsive-lightbox' ),
627
+ 'options' => $this->scripts['fancybox']['easings'],
628
+ 'parent' => 'fancybox'
629
+ ),
630
+ 'speeds' => array(
631
+ 'title' => __( 'Speed (in/out)', 'responsive-lightbox' ),
632
+ 'section' => 'responsive_lightbox_configuration',
633
+ 'type' => 'number',
634
+ 'description' => __( 'Speed of the fade and elastic transitions, in milliseconds.', 'responsive-lightbox' ),
635
+ 'append' => 'ms',
636
+ 'parent' => 'fancybox'
637
+ ),
638
+ 'change_speed' => array(
639
+ 'title' => __( 'Change speed', 'responsive-lightbox' ),
640
+ 'section' => 'responsive_lightbox_configuration',
641
+ 'type' => 'number',
642
+ 'description' => __( 'Speed of resizing when changing gallery items, in milliseconds.', 'responsive-lightbox' ),
643
+ 'append' => 'ms',
644
+ 'parent' => 'fancybox'
645
+ ),
646
+ 'change_fade' => array(
647
+ 'title' => __( 'Change fade', 'responsive-lightbox' ),
648
+ 'section' => 'responsive_lightbox_configuration',
649
+ 'type' => 'number',
650
+ 'description' => __( 'Speed of the content fading while changing gallery items.', 'responsive-lightbox' ),
651
+ 'append' => 'ms',
652
+ 'parent' => 'fancybox'
653
+ ),
654
+ 'padding' => array(
655
+ 'title' => __( 'Padding', 'responsive-lightbox' ),
656
+ 'section' => 'responsive_lightbox_configuration',
657
+ 'type' => 'number',
658
+ 'description' => __( 'Space between FancyBox wrapper and content.', 'responsive-lightbox' ),
659
+ 'append' => 'px',
660
+ 'parent' => 'fancybox'
661
+ ),
662
+ 'margin' => array(
663
+ 'title' => __( 'Margin', 'responsive-lightbox' ),
664
+ 'section' => 'responsive_lightbox_configuration',
665
+ 'type' => 'number',
666
+ 'description' => __( 'Space between viewport and FancyBox wrapper.', 'responsive-lightbox' ),
667
+ 'append' => 'px',
668
+ 'parent' => 'fancybox'
669
+ ),
670
+ 'video_width' => array(
671
+ 'title' => __( 'Video width', 'responsive-lightbox' ),
672
+ 'section' => 'responsive_lightbox_configuration',
673
+ 'type' => 'number',
674
+ 'description' => __( 'Width of the video.', 'responsive-lightbox' ),
675
+ 'append' => 'px',
676
+ 'parent' => 'fancybox'
677
+ ),
678
+ 'video_height' => array(
679
+ 'title' => __( 'Video height', 'responsive-lightbox' ),
680
+ 'section' => 'responsive_lightbox_configuration',
681
+ 'type' => 'number',
682
+ 'description' => __( 'Height of the video.', 'responsive-lightbox' ),
683
+ 'append' => 'px',
684
+ 'parent' => 'fancybox'
685
+ ),
686
+ );
687
+
688
+ break;
689
+
690
+ case ( 'nivo' ) :
691
+
692
+ $this->settings['configuration']['prefix'] = 'rl_nv';
693
+ $this->settings['configuration']['fields'] = array(
694
+ 'effect' => array(
695
+ 'title' => __( 'Effect', 'responsive-lightbox' ),
696
+ 'section' => 'responsive_lightbox_configuration',
697
+ 'type' => 'radio',
698
+ 'description' => __( 'The effect to use when showing the lightbox.', 'responsive-lightbox' ),
699
+ 'options' => $this->scripts['nivo']['effects'],
700
+ 'parent' => 'nivo'
701
+ ),
702
+ 'keyboard_nav' => array(
703
+ 'title' => __( 'Keyboard navigation', 'responsive-lightbox' ),
704
+ 'section' => 'responsive_lightbox_configuration',
705
+ 'type' => 'boolean',
706
+ 'label' => __( 'Enable to close lightbox on overlay click.', 'responsive-lightbox' ),
707
+ 'parent' => 'nivo'
708
+ ),
709
+ 'click_overlay_to_close' => array(
710
+ 'title' => __( 'Click overlay to close', 'responsive-lightbox' ),
711
+ 'section' => 'responsive_lightbox_configuration',
712
+ 'type' => 'boolean',
713
+ 'label' => __( 'Enable keyboard navigation (left/right/escape).', 'responsive-lightbox' ),
714
+ 'parent' => 'nivo'
715
+ ),
716
+ 'error_message' => array(
717
+ 'title' => __( 'Error message', 'responsive-lightbox' ),
718
+ 'section' => 'responsive_lightbox_configuration',
719
+ 'type' => 'text',
720
+ 'class' => 'large-text',
721
+ 'label' => __( 'Error message if the content cannot be loaded.', 'responsive-lightbox' ),
722
+ 'parent' => 'nivo'
723
+ ),
724
+ );
725
+
726
+ break;
727
+
728
+ case ( 'imagelightbox' ) :
729
+
730
+ $this->settings['configuration']['prefix'] = 'rl_il';
731
+ $this->settings['configuration']['fields'] = array(
732
+ 'animation_speed' => array(
733
+ 'title' => __( 'Animation speed', 'responsive-lightbox' ),
734
+ 'section' => 'responsive_lightbox_configuration',
735
+ 'type' => 'number',
736
+ 'description' => __( 'Animation speed.', 'responsive-lightbox' ),
737
+ 'append' => 'ms',
738
+ 'parent' => 'imagelightbox'
739
+ ),
740
+ 'preload_next' => array(
741
+ 'title' => __( 'Preload next image', 'responsive-lightbox' ),
742
+ 'section' => 'responsive_lightbox_configuration',
743
+ 'type' => 'boolean',
744
+ 'label' => __( 'Silently preload the next image.', 'responsive-lightbox' ),
745
+ 'parent' => 'imagelightbox'
746
+ ),
747
+ 'enable_keyboard' => array(
748
+ 'title' => __( 'Enable keyboard keys', 'responsive-lightbox' ),
749
+ 'section' => 'responsive_lightbox_configuration',
750
+ 'type' => 'boolean',
751
+ 'label' => __( 'Enable keyboard shortcuts (arrows Left/Right and Esc).', 'responsive-lightbox' ),
752
+ 'parent' => 'imagelightbox'
753
+ ),
754
+ 'quit_on_end' => array(
755
+ 'title' => __( 'Quit after last image', 'responsive-lightbox' ),
756
+ 'section' => 'responsive_lightbox_configuration',
757
+ 'type' => 'boolean',
758
+ 'label' => __( 'Quit after viewing the last image.', 'responsive-lightbox' ),
759
+ 'parent' => 'imagelightbox'
760
+ ),
761
+ 'quit_on_image_click' => array(
762
+ 'title' => __( 'Quit on image click', 'responsive-lightbox' ),
763
+ 'section' => 'responsive_lightbox_configuration',
764
+ 'type' => 'boolean',
765
+ 'label' => __( 'Quit when the viewed image is clicked.', 'responsive-lightbox' ),
766
+ 'parent' => 'imagelightbox'
767
+ ),
768
+ 'quit_on_document_click' => array(
769
+ 'title' => __( 'Quit on anything click', 'responsive-lightbox' ),
770
+ 'section' => 'responsive_lightbox_configuration',
771
+ 'type' => 'boolean',
772
+ 'label' => __( 'Quit when anything but the viewed image is clicked.', 'responsive-lightbox' ),
773
+ 'parent' => 'imagelightbox'
774
+ ),
775
+ );
776
+
777
+ break;
778
+
779
+ default :
780
+ break;
781
+ }
782
+
783
+ $this->tabs = array(
784
+ 'settings' => array(
785
+ 'name' => __( 'General settings', 'responsive-lightbox' ),
786
+ 'key' => 'responsive_lightbox_settings',
787
+ 'submit' => 'save_rl_settings',
788
+ 'reset' => 'reset_rl_settings',
789
+ ),
790
+ 'configuration' => array(
791
+ 'name' => __( 'Lightbox settings', 'responsive-lightbox' ),
792
+ 'key' => 'responsive_lightbox_configuration',
793
+ 'submit' => 'save_' . $this->settings['configuration']['prefix'] . '_configuration',
794
+ 'reset' => 'reset_' . $this->settings['configuration']['prefix'] . '_configuration'
795
+ )
796
+ );
797
+
798
+ }
799
+
800
+ /**
801
+ * Register options page
802
+ *
803
+ * @return void
804
+ */
805
+ public function admin_menu_options() {
806
+ add_options_page(
807
+ __( 'Responsive Lightbox', 'responsive-lightbox' ), __( 'Responsive Lightbox', 'responsive-lightbox' ), 'manage_options', 'responsive-lightbox', array( &$this, 'options_page' )
808
+ );
809
+ }
810
+
811
+ /**
812
+ * Render options page
813
+ *
814
+ * @return void
815
+ */
816
+ public function options_page() {
817
+ $tab_key = (isset( $_GET['tab'] ) ? $_GET['tab'] : 'settings');
818
+
819
+ echo '
820
+ <div class="wrap">' . screen_icon() . '
821
+ <h2>' . __( 'Responsive Lightbox', 'responsive-lightbox' ) . '</h2>
822
+ <h2 class="nav-tab-wrapper">';
823
+
824
+ foreach ( $this->tabs as $key => $name ) {
825
+ echo '
826
+ <a class="nav-tab ' . ($tab_key == $key ? 'nav-tab-active' : '') . '" href="' . esc_url( admin_url( 'options-general.php?page=responsive-lightbox&tab=' . $key ) ) . '">' . $name['name'] . '</a>';
827
+ }
828
+
829
+ echo '
830
+ </h2>
831
+ <div class="responsive-lightbox-settings">
832
+
833
+ <div class="df-credits">
834
+ <h3 class="hndle">' . __( 'Responsive Lightbox', 'responsive-lightbox' ) . ' ' . $this->defaults['version'] . '</h3>
835
+ <div class="inside">
836
+ <h4 class="inner">' . __( 'Need support?', 'responsive-lightbox' ) . '</h4>
837
+ <p class="inner">' . __( 'If you are having problems with this plugin, please talk about them in the', 'responsive-lightbox' ) . ' <a href="http://www.dfactory.eu/support/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=support" target="_blank" title="' . __( 'Support forum', 'responsive-lightbox' ) . '">' . __( 'Support forum', 'responsive-lightbox' ) . '</a></p>
838
+ <hr />
839
+ <h4 class="inner">' . __( 'Do you like this plugin?', 'responsive-lightbox' ) . '</h4>
840
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank" class="inner">
841
+ <input type="hidden" name="cmd" value="_s-xclick">
842
+ <input type="hidden" name="hosted_button_id" value="8AL8ULUN9R76U">
843
+ <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
844
+ <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
845
+ </form>
846
+ <p class="inner"><a href="http://wordpress.org/support/view/plugin-reviews/responsive-lightbox" target="_blank" title="' . __( 'Rate it 5', 'responsive-lightbox' ) . '">' . __( 'Rate it 5', 'responsive-lightbox' ) . '</a> ' . __( 'on WordPress.org', 'responsive-lightbox' ) . '<br />' .
847
+ __( 'Blog about it & link to the', 'responsive-lightbox' ) . ' <a href="http://www.dfactory.eu/plugins/responsive-lightbox/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=blog-about" target="_blank" title="' . __( 'plugin page', 'responsive-lightbox' ) . '">' . __( 'plugin page', 'responsive-lightbox' ) . '</a><br />' .
848
+ __( 'Check out our other', 'responsive-lightbox' ) . ' <a href="http://www.dfactory.eu/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=other-plugins" target="_blank" title="' . __( 'WordPress plugins', 'responsive-lightbox' ) . '">' . __( 'WordPress plugins', 'responsive-lightbox' ) . '</a>
849
+ </p>
850
+ <hr />
851
+ <p class="df-link inner">Created by <a href="http://www.dfactory.eu/?utm_source=responsive-lightbox-settings&utm_medium=link&utm_campaign=created-by" target="_blank" title="dFactory - Quality plugins for WordPress"><img src="' . RESPONSIVE_LIGHTBOX_URL . '/images/logo-dfactory.png' . '" title="dFactory - Quality plugins for WordPress" alt="dFactory - Quality plugins for WordPress" /></a></p>
852
+ </div>
853
+ </div>
854
+
855
+ <form action="options.php" method="post">
856
+ <input type="hidden" name="script_r" value="' . esc_attr( $this->options['settings']['script'] ) . '" />';
857
+
858
+ wp_nonce_field( 'update-options' );
859
+ settings_fields( $this->tabs[$tab_key]['key'] );
860
+ do_settings_sections( $this->tabs[$tab_key]['key'] );
861
+
862
+ echo '
863
+ <p class="submit">';
864
+
865
+ submit_button( '', array( 'primary', 'save-' . $tab_key ), $this->tabs[$tab_key]['submit'], false );
866
+
867
+ echo ' ';
868
+ echo submit_button( __( 'Reset to defaults', 'responsive-lightbox' ), array( 'secondary', 'reset-' . $tab_key ), $this->tabs[$tab_key]['reset'], false );
869
+
870
+ echo '
871
+ </p>
872
+ </form>
873
+ </div>
874
+ <div class="clear"></div>
875
+ </div>';
876
+ }
877
+
878
+ /**
879
+ * Render settings function
880
+ *
881
+ * @return void
882
+ */
883
+ public function register_settings() {
884
+
885
+ foreach ( $this->settings as $setting_id => $setting ) {
886
+
887
+ // set key
888
+ $setting_key = $setting_id;
889
+ $setting_id = 'responsive_lightbox_' . $setting_id;
890
+
891
+ // register setting
892
+ register_setting(
893
+ esc_attr( $setting_id ),
894
+ ! empty( $setting['option_name'] ) ? esc_attr( $setting['option_name'] ) : $setting_id,
895
+ ! empty( $setting['callback'] ) ? $setting['callback'] : array( &$this, 'validate_settings' )
896
+ );
897
+
898
+ // register sections
899
+ if ( ! empty( $setting['sections'] ) && is_array( $setting['sections'] ) ) {
900
+
901
+ foreach ( $setting['sections'] as $section_id => $section ) {
902
+
903
+ add_settings_section(
904
+ esc_attr( $section_id ),
905
+ ! empty( $section['title'] ) ? esc_html( $section['title'] ) : '',
906
+ ! empty( $section['callback'] ) ? $section['callback'] : '',
907
+ ! empty( $section['page'] ) ? esc_attr( $section['page'] ) : $section_id
908
+ );
909
+ }
910
+
911
+ }
912
+
913
+ // register fields
914
+ if ( ! empty( $setting['fields'] ) && is_array( $setting['fields'] ) ) {
915
+
916
+ foreach ( $setting['fields'] as $field_id => $field ) {
917
+
918
+ // prefix field id?
919
+ $field_key = $field_id;
920
+ $field_id = ( ! empty( $setting['prefix'] ) ? $setting['prefix'] . '_' : '' ) . $field_id;
921
+
922
+ // field args
923
+ $args = array(
924
+ 'id' => ! empty( $field['id'] ) ? $field['id'] : $field_id,
925
+ 'class' => ! empty( $field['class'] ) ? $field['class'] : '',
926
+ 'name' => $setting['option_name'] . ( ! empty( $field['parent'] ) ? '[' . $field['parent'] . ']' : '' ) . '[' . $field_key . ']',
927
+ 'type' => ! empty( $field['type'] ) ? $field['type'] : 'text',
928
+ 'label' => ! empty( $field['label'] ) ? $field['label'] : '',
929
+ 'description' => ! empty( $field['description'] ) ? $field['description'] : '',
930
+ 'append' => ! empty( $field['append'] ) ? esc_html( $field['append'] ) : '',
931
+ 'prepend' => ! empty( $field['prepend'] ) ? esc_html( $field['prepend'] ) : '',
932
+ 'min' => ! empty( $field['min'] ) ? (int) $field['min'] : '',
933
+ 'max' => ! empty( $field['max'] ) ? (int) $field['max'] : '',
934
+ 'options' => ! empty( $field['options'] ) ? $field['options'] : '',
935
+ 'fields' => ! empty( $field['fields'] ) ? $field['fields'] : '',
936
+ 'default' => $field['type'] === 'multiple' ? '' : ( $this->sanitize_field( ! empty( $field['parent'] ) ? $this->defaults[$setting_key][$field['parent']][$field_key] : $this->defaults[$setting_key][$field_key], $field['type'] ) ),
937
+ 'value' => $field['type'] === 'multiple' ? '' : ( $this->sanitize_field( ! empty( $field['parent'] ) ? $this->options[$setting_key][$field['parent']][$field_key] : $this->options[$setting_key][$field_key], $field['type'] ) ),
938
+ 'label_for' => $field_id,
939
+ 'return' => false
940
+ );
941
+
942
+ if ( $args['type'] === 'multiple' ) {
943
+ foreach ( $args['fields'] as $subfield_id => $subfield ) {
944
+ $args['fields'][$subfield_id] = wp_parse_args( $subfield, array(
945
+ 'id' => $subfield_id,
946
+ 'class' => ! empty( $subfield['class'] ) ? $subfield['class'] : '',
947
+ 'name' => $setting['option_name'] . ( ! empty( $subfield['parent'] ) ? '[' . $subfield['parent'] . ']' : '' ) . '[' . $subfield_id . ']',
948
+ 'default' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? $this->defaults[$setting_key][$subfield['parent']][$subfield_id] : $this->defaults[$setting_key][$subfield_id], $subfield['type'] ),
949
+ 'value' => $this->sanitize_field( ! empty( $subfield['parent'] ) ? $this->options[$setting_key][$subfield['parent']][$subfield_id] : $this->options[$setting_key][$subfield_id], $subfield['type'] ),
950
+ 'return' => true
951
+ ) );
952
+ }
953
+ }
954
+
955
+ add_settings_field(
956
+ esc_attr( $field_id ),
957
+ ! empty( $field['title'] ) ? esc_html( $field['title'] ) : '',
958
+ array( &$this, 'render_field' ),
959
+ ! empty( $field['page'] ) ? esc_attr( $field['page'] ) : $setting_id,
960
+ ! empty( $field['section'] ) ? esc_attr( $field['section'] ) : '',
961
+ $args
962
+ );
963
+
964
+ }
965
+
966
+ }
967
+
968
+ }
969
+
970
+ }
971
+
972
+ /**
973
+ * Render settings field function
974
+ *
975
+ * @param array $args
976
+ * @return mixed
977
+ */
978
+ public function render_field( $args ) {
979
+
980
+ if ( empty( $args ) || ! is_array( $args ) )
981
+ return;
982
+
983
+ $html = '';
984
+
985
+ switch ( $args['type'] ) {
986
+
987
+ case ( 'boolean' ) :
988
+
989
+ $html .= '<label class="cb-checkbox"><input id="' . $args['id'] . '" type="checkbox" name="' . $args['name'] . '" value="1" ' . checked( true, (bool) $args['value'], false ) . ' />' . $args['label'] . '</label>';
990
+ break;
991
+
992
+ case ( 'radio' ) :
993
+
994
+ foreach ( $args['options'] as $key => $name ) {
995
+ $html .= '<label class="cb-radio"><input id="' . $args['id'] . '-' . $key . '" type="radio" name="' . $args['name'] . '" value="' . $key . '" ' . checked( $key, $args['value'], false ) . ' />' . $name . '</label>';
996
+ }
997
+ break;
998
+
999
+ case ( 'checkbox' ) :
1000
+
1001
+ foreach ( $args['options'] as $key => $name ) {
1002
+ $html .= '<label class="cb-checkbox"><input id="' . $args['id'] . '-' . $key . '" type="checkbox" name="' . $args['name'] . '" value="' . $key . '" ' . checked( $key, $args['value'], false ) . ' />' . $name . '</label>';
1003
+ }
1004
+ break;
1005
+
1006
+ case ( 'select' ) :
1007
+
1008
+ $html .= '<select id="' . $args['id'] . '" name="' . $args['name'] . '" value="' . $args['value'] . '" />';
1009
+
1010
+ foreach ( $args['options'] as $key => $name ) {
1011
+ $html .= '<option value="' . $key . '" ' . selected( $args['value'], $key, false ) . '>' . $name . '</option>';
1012
+ }
1013
+
1014
+ $html .= '</select>';
1015
+ break;
1016
+
1017
+ case ( 'multiple' ) :
1018
+
1019
+ $html .= '<fieldset>';
1020
+
1021
+ foreach ( $args['fields'] as $subfield_id => $subfield_args ) {
1022
+ $html .= $this->render_field( $subfield_args ) . '<br />';
1023
+ }
1024
+
1025
+ $html .= '</fieldset>';
1026
+ break;
1027
+
1028
+ case ( 'range' ) :
1029
+ $html .= '<input id="' . $args['id'] . '" type="range" name="' . $args['name'] . '" value="' . $args['value'] . '" min="' . $args['min'] . '" max="' . $args['max'] . '" oninput="this.form.' . $args['id'] . '_range.value=this.value" />';
1030
+ $html .= '<output name="' . $args['id'] . '_range">' . esc_attr( $this->options['configuration']['prettyphoto']['opacity'] ) . '</output>';
1031
+ break;
1032
+
1033
+ case ( 'color_picker' ) :
1034
+ $html .= '<input id="' . $args['id'] . '" class="color-picker" type="text" value="' . $args['value'] . '" name="' . $args['name'] . '" data-default-color="' . $args['default'] . '" />';
1035
+ break;
1036
+
1037
+ case ( 'number' ) :
1038
+ $html .= ( ! empty( $args['prepend'] ) ? '<span>' . $args['prepend'] . '</span> ' : '' );
1039
+ $html .= '<input id="' . $args['id'] . '" type="text" value="' . $args['value'] . '" name="' . $args['name'] . '" />';
1040
+ $html .= ( ! empty( $args['append'] ) ? ' <span>' . $args['append'] . '</span>' : '' );
1041
+ break;
1042
+
1043
+ case ( 'text' ) :
1044
+ default :
1045
+ $html .= ( ! empty( $args['prepend'] ) ? '<span>' . $args['prepend'] . '</span> ' : '' );
1046
+ $html .= '<input id="' . $args['id'] . '" class="' . $args['class'] . '" type="text" value="' . $args['value'] . '" name="' . $args['name'] . '" />';
1047
+ $html .= ( ! empty( $args['append'] ) ? ' <span>' . $args['append'] . '</span>' : '' );
1048
+ break;
1049
+
1050
+ }
1051
+
1052
+ if ( ! empty ( $args['description'] ) ) {
1053
+ $html .= '<p class="description">' . $args['description'] . '</p>';
1054
+ }
1055
+
1056
+ if ( ! empty( $args['return'] ) ) {
1057
+ return $html;
1058
+ } else {
1059
+ echo $html;
1060
+ }
1061
+ }
1062
+
1063
+ /**
1064
+ * Sanitize field function
1065
+ *
1066
+ * @param mixed
1067
+ * @param string
1068
+ * @return mixed
1069
+ */
1070
+ public function sanitize_field( $value = null, $type = '', $args = array() ) {
1071
+ if ( is_null( $value ) )
1072
+ return null;
1073
+
1074
+ switch ( $type ) {
1075
+
1076
+ case 'boolean':
1077
+ $value = empty( $value ) ? false : true;
1078
+ break;
1079
+
1080
+ case 'checkbox':
1081
+ $value = is_array( $value ) ? array_map( 'sanitize_text_field', $value ) : false;
1082
+ break;
1083
+
1084
+ case 'radio':
1085
+ $value = is_array( $value ) ? false : sanitize_text_field( $value );
1086
+ break;
1087
+
1088
+ case 'textarea':
1089
+ case 'wysiwyg':
1090
+ $value = wp_kses_post( $value );
1091
+ break;
1092
+
1093
+ case 'color_picker':
1094
+ $value = ! $value || '#' == $value ? '' : esc_attr( $value );
1095
+ break;
1096
+
1097
+ case 'number':
1098
+ $value = ! $value || is_array( $value ) ? '' : str_replace( ',', '', $value );
1099
+
1100
+ if ( ! empty( $args['type'] ) ) {
1101
+ switch ( $args['type'] ) {
1102
+ case 'int':
1103
+ $value = (int) $value;
1104
+ break;
1105
+
1106
+ case 'absint':
1107
+ $value = absint( $value );
1108
+ break;
1109
+
1110
+ case 'float':
1111
+ default:
1112
+ $value = floatval( $value );
1113
+ break;
1114
+ }
1115
+ } else {
1116
+ $value = floatval( $value );
1117
+ }
1118
+ break;
1119
+
1120
+ case 'text':
1121
+ case 'select':
1122
+ default:
1123
+ $value = is_array( $value ) ? array_map( 'sanitize_text_field', $value ) : sanitize_text_field( $value );
1124
+ break;
1125
+ }
1126
+
1127
+ return stripslashes_deep( $value );
1128
+ }
1129
+
1130
+ /**
1131
+ * Validate settings function
1132
+ *
1133
+ * @param array $input
1134
+ * @return array
1135
+ */
1136
+ public function validate_settings( $input ) {
1137
+ // check cap
1138
+ if ( ! current_user_can( 'manage_options') ) {
1139
+ return $input;
1140
+ }
1141
+
1142
+ // check page
1143
+ if ( ! ( $option_page = esc_attr( $_POST['option_page'] ) ) )
1144
+ return $input;
1145
+
1146
+ foreach ( $this->settings as $id => $setting ) {
1147
+
1148
+ $key = array_search( $option_page, $setting );
1149
+
1150
+ if ( $key ) {
1151
+ // set key
1152
+ $setting_id = $id;
1153
+ continue;
1154
+ }
1155
+ }
1156
+
1157
+ // check setting id
1158
+ if ( ! $setting_id )
1159
+ return $input;
1160
+
1161
+ // save settings
1162
+ if ( isset( $_POST['save' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) {
1163
+
1164
+ if ( $this->settings[$setting_id]['fields'] ) {
1165
+
1166
+ foreach ( $this->settings[$setting_id]['fields'] as $field_id => $field ) {
1167
+
1168
+ if ( $field['type'] === 'multiple' ) {
1169
+
1170
+ if ( $field['fields'] ) {
1171
+
1172
+ foreach ( $field['fields'] as $subfield_id => $subfield ) {
1173
+
1174
+ switch ( $subfield['type'] ) {
1175
+ case 'boolean' :
1176
+ $input[$subfield_id] = isset( $input[$subfield_id] );
1177
+ break;
1178
+
1179
+ default :
1180
+ $input[$subfield_id] = isset( $input[$subfield_id] ) ? $this->sanitize_field( $input[$subfield_id], $subfield['type'] ) : $this->defaults[$setting_id][$field_id][$subfield_id];
1181
+ break;
1182
+ }
1183
+
1184
+ }
1185
+
1186
+ }
1187
+
1188
+ } else {
1189
+
1190
+ switch ( $field['type'] ) {
1191
+ case 'boolean' :
1192
+ $input[$field_id] = isset( $input[$field_id] );
1193
+ break;
1194
+
1195
+ default :
1196
+ $input[$field_id] = isset( $input[$field_id] ) ? $this->sanitize_field( $input[$field_id], $field['type'] ) : $this->defaults[$setting_id][$field_id];
1197
+ break;
1198
+ }
1199
+
1200
+ }
1201
+ }
1202
+
1203
+ }
1204
+
1205
+ if ( $setting_id === 'configuration' ) {
1206
+ // merge scripts settings
1207
+ $input = array_merge( $this->options['configuration'], $input );
1208
+ }
1209
+
1210
+ } elseif ( isset( $_POST['reset' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id] ) ) {
1211
+
1212
+ if ( $setting_id === 'configuration' ) {
1213
+ // merge scripts settings
1214
+ $input[$this->options['settings']['script']] = $this->defaults['configuration'][$this->options['settings']['script']];
1215
+ $input = array_merge( $this->options['configuration'], $input );
1216
+ } else {
1217
+ $input = $this->defaults[$setting_id];
1218
+ }
1219
+
1220
+ add_settings_error( 'reset' . '_' . $this->settings[$setting_id]['prefix'] . '_' . $setting_id, 'settings_restored', __( 'Settings restored to defaults.', 'responsive-lightbox' ), 'updated' );
1221
+
1222
+ }
1223
+
1224
+ // echo '<pre>'; print_r($this->settings[$setting_id]['prefix']); echo '</pre>';
1225
+ // echo '<pre>'; print_r($input); echo '</pre>';
1226
+ // echo '<pre>'; print_r($_POST); echo '</pre>';
1227
+
1228
+ return $input;
1229
+ }
1230
+
1231
+ }
js/admin.js CHANGED
@@ -2,109 +2,27 @@
2
3
$( document ).ready( function () {
4
5
- $( '.wplikebtns' ).buttonset();
6
- $( '#rl_fb_overlay_color_input' ).wpColorPicker();
7
8
- $( document ).on( 'click', '#rl-fb-modal-yes', function ( event ) {
9
- $( '#rl-fb-show-overlay-yes' ).trigger( 'click' );
10
- $( '#rl-fb-show-overlay-no' ).button( 'disable' );
11
- $( '#rl-fb-show-overlay-yes' ).button( 'disable' );
12
- $( '#rl-fb-show-close-button-no' ).trigger( 'click' );
13
- $( '#rl-fb-show-close-button-no' ).button( 'disable' );
14
- $( '#rl-fb-show-close-button-yes' ).button( 'disable' );
15
- $( '#rl-fb-enable-escape-button-no' ).trigger( 'click' );
16