Home › Forums › General Issues › Safe way to include ACF and extension in theme › Reply To: Safe way to include ACF and extension in theme
Here’s how I set ACF within my plugins. Works well for me and doesn’t conflict when I have multiple plugins using ACF.
// Check if ACF is used with another plugin, if not already called, use this one if( ! class_exists('acf') ) { // Load only limited functionality define( 'ACF_LITE' , true ); // Load the ACF Core include_once( SET_PLUGIN_NAME_DIR . '/includes/acf/acf.php'); // Repeater Add-On if( ! class_exists('acf_repeater_plugin') ) { include_once( SET_PLUGIN_NAME_DIR . '/includes/acf/add-ons/acf-repeater/acf-repeater.php'); } // Reapeater Collapser Add-on if( ! class_exists( 'acf_repeater_collapser_assets' ) ) { include_once( SET_PLUGIN_NAME_DIR . '/includes/acf/add-ons/acf-repeater-collapser/acf_repeater_collapser.php'); } // Options Add-on if( ! class_exists('acf_options_page_plugin') ) { include_once( SET_PLUGIN_NAME_DIR . '/includes/acf/add-ons/acf-options-page/acf-options-page.php'); // Remove the defualt "Options" Page from ACF as it would be included within the plugin menu or elsewhere. if( ! function_exists("remove_acf_options_page")) { function remove_acf_options_page() { remove_menu_page('acf-options'); } add_action('admin_menu', 'remove_acf_options_page', 99); } } // WYSIWYG Editor Add-on if( ! class_exists( 'acf_field_wp_wysiwyg_plugin' ) ) { include_once( SET_PLUGIN_NAME_DIR . '/includes/acf/add-ons/acf-wp-wysiwyg/acf-wp_wysiwyg.php'); } // Gallery Add-on if( ! class_exists( 'acf_field_gallery' ) ) { include_once( SET_PLUGIN_NAME_DIR . '/includes/acf/add-ons/acf-gallery/acf-gallery.php'); } // Address Field Add-on if( ! class_exists( 'acf_field_address_plugin' ) ) { include_once( SET_PLUGIN_NAME_DIR . '/includes/acf/add-ons/acf-field-address/acf-address.php'); } }
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.