Skip to content

Instantly share code, notes, and snippets.

@ambercouch
Created July 18, 2023 14:22
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 ambercouch/76510f914e31ba2a5f8304ac8f1d1c76 to your computer and use it in GitHub Desktop.
Save ambercouch/76510f914e31ba2a5f8304ac8f1d1c76 to your computer and use it in GitHub Desktop.
WP AFC - include acf if not already active
<?php
add_action('init', 'acsab_init', 0);
function acsab_init(){
if((! is_plugin_active('advanced-custom-fields/acf.php'))&& ( ! is_plugin_active('advanced-custom-fields-pro/acf.php')))
{
// Define path and URL to the ACF plugin.
define( 'ACSAB_ACF_PATH', 'inc/acf/' );
define( 'ACSAB_ACF_URL', plugin_dir_url( __FILE__ ) . 'inc/acf/' );
// Include the ACF plugin.
require_once( ACSAB_ACF_PATH . 'acf.php' );
// Customize the url setting to fix incorrect asset URLs.
add_filter('acf/settings/url', 'acsab_acf_settings_url');
function acsab_acf_settings_url( $url ) {
return ACSAB_ACF_URL;
}
// (Optional) Hide the ACF admin menu item.
//add_filter('acf/settings/show_admin', 'acsab_acf_settings_show_admin');
function acsab_acf_settings_show_admin( $show_admin ) {
//return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment