Responsive Lightbox & Gallery - Version 2.0.5

Version Description

  • Fix: Escaped characters on titles and descriptions
  • Fix: Gallery shortcode not accepting image order
  • Fix: Gallery using default parameters instead of the settings
  • Fix: PHP fatal error if gallery builder is disabled
Download this release

Release Info

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

Code changes from version 2.0.4 to 2.0.5

css/gallery.css CHANGED
@@ -28,9 +28,9 @@
28
background-color: rgba(0,0,0,0.8);
29
overflow: hidden;
30
word-wrap: break-word;
31
- padding: 1rem 1.5rem;
32
font-weight: normal;
33
- line-height: 1rem;
34
text-align: left;
35
word-wrap: break-word;
36
backface-visibility: hidden;
@@ -53,13 +53,13 @@
53
.rl-gallery .rl-gallery-item-title,
54
.rl-gallery .rl-gallery-item-caption {
55
display: block;
56
- font-size: 0.85rem;
57
color: #fff;
58
}
59
60
.rl-gallery .rl-gallery-item-caption {
61
display: block;
62
- font-size: 0.75rem;
63
color: #ccc;
64
}
65
@@ -122,22 +122,22 @@
122
align-items: center;
123
justify-content: center;
124
text-decoration: none;
125
- width: 1rem;
126
- height: 1rem;
127
text-align: center;
128
font-variant: normal;
129
text-transform: none;
130
- line-height: 1rem;
131
-webkit-font-smoothing: antialiased;
132
-moz-osx-font-smoothing: grayscale;
133
position: absolute;
134
top: 50%;
135
left: 50%;
136
- margin-top: -1rem;
137
- margin-left: -1rem;
138
background-color: rgba(0,0,0,0.8);
139
color: #fff;
140
- padding: 1rem;
141
border-radius: 50%;
142
filter: "alpha(opacity=0)";
143
opacity: 0;
@@ -332,11 +332,11 @@
332
}
333
.rl-gallery.rl-hover-effect-5 .rl-gallery-link:hover:before,
334
.rl-gallery.rl-hover-effect-5 .rl-gallery-link.hover:before {
335
- webkit-transform: translateY(2rem);
336
- -moz-transform: translateY(2rem);
337
- -ms-transform: translateY(2rem);
338
- -o-transform: translateY(2rem);
339
- transform: translateY(2rem);
340
}
341
.rl-gallery.rl-hover-effect-5 .rl-gallery-link:after {
342
filter: "alpha(opacity=100)";
@@ -411,15 +411,15 @@
411
.rl-gallery.rl-hover-effect-7 .rl-gallery-link:before {
412
filter: "alpha(opacity=100)";
413
opacity: 1;
414
- top: -2rem;
415
}
416
.rl-gallery.rl-hover-effect-7 .rl-gallery-link:hover:before,
417
.rl-gallery.rl-hover-effect-7 .rl-gallery-link.hover:before {
418
- webkit-transform: translateY(4rem);
419
- -moz-transform: translateY(4rem);
420
- -ms-transform: translateY(4rem);
421
- -o-transform: translateY(4rem);
422
- transform: translateY(4rem);
423
}
424
.rl-gallery.rl-hover-effect-7 .rl-gallery-link img {
425
position: relative;
@@ -432,14 +432,14 @@
432
}
433
.rl-gallery.rl-hover-effect-7 .rl-gallery-link:hover img,
434
.rl-gallery.rl-hover-effect-7 .rl-gallery-link.hover img {
435
- -webkit-transform: translateY(-5rem);
436
- -moz-transform: translateY(-5rem);
437
- -ms-transform: translateY(-5rem);
438
- -o-transform: translateY(-5rem);
439
- transform: translateY(-5rem);
440
}
441
.rl-gallery.rl-hover-effect-7 .rl-gallery-link .rl-gallery-caption {
442
- height: 5rem;
443
filter: "alpha(opacity=100)";
444
opacity: 1;
445
}
@@ -452,15 +452,15 @@
452
.rl-gallery.rl-hover-effect-8 .rl-gallery-link:before {
453
filter: "alpha(opacity=100)";
454
opacity: 1;
455
- top: -2rem;
456
}
457
.rl-gallery.rl-hover-effect-8 .rl-gallery-link:hover:before,
458
.rl-gallery.rl-hover-effect-8 .rl-gallery-link.hover:before {
459
- webkit-transform: translateY(4rem);
460
- -moz-transform: translateY(4rem);
461
- -ms-transform: translateY(4rem);
462
- -o-transform: translateY(4rem);
463
- transform: translateY(4rem);
464
}
465
.rl-gallery.rl-hover-effect-8 .rl-gallery-link img {
466
z-index: 1;
@@ -471,14 +471,14 @@
471
transition: transform 0.3s;
472
}
473
.rl-gallery.rl-hover-effect-8 .rl-gallery-link:hover img {
474
- -webkit-transform: translateY(-3rem);
475
- -moz-transform: translateY(-3rem);
476
- -ms-transform: translateY(-3rem);
477
- -o-transform: translateY(-3rem);
478
- transform: translateY(-3rem);
479
}
480
.rl-gallery.rl-hover-effect-8 .rl-gallery-link .rl-gallery-caption {
481
- height: 5rem;
482
filter: "alpha(opacity=100)";
483
opacity: 1;
484
-webkit-transform: translateY(100%);
@@ -542,9 +542,9 @@
542
transform: scale(1);
543
}
544
.rl-gallery.rl-hover-effect-9 .rl-gallery-link:after {
545
- height: calc(100% - 1rem);
546
- width: calc(100% - 1rem);
547
- margin: 0.5rem;
548
}
549
.rl-gallery.rl-hover-effect-9 .rl-gallery-link:hover:after,
550
.rl-gallery.rl-hover-effect-9 .rl-gallery-link.hover:after {
28
background-color: rgba(0,0,0,0.8);
29
overflow: hidden;
30
word-wrap: break-word;
31
+ padding: 1em 1.5em;
32
font-weight: normal;
33
+ line-height: 1em;
34
text-align: left;
35
word-wrap: break-word;
36
backface-visibility: hidden;
53
.rl-gallery .rl-gallery-item-title,
54
.rl-gallery .rl-gallery-item-caption {
55
display: block;
56
+ font-size: 0.85em;
57
color: #fff;
58
}
59
60
.rl-gallery .rl-gallery-item-caption {
61
display: block;
62
+ font-size: 0.75em;
63
color: #ccc;
64
}
65
122
align-items: center;
123
justify-content: center;
124
text-decoration: none;
125
+ width: 1em;
126
+ height: 1em;
127
text-align: center;
128
font-variant: normal;
129
text-transform: none;
130
+ line-height: 1em;
131
-webkit-font-smoothing: antialiased;
132
-moz-osx-font-smoothing: grayscale;
133
position: absolute;
134
top: 50%;
135
left: 50%;
136
+ margin-top: -1em;
137
+ margin-left: -1em;
138
background-color: rgba(0,0,0,0.8);
139
color: #fff;
140
+ padding: 1em;
141
border-radius: 50%;
142
filter: "alpha(opacity=0)";
143
opacity: 0;
332
}
333
.rl-gallery.rl-hover-effect-5 .rl-gallery-link:hover:before,
334
.rl-gallery.rl-hover-effect-5 .rl-gallery-link.hover:before {
335
+ webkit-transform: translateY(2em);
336
+ -moz-transform: translateY(2em);
337
+ -ms-transform: translateY(2em);
338
+ -o-transform: translateY(2em);
339
+ transform: translateY(2em);
340
}
341
.rl-gallery.rl-hover-effect-5 .rl-gallery-link:after {
342
filter: "alpha(opacity=100)";
411
.rl-gallery.rl-hover-effect-7 .rl-gallery-link:before {
412
filter: "alpha(opacity=100)";
413
opacity: 1;
414
+ top: -2em;
415
}
416
.rl-gallery.rl-hover-effect-7 .rl-gallery-link:hover:before,
417
.rl-gallery.rl-hover-effect-7 .rl-gallery-link.hover:before {
418
+ webkit-transform: translateY(4em);
419
+ -moz-transform: translateY(4em);
420
+ -ms-transform: translateY(4em);
421
+ -o-transform: translateY(4em);
422
+ transform: translateY(4em);
423
}
424
.rl-gallery.rl-hover-effect-7 .rl-gallery-link img {
425
position: relative;
432
}
433
.rl-gallery.rl-hover-effect-7 .rl-gallery-link:hover img,
434
.rl-gallery.rl-hover-effect-7 .rl-gallery-link.hover img {
435
+ -webkit-transform: translateY(-5em);
436
+ -moz-transform: translateY(-5em);
437
+ -ms-transform: translateY(-5em);
438
+ -o-transform: translateY(-5em);
439
+ transform: translateY(-5em);
440
}
441
.rl-gallery.rl-hover-effect-7 .rl-gallery-link .rl-gallery-caption {
442
+ height: 5em;
443
filter: "alpha(opacity=100)";
444
opacity: 1;
445
}
452
.rl-gallery.rl-hover-effect-8 .rl-gallery-link:before {
453
filter: "alpha(opacity=100)";
454
opacity: 1;
455
+ top: -2em;
456
}
457
.rl-gallery.rl-hover-effect-8 .rl-gallery-link:hover:before,
458
.rl-gallery.rl-hover-effect-8 .rl-gallery-link.hover:before {
459
+ webkit-transform: translateY(4em);
460
+ -moz-transform: translateY(4em);
461
+ -ms-transform: translateY(4em);
462
+ -o-transform: translateY(4em);
463
+ transform: translateY(4em);
464
}
465
.rl-gallery.rl-hover-effect-8 .rl-gallery-link img {
466
z-index: 1;
471
transition: transform 0.3s;
472
}
473
.rl-gallery.rl-hover-effect-8 .rl-gallery-link:hover img {
474
+ -webkit-transform: translateY(-3em);
475
+ -moz-transform: translateY(-3em);
476
+ -ms-transform: translateY(-3em);
477
+ -o-transform: translateY(-3em);
478
+ transform: translateY(-3em);
479
}
480
.rl-gallery.rl-hover-effect-8 .rl-gallery-link .rl-gallery-caption {
481
+ height: 5em;
482
filter: "alpha(opacity=100)";
483
opacity: 1;
484
-webkit-transform: translateY(100%);
542
transform: scale(1);
543
}
544
.rl-gallery.rl-hover-effect-9 .rl-gallery-link:after {
545
+ height: calc(100% - 1em);
546
+ width: calc(100% - 1em);
547
+ margin: 0.5em;
548
}
549
.rl-gallery.rl-hover-effect-9 .rl-gallery-link:hover:after,
550
.rl-gallery.rl-hover-effect-9 .rl-gallery-link.hover:after {
includes/class-frontend.php CHANGED
@@ -238,10 +238,10 @@ class Responsive_Lightbox_Frontend {
238
if ( $result[1] !== 'norl' ) {
239
// gallery?
240
if ( $args['settings']['plugin']['images_as_gallery'] || $args['settings']['plugin']['force_custom_gallery'] )
241
- $link = preg_replace( '/data-rel=(\'|")(.*?)(\'|")/s', 'data-rel="' . $args['selector'] . '-gallery-' . $this->gallery_no . '" data-rl_title="' . $title . '" data-rl_caption="' . $caption . '"' . ( $args['script'] === 'magnific' ? ' data-magnific_type="gallery"' : '' ) . ( $args['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $args['link_number'] . '"' : '' ), $link );
242
// single image
243
else
244
- $link = preg_replace( '/data-rel=(\'|")(.*?)(\'|")/s', 'data-rel="' . $args['selector'] . '-image-' . base64_encode( $result[1] ) . '"' . ( $args['script'] === 'magnific' ? ' data-magnific_type="image"' : '' ) . ( $args['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $args['link_number'] . '"' : '' ) . ' data-rl_title="' . $title . '" data-rl_caption="' . $caption . '"', $link );
245
}
246
// link without data-rel
247
} else {
@@ -251,18 +251,24 @@ class Responsive_Lightbox_Frontend {
251
if ( preg_match( '/<a.*?(?:rel)=(?:\'|")(.*?)(?:\'|").*?>/is', $link, $result ) === 1 ) {
252
// allow to modify link?
253
if ( $result[1] !== 'norl' )
254
- $link = preg_replace( '/rel=(\'|")(.*?)(\'|")/', 'data-rel="' . $args['selector'] . '-gallery-' . $this->gallery_no . '" data-rl_title="' . $title . '" data-rl_caption="' . $caption . '"' . ( $args['script'] === 'magnific' ? ' data-magnific_type="gallery"' : '' ) . ( $args['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $args['link_number'] . '"' : '' ), $link );
255
} else
256
- $link = '<a' . $args['link_parts'][0] . ' href="' . $args['link_parts'][1] . '.' . $args['link_parts'][2] . '" data-rel="' . $args['selector'] . '-gallery-' . $this->gallery_no . '" data-rl_title="' . $title . '" data-rl_caption="' . $caption . '"' . ( $args['script'] === 'magnific' ? ' data-magnific_type="gallery"' : '' ) . ( $args['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $args['link_number'] . '"' : '' ) . $args['link_parts'][3] . '>';
257
} else
258
- $link = '<a' . $args['link_parts'][0] . 'href="' . $args['link_parts'][1] . '.' . $args['link_parts'][2] . '"' . $args['link_parts'][3] . ' data-rel="' . $args['selector'] . ( $args['settings']['plugin']['images_as_gallery'] ? $args['rel_hash'] : '-image-' . $args['link_number'] ) . '"' . ( $args['script'] === 'magnific' ? ' data-magnific_type="image"' : '' ) . ( $args['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $args['link_number'] . '"' : '' ) . ' data-rl_title="' . $title . '" data-rl_caption="' . $caption . '">';
259
}
260
261
// title exists?
262
if ( preg_match( '/<a.*? title=(?:\'|").*?(?:\'|").*?>/is', $link ) === 1 ) {
263
- $link = preg_replace( '/(<a.*? title=(?:\'|")).*?((?:\'|").*?>)/s', '${1}' . $title . '$2', $link );
264
} else
265
- $link = preg_replace( '/(<a.*?)>/s', '$1 title="' . $title . '">', $link );
266
267
return apply_filters( 'rl_lightbox_image_link', $link, $args );
268
}
@@ -334,12 +340,13 @@ class Responsive_Lightbox_Frontend {
334
335
// add title and rl_title if needed
336
if ( preg_match( '/<a.*? title=(?:\'|").*?(?:\'|").*?>/is', $link ) === 1 )
337
- $link = preg_replace( '/(<a.*? title=(?:\'|")).*?((?:\'|").*?>)/s', '$1' . $title . '" data-rl_title="'. $title .'$2', $link );
338
else
339
- $link = preg_replace( '/(<a.*?)>/s', '$1 title="' . $title . '" data-rl_title="'. $title .'">', $link );
340
341
// add class if needed
342
- if ( preg_match( '/<a.*? class=(?:\'|").*?(?:\'|").*?>/is', $link ) === 1 )
343
$link = preg_replace( '/(<a.*?) class=(?:\'|")(.*?)(?:\'|")(.*?>)/s', '$1 class="$2 rl-gallery-link" $3', $link );
344
else
345
$link = preg_replace( '/(<a.*?)>/s', '$1 class="rl-gallery-link">', $link );
@@ -363,7 +370,7 @@ class Responsive_Lightbox_Frontend {
363
$caption = esc_attr( wp_strip_all_tags( trim( nl2br( $args['caption'] ) ), true ) );
364
365
// add rl_caption
366
- $link = preg_replace( '/(<a.*?)>/s', '$1 data-rl_caption="'. preg_quote( $caption ) .'">', $link );
367
368
if ( isset( $_GET['rl_gallery_no'], $_GET['rl_page'] ) )
369
$this->gallery_no = (int) $_GET['rl_gallery_no'];
@@ -447,11 +454,14 @@ class Responsive_Lightbox_Frontend {
447
* @return array Gallery fields
448
*/
449
public function get_gallery_fields( $type ) {
450
// get gallery fields
451
- $gallery_fields = Responsive_Lightbox()->settings->settings[$type . '_gallery']['fields'];
452
453
// assign settings and defaults
454
- $gallery_defaults = Responsive_Lightbox()->defaults[$type . '_gallery'];
455
456
// make a copy
457
$fields_copy = $gallery_fields;
@@ -460,9 +470,12 @@ class Responsive_Lightbox_Frontend {
460
if ( $field['type'] === 'multiple' ) {
461
foreach ( $field['fields'] as $subfield_key => $subfield ) {
462
$gallery_fields[$field_key]['fields'][$subfield_key]['default'] = $gallery_defaults[$subfield_key];
463
}
464
- } else
465
$gallery_fields[$field_key]['default'] = $gallery_defaults[$field_key];
466
}
467
468
// get shortcode gallery fields combined with defaults
@@ -507,10 +520,10 @@ class Responsive_Lightbox_Frontend {
507
foreach ( $fields as $field_key => $field ) {
508
if ( $field['type'] === 'multiple' ) {
509
foreach ( $field['fields'] as $subfield_key => $subfield ) {
510
- $field_atts[$subfield_key] = $subfield['default'];
511
}
512
} else
513
- $field_atts[$field_key] = $field['default'];
514
}
515
516
// is it rl gallery?
@@ -655,9 +668,8 @@ class Responsive_Lightbox_Frontend {
655
// other field?
656
} else {
657
// valid argument?
658
- if ( array_key_exists( $field_key, $atts ) ) {
659
$atts[$field_key] = Responsive_Lightbox()->galleries->sanitize_field( $field_key, $atts[$field_key], $field );
660
- }
661
}
662
}
663
@@ -710,7 +722,7 @@ class Responsive_Lightbox_Frontend {
710
'post_type' => 'attachment',
711
'post_mime_type' => 'image',
712
'order' => $shortcode_atts['order'],
713
- 'orderby' => $shortcode_atts['orderby'],
714
'fields' => 'ids'
715
)
716
);
@@ -857,10 +869,10 @@ class Responsive_Lightbox_Frontend {
857
$link .= '<span class="rl-gallery-caption">';
858
859
if ( $title )
860
- $link .= '<span class="rl-gallery-item-title">' . $title . '</span>';
861
862
if ( $caption )
863
- $link .= '<span class="rl-gallery-item-caption">' . $caption . '</span>';
864
865
$link .= '</span>';
866
}
@@ -1481,7 +1493,7 @@ class Responsive_Lightbox_Frontend {
1481
// sanitize gallery fields
1482
$atts = $this->sanitize_shortcode_args( $atts, $fields );
1483
1484
- // break if it is not basicgrid gallery
1485
if ( ! ( $atts['type'] === 'basicgrid' || ( $atts['type'] === '' && ( ( $rl_gallery && Responsive_Lightbox()->options['settings']['builder_gallery'] === 'basicgrid' ) || ( ! $rl_gallery && Responsive_Lightbox()->options['settings']['default_gallery'] === 'basicgrid' ) ) ) ) )
1486
return $output;
1487
@@ -1662,7 +1674,7 @@ class Responsive_Lightbox_Frontend {
1662
);
1663
1664
// is there rl_gallery ID?
1665
- $rl_gallery_id = ! empty( $shortcode_atts['rl_gallery_id'] ) ? (int) $shortcode_atts['rl_gallery_id'] : 0;
1666
1667
// is it rl gallery?
1668
$rl_gallery = Responsive_Lightbox()->options['builder']['gallery_builder'] && $rl_gallery_id && get_post_type( $rl_gallery_id ) === 'rl_gallery';
@@ -1683,7 +1695,7 @@ class Responsive_Lightbox_Frontend {
1683
// sanitize gallery fields
1684
$atts = $this->sanitize_shortcode_args( $atts, $fields );
1685
1686
- // break if it is not basicslider gallery
1687
if ( ! ( $atts['type'] === 'basicslider' || ( $atts['type'] === '' && ( ( $rl_gallery && Responsive_Lightbox()->options['settings']['builder_gallery'] === 'basicslider' ) || ( ! $rl_gallery && Responsive_Lightbox()->options['settings']['default_gallery'] === 'basicslider' ) ) ) ) )
1688
return $output;
1689
238
if ( $result[1] !== 'norl' ) {
239
// gallery?
240
if ( $args['settings']['plugin']['images_as_gallery'] || $args['settings']['plugin']['force_custom_gallery'] )
241
+ $link = preg_replace( '/data-rel=(\'|")(.*?)(\'|")/s', 'data-rel="' . $args['selector'] . '-gallery-' . $this->gallery_no . '" data-rl_title="__RL_IMAGE_TITLE__" data-rl_caption="__RL_IMAGE_CAPTION__"' . ( $args['script'] === 'magnific' ? ' data-magnific_type="gallery"' : '' ) . ( $args['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $args['link_number'] . '"' : '' ), $link );
242
// single image
243
else
244
+ $link = preg_replace( '/data-rel=(\'|")(.*?)(\'|")/s', 'data-rel="' . $args['selector'] . '-image-' . base64_encode( $result[1] ) . '"' . ( $args['script'] === 'magnific' ? ' data-magnific_type="image"' : '' ) . ( $args['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $args['link_number'] . '"' : '' ) . ' data-rl_title="__RL_IMAGE_TITLE__" data-rl_caption="__RL_IMAGE_CAPTION__"', $link );
245
}
246
// link without data-rel
247
} else {
251
if ( preg_match( '/<a.*?(?:rel)=(?:\'|")(.*?)(?:\'|").*?>/is', $link, $result ) === 1 ) {
252
// allow to modify link?
253
if ( $result[1] !== 'norl' )
254
+ $link = preg_replace( '/rel=(\'|")(.*?)(\'|")/', 'data-rel="' . $args['selector'] . '-gallery-' . $this->gallery_no . '" data-rl_title="__RL_IMAGE_TITLE__" data-rl_caption="__RL_IMAGE_CAPTION__"' . ( $args['script'] === 'magnific' ? ' data-magnific_type="gallery"' : '' ) . ( $args['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $args['link_number'] . '"' : '' ), $link );
255
} else
256
+ $link = '<a' . $args['link_parts'][0] . ' href="' . $args['link_parts'][1] . '.' . $args['link_parts'][2] . '" data-rel="' . $args['selector'] . '-gallery-' . $this->gallery_no . '" data-rl_title="__RL_IMAGE_TITLE__" data-rl_caption="__RL_IMAGE_CAPTION__"' . ( $args['script'] === 'magnific' ? ' data-magnific_type="gallery"' : '' ) . ( $args['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $args['link_number'] . '"' : '' ) . $args['link_parts'][3] . '>';
257
} else
258
+ $link = '<a' . $args['link_parts'][0] . 'href="' . $args['link_parts'][1] . '.' . $args['link_parts'][2] . '"' . $args['link_parts'][3] . ' data-rel="' . $args['selector'] . ( $args['settings']['plugin']['images_as_gallery'] ? $args['rel_hash'] : '-image-' . $args['link_number'] ) . '"' . ( $args['script'] === 'magnific' ? ' data-magnific_type="image"' : '' ) . ( $args['script'] === 'imagelightbox' ? ' data-imagelightbox="' . $args['link_number'] . '"' : '' ) . ' data-rl_title="__RL_IMAGE_TITLE__" data-rl_caption="__RL_IMAGE_CAPTION__">';
259
}
260
261
+ // use safe replacement
262
+ $link = str_replace( '__RL_IMAGE_TITLE__', $title, str_replace( '__RL_IMAGE_CAPTION__', $caption, $link ) );
263
+
264
// title exists?
265
if ( preg_match( '/<a.*? title=(?:\'|").*?(?:\'|").*?>/is', $link ) === 1 ) {
266
+ $link = preg_replace( '/(<a.*? title=(?:\'|")).*?((?:\'|").*?>)/s', '${1}__RL_IMAGE_TITLE__$2', $link );
267
} else
268
+ $link = preg_replace( '/(<a.*?)>/s', '$1 title="__RL_IMAGE_TITLE__">', $link );
269
+
270
+ // last safe replacement
271
+ $link = str_replace( '__RL_IMAGE_TITLE__', $title, $link );
272
273
return apply_filters( 'rl_lightbox_image_link', $link, $args );
274
}
340
341
// add title and rl_title if needed
342
if ( preg_match( '/<a.*? title=(?:\'|").*?(?:\'|").*?>/is', $link ) === 1 )
343
+ $link = str_replace( '__RL_IMAGE_TITLE__', $title, preg_replace( '/(<a.*? title=(?:\'|")).*?((?:\'|").*?>)/s', '$1__RL_IMAGE_TITLE__" data-rl_title="__RL_IMAGE_TITLE__$2', $link ) );
344
else
345
+ $link = str_replace( '__RL_IMAGE_TITLE__', $title, preg_replace( '/(<a.*?)>/s', '$1 title="__RL_IMAGE_TITLE__" data-rl_title="__RL_IMAGE_TITLE__">', $link ) );
346
347
+
348
// add class if needed
349
+ if ( preg_match( '/<a[^>]*? class=(?:\'|").*?(?:\'|").*?>/is', $link ) === 1 )
350
$link = preg_replace( '/(<a.*?) class=(?:\'|")(.*?)(?:\'|")(.*?>)/s', '$1 class="$2 rl-gallery-link" $3', $link );
351
else
352
$link = preg_replace( '/(<a.*?)>/s', '$1 class="rl-gallery-link">', $link );
370
$caption = esc_attr( wp_strip_all_tags( trim( nl2br( $args['caption'] ) ), true ) );
371
372
// add rl_caption
373
+ $link = str_replace( '__RL_IMAGE_CAPTION__', $caption, preg_replace( '/(<a.*?)>/s', '$1 data-rl_caption="__RL_IMAGE_CAPTION__">', $link ) );
374
375
if ( isset( $_GET['rl_gallery_no'], $_GET['rl_page'] ) )
376
$this->gallery_no = (int) $_GET['rl_gallery_no'];
454
* @return array Gallery fields
455
*/
456
public function get_gallery_fields( $type ) {
457
+ $rl = Responsive_Lightbox();
458
+
459
// get gallery fields
460
+ $gallery_fields = $rl->settings->settings[$type . '_gallery']['fields'];
461
462
// assign settings and defaults
463
+ $gallery_defaults = $rl->defaults[$type . '_gallery'];
464
+ $gallery_values = $rl->options[$type . '_gallery'];
465
466
// make a copy
467
$fields_copy = $gallery_fields;
470
if ( $field['type'] === 'multiple' ) {
471
foreach ( $field['fields'] as $subfield_key => $subfield ) {
472
$gallery_fields[$field_key]['fields'][$subfield_key]['default'] = $gallery_defaults[$subfield_key];
473
+ $gallery_fields[$field_key]['fields'][$subfield_key]['value'] = array_key_exists( $subfield_key, $gallery_values ) ? $gallery_values[$subfield_key] : $gallery_defaults[$subfield_key];
474
}
475
+ } else {
476
$gallery_fields[$field_key]['default'] = $gallery_defaults[$field_key];
477
+ $gallery_fields[$field_key]['value'] = array_key_exists( $field_key, $gallery_values ) ? $gallery_values[$field_key] : $gallery_defaults[$field_key];
478
+ }
479
}
480
481
// get shortcode gallery fields combined with defaults
520
foreach ( $fields as $field_key => $field ) {
521
if ( $field['type'] === 'multiple' ) {
522
foreach ( $field['fields'] as $subfield_key => $subfield ) {
523
+ $field_atts[$subfield_key] = array_key_exists( 'value', $subfield ) ? $subfield['value'] : $subfield['default'];
524
}
525
} else
526
+ $field_atts[$field_key] = array_key_exists( 'value', $field ) ? $field['value'] : $field['default'];
527
}
528
529
// is it rl gallery?
668
// other field?
669
} else {
670
// valid argument?
671
+ if ( array_key_exists( $field_key, $atts ) )
672
$atts[$field_key] = Responsive_Lightbox()->galleries->sanitize_field( $field_key, $atts[$field_key], $field );
673
}
674
}
675
722
'post_type' => 'attachment',
723
'post_mime_type' => 'image',
724
'order' => $shortcode_atts['order'],
725
+ 'orderby' => ( $shortcode_atts['orderby'] === 'menu_order' || $shortcode_atts['orderby'] === '' ? 'post__in' : $shortcode_atts['orderby'] ),
726
'fields' => 'ids'
727
)
728
);
869
$link .= '<span class="rl-gallery-caption">';
870
871
if ( $title )
872
+ $link .= '<span class="rl-gallery-item-title">' . esc_html( $title ) . '</span>';
873
874
if ( $caption )
875
+ $link .= '<span class="rl-gallery-item-caption">' . esc_html( $caption ) . '</span>';
876
877
$link .= '</span>';
878
}
1493
// sanitize gallery fields
1494
$atts = $this->sanitize_shortcode_args( $atts, $fields );
1495
1496
+ // break if it is not basic grid gallery
1497
if ( ! ( $atts['type'] === 'basicgrid' || ( $atts['type'] === '' && ( ( $rl_gallery && Responsive_Lightbox()->options['settings']['builder_gallery'] === 'basicgrid' ) || ( ! $rl_gallery && Responsive_Lightbox()->options['settings']['default_gallery'] === 'basicgrid' ) ) ) ) )
1498
return $output;
1499
1674
);
1675
1676
// is there rl_gallery ID?
1677
+ $rl_gallery_id = $defaults['rl_gallery_id'] = ! empty( $shortcode_atts['rl_gallery_id'] ) ? (int) $shortcode_atts['rl_gallery_id'] : 0;
1678
1679
// is it rl gallery?
1680
$rl_gallery = Responsive_Lightbox()->options['builder']['gallery_builder'] && $rl_gallery_id && get_post_type( $rl_gallery_id ) === 'rl_gallery';
1695
// sanitize gallery fields
1696
$atts = $this->sanitize_shortcode_args( $atts, $fields );
1697
1698
+ // break if it is not basic slider gallery
1699
if ( ! ( $atts['type'] === 'basicslider' || ( $atts['type'] === '' && ( ( $rl_gallery && Responsive_Lightbox()->options['settings']['builder_gallery'] === 'basicslider' ) || ( ! $rl_gallery && Responsive_Lightbox()->options['settings']['default_gallery'] === 'basicslider' ) ) ) ) )
1700
return $output;
1701
includes/class-galleries.php CHANGED
@@ -47,7 +47,6 @@ class Responsive_Lightbox_Galleries {
47
add_action( 'wp_ajax_rl-get-gallery-page-content', array( $this, 'get_gallery_page' ) );
48
add_action( '_wp_put_post_revision', array( $this, 'save_revision' ) );
49
add_action( 'shutdown', array( $this, 'shutdown_preview' ) );
50
- // add_action( 'wp_ajax_rl-get-query-args', array( $this, 'get_query_args' ) );
51
52
// filters
53
add_filter( 'manage_rl_gallery_posts_columns', array( $this, 'gallery_columns' ) );
@@ -1397,8 +1396,6 @@ class Responsive_Lightbox_Galleries {
1397
* @return array
1398
*/
1399
public function get_gallery_images( $gallery_id = 0, $args = array() ) {
1400
- global $pagenow;
1401
-
1402
$images = array();
1403
$excluded = array();
1404
@@ -1446,10 +1443,11 @@ class Responsive_Lightbox_Galleries {
1446
}
1447
}
1448
1449
// is it preview?
1450
- if ( ( in_array( $pagenow, array( 'post.php', 'post-new.php' ), true ) && $gallery_id ) || ( isset( $_POST['action'] ) && $_POST['action'] === 'rl-get-preview-content' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && $_POST['action'] === 'rl-post-gallery-preview' ) ) {
1451
$args['images_per_page'] = 0;
1452
- }
1453
1454
if ( isset( $_GET['rl_page'] ) )
1455
$args['page'] = (int) $_GET['rl_page'];
@@ -2312,49 +2310,6 @@ class Responsive_Lightbox_Galleries {
2312
return apply_filters( 'rl_get_gallery_query_attachments', $attachments, $posts, $args );
2313
}
2314
2315
- /**
2316
- * Get query arguments based on type.
2317
- *
2318
- * @return string Encoded JSON with values
2319
- */
2320
- public function get_query_args() {
2321
- // if ( isset( $_GET['type'], $_GET['nonce'], $_GET['search'], $_GET['page'] ) && check_ajax_referer( 'rl-gallery', 'nonce', false ) ) {
2322
- if ( isset( $_POST['type'], $_POST['post_id'], $_POST['nonce'] ) && check_ajax_referer( 'rl-gallery', 'nonce', false ) ) {
2323
- $data = $this->prepare_query_args( $_POST['type'] );
2324
- $html = '';
2325
-
2326
- if ( ! empty( $data ) ) {
2327
- $images = get_post_meta( (int) $_POST['post_id'], '_rl_images', true );
2328
-
2329
- if ( isset( $images['featured'], $images['featured'][$_POST['type']] ) ) {
2330
- $selected = $images['featured'][$_POST['type']];
2331
- } else
2332
- $selected = array();
2333
-
2334
- if ( $_POST['type'] === 'post_term' ) {
2335
- foreach ( $data as $taxanomy => $group ) {
2336
- $html .= '<optgroup label="' . esc_attr( $group['label'] ) . '">';
2337
-
2338
- foreach ( $group['terms'] as $term_id => $name ) {
2339
- $html .= '<option value="' . $term_id . '" ' . selected( in_array( $term_id, $selected, false ), true, false ) . '>' . esc_html( $name ) . '</option>';
2340
- }
2341
-
2342
- $html .= '</optgroup>';
2343
- }
2344
- } else {
2345
- foreach ( $data as $key => $label ) {
2346
- $html .= '<option value="' . $key . '" ' . selected( in_array( $key, $selected, false ), true, false ) . '>' . $label . '</option>';
2347
- }
2348
- }
2349
- }
2350
-
2351
- wp_send_json_success( array( 'html' => $html ) );
2352
- } else
2353
- wp_send_json_error();
2354
-
2355
- exit;
2356
- }
2357
-
2358
/**
2359
* Load featured content query args.
2360
*
47
add_action( 'wp_ajax_rl-get-gallery-page-content', array( $this, 'get_gallery_page' ) );
48
add_action( '_wp_put_post_revision', array( $this, 'save_revision' ) );
49
add_action( 'shutdown', array( $this, 'shutdown_preview' ) );
50
51
// filters
52
add_filter( 'manage_rl_gallery_posts_columns', array( $this, 'gallery_columns' ) );
1396
* @return array
1397
*/
1398
public function get_gallery_images( $gallery_id = 0, $args = array() ) {
1399
$images = array();
1400
$excluded = array();
1401
1443
}
1444
}
1445
1446
+ global $pagenow;
1447
+
1448
// is it preview?
1449
+ if ( ( in_array( $pagenow, array( 'post.php', 'post-new.php' ), true ) && $gallery_id ) || ( isset( $_POST['action'] ) && $_POST['action'] === 'rl-get-preview-content' ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && ( $_POST['action'] === 'rl-post-gallery-preview' || $_POST['action'] === 'rl-get-menu-content' ) ) )
1450
$args['images_per_page'] = 0;
1451
1452
if ( isset( $_GET['rl_page'] ) )
1453
$args['page'] = (int) $_GET['rl_page'];
2310
return apply_filters( 'rl_get_gallery_query_attachments', $attachments, $posts, $args );
2311
}
2312
2313
/**
2314
* Load featured content query args.
2315
*
includes/class-settings.php CHANGED
@@ -468,19 +468,19 @@ class Responsive_Lightbox_Settings {
468
'type' => 'number',
469
'min' => 0,
470
'max' => 6,
471
- 'append' => __( 'large devices / desktops (>1200px)', 'responsive-lightbox' )
472
),
473
'columns_md' => array(
474
'type' => 'number',
475
'min' => 0,
476
'max' => 6,
477
- 'append' => __( 'medium devices / desktops (>992px)', 'responsive-lightbox' )
478
),
479
'columns_sm' => array(
480
'type' => 'number',
481
'min' => 0,
482
'max' => 6,
483
- 'append' => __( 'small devices / tablets (>768px)', 'responsive-lightbox' )
484
),
485
'columns_xs' => array(
486
'type' => 'number',
@@ -745,21 +745,21 @@ class Responsive_Lightbox_Settings {
745
'min' => 0,
746
'max' => 6,
747
'default' => 4,
748
- 'append' => __( 'large devices / desktops (?1200px)', 'responsive-lightbox' )
749
),
750
'columns_md' => array(
751
'type' => 'number',
752
'min' => 0,
753
'max' => 6,
754
'default' => 3,
755
- 'append' => __( 'medium devices / desktops (?992px)', 'responsive-lightbox' )
756
),
757
'columns_sm' => array(
758
'type' => 'number',
759
'min' => 0,
760
'max' => 6,
761
'default' => 2,
762
- 'append' => __( 'small devices / tablets (?768px)', 'responsive-lightbox' )
763
),
764
'columns_xs' => array(
765
'type' => 'number',
468
'type' => 'number',
469
'min' => 0,
470
'max' => 6,
471
+ 'append' => __( 'large devices / desktops (&ge;1200px)', 'responsive-lightbox' )
472
),
473
'columns_md' => array(
474
'type' => 'number',
475
'min' => 0,
476
'max' => 6,
477
+ 'append' => __( 'medium devices / desktops (&ge;992px)', 'responsive-lightbox' )
478
),
479
'columns_sm' => array(
480
'type' => 'number',
481
'min' => 0,
482
'max' => 6,
483
+ 'append' => __( 'small devices / tablets (&ge;768px)', 'responsive-lightbox' )
484
),
485
'columns_xs' => array(
486
'type' => 'number',
745
'min' => 0,
746
'max' => 6,
747
'default' => 4,
748
+ 'append' => __( 'large devices / desktops (&ge;1200px)', 'responsive-lightbox' )
749
),
750
'columns_md' => array(
751
'type' => 'number',
752
'min' => 0,
753
'max' => 6,
754
'default' => 3,
755
+ 'append' => __( 'medium devices / desktops (&ge;992px)', 'responsive-lightbox' )
756
),
757
'columns_sm' => array(
758
'type' => 'number',
759
'min' => 0,
760
'max' => 6,
761
'default' => 2,
762
+ 'append' => __( 'small devices / tablets (&ge;768px)', 'responsive-lightbox' )
763
),
764
'columns_xs' => array(
765
'type' => 'number',
includes/functions.php CHANGED
@@ -73,7 +73,10 @@ function rl_get_gallery_fields_atts( $fields, $shortcode_atts, $gallery = true )
73
* @return array Gallery images
74
*/
75
function rl_get_gallery_images( $gallery_id, $args ) {
76
- return Responsive_Lightbox()->galleries->get_gallery_images( $gallery_id, $args );
77
}
78
79
/**
73
* @return array Gallery images
74
*/
75
function rl_get_gallery_images( $gallery_id, $args ) {
76
+ if ( did_action( 'init' ) )
77
+ return Responsive_Lightbox()->galleries->get_gallery_images( $gallery_id, $args );
78
+ else
79
+ return array();
80
}
81
82
/**
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dfactory
3
Donate link: http://www.dfactory.eu/
4
Tags: gallery, images, lightbox, photos, theme, photo, image, picture, slideshow, modal, overlay, video
5
Requires at least: 4.0
6
- Tested up to: 4.9.5
7
- Stable tag: 2.0.4
8
Requires PHP: 5.2.4
9
License: MIT License
10
License URI: http://opensource.org/licenses/MIT
@@ -78,6 +78,12 @@ No questions yet.
78
79
== Changelog ==
80
81
= 2.0.4 =
82
* Fix: Gallery sorting and orderby not working
83
* Fix: Slow db query on post edit screen
@@ -351,7 +357,8 @@ Initial release
351
352
== Upgrade Notice ==
353
354
- = 2.0.4 =
355
- * Fix: Gallery sorting and orderby not working
356
- * Fix: Slow db query on post edit screen
357
- * Fix: WooCommerce gallery undefined method for get_gallery_image_ids
3
Donate link: http://www.dfactory.eu/
4
Tags: gallery, images, lightbox, photos, theme, photo, image, picture, slideshow, modal, overlay, video
5
Requires at least: 4.0
6
+ Tested up to: 4.9.6
7
+ Stable tag: 2.0.5
8
Requires PHP: 5.2.4
9
License: MIT License
10
License URI: http://opensource.org/licenses/MIT
78
79
== Changelog ==
80
81
+ = 2.0.5 =
82
+ * Fix: Escaped characters on titles and descriptions
83
+ * Fix: Gallery shortcode not accepting image order
84
+ * Fix: Gallery using default parameters instead of the settings
85
+ * Fix: PHP fatal error if gallery builder is disabled
86
+
87
= 2.0.4 =
88
* Fix: Gallery sorting and orderby not working
89
* Fix: Slow db query on post edit screen
357
358
== Upgrade Notice ==
359
360
+ = 2.0.5 =
361
+ * Fix: Escaped characters on titles and descriptions
362
+ * Fix: Gallery shortcode not accepting image order
363
+ * Fix: Gallery using default parameters instead of the settings
364
+ * Fix: PHP fatal error if gallery builder is disabled
responsive-lightbox.php CHANGED
@@ -2,7 +2,7 @@
2
/*
3
Plugin Name: Responsive Lightbox & Gallery
4
Description: Responsive Lightbox & Gallery allows users to create galleries and view larger versions of images, galleries and videos in a lightbox (overlay) effect optimized for mobile devices.
5
- Version: 2.0.4
6
Author: dFactory
7
Author URI: http://www.dfactory.eu/
8
Plugin URI: http://www.dfactory.eu/plugins/responsive-lightbox/
@@ -30,8 +30,8 @@ define( 'RESPONSIVE_LIGHTBOX_PATH', plugin_dir_path( __FILE__ ) );
30
define( 'RESPONSIVE_LIGHTBOX_REL_PATH', dirname( plugin_basename( __FILE__ ) ) . DIRECTORY_SEPARATOR );
31
32
include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-fast-image.php' );
33
- include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-frontend.php' );
34
include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-galleries.php' );
35
include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-settings.php' );
36
include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-tour.php' );
37
include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-welcome.php' );
@@ -42,7 +42,7 @@ include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'fun
42
* Responsive Lightbox class.
43
*
44
* @class Responsive_Lightbox
45
- * @version 2.0.4
46
*/
47
class Responsive_Lightbox {
48
@@ -238,7 +238,7 @@ class Responsive_Lightbox {
238
'origin_left' => true,
239
'origin_top' => true
240
),
241
- 'version' => '2.0.4',
242
'activation_date' => ''
243
);
244
public $options = array();
2
/*
3
Plugin Name: Responsive Lightbox & Gallery
4
Description: Responsive Lightbox & Gallery allows users to create galleries and view larger versions of images, galleries and videos in a lightbox (overlay) effect optimized for mobile devices.
5
+ Version: 2.0.5
6
Author: dFactory
7
Author URI: http://www.dfactory.eu/
8
Plugin URI: http://www.dfactory.eu/plugins/responsive-lightbox/
30
define( 'RESPONSIVE_LIGHTBOX_REL_PATH', dirname( plugin_basename( __FILE__ ) ) . DIRECTORY_SEPARATOR );
31
32
include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-fast-image.php' );
33
include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-galleries.php' );
34
+ include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-frontend.php' );
35
include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-settings.php' );
36
include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-tour.php' );
37
include_once( RESPONSIVE_LIGHTBOX_PATH . 'includes' . DIRECTORY_SEPARATOR . 'class-welcome.php' );
42
* Responsive Lightbox class.
43
*
44
* @class Responsive_Lightbox
45
+ * @version 2.0.5
46
*/
47
class Responsive_Lightbox {
48
238
'origin_left' => true,
239
'origin_top' => true
240
),
241
+ 'version' => '2.0.5',
242
'activation_date' => ''
243
);
244
public $options = array();