Created
July 18, 2023 14:22
-
-
Save ambercouch/76510f914e31ba2a5f8304ac8f1d1c76 to your computer and use it in GitHub Desktop.
WP AFC - include acf if not already active
This file contains 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 | |
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