static function metabox($args) { $CTCT_SuperClass = new CTCT_SuperClass(); $cf7_ctct_defaults = array(); $cf7_ctct = get_option('cf7_ctct_' . $args->id, $cf7_ctct_defaults); ?> <script> jQuery(document).ready(function($) { $('.ctctcf7-tooltip').tooltip({ content: function () { return $(this).prop('title'); } }); }); </script> <div class="ctctcf7-tooltip" title="<h6><?php _e('Backward Compatibility', 'ctctcf7'); ?> </h6><p><?php _e('Starting with Version 2.0 of Contact Form 7 Newsletter plugin, the lists a form sends data to should be defined by generating a tag above ↑</p><p>For backward compatibility, <strong>if you don\'t define any forms using a tag above</strong>, your form will continue to send contact data to these lists:', 'ctctcf7'); ?> </p><ul class='ul-disc'> <?php $lists = CTCT_SuperClass::getAvailableLists(); foreach ($lists as $list) { if (!in_array($list['link'], (array) $cf7_ctct['lists'])) { continue; } echo '<li>' . $list['name'] . '</li>'; } ?> </ul><p><strong>For full instructions, go to the Contact > Constant Contact page and click 'View integration instructions'.</strong></p>"><?php _e('Where are my lists?', 'ctctcf7'); ?> </div> <a href="http://katz.si/4w"><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 { ?> <div class="mail-field clear"> <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> </div> <?php return; } ?> <div class="mail-fields clear" id="wpcf7-ctct-all-fields"> <!-- Backward Compatibility --> <div><?php foreach ((array) $cf7_ctct['lists'] as $list) { echo '<input type="hidden" name="wpcf7-ctct[lists][]" value="' . $list . '" />'; } ?> </div> <!-- End Backward Compatibility --> <div class="clear ctct-fields"> <hr style="border:0; border-bottom:1px solid #ccc; padding-top:1em" /> <div class="clear"></div> <?php $instructions = __('<h2>Integration Fields</h2>', 'ctctcf7'); $instructions .= '<p class="howto">'; $instructions .= __('For each of the Integration Fields below, select the value you would like sent to Constant Contact.', 'ctctcf7'); $instructions .= '</p>'; echo $instructions; ?> <?php $i = 0; foreach ($CTCT_SuperClass->listMergeVars() as $var) { ?> <div class="half-<?php if ($i % 2 === 0) { echo 'left'; } else { echo 'right'; } ?> " style="clear:none;"> <div class="mail-field"> <label for="wpcf7-ctct-<?php echo $var['tag']; ?> "><?php echo $var['name']; echo !empty($var['req']) ? _e(' <strong>← This setting is required.</strong>', 'ctctcf7') : ''; ?> </label><br /> <input type="text" id="wpcf7-ctct-<?php echo isset($var['tag']) ? $var['tag'] : ''; ?> " name="wpcf7-ctct[fields][<?php echo isset($var['tag']) ? $var['tag'] : ''; ?> ]" class="wide" size="70" value="<?php echo @esc_attr(isset($cf7_ctct['fields'][$var['tag']]) ? $cf7_ctct['fields'][$var['tag']] : ''); ?> " <?php if (isset($var['placeholder'])) { echo ' placeholder="Example: ' . $var['placeholder'] . '"'; } ?> /> </div> </div> <?php if ($i % 2 === 1) { echo '<div class="clear"></div>'; } $i++; } ?> <div class="clear mail-field" style="width:50%;"> <label for="wpcf7-ctct-accept"><?php echo esc_html(__('Opt-In Field', 'ctctcf7')); ?> <span class="howto"><?php _e('<strong>If you generated a "Constant Contact Lists" field above, this setting is not necessary, and will be ignored.</strong>', 'ctctcf7'); ?> </span> <input type="text" id="wpcf7-ctct-accept" name="wpcf7-ctct[accept]" placeholder="Example: [checkbox-456]" class="wide" size="70" value="<?php echo esc_attr(isset($cf7_ctct['accept']) ? $cf7_ctct['accept'] : ''); ?> " /> <span class="howto"><?php _e('If the user should check a box to be added to the lists, enter the checkbox field here. Leave blank to have no opt-in field.', 'ctctcf7'); ?> </span> </label> </div> </div> <div class="clear"></div> </div> <?php }
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("'", '&#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">⬇</span> <input type="text" class="mail-tag" readonly="readonly" onfocus="this.select()" /></div> </div> </form> </div> <?php }
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; }
<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( "'", '&#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);