plugin = $plugin; } public function maybeIncludeAcfPlugin(): void { if (true === $this->plugin->isAcfPluginAvailable()) { return; } // Hide ACF admin menu (as we loaded ACF only for our plugin) add_filter('acf/settings/show_admin', '__return_false'); require_once __DIR__ . '/../vendors/advanced-custom-fields/acf.php'; // used in the AcfDataVendor to skip loading if it's inner ACF define('ACF_VIEWS_INNER_ACF', true); } public function setHooks(CurrentScreen $currentScreen): void { if (false === $currentScreen->isAdmin() || (false === $currentScreen->isAdminCptRelated(ViewsCpt::NAME) && false === $currentScreen->isAdminCptRelated(CardsCpt::NAME) && false === $currentScreen->isAjax())) { return; } add_action('plugins_loaded', [$this, 'maybeIncludeAcfPlugin']); } }