Skip to content

Instantly share code, notes, and snippets.

@leepeterson
Forked from billerickson/be-disable-acf-frontend.php
Last active September 17, 2020 07:27
Show Gist options
  • Save leepeterson/a1195fd442f7295968cd042e66ea13c1 to your computer and use it in GitHub Desktop.
Save leepeterson/a1195fd442f7295968cd042e66ea13c1 to your computer and use it in GitHub Desktop.

Revisions

  1. Lee Peterson revised this gist Oct 17, 2016. 2 changed files with 40 additions and 26 deletions.
    40 changes: 40 additions & 0 deletions acf-disable-frontend.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    <?php
    /**
    * Plugin Name: Disable ACF on Frontend
    * Description: Disable ACF functions on the front-end of WordPress in order to provide a performance boost.
    * Version: 2.0
    * Author: Lee Peterson
    * Author URI: http://www.leepeterson.me
    * License: MIT
    * License URI: http://www.opensource.org/licenses/mit-license.php
    */

    /**
    * Disable ACF on Frontend
    *
    * This is a forked and modified version of Bill Erickson's
    * Disable ACF Front-end (http://www.billerickson.net/code/disable-acf-frontend/).
    * It accounts for both free and premium versions of Advanced Custom Fields.
    */
    function jc_acf_disable_frontend( $plugins ) {

    $acf_types = array();

    if ( ! is_admin() ) {
    array_push( $acf_types,
    'advanced-custom-fields/acf.php', // ACF Free Version
    'advanced-custom-fields-pro/acf.php' // ACF Pro Version
    );
    }

    foreach( $acf_types as $plugin ) {
    $key = array_search( $plugin, $plugins );

    if( false !== $key ) {
    unset( $plugins[ $key ] );
    }
    }

    return $plugins;
    }
    add_filter( 'option_active_plugins', 'jc_acf_disable_frontend' );
    26 changes: 0 additions & 26 deletions be-disable-acf-frontend.php
    Original file line number Diff line number Diff line change
    @@ -1,26 +0,0 @@
    <?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' );
  2. @billerickson billerickson renamed this gist Aug 26, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @billerickson billerickson revised this gist Aug 26, 2016. 1 changed file with 14 additions and 2 deletions.
    16 changes: 14 additions & 2 deletions general.php
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,23 @@
    <?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] );
  4. @billerickson billerickson created this gist Aug 26, 2016.
    14 changes: 14 additions & 0 deletions general.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    <?php


    /**
    * Disable ACF on Frontend
    *
    */
    function ea_disable_acf_on_frontend( $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' );