Forked from billerickson/be-disable-acf-frontend.php
Last active
September 17, 2020 07:27
-
-
Save leepeterson/a1195fd442f7295968cd042e66ea13c1 to your computer and use it in GitHub Desktop.
Disable ACF functions on the front-end of WordPress in order to provide a performance boost.
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 Frontend | |
| * Description: Provides a performance boost if ACF frontend functions aren't being used | |
| * Version: 1.0 | |
| * Author: Bill Erickson | |
| * Author URI: http://www.billerickson.net | |
| * License: MIT | |
| * License URI: http://www.opensource.org/licenses/mit-license.php | |
| */ | |
| /** | |
| * Disable ACF on Frontend | |
| * | |
| */ | |
| function ea_disable_acf_on_frontend( $plugins ) { | |
| if( is_admin() ) | |
| return $plugins; | |
| foreach( $plugins as $i => $plugin ) | |
| if( 'advanced-custom-fields-pro/acf.php' == $plugin ) | |
| unset( $plugins[$i] ); | |
| return $plugins; | |
| } | |
| add_filter( 'option_active_plugins', 'ea_disable_acf_on_frontend' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment