plugin = $plugin; $this->viewsCpt = $viewsCpt; $this->cardsCpt = $cardsCpt; } public function maybeIncludeAcfPlugin(): void { if ($this->plugin->isAcfPluginAvailable() || (!$this->viewsCpt->isMyAdminRequest() && !$this->cardsCpt->isMyAdminRequest())) { 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(bool $isAdmin): void { add_action('plugins_loaded', [$this, 'maybeIncludeAcfPlugin']); } }