centminmod / autoptimize-gzip

Autoptimize Gzip Wordpress Plugin hooks into Autoptimize API to enable pre-gzip compression of Autoptimize'd CSS & JS files
GNU General Public License v2.0
21 stars 2 forks source link

Plugin corrections ? #1

Open centminmod opened 6 years ago

centminmod commented 6 years ago

As this is my first Wordpress plugin not sure if it's correct to just use code like

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

add_filter('autoptimize_filter_cache_create_static_gzip','__return_true');

or should I be checking if Autoptimize plugin exists first ?

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

include_once( ABSPATH . 'wp-admin/includes/plugin.php' );

if ( is_plugin_active('autoptimize/autoptimize.php') ) {
  add_filter('autoptimize_filter_cache_create_static_gzip','__return_true');
}

If any folks have suggestions, I am all ears and eyes :)

futtta commented 6 years ago

if AO is not active, the filter will just sit there silently without causing any problems whatsoever, so I would not bother with the overhead of is_plugin_active :)