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-jetpack-compatibility.php
69 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Jetpack Compatibility Class |
| 9 | * |
| 10 | * @since 2.0.25 |
| 11 | * |
| 12 | * @package foogallery |
| 13 | */ |
| 14 | |
| 15 | if ( ! class_exists( 'FooGallery_Jetpack_Compatibility' ) ) { |
| 16 | |
| 17 | /** |
| 18 | * Class FooGallery_Jetpack_Compatibility |
| 19 | */ |
| 20 | class FooGallery_Jetpack_Compatibility { |
| 21 | |
| 22 | /** |
| 23 | * FooGallery_Jetpack_Compatibility constructor. |
| 24 | */ |
| 25 | public function __construct() { |
| 26 | // Add 'skip-lazy' class onto all image tags generated by FooGallery. |
| 27 | add_filter( 'foogallery_attachment_html_image_attributes', array( $this, 'add_lazy_image_attributes' ), 10, 3 ); |
| 28 | |
| 29 | // Add 'data' to allowed protocols. |
| 30 | // This it to overcome a conflict with JetPack lazy images, whereby JP passes all image attributes through the wp_kses_hair function |
| 31 | // This results in our image placeholder src of 'data:image/svg+xml...' being replaced with 'image/svg+xml...' which returns a 404. |
| 32 | add_filter( 'kses_allowed_protocols', array( $this, 'add_data_to_allowed_protocols' ) ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Adds skip-lazy class to all img tags so that they get ignored by lazy loading plugins |
| 37 | * |
| 38 | * @param array $attr the attributes. |
| 39 | * @param array $args extra arguments. |
| 40 | * @param FooGalleryAttachment $foogallery_attachment the current attachment. |
| 41 | * |
| 42 | * @return mixed |
| 43 | */ |
| 44 | public function add_lazy_image_attributes( $attr, $args, $foogallery_attachment ) { |
| 45 | if ( array_key_exists( 'class', $attr ) ) { |
| 46 | $attr['class'] .= ' skip-lazy'; |
| 47 | } else { |
| 48 | $attr['class'] = 'skip-lazy'; |
| 49 | } |
| 50 | |
| 51 | return $attr; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | /** |
| 56 | * Add 'data' to allowed protocols. |
| 57 | * |
| 58 | * @param array $protocols existing allowed protocols. |
| 59 | * |
| 60 | * @return mixed |
| 61 | */ |
| 62 | public function add_data_to_allowed_protocols( $protocols ) { |
| 63 | $protocols[] = 'data'; |
| 64 | |
| 65 | return $protocols; |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 |