Forked from billerickson/be-disable-acf-frontend.php
Last active
July 26, 2019 19:28
-
-
Save conorbarclay/ca8056d7a432c582d0c5b6d18d654794 to your computer and use it in GitHub Desktop.
A forked and modified version of Bill Erickson's "Disable ACF Frontend" MU plugin that adds some extra checks for front-end requests.
This file contains hidden or 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: Disable ACF on Front-End | |
* Description: Provides a performance boost if ACF front-end functions aren't being used. | |
* Version: 1.0 | |
* Author: Honeycomb Creative | |
* Author URI: https://www.billerickson.net/code/disable-acf-frontend/ | |
* License: MIT | |
* License URI: http://www.opensource.org/licenses/mit-license.php | |
*/ | |
/** | |
* This is a forked and modified version of Bill Erickson's | |
* "Disable ACF Frontend" (http://www.billerickson.net/code/disable-acf-frontend/). | |
* | |
* Adds some extra checks for front-end requests. | |
* For instance, plugins installed/deleted via WP CLI would (annoyingly) trigger ACF deactivation. | |
* | |
* @param array $plugins List of plugins. | |
* | |
* @return array | |
*/ | |
function hny_disable_acf_on_frontend( $plugins ) { | |
if ( ! is_admin() && ! defined( 'WP_CLI' ) ) { | |
foreach ( $plugins as $i => $plugin ) { | |
if ( 'advanced-custom-fields-pro/acf.php' === $plugin ) { | |
unset( $plugins[ $i ] ); | |
} | |
} | |
} | |
return $plugins; | |
} | |
add_filter( 'option_active_plugins', 'hny_disable_acf_on_frontend' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment