コード例 #1
0
 private static function getLists($page = null, $outputLists = array())
 {
     $Lists = CTCT_SuperClass::CC_ListsCollection()->getLists($page);
     if (!$Lists || empty($Lists)) {
         return array();
     }
     foreach ($Lists[0] as $List) {
         $listid = preg_replace('/.*?\\/lists\\/(.+)/ism', '$1', $List->getLink());
         $vars = array('link' => $List->getLink(), 'id' => $listid, 'name' => $List->getName());
         $outputLists[$listid] = $vars;
     }
     if (isset($Lists[1]['next'])) {
         $page = self::findNextLink($Lists[1]['next']);
     }
     if ($page) {
         $outputLists = self::getLists($page, $outputLists);
     }
     return $outputLists;
 }
コード例 #2
0
 static function process_submission($obj)
 {
     $cf7_ctct = get_option('cf7_ctct_' . $obj->id);
     // Let the shortcode functionality work with the data using a filter.
     $cf7_ctct = apply_filters('ctctcf7_push', apply_filters('ctctcf7_push_form_' . $obj->id, $cf7_ctct, $obj), $obj);
     if (empty($cf7_ctct)) {
         return $obj;
     }
     if (empty($cf7_ctct['active']) || empty($cf7_ctct['fields']) || empty($cf7_ctct['lists'])) {
         return $obj;
     }
     self::get_includes();
     // If it doesn't load for some reason....
     if (!class_exists('CTCT_SuperClass')) {
         return $obj;
     }
     // If there are no fields defined.
     if (empty($cf7_ctct['fields'])) {
         return $obj;
     }
     $contact = array();
     foreach ($cf7_ctct['fields'] as $key => $field) {
         if (empty($key) || empty($field)) {
             continue;
         }
         $value = self::get_submitted_value($field, $obj);
         $contact[$key] = self::process_field($key, $value);
     }
     $contact = self::process_contact($contact);
     // We need an email address to continue.
     if (empty($contact['email_address']) || !is_email($contact['email_address'])) {
         return $obj;
     }
     // For debug only
     # $contact['email_address'] = rand(0,10000).$contact['email_address']; // REMOVE!!!!!
     $CTCT_SuperClass = new CTCT_SuperClass();
     $contact_exists = $CTCT_SuperClass->CC_ContactsCollection()->searchByEmail($contact['email_address']);
     // If there's a field to opt in, and the opt-in field is empty, return.
     if (!empty($cf7_ctct['accept'])) {
         $accept = self::get_submitted_value($cf7_ctct['accept'], $obj);
         if (empty($accept)) {
             return $obj;
         }
         $contact['opt_in_source'] = 'ACTION_BY_CONTACT';
     } else {
         // Don't send them a welcome email
         $contact['opt_in_source'] = 'ACTION_BY_CUSTOMER';
     }
     // Create a new contact.
     if (!$contact_exists) {
         $expected_response = 201;
         $Contact = $CTCT_SuperClass->CC_Contact($contact);
         $ExistingContact = false;
         foreach ((array) $cf7_ctct['lists'] as $list) {
             $Contact->setLists($list);
         }
         $Contact->setOptInSource($contact['opt_in_source']);
         $response = $CTCT_SuperClass->CC_ContactsCollection()->createContact($Contact, false);
     } else {
         $expected_response = 204;
         $Contact = false;
         $ExistingContact = $CTCT_SuperClass->CC_ContactsCollection()->listContactDetails($contact_exists[0][0]);
         $ExistingContact->setOptInSource($contact['opt_in_source']);
         // Update the existing contact with the new data
         self::mapMergeVars($contact, $ExistingContact);
         // Update Lists
         $lists = $ExistingContact->getLists();
         foreach ((array) $cf7_ctct['lists'] as $list) {
             $lists[] = 'https://api.constantcontact.com' . $list;
         }
         // Remove dupe lists
         $set_lists = array_unique($lists);
         // Update contact lists
         foreach ($set_lists as $list) {
             $ExistingContact->setLists($list);
         }
         $response = $CTCT_SuperClass->CC_ContactsCollection()->updateContact($ExistingContact->getId(), $ExistingContact, false);
     }
     if (floatval($response['info']['http_code']) !== floatval($expected_response)) {
         do_action('cf7_ctct_failed', $response, $Contact, $ExistingContact);
     } else {
         do_action('cf7_ctct_succeeded', $response, $Contact, $ExistingContact);
     }
     return $obj;
 }
コード例 #3
0
<?php

/**
 * @global object $args
 */
$CTCT_SuperClass = new CTCT_SuperClass();
$cf7_ctct_defaults = array();
$cf_id = method_exists($args, 'id') ? $args->id() : $args->id;
$cf7_ctct = get_option('cf7_ctct_' . $cf_id, $cf7_ctct_defaults);
?>
<a href="http://katz.si/4w" target="_blank"><img src="<?php 
echo plugins_url('CTCT_horizontal_logo.png', __FILE__);
?>
" width="281" height="47" alt="Constant Contact Logo" style="margin-top:.5em;" /></a>

<?php 
if (self::validateApi()) {
    ?>
	<div class="mail-field clear" style="padding-bottom:.75em">
		<input type="checkbox" id="wpcf7-ctct-active" name="wpcf7-ctct[active]" value="1"<?php 
    checked(isset($cf7_ctct['active']) && $cf7_ctct['active'] == 1, true);
    ?>
 />
		<label for="wpcf7-ctct-active"><?php 
    echo esc_html(__('Send form entries to Constant Contact', 'ctctcf7'));
    ?>
</label>
	</div>
<?php 
} else {
    ?>
コード例 #4
0
 static function get_submitted_lists()
 {
     $submitted = NULL;
     $lists = $output = array();
     if (class_exists('WPCF7_Submission')) {
         $submission = WPCF7_Submission::get_instance();
         $submitted = $submission ? $submission->get_posted_data() : NULL;
     }
     if ($submitted !== NULL && is_array($submitted)) {
         foreach ($submitted as $key => $data) {
             if (false !== strpos($key, 'ctct-') && !empty($data) && is_array($data)) {
                 $lists = array_merge($lists, $data);
             }
         }
     }
     $all_lists = CTCT_SuperClass::getAvailableLists();
     if (is_array($all_lists)) {
         foreach ($all_lists as $list) {
             if (in_array($list['id'], (array) $lists)) {
                 $output[] = $list['link'];
             }
         }
     }
     return $output;
 }
コード例 #5
0
    function tag_generator()
    {
        if (!self::validateApi()) {
            ?>
		<div id="wpcf7-tg-pane-ctct" class="hidden">
			<form action="">
				<div class="error inline"><p><?php 
            _e(sprintf('The plugin\'s Constant Contact settings are not configured properly. <a href="%s">Go configure them now.', admin_url('admin.php?page=ctct_cf7')), 'ctctcf7');
            ?>
</a></p></div>
			</form>
		</div>
		<?php 
            return;
        }
        ?>
		<div id="wpcf7-tg-pane-ctct" class="hidden">
			<form action="">
				<style>
				.js .postbox .tg-pane h3 {
					cursor: default;
				}
				.ctctcf7_subscribe_list ul {
					-webkit-columns:15em;
					-moz-columns:15em;
					columns:15em;
					max-height:200px;
					overflow:auto;
				}
				</style>

				<p class="error"><?php 
        _e('After adding this Tag to the form, you will need to define the Integration Fields in the "Constant Contact" box lower on the page.', "wpcf7");
        ?>
</p>
				<div>
					<input type="hidden" name="name" class="tg-name" value="" />
					<input class="option" name="type" type="hidden" />
				</div>
				<h3><?php 
        _e('How should users subscribe?', 'ctctcf7');
        ?>
</h3>
				<ul>
					<li><label for="subscribe_type_hidden"><input id="subscribe_type_hidden" type="radio" value="hidden" name="subscribe_type_radio" class="option" onchange="jQuery(document).trigger('ctct_change_type');" /> <?php 
        _e('Hidden (subscribe without asking)', 'ctctcf7');
        ?>
</label></li>
					<li><label for="subscribe_type_single"><input id="subscribe_type_single" type="radio" value="single" name="subscribe_type_radio" class="option" onchange="jQuery(document).trigger('ctct_change_type');" /> <?php 
        _e('Opt-in checkbox', 'ctctcf7');
        ?>
</label></li>
					<li><label for="subscribe_type_dropdown"><input id="subscribe_type_dropdown" type="radio" value="dropdown" name="subscribe_type_radio" class="option" onchange="jQuery(document).trigger('ctct_change_type');" /> <?php 
        _e('Drop-down select lists', 'ctctcf7');
        ?>
</label></li>
					<li><label for="subscribe_type_checkboxes"><input id="subscribe_type_checkboxes" type="radio" value="checkboxes" name="subscribe_type_radio" class="option" onchange="jQuery(document).trigger('ctct_change_type');" /> <?php 
        _e('Checkboxes select lists', 'ctctcf7');
        ?>
</label></li>
				</ul>

				<div class="subscribe_type_hidden" style="display:none;">
					<h3><?php 
        _e('Sign users up for the following lists:', 'ctctcf7');
        ?>
</h3>
				</div>

				<div class="subscribe_type_checkboxes" style="display:none;">
					<h3><?php 
        _e('Allow users to pick from the following lists:', 'ctctcf7');
        ?>
</h3>
				</div>

				<div class="subscribe_type_single" style="display:none;">
					<h3><label for="ctctcf7_single_checkbox_label_editor"><?php 
        _e('Label for the opt-in checkbox', 'ctctcf7');
        ?>
</label></h3>
						<p><input type="text" data-default="<?php 
        _e('Sign me up for your newsletter', 'ctctcf7');
        ?>
" id="ctctcf7_single_checkbox_label_editor" value="" class="widefat urlencode" data-target="#ctctcf7_single_checkbox_label" /></p>
						<input class="option" id="ctctcf7_single_checkbox_label" name="label" type="hidden" />
						<h3><?php 
        _e('When users opt-in, sign them up for the following lists:', 'ctctcf7');
        ?>
</h3>
				</div>

				<div class="subscribe_type_dropdown" style="display:none;">
					<h3><label for=""><?php 
        _e('First option in the dropdown', 'ctctcf7');
        ?>
</label></h3>
					<p><input type="text" data-default="<?php 
        _e('Select a newsletter', 'ctctcf7');
        ?>
" id="" value="" class="widefat urlencode" data-target="#ctctcf7_dropdown_first_option" /></p>
					<input class="option" id="ctctcf7_dropdown_first_option" name="first" type="hidden" />
					<h3><?php 
        _e('Include the following lists in the dropdown:', 'ctctcf7');
        ?>
</h3>
				</div>

				<div class="ctctcf7_subscribe_list" style="display:none;">
					<ul class="clear">
					<?php 
        $lists = CTCT_SuperClass::getAvailableLists();
        foreach ($lists as $list) {
            echo '
						<li>
							<label for="wpcf7-ctct-list-' . $list['id'] . '">
								<input type="checkbox" class="option" name="\'' . str_replace("'", '&amp;#39;', $list['name']) . '::#' . $list['id'] . '\'" id="wpcf7-ctct-list-' . $list['id'] . '" value="' . $list['link'] . '" ' . @checked(is_array($list) && in_array($list['link'], (array) $cf7_ctct['lists']), true, false) . ' />
							' . $list['name'] . '
							</label>
						</li>';
        }
        ?>
					</ul>
					<p class="alignright"><a href="<?php 
        echo add_query_arg(array('cache' => rand(1, 20000)));
        ?>
"><?php 
        _e('Refresh Lists', 'ctctcf7');
        ?>
</a></p>
					<div class="clear"></div>
				</div>
				<div id="ctctcf7-tg-tags" style="display:none;">
					<h4 class="description"><?php 
        _e('Select list(s) above to generate the form code.', 'ctctcf7');
        ?>
</h4>
					<div class="tg-tag"><?php 
        echo __("Copy this code and paste it into the form on the left. There should only be one of these tags per form.", 'ctctcf7');
        ?>
<br /><input type="text" name="ctct" class="tag" readonly="readonly" onfocus="this.select()" /></div>

					<div class="tg-mail-tag"><?php 
        echo esc_html(__("And, put this code into the Mail fields below.", 'ctctcf7'));
        ?>
<br /><span class="arrow">&#11015;</span>&nbsp;<input type="text" class="mail-tag" readonly="readonly" onfocus="this.select()" /></div>
				</div>
			</form>
		</div>
		<?php 
    }
コード例 #6
0
				<p><input type="text" data-default="<?php 
_e('Select a newsletter', 'ctctcf7');
?>
" id="" value="" class="widefat urlencode" data-target="#ctctcf7_dropdown_first_option" /></p>
				<input class="option" id="ctctcf7_dropdown_first_option" name="first" type="hidden" />
				<h3><?php 
_e('Include the following lists in the dropdown:', 'ctctcf7');
echo $this->get_refresh_lists_link();
?>
</h3>
			</div>

			<div class="ctctcf7_subscribe_list" style="display:none;">
				<ul class="clear">
					<?php 
$lists = CTCT_SuperClass::getAvailableLists();
$CTCT_SuperClass = new CTCT_SuperClass();
$cf7_ctct_defaults = array();
$cf_id = method_exists($args, 'id') ? $args->id() : $args->id;
$cf7_ctct = get_option('cf7_ctct_' . $cf_id, $cf7_ctct_defaults);
$cf7_ctct_lists = isset($cf7_ctct) && !empty($cf7_ctct['lists']) ? (array) $cf7_ctct['lists'] : array();
$output = '';
$template = '<li><label><input type="checkbox" class="option" name="\'{list_name}::#{list_id}\'" {checked} /> {label}</label></li>';
foreach ($lists as $list) {
    $list_output = $template;
    $value = $list['link'];
    $label = esc_html($list['name']);
    $checked = checked(is_array($list) && in_array($list['link'], $cf7_ctct_lists), true, false);
    #$list_name = str_replace( "'", '&amp;#39;', $list['name'] ).'::#'.$list['id'];
    $list_output = str_replace('{list_name}', esc_html($list['name']), $list_output);
    $list_output = str_replace('{list_id}', esc_html($list['id']), $list_output);