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