Forked from glueckpress/wp-rocket-unlazyload-essential-grid.php
Created
October 10, 2018 01:42
-
-
Save bewho/6e1401ee8f278c38431f7689ed954400 to your computer and use it in GitHub Desktop.
[WordPress][WP Rocket] Programmatically disables WP Rocket’s LazyLoad feature on pages with Essential Grid.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WP Rocket | UnLazyLoad Essential Grid | |
* Description: Disables WP Rocket’s LazyLoad feature on pages with <a href="https://www.themepunch.com/portfolio/essential-grid-wordpress-plugin/">Essential Grid</a>. | |
* Author: WP Rocket Support Team | |
* Author URI: http://wp-rocket.me/ | |
* Plugin URI: http://docs.wp-rocket.me/article/139-disable-lazyload-on-mobile#inactive | |
* License: GNU General Public License v3 or later | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
defined( 'ABSPATH' ) or die( 'You know better.' ); | |
/** | |
* Disables WP Rocket’s LazyLoad feature on pages with Essential Grid. | |
* @param string $content WP Post content | |
* @return string WP Post content | |
*/ | |
function wp_rocket__unlazyload_essential_grid( $content ) { | |
if ( is_admin() || ! class_exists( 'Essential_Grid' ) || ! function_exists( 'has_shortcode' ) ) | |
return $content; | |
if ( has_shortcode( $content, 'ess_grid' ) | |
|| has_shortcode( $content, 'ess_grid_search' ) | |
|| has_shortcode( $content, 'ess_grid_nav' ) | |
|| has_shortcode( $content, 'ess_grid_ajax_target' ) ) { | |
add_filter( 'do_rocket_lazyload', '__return_false' ); | |
} | |
return $content; | |
} | |
add_filter( 'the_content', 'wp_rocket__unlazyload_essential_grid' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment