elementor
7 months ago
class-autoptimize-compatibility.php
7 months ago
class-elasticpress-compatibility.php
7 months ago
class-elementor-compatibility.php
7 months ago
class-foobox-compatibility.php
7 months ago
class-foogallery-compatibility.php
7 months ago
class-foovideo-compatibility.php
7 months ago
class-jetpack-compatibility.php
7 months ago
class-polylang-compatibility.php
7 months ago
class-responsive-lightbox-dfactory-compatibility.php
7 months ago
class-wpoptimize-compatibility.php
7 months ago
class-wprocket-compatibility.php
7 months ago
view-foovideo-offer.php
7 months ago
class-responsive-lightbox-dfactory-compatibility.php
61 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Builds in support for the Responsive Lightbox plugin by dFactory |
| 4 | * Created by brad. |
| 5 | * Date: 13/05/2017 |
| 6 | * |
| 7 | * @since 1.2.21 |
| 8 | */ |
| 9 | if ( ! class_exists( 'FooGallery_Responsive_Lightbox_dFactory_Compatibility' ) ) { |
| 10 | |
| 11 | class FooGallery_Responsive_Lightbox_dFactory_Compatibility { |
| 12 | |
| 13 | function __construct() { |
| 14 | add_filter( 'foogallery_gallery_template_field_lightboxes', array( $this, 'add_lightbox' ), 99 ); |
| 15 | add_filter( 'foogallery_attachment_html_link_attributes', array( $this, 'add_attributes' ), 10, 3 ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Add the dFactory lightbox to the available FooGallery lightboxes |
| 20 | * @param $lightboxes |
| 21 | * |
| 22 | * @return mixed |
| 23 | * @since 1.2.21 |
| 24 | */ |
| 25 | function add_lightbox($lightboxes) { |
| 26 | if ( class_exists( 'Responsive_Lightbox' ) ) { |
| 27 | $option_text = __( 'Responsive Lightbox by dFactory', 'foogallery' ); |
| 28 | $lightboxes['dfactory'] = $option_text; |
| 29 | } |
| 30 | |
| 31 | return $lightboxes; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * If the dFactory lightbox is selected for the gallery, then make the integration work |
| 36 | * |
| 37 | * @param $attr |
| 38 | * @param $args |
| 39 | * @param $attachment |
| 40 | * |
| 41 | * @return mixed |
| 42 | * @since 1.2.21 |
| 43 | */ |
| 44 | function add_attributes($attr, $args, $attachment) { |
| 45 | if ( class_exists( 'Responsive_Lightbox' ) ) { |
| 46 | $lightbox = foogallery_gallery_template_setting( 'lightbox', 'unknown' ); |
| 47 | |
| 48 | //only add attributes if the dfactory lightbox is in use |
| 49 | if ( 'dfactory' === $lightbox ) { |
| 50 | $attr['data-rel'] = 'lightbox'; |
| 51 | |
| 52 | if ( !empty( $attachment->caption ) ) { |
| 53 | $attr['title'] = $attachment->caption; |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | return $attr; |
| 59 | } |
| 60 | } |
| 61 | } |