Last active
November 14, 2019 10:27
-
-
Save wpmudev-sls/8ff039ae2c3ccc38f206ffae8a344cc3 to your computer and use it in GitHub Desktop.
Fix assets optimization conflict with Optima Express IDX Plugin
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: [Hummingbird Pro] - Fix assets optimization conflict with Optima Express IDX Plugin | |
* Description: [Hummingbird Pro] - Fix assets optimization conflict with Optima Express IDX Plugin - 1148655793728735 | |
* Author: Thobk @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
add_action( 'plugins_loaded', 'wpmudev_hmbp_fix_exception_serialization_func', 100 ); | |
function wpmudev_hmbp_fix_exception_serialization_func() { | |
// if you want to copy to your child theme's functions.php file, please start here: | |
if( defined('WPHB_VERSION') && class_exists('iHomefinderAutoloader') && class_exists( 'Hummingbird\WP_Hummingbird' ) && class_exists('Hummingbird\Core\Settings') ){ | |
if( ! Hummingbird\Core\Settings::get_setting( 'enabled', 'minify' ) ){ | |
return; | |
} | |
add_filter( 'print_styles_array', 'wpmudev_hmbp_maybe_filter_ihf_styles', 4 ); | |
function wpmudev_hmbp_maybe_filter_ihf_styles( $handles ){ | |
global $wp_styles; | |
foreach( $handles as $handle ){ | |
if( isset( $wp_styles->registered[ $handle ] ) && 0 === strpos( $handle, 'ihf-') ){ | |
if( ! is_string( $wp_styles->registered[ $handle ]->src ) ){ | |
$wp_styles->registered[ $handle ]->src = (array) $wp_styles->registered[ $handle ]->src; | |
$wp_styles->registered[ $handle ]->src = $wp_styles->registered[ $handle ]->src[0]; | |
} | |
} | |
} | |
return $handles; | |
} | |
add_filter( 'print_scripts_array', 'wpmudev_hmbp_maybe_filter_ihf_scripts', 4 ); | |
function wpmudev_hmbp_maybe_filter_ihf_scripts( $handles ){ | |
global $wp_scripts; | |
foreach( $handles as $handle ){ | |
if( isset( $wp_scripts->registered[ $handle ] ) && 0 === strpos( $handle, 'ihf-') ){ | |
if( ! is_string( $wp_scripts->registered[ $handle ]->src ) ){ | |
$wp_scripts->registered[ $handle ]->src = (array) $wp_scripts->registered[ $handle ]->src; | |
$wp_scripts->registered[ $handle ]->src = $wp_scripts->registered[ $handle ]->src[0]; | |
} | |
} | |
} | |
return $handles; | |
} | |
} | |
// and end here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment