/** * Let's go... * * Runs at `plugins_loaded` priority 30. */ public function init() { // load plugin options $this->options = $options = $this->load_options(); // Load area-specific code if (!is_admin()) { // @todo make this optional $this->webhooks = new Webhook\Listener($this->options); $this->webhooks->add_hooks(); } elseif (defined('DOING_AJAX') && DOING_AJAX) { $ajax = new AjaxListener($this->options); $ajax->add_hooks(); } else { $admin = new Admin\Manager($this->options, $this->list_synchronizer); $admin->add_hooks(); } // if a list was selected, initialise the ListSynchronizer class if ($this->options['list'] != '' && $this->options['enabled']) { // @todo make this filterable (wait for DI container in core?) $worker = $options['worker_type'] === 'shutdown' ? new ShutdownWorker() : new CronWorker(); $scheduler = new Producer($worker); $scheduler->add_hooks(); $this->list_synchronizer = new ListSynchronizer($this->options['list'], $this->options['role'], $this->options); $this->list_synchronizer->add_hooks(); } if (defined('WP_CLI') && WP_CLI) { $commands = new CommandProvider(); $commands->register(); } }