Skip to content

Commit 6cbb60c

Browse files
Merge pull request #41 from MachoThemes/master
3.1.2 update
2 parents 0414579 + ed0118a commit 6cbb60c

File tree

2 files changed

+66
-79
lines changed

2 files changed

+66
-79
lines changed

fancybox.php

Lines changed: 59 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin Name: FancyBox for WordPress
55
Plugin URI: https://wordpress.org/plugins/fancybox-for-wordpress/
66
Description: Integrates <a href="http://fancyapps.com/fancybox/3/">FancyBox 3</a> into WordPress.
7-
Version: 3.1.0
7+
Version: 3.1.2
88
Author: Colorlib
99
Author URI: https://colorlib.com/wp/
1010
@@ -19,7 +19,7 @@
1919
* Plugin Init
2020
*/
2121
// Constants
22-
define( 'FBFW_VERSION', '3.1.0' );
22+
define( 'FBFW_VERSION', '3.1.2' );
2323
define( 'FBFW_PATH', plugin_dir_path( __FILE__ ) );
2424
define( 'FBFW_URL', plugin_dir_url( __FILE__ ) );
2525
define( 'FBFW_PLUGIN_BASE', plugin_basename( __FILE__ ) );
@@ -106,7 +106,7 @@ function mfbfw_defaults() {
106106
jQuery.each(arr, function() {
107107
var title = jQuery(this).children("img").attr("title");
108108
var caption = jQuery(this).next("figcaption").html();
109-
if(caption.length){jQuery(this).attr("title",title+" " + caption)}else{ jQuery(this).attr("title",title);}console.log(caption);
109+
if(caption.length){jQuery(this).attr("title",title+" " + caption)}else{ jQuery(this).attr("title",title);};
110110
}); ',
111111
'nojQuery' => '',
112112
'extraCallsEnable' => '',
@@ -266,111 +266,92 @@ function mfbfw_init() {
266266
' . ( isset( $mfbfw['titleColor'] ) && $mfbfw['titlePosition'] == 'inside' ? 'div.fancybox-caption p.caption-title{color:' . $mfbfw['titleColor'] . '}' : 'div.fancybox-caption p.caption-title{color:#fff}' ) . '
267267
' . ( isset( $mfbfw['titlePosition'] ) ? 'div.fancybox-caption {color:' . $mfbfw['titleColor'] . '}' : 'div.fancybox-caption p.caption-title{color:#333333}' ) . $captionPosition . '
268268
</style>';
269-
270-
echo '
269+
?>
271270
<script type="text/javascript">
272271
jQuery(function(){
273272

274273
jQuery.fn.getTitle = function() { // Copy the title of every IMG tag and add it to its parent A so that fancybox can show titles
275-
' . $mfbfw['copyTitleFunction'] . '
274+
<?php echo $mfbfw['copyTitleFunction'] ?>
276275
}
277276

278277
// Supported file extensions
279-
var thumbnails = jQuery("a:has(img)").not(".nolightbox, .nofancybox, a:has(img.nolightbox, img.nofancybox)").filter( function() { return /\.(jpe?g|png|gif|bmp|mp4)?.+$/i.test(jQuery(this).attr("href")) });';
280-
if ( $mfbfw['galleryType'] == 'post' ) {
278+
var thumbnails = jQuery("a:has(img)").not(".nolightbox").filter( function() { return /\.(jpe?g|png|gif|bmp)$/i.test(jQuery(this).attr('href')) });
279+
<?php if ( $mfbfw['galleryType'] == 'post' ) { ?>
281280

282281
// Gallery type BY POST and on post or page (so only one post or page is visible)
283-
if ( is_singular() ) {
284-
echo '
285-
// Gallery by post
286-
thumbnails.addClass("fancybox").attr("data-fancybox","gallery").getTitle();
287-
';
288-
289-
// Gallery type BY POST, but neither on post or page, so make a different rel attribute on each post
290-
} else {
291-
echo '
292-
// Gallery by post
293-
var posts = jQuery(".post");
294-
posts.each(function() {
295-
jQuery(this).find(thumbnails).addClass("fancybox").attr("data-fancybox","gallery"+posts.index(this)).attr("rel","fancybox"+posts.index(this)).getTitle()
296-
});
297-
';
298-
}
282+
<?php if ( is_singular() ) { ?>
283+
// Gallery by post
284+
thumbnails.addClass("fancybox").attr("data-fancybox","gallery").getTitle();
285+
286+
<?php } else { ?>
287+
// Gallery by post
288+
var posts = jQuery(".post");
289+
posts.each(function() {
290+
jQuery(this).find(thumbnails).addClass("fancybox").attr("data-fancybox","gallery"+posts.index(this)).attr("rel","fancybox"+posts.index(this)).getTitle()
291+
});
292+
293+
<?php } ?>
299294

300295
// Gallery type ALL
301-
} elseif ( $mfbfw['galleryType'] == 'all' ) {
302-
echo '
296+
<?php } elseif ( $mfbfw['galleryType'] == 'all' ) { ?>
303297
// Gallery All
304298
thumbnails.addClass("fancybox").attr("data-fancybox","gallery").getTitle();
305-
';
306299

307300
// Gallery type NONE
308-
} elseif ( $mfbfw['galleryType'] == 'none' ) {
309-
echo '
301+
<?php } elseif ( $mfbfw['galleryType'] == 'none' ) { ?>
310302
// No Galleries
311303
thumbnails.each(function(){
312304
var rel = jQuery(this).attr("rel");
313305
var imgTitle = jQuery(this).children("img").attr("title");
314306
jQuery(this).addClass("fancybox").attr("data-fancybox",rel);
315307
jQuery(this).attr("title",imgTitle);
316-
})
317-
';
308+
});
318309

319310
// Else, gallery type is custom, so just print the custom expression
320-
} else {
321-
echo '
322-
// Custom Expression
323-
' . $mfbfw['customExpression'] . '
324-
';
325-
}
311+
<?php } else { ?>
312+
/* Custom Expression */
313+
<?php echo $mfbfw['customExpression']; ?>
314+
<?php } ?>
326315

327-
// Call fancybox and apply it on any link with a rel atribute that starts with "fancybox", with the options set on the admin panel
328-
echo '
316+
// Call fancybox and apply it on any link with a rel atribute that starts with "fancybox", with the options set on the admin panel
329317
jQuery("a.fancybox").fancybox({
330-
"loop": ' . ( isset( $mfbfw['cyclic'] ) && $mfbfw['cyclic'] ? 'true' : 'false' ) . ',
331-
"smallBtn": ' . ( isset( $mfbfw['showCloseButton'] ) && $mfbfw['showCloseButton'] ? 'true' : 'false' ) . ',
332-
"zoomOpacity": "' . ( isset( $mfbfw['zoomOpacity'] ) && $mfbfw['zoomOpacity'] ? 'auto' : 'false' ) . '",
333-
"animationEffect": "' . $mfbfw['transitionIn'] . '",
334-
"animationDuration": ' . $mfbfw['zoomSpeedIn'] . ',
335-
"transitionEffect": "' . $mfbfw['transitionEffect'] . '",
336-
"transitionDuration" : "' . $mfbfw['zoomSpeedChange'] . '",
337-
"overlayShow": ' . ( isset( $mfbfw['overlayShow'] ) && $mfbfw['overlayShow'] ? 'true' : 'false' ) . ',
338-
"overlayOpacity": "' . $mfbfw['overlayOpacity'] . '",
339-
"titleShow": ' . ( isset( $mfbfw['titleShow'] ) && $mfbfw['titleShow'] ? 'true' : 'false' ) . ',
340-
"titlePosition": "' . $mfbfw['titlePosition'] . '",
341-
"keyboard": ' . ( isset( $mfbfw['enableEscapeButton'] ) && $mfbfw['enableEscapeButton'] ? 'true' : 'false' ) . ',
342-
"showCloseButton": ' . ( isset( $mfbfw['showCloseButton'] ) && $mfbfw['showCloseButton'] ? 'true' : 'false' ) . ',
343-
"arrows": ' . ( isset( $mfbfw['showNavArrows'] ) && $mfbfw['showNavArrows'] ? 'true' : 'false' ) . ',
344-
"clickContent": ' . ( isset( $mfbfw['hideOnContentClick'] ) && $mfbfw['hideOnContentClick'] ? '"close"' : 'false' ) . ',
345-
"clickSlide": ' . ( isset( $mfbfw['hideOnOverlayClick'] ) && $mfbfw['hideOnOverlayClick'] ? 'function(current, event) {
346-
return current.type === "image" ? "close" : false;
347-
}' : 'false' ) . ',
348-
"wheel": ' . ( isset( $mfbfw['mouseWheel'] ) && $mfbfw['mouseWheel'] ? 'true' : 'false' ) . ',
349-
' . $frameSize . '
350-
"onInit": ' . ( isset( $mfbfw['callbackEnable'], $mfbfw['callbackOnStart'] ) && $mfbfw['callbackEnable'] && $mfbfw['callbackOnStart'] ? $mfbfw['callbackOnStart'] . ',' : 'function() { },' ) . '
351-
"onDeactivate": ' . ( isset( $mfbfw['callbackEnable'], $mfbfw['callbackOnCancel'] ) && $mfbfw['callbackEnable'] && $mfbfw['callbackOnCancel'] ? $mfbfw['callbackOnCancel'] . ',' : 'function() { },' ) . '
352-
"beforeClose": ' . ( isset( $mfbfw['callbackEnable'], $mfbfw['callbackOnCleanup'] ) && $mfbfw['callbackEnable'] && $mfbfw['callbackOnCleanup'] ? $mfbfw['callbackOnCleanup'] . ',' : 'function() { },' ) . '
353-
"afterShow": ' . ( isset( $mfbfw['callbackEnable'], $mfbfw['callbackOnComplete'] ) && $mfbfw['callbackEnable'] && $mfbfw['callbackOnComplete'] ? $mfbfw['callbackOnComplete'] . ',' : 'function() { },' ) . '
354-
"afterClose": ' . ( isset( $mfbfw['callbackEnable'], $mfbfw['callbackOnClose'] ) && $mfbfw['callbackEnable'] && $mfbfw['callbackOnClose'] ? $mfbfw['callbackOnClose'] . ',' : 'function() { },' ) . '
355-
"toolbar":' . ( isset( $mfbfw['showToolbar'] ) && $mfbfw['showToolbar'] ? 'true' : 'false' ) . ',
356-
"preventCaptionOverlap": true,
357-
"caption" : ' . $caption . ',
358-
"afterLoad" : ' . $afterLoad . ',
318+
loop: <?php echo ( isset( $mfbfw['cyclic'] ) && $mfbfw['cyclic'] ? 'true' : 'false' ) ?>,
319+
smallBtn: <?php echo ( isset( $mfbfw['showCloseButton'] ) && $mfbfw['showCloseButton'] ? 'true' : 'false' ) ?>,
320+
zoomOpacity: <?php echo ( isset( $mfbfw['zoomOpacity'] ) && $mfbfw['zoomOpacity'] ? '"auto"' : 'false' ) ?>,
321+
animationEffect: "<?php echo $mfbfw['transitionIn'] ?>",
322+
animationDuration: <?php echo $mfbfw['zoomSpeedIn'] ?>,
323+
transitionEffect: "<?php echo $mfbfw['transitionEffect'] ?>",
324+
transitionDuration : "<?php echo $mfbfw['zoomSpeedChange'] ?>",
325+
overlayShow: <?php echo ( isset( $mfbfw['overlayShow'] ) && $mfbfw['overlayShow'] ? 'true' : 'false' ) ?>,
326+
overlayOpacity: "<?php echo $mfbfw['overlayOpacity'] ?>",
327+
titleShow: <?php echo ( isset( $mfbfw['titleShow'] ) && $mfbfw['titleShow'] ? 'true' : 'false' ) ?>,
328+
titlePosition: "<?php echo $mfbfw['titlePosition'] ?>",
329+
keyboard: <?php echo ( isset( $mfbfw['enableEscapeButton'] ) && $mfbfw['enableEscapeButton'] ? 'true' : 'false' ) ?>,
330+
showCloseButton: <?php echo ( isset( $mfbfw['showCloseButton'] ) && $mfbfw['showCloseButton'] ? 'true' : 'false' ) ?>,
331+
arrows: <?php echo ( isset( $mfbfw['showNavArrows'] ) && $mfbfw['showNavArrows'] ? 'true' : 'false' ) ?>,
332+
clickContent: <?php echo ( isset( $mfbfw['hideOnContentClick'] ) && $mfbfw['hideOnContentClick'] ? '"close"' : 'false' ) ?>,
333+
clickSlide: <?php echo ( isset( $mfbfw['hideOnOverlayClick'] ) && $mfbfw['hideOnOverlayClick'] ? 'function(current, event) {return current.type === "image" ? "close" : false;}' : 'false' ) ?>,
334+
wheel: <?php echo ( isset( $mfbfw['mouseWheel'] ) && $mfbfw['mouseWheel'] ? 'true' : 'false' ) ?>,
335+
toolbar: <?php echo ( isset( $mfbfw['showToolbar'] ) && $mfbfw['showToolbar'] ? 'true' : 'false' ) ?>,
336+
preventCaptionOverlap: true,
337+
onInit: <?php echo ( isset( $mfbfw['callbackEnable'], $mfbfw['callbackOnStart'] ) && $mfbfw['callbackEnable'] && $mfbfw['callbackOnStart'] ? $mfbfw['callbackOnStart'] . ',' : 'function() { },' ) ?>
338+
onDeactivate: <?php echo ( isset( $mfbfw['callbackEnable'], $mfbfw['callbackOnCancel'] ) && $mfbfw['callbackEnable'] && $mfbfw['callbackOnCancel'] ? $mfbfw['callbackOnCancel'] . ',' : 'function() { },' ) ?>
339+
beforeClose: <?php echo ( isset( $mfbfw['callbackEnable'], $mfbfw['callbackOnCleanup'] ) && $mfbfw['callbackEnable'] && $mfbfw['callbackOnCleanup'] ? $mfbfw['callbackOnCleanup'] . ',' : 'function() { },' ) ?>
340+
afterShow: <?php echo ( isset( $mfbfw['callbackEnable'], $mfbfw['callbackOnComplete'] ) && $mfbfw['callbackEnable'] && $mfbfw['callbackOnComplete'] ? $mfbfw['callbackOnComplete'] . ',' : 'function() { },' ) ?>
341+
afterClose: <?php echo ( isset( $mfbfw['callbackEnable'], $mfbfw['callbackOnClose'] ) && $mfbfw['callbackEnable'] && $mfbfw['callbackOnClose'] ? $mfbfw['callbackOnClose'] . ',' : 'function() { },' ) ?>
342+
caption : <?php echo $caption ?>,
343+
afterLoad : <?php echo $afterLoad ?>,
344+
<?php echo $frameSize ?>
359345
});
360-
';
346+
<?php if ( isset( $mfbfw['extraCallsEnable'] ) && $mfbfw['extraCallsEnable'] ) {
347+
echo "/* Extra Calls */";
348+
echo $mfbfw['extraCallsData'];
349+
} ?>
361350

362-
if ( isset( $mfbfw['extraCallsEnable'] ) && $mfbfw['extraCallsEnable'] ) {
363-
echo '
364-
// Extra Calls
365-
' . $mfbfw['extraCallsData'] . '
366-
';
367-
}
368-
369-
echo '
370351
})
371352
</script>
372353
<!-- END Fancybox for WordPress -->
373-
';
354+
<?php
374355
}
375356
}
376357

readme.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: silkalns
33
Tags: fancybox, lightbox, jquery, gallery, image, images, photo, photos, picture, pictures, zoom
44
Requires at least: 3.4
55
Tested up to: 4.9
6-
Stable tag: 3.1.0
6+
Stable tag: 3.1.2
77
License: GPL/MIT
88

99
Seamlessly integrates FancyBox lightbox into your WordPress blog: Upload, activate, and you're done. Additional configuration optional.
@@ -31,6 +31,12 @@ If you enjoy using FancyBox lightbox for WordPress please leave a [positive feed
3131

3232
== Changelog ==
3333

34+
= 3.1.2 =
35+
* Fixed "All links get the fancybox class"
36+
37+
= 3.1.1 =
38+
* Removed print_r from fancybox.php
39+
3440
= 3.1.0 =
3541
* Updated FancyBox library to the latest version
3642
* Changed Admin UI

0 commit comments

Comments
 (0)