/** * 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(); } }
/** * */ public function add_user_actions(WP_User $user) { if (!$this->list_synchronizer instanceof ListSynchronizer) { return; } $is_subscribed = $this->list_synchronizer->get_user_subscriber_uid($user); $sync_url = add_query_arg(array('mc4wp-sync-action' => 'sync-user', 'user_id' => $user->ID)); ?> <h3><?php _e('MailChimp Status', 'mailchimp-sync'); ?> </h3> <p><?php printf(__('To change your list synchronization settings, please go to the <a href="%s">MailChimp Sync settings page</a>.', 'mailchimp-sync'), admin_url('admin.php?page=mailchimp-for-wp-sync')); ?> </p> <table class="form-table"> <tr> <th><?php $is_subscribed ? _e('Subscribed', 'mailchimp-for-wp') : _e('Not Subscribed', 'mailchimp-sync'); ?> </th> <td> <a href="<?php echo esc_url($sync_url); ?> " class="button"> <?php $is_subscribed ? _e('Update') : _e('Subscribe', 'mailchimp-for-wp'); ?> </a> </td> </tr> </table> <?php }