PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.2.6
Gallery : FooGallery v3.2.6
3.3.2 3.3.3 3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 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 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-wprocket-compatibility.php
70 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * Adds support for WPRocket in FooGallery
9 * Created by brad.
10 * Date: 11/06/2017
11 *
12 * @since 1.3.3
13 */
14 if ( ! class_exists( 'FooGallery_WPRocket_Compatibility' ) ) {
15
16 class FooGallery_WPRocket_Compatibility {
17
18 function __construct() {
19 add_action( 'plugins_loaded', array( $this, 'init_wprocket' ) );
20 }
21
22 /**
23 * Init hooks for WPRocket
24 */
25 function init_wprocket() {
26 //check that WPRocket is activated
27 if ( defined( 'WP_ROCKET_VERSION' ) ) {
28 //add_filter( 'foogallery_process_image_url', array( $this, 'force_images_to_use_rocket_cdn' ), 999 );
29 add_filter( 'foogallery_attachment_html_image_attributes', array( $this, 'alter_image_attributes' ), 10, 3 );
30 add_filter( 'rocket_excluded_inline_js_content', array( $this, 'ensure_foogallery_items_excluded' ) );
31 }
32 }
33
34 function ensure_foogallery_items_excluded( $excluded_inline ) {
35 $excluded_inline[] = 'window["foogallery-gallery-';
36 return $excluded_inline;
37 }
38
39 /**
40 *
41 * @param $url
42 *
43 * @return mixed
44 */
45 function force_images_to_use_rocket_cdn( $url ) {
46 if ( function_exists( 'get_rocket_cdn_url' ) ) {
47 return get_rocket_cdn_url( $url );
48 }
49
50 return $url;
51 }
52
53 /**
54 * Ensure that WPRocket lazyloading does not interfere with FooGallery's lazy loading
55 *
56 * @uses "foogallery_attachment_html_image_attributes" filter
57 *
58 * @param $attr
59 * @param $args
60 * @param object|FooGalleryAttachment $object
61 *
62 * @return array
63 */
64 function alter_image_attributes( $attr, $args, $object ) {
65 $attr['data-no-lazy'] = '1';
66 return $attr;
67 }
68 }
69 }
70