/** * Hook into 'register_post' action to manage subscription of new users during user registration * * @uses KWSConstantContact::addUpdateContact() * @global $cc * @param string $login The login name of the user * @param string $email The email address of the user * @param WP_Error $errors any errors going on thrown by WordPress * @return <type> */ function process_submission($login = '', $email = '', $errors = false) { $KWSLog = new KWSLog(); do_action('ctct_log', 'Starting to process registration for ' . $login); // Don't register users if there are errors thrown by WordPress if (!empty($errors->errors)) { return; } $has_subscribed = false; $post = $_POST; if ($this->method == 'checkbox' && !empty($post['ctct-subscribe'])) { // subscribe or update the user to the lists admin have selected $has_subscribed = true; $post['lists'] = CTCT_Settings::get('registration_checkbox_lists'); } else { if (!empty($post['lists']) && is_array($post['lists'])) { // subscribe or update the user to the lists they have selected $has_subscribed = true; } } if ($has_subscribed) { do_action('ctct_log', sprintf('Processing Registration for %s', $email)); $returnContact = WP_CTCT::getInstance()->cc->addUpdateContact(apply_filters('cc_register_post_data', $post, $login, $email, $errors)); } }
/** * Show notices everywhere. It's immediately necessary for them to update. * @return void */ function admin_notice() { global $pagenow; // Don't show the notice on the settings page if ($pagenow === 'admin.php' && !empty($_GET['page']) && $_GET['page'] === 'constant-contact-api') { return; } $CTCT = WP_CTCT::getInstance(); ?> <div class="error"> <p><img src="<?php echo plugins_url('images/admin/logo-horizontal.png', CTCT_FILE); ?> " width="225" height="33" alt="" /></p> <h3><?php esc_html_e('The Constant Contact plugin isn\'t connected.', 'ctct'); ?> </h3> <p><?php esc_html_e('Please log in to Constant Contact using the button below and your site will be connected.', 'ctct'); ?> </p> <p><a href="<?php echo $CTCT->oauth->getAuthorizationUrl(); ?> " class="button button-primary button-hero"><?php esc_html_e('Authorize the Plugin on ConstantContact.com', 'ctct'); ?> </a></p> </div> <?php }
/** * Sends the email and (optionally) first name of the commenter to the * current MailChimp list. * * @since 1.0.0 * * @global WP_User $current_user WP User object */ public function comment_post($posted_data) { global $current_user; $data = array_map('esc_attr', $_POST); if (is_user_logged_in()) { $data['name'] = empty($data['name']) ? $current_user->data->display_name : $data['name']; $data['email'] = $current_user->data->user_email; } $data['email'] = rand(0, 10000000) . $data['email']; $data['lists'] = self::get_lists(); // Is the checkbox set? If so, add/update user if (isset($data['ctct-subscribe']) && $data['ctct-subscribe'] === 'subscribe') { $returnContact = WP_CTCT::getInstance()->cc->addUpdateContact($data); } return $posted_data; }
function __construct($force_load = false) { if (!is_admin() && !$force_load) { return; } $this->addIncludes(); $WP_CTCT = WP_CTCT::getInstance(); $this->cc = $WP_CTCT->cc; $this->oauth = $WP_CTCT->oauth; $this->title = $this->getTitle(); $this->key = $this->getKey(); $this->id = $this->getID(); if (is_admin()) { $this->processForms(); add_action('admin_menu', array(&$this, 'add_menu')); add_action('admin_notices', array(&$this, 'print_notices')); add_action('admin_print_scripts', array(&$this, 'print_scripts')); add_action('admin_print_scripts', array(&$this, 'addScripts'), 11); add_action('admin_print_styles', array(&$this, 'print_styles')); add_filter('constant_contact_help_tabs', array(&$this, 'help_tabs')); } $this->addActions(); }
/** * Convert an array of List objects into HTML output * * @param array $passed_items List array * @param array $atts Settings; `fill`, `selected`, `format`; `format` should use replacement tags with the tag being the name of the var of the List object you want to replace. For example, `%%name%% (%%contact_count%% Contacts)` will return an item with the content "List Name (140 Contacts)" * * `showhidden` If true, will exclude lists that have a status of "hidden" in http://dotcms.constantcontact.com/docs/contact-list-api/contactlist-collection.html * * @return [type] [description] */ static function outputHTML($passed_items = array(), $atts = array()) { $settings = wp_parse_args($atts, array('type' => 'checkboxes', 'fill' => true, 'format' => '<span>%%name%%</span>', 'id_attr' => 'ctct-%%id%%', 'name_attr' => 'lists', 'checked' => array(), 'include' => array(), 'showhidden' => true, 'class' => '', 'blank' => '')); extract($settings); $items = array(); // Tell the cache that if the current requests are forced to be // refreshed, the cache should also reset this key. // See Cache_WP_HTTP add_filter('flush_key', function () { return 'ctct_all_lists'; }); if ($passed_items === 'all') { $items = WP_CTCT::getInstance()->cc->getAllLists(); } elseif (!empty($passed_items) && is_array($passed_items)) { foreach ($passed_items as $item) { global $list_id; if ($fill) { $list_id = is_object($item) ? $item->id : $item; $list_id = esc_attr($list_id); // Tell Cache_WP_HTTP to use the following key // as the transient name add_filter('ctct_cachekey', function () { global $list_id; return 'ctct_list_' . $list_id; }); $item = WP_CTCT::getInstance()->cc->getList(CTCT_ACCESS_TOKEN, $list_id); } $items[] = $item; } } $before = $before_item = $after_item = $after = ''; switch ($type) { case 'hidden': $format = '<input type="hidden" value="%%id%%" name="%%name_attr%%[]" />'; break; case 'ul': $before = '<ul class="ul-square">'; $before_item = '<li>'; $after_item = '</li>'; $after = '</ul>'; break; case 'dropdown': case 'select': case 'multiselect': $multiple = ''; // Even though the multiselect option is no longer available // in the settings, keep this around for backward compatibility. // And if crazy people want multi-selects if ($type === 'select' || $type === 'multiselect') { $multiple = ' multiple="multiple"'; } $before = '<select name="%%name_attr%%"' . $multiple . ' class="select2 ctct-lists">'; $before_item = '<option value="%%id%%">'; $after_item = '</option>'; $after = '</select>'; // Allow passing a blank item title if (!empty($blank)) { $before .= '<option value="">' . esc_html($blank) . '</option>'; } break; case 'checkbox': case 'checkboxes': $before = '<ul class="ctct-lists ctct-checkboxes ' . esc_attr($class) . '">'; $before_item = '<li><label for="%%id_attr%%"><input type="checkbox" id="%%id_attr%%" value="%%id%%" name="%%name_attr%%[]" %%checked%% /> '; $after_item = '</label></li>'; $after = '</ul>'; break; } $output = $before; $items_output = ''; foreach ($items as &$item) { // If include was specified, then we need to skip lists not included if (is_array($passed_items) && (!empty($include) && !in_array($item->id, $include)) || $item->status === 'HIDDEN' && !$showhidden) { #continue; } $item = new KWSContactList($item); $item_content = !empty($format) || is_null($format) ? $format : $item->name; $tmp_output = $before_item . $item_content . $after_item . "\n"; $tmp_output = str_replace('%%id%%', sanitize_title($item->get('id')), $tmp_output); $tmp_output = str_replace('%%name%%', $item->get('name', false), $tmp_output); $tmp_output = str_replace('%%status%%', $item->get('status', false), $tmp_output); $tmp_output = str_replace('%%contact_count%%', $item->get('contact_count', true), $tmp_output); $tmp_output = str_replace('%%checked%%', checked(in_array($item->get('id'), (array) $checked) || is_null($checked) && $item->get('status') === 'ACTIVE', true, false), $tmp_output); $items_output .= $tmp_output; } $output .= $items_output; $output .= $after; $output = str_replace('%%name_attr%%', $name_attr, $output); $output = str_replace('%%id_attr%%', $id_attr, $output); return $output; }
include_once CTCT_DIR_PATH . 'classes/class.kwscontact.php'; include_once CTCT_DIR_PATH . 'classes/class.kwscontactlist.php'; include_once CTCT_DIR_PATH . 'classes/class.kwscampaign.php'; include_once CTCT_DIR_PATH . 'classes/class.kwsajax.php'; include_once CTCT_DIR_PATH . 'classes/class.ctct_admin_page.php'; include_once CTCT_DIR_PATH . 'classes/class.ctct_settings.php'; include_once CTCT_DIR_PATH . 'classes/class.ctct_admin.php'; include_once CTCT_DIR_PATH . 'lib/kwslog.php'; $this->log = new KWSLog('ctct', 'Constant Contact'); /** Admin pages */ include_once CTCT_DIR_PATH . 'admin/profile.php'; include_once CTCT_DIR_PATH . 'admin/campaigns.php'; include_once CTCT_DIR_PATH . 'admin/contacts.php'; include_once CTCT_DIR_PATH . 'admin/lists.php'; // If the plugin is not configured, don't do anything else. if (!is_ctct_configured()) { return; } /** Modules */ include_once CTCT_DIR_PATH . 'lib/registration.php'; include_once CTCT_DIR_PATH . 'lib/constant-analytics/constant-analytics.php'; include_once CTCT_DIR_PATH . 'lib/comment-form-signup.php'; include_once CTCT_DIR_PATH . 'lib/simple-widget.php'; if (CTCT_Settings::get('eventspot')) { include_once CTCT_DIR_PATH . 'lib/eventspot/eventspot.php'; } include_once CTCT_DIR_PATH . 'lib/form-designer/form-designer.php'; } } WP_CTCT::getInstance();