Skip to content

Commit 6f9fd18

Browse files
committed
#54 added option to disable lightbox for link to pdf files / changelog update / exclude pdf condition
1 parent 90ceefb commit 6f9fd18

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

fancybox.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ function mfbfw_enqueue_scripts() {
172172

173173
// Register Scripts
174174
wp_register_script( 'fancybox', FBFW_URL . 'assets/js/jquery.fancybox.js', $jquery, '1.3.4', $footer ); // Main Fancybox script
175+
175176
// Enqueue Scripts
176177
wp_enqueue_script( 'fancybox' ); // Load fancybox
177178

@@ -290,7 +291,23 @@ function mfbfw_init() {
290291
}
291292

292293
// Supported file extensions
293-
var thumbnails = jQuery("a:has(img)").not(".nolightbox").not('.envira-gallery-link').not('.ngg-simplelightbox').filter( function() { return /\.(jpe?g|png|gif|mp4|webp|bmp|pdf)(\?[^/]*)*$/i.test(jQuery(this).attr('href')) });
294+
295+
<?php
296+
if(isset($mfbfw['exclude_pdf']) && 'on' == $mfbfw['exclude_pdf']){
297+
?>
298+
var thumbnails = jQuery("a:has(img)").not(".nolightbox").not('.envira-gallery-link').not('.ngg-simplelightbox').filter(function () {
299+
return /\.(jpe?g|png|gif|mp4|webp|bmp)(\?[^/]*)*$/i.test(jQuery(this).attr('href'))
300+
});
301+
<?php
302+
} else {
303+
?>
304+
var thumbnails = jQuery("a:has(img)").not(".nolightbox").not('.envira-gallery-link').not('.ngg-simplelightbox').filter(function () {
305+
return /\.(jpe?g|png|gif|mp4|webp|bmp|pdf)(\?[^/]*)*$/i.test(jQuery(this).attr('href'))
306+
});
307+
<?php
308+
}
309+
?>
310+
294311

295312
// Add data-type iframe for links that are not images or videos.
296313
var iframeLinks = jQuery('.fancyboxforwp').filter( function() { return ! /\.(jpe?g|png|gif|mp4|webp|bmp|pdf)(\?[^/]*)*$/i.test(jQuery(this).attr('href')) }).filter( function() { return ! /vimeo|youtube/i.test(jQuery(this).attr('href')) });

lib/admin-tab-behaviour.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,31 @@
174174
</fieldset>
175175
</td>
176176
</tr>
177+
<tr valign="top">
178+
<th scope="row"><?php _e( 'Exclude PDF files', 'mfbfw' ); ?>
179+
<span class="tooltip-right"
180+
data-tooltip="<?php _e( 'Excludes links to files type .pdf from being displayed in the lightbox (default: off)', 'mfbfw' ); ?>">
181+
<i class="dashicons dashicons-editor-help"></i>
182+
</span>
183+
</th>
184+
<td>
185+
<fieldset>
186+
<div class="epsilon-toggle">
187+
<input class="epsilon-toggle__input" type="checkbox" id="exclude_pdf" name="mfbfw[exclude_pdf]" <?php checked( 1, isset( $settings['exclude_pdf'] ) && $settings['exclude_pdf'] ); ?> >
188+
<div class="epsilon-toggle__items">
189+
<span class="epsilon-toggle__track"></span>
190+
<span class="epsilon-toggle__thumb"></span>
191+
<svg class="epsilon-toggle__off" width="6" height="6" aria-hidden="true" role="img" focusable="false" viewBox="0 0 6 6">
192+
<path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path>
193+
</svg>
194+
<svg class="epsilon-toggle__on" width="2" height="6" aria-hidden="true" role="img" focusable="false" viewBox="0 0 2 6">
195+
<path d="M0 0h2v6H0z"></path>
196+
</svg>
197+
</div>
198+
</div>
199+
<div class="cf"></div>
200+
</fieldset>
201+
</td>
202+
</tr>
177203
</tbody>
178204
</table>

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ If you enjoy using FancyBox lightbox for WordPress please leave a [positive feed
3434
= 3.2.0 =
3535
* Admin UI minor update
3636
* Removed unneeded ie css file
37+
* Added option in Behaviour tab to exclude links that target .pdf files from being displayed in the lightbox
3738

3839
= 3.1.9 =
3940
* Replace $.fancebox with $.fancyboxforwp.

0 commit comments

Comments
 (0)