Conditionally load public and admin code with AJAX working on both sides
I managed to resolve this issue by also checking for public interface. I created new function isPublic() to check if it is public. So here is my final code: if ($this->isPublic()) { require_once(plugin_dir_path(dirname(__FILE__)) . ‘public/class-public.php’); $this->Public = new Public(); } elseif ($this->isAdmin()) { require_once(plugin_dir_path(dirname(__FILE__)) . ‘admin/class-admin.php’); $this->Admin = new Admin(); } and here are helper … Read more