Skip to content

Instantly share code, notes, and snippets.

@wpmudev-sls
Last active February 19, 2020 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpmudev-sls/e0c80c8c8807a5c08baf1f9cad202a67 to your computer and use it in GitHub Desktop.
Save wpmudev-sls/e0c80c8c8807a5c08baf1f9cad202a67 to your computer and use it in GitHub Desktop.
Use resize function of Smush instead of WP
<?php
/**
* Plugin Name: [Smush Pro] - Use resize function of Smush instead of WP
* Description: [Smush Pro] - Use resize function of Smush instead of WP (WP >= 5.3.0)
* Task: 0/11289012348292/1157314744592171
* Author: Thobk @ WPMUDEV
* Author URI: https://premium.wpmudev.org
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) { exit; } elseif ( defined( 'WP_CLI' ) && WP_CLI ) { return; }
add_action( 'after_setup_theme', 'wpmudev_smpro_enable_resize_on_wp_5_3_0_func', 100 );
function wpmudev_smpro_enable_resize_on_wp_5_3_0_func() {
if( defined('WP_SMUSH_VERSION') && ( class_exists( 'Smush\WP_Smush' ) || class_exists('WP_Smush') ) && is_admin() ){
if( class_exists('WP_Smush') ){
remove_action( 'admin_init', array( WP_Smush::get_instance()->core()->mod->resize, 'maybe_disable_module' ), 15 );
}else{
remove_action( 'admin_init', array( Smush\WP_Smush::get_instance()->core()->mod->resize, 'maybe_disable_module' ), 15 );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment