PluginProbe ʕ •ᴥ•ʔ
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel / trunk
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel vtrunk
trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / compatibility / class-wprocket-compatibility.php
foogallery / includes / compatibility Last commit date
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-wprocket-compatibility.php
65 lines
1 <?php
2 /**
3 * Adds support for WPRocket in FooGallery
4 * Created by brad.
5 * Date: 11/06/2017
6 *
7 * @since 1.3.3
8 */
9 if ( ! class_exists( 'FooGallery_WPRocket_Compatibility' ) ) {
10
11 class FooGallery_WPRocket_Compatibility {
12
13 function __construct() {
14 add_action( 'plugins_loaded', array( $this, 'init_wprocket' ) );
15 }
16
17 /**
18 * Init hooks for WPRocket
19 */
20 function init_wprocket() {
21 //check that WPRocket is activated
22 if ( defined( 'WP_ROCKET_VERSION' ) ) {
23 //add_filter( 'foogallery_process_image_url', array( $this, 'force_images_to_use_rocket_cdn' ), 999 );
24 add_filter( 'foogallery_attachment_html_image_attributes', array( $this, 'alter_image_attributes' ), 10, 3 );
25 add_filter( 'rocket_excluded_inline_js_content', array( $this, 'ensure_foogallery_items_excluded' ) );
26 }
27 }
28
29 function ensure_foogallery_items_excluded( $excluded_inline ) {
30 $excluded_inline[] = 'window["foogallery-gallery-';
31 return $excluded_inline;
32 }
33
34 /**
35 *
36 * @param $url
37 *
38 * @return mixed
39 */
40 function force_images_to_use_rocket_cdn( $url ) {
41 if ( function_exists( 'get_rocket_cdn_url' ) ) {
42 return get_rocket_cdn_url( $url );
43 }
44
45 return $url;
46 }
47
48 /**
49 * Ensure that WPRocket lazyloading does not interfere with FooGallery's lazy loading
50 *
51 * @uses "foogallery_attachment_html_image_attributes" filter
52 *
53 * @param $attr
54 * @param $args
55 * @param object|FooGalleryAttachment $object
56 *
57 * @return array
58 */
59 function alter_image_attributes( $attr, $args, $object ) {
60 $attr['data-no-lazy'] = '1';
61 return $attr;
62 }
63 }
64 }
65