function create_mailchimp_box() { /* echo '<label for="mailchimp-enabled-yes">' . __('Enable MailChimp integration:', 'wdsi') . ' </label>' . $this->_create_checkbox('mailchimp-enabled') . '<br />'; */ $api_key = $this->_get_option('mailchimp-api_key'); echo '<label for="wdsi-mailchimp-api_key">' . __('MailChimp API key:') . '</label>' . '<input type="text" class="long" name="wdsi[mailchimp-api_key]" id="wdsi-mailchimp-api_key" value="' . esc_attr($api_key) . '" />' . '<br />'; if (!$api_key) { echo $this->_create_hint(__('Enter your API key here, then save the settings to continue', 'wdsi')); return false; } $mailchimp = new Wdsi_Mailchimp($api_key); $lists = $mailchimp->get_lists(); $current = $this->_get_option('mailchimp-default_list'); echo '<label>' . __('Default subscription list:', 'wdsi') . ' </label>'; echo '<div class="wpmudev-ui-select"><select name="wdsi[mailchimp-default_list]">'; echo '<option></option>'; foreach ($lists as $list) { $selected = $list['id'] == $current ? 'selected="selected"' : ''; echo '<option value="' . esc_attr($list['id']) . '" ' . $selected . '>' . $list['name'] . '</option>'; } echo '</select></div>'; // We got this far, we have the API key echo ' <a href="#mcls-refresh" id="wdcp-mcls-refresh">' . __('Refresh', 'wdsi') . '</a>'; echo $this->_create_hint(__('Select a default list you wish to subscribe your visitors to.', 'wdsi')); $subscription_message = $this->_get_option('mailchimp-subscription_message'); $subscription_message = $subscription_message ? $subscription_message : __('All good, thank you!', 'wdsi'); $subscription_message = wp_strip_all_tags($subscription_message); echo '<br />' . '<label for="wdsi-mailchimp-subscription_message">' . __('Successful subscription message:', 'wdsi') . '</label> ' . '<input type="text" class="long" name="wdsi[mailchimp-subscription_message]" id="wdsi-mailchimp-subscription_message" value="' . esc_attr($subscription_message) . '" />' . ''; }
function render_content_type() { global $post; $opts = get_post_meta($post->ID, 'wdsi-type', true); $type = wdsi_getval($opts, 'content_type', 'text'); echo '<div class="wpmudev-ui">'; echo '' . '<input type="radio" name="wdsi-type[content_type]" id="wdsi-content_type-text" value="text" ' . ('text' == $type ? 'checked="checked"' : '') . ' />' . ' ' . '<label for="wdsi-content_type-text">' . __('Text message', 'wdsi') . '</label>' . '<br />'; echo '' . '<input type="radio" name="wdsi-type[content_type]" id="wdsi-content_type-mailchimp" value="mailchimp" ' . ('mailchimp' == $type ? 'checked="checked"' : '') . ' />' . ' ' . '<label for="wdsi-content_type-mailchimp">' . __('MailChimp subscription form', 'wdsi') . '</label>' . '<br />'; echo '' . '<input type="radio" name="wdsi-type[content_type]" id="wdsi-content_type-related" value="related" ' . ('related' == $type ? 'checked="checked"' : '') . ' />' . ' ' . '<label for="wdsi-content_type-related">' . __('Related posts', 'wdsi') . '</label>' . '<br />'; $data = new Wdsi_Options(); if ($data->get_option('allow_widgets')) { echo '' . '<input type="radio" name="wdsi-type[content_type]" id="wdsi-content_type-widgets" value="widgets" ' . ('widgets' == $type ? 'checked="checked"' : '') . ' />' . ' ' . '<label for="wdsi-content_type-widgets">' . __('Sidebar widgets', 'wdsi') . '</label>' . '<br />'; } // --- Message echo '<div id="wdsi-content_type-options-text" class="wdsi-content_type" style="display:none"></div>'; // --- MailChimp echo '<div id="wdsi-content_type-options-mailchimp" class="wdsi-content_type" style="display:none">'; $defaults = get_option('wdsi'); $api_key = wdsi_getval($opts, 'mailchimp-api_key', wdsi_getval($defaults, 'mailchimp-api_key')); echo '<label for="wdsi-mailchimp-api_key">' . __('MailChimp API key:') . '</label>' . '<input type="text" class="long" name="wdsi-type[mailchimp-api_key]" id="wdsi-mailchimp-api_key" value="' . esc_attr($api_key) . '" />' . '<br />'; if (!$api_key) { echo $this->_create_hint(__('Enter your API key here, then save the post to continue', 'wdsi')); } else { $mailchimp = new Wdsi_Mailchimp($api_key); $lists = $mailchimp->get_lists(); $current = wdsi_getval($opts, 'mailchimp-default_list', wdsi_getval($defaults, 'mailchimp-default_list')); echo '<label>' . __('Default subscription list:', 'wdsi') . ' </label>'; echo '<div class="wpmudev-ui-select"><select name="wdsi-type[mailchimp-default_list]">'; echo '<option></option>'; foreach ($lists as $list) { $selected = $list['id'] == $current ? 'selected="selected"' : ''; echo '<option value="' . esc_attr($list['id']) . '" ' . $selected . '>' . $list['name'] . '</option>'; } echo '</select></div>'; // We got this far, we have the API key //echo ' <a href="#mcls-refresh" id="wdcp-mcls-refresh">' . __('Refresh', 'wdsi') . '</a>'; echo $this->_create_hint(__('Select a default list you wish to subscribe your visitors to.', 'wdsi')); $placeholder = wdsi_getval($opts, 'mailchimp-placeholder', '*****@*****.**'); echo '<label for="wdsi-mailchimp-placeholder">' . __('Placeholder text:', 'wdsi') . '</label>' . '<input type="text" class="long" name="wdsi-type[mailchimp-placeholder]" id="wdsi-mailchimp-placeholder" value="' . esc_attr($placeholder) . '" />' . '<br />'; $position = wdsi_getval($opts, 'mailchimp-position', 'after'); echo '<label for="wdsi-mailchimp-position-after">' . __('Show my form:', 'wdsi') . '</label><br />'; echo '' . '<input type="radio" name="wdsi-type[mailchimp-position]" id="wdsi-mailchimp-position-after" value="after" ' . checked('after', $position, false) . ' />' . '<label for="wdsi-mailchimp-position-after">' . __('After the message text', 'wdsi') . '</label>' . '<br />'; echo '' . '<input type="radio" name="wdsi-type[mailchimp-position]" id="wdsi-mailchimp-position-before" value="before" ' . checked('before', $position, false) . ' />' . '<label for="wdsi-mailchimp-position-before">' . __('Before the message text', 'wdsi') . '</label>' . '<br />'; $subscription_message = wdsi_getval($opts, 'mailchimp-subscription_message', wdsi_getval($defaults, 'mailchimp-subscription_message')); $subscription_message = $subscription_message ? $subscription_message : __('All good, thank you!', 'wdsi'); $subscription_message = wp_strip_all_tags($subscription_message); echo '<br />' . '<label for="wdsi-mailchimp-subscription_message">' . __('Successful subscription message:', 'wdsi') . '</label> ' . '<input type="text" class="long" name="wdsi-type[mailchimp-subscription_message]" id="wdsi-mailchimp-subscription_message" value="' . esc_attr($subscription_message) . '" />' . ''; } echo '</div>'; // --- Related posts echo '<div id="wdsi-content_type-options-related" class="wdsi-content_type" style="display:none">'; $count = wdsi_getval($opts, 'related-posts_count', 3); echo '<label>' . __('Show this many related posts:', 'wdsi') . ' </label>'; echo '<div class="wpmudev-ui-select"><select name="wdsi-type[related-posts_count]">'; foreach (range(1, 10) as $item) { $selected = $item == $count ? 'selected="selected"' : ''; echo '<option value="' . esc_attr($item) . '" ' . $selected . '>' . $item . '</option>'; } echo '</select></div><br />'; $taxonomies = get_taxonomies(array('public' => true), 'objects'); $related_tax = wdsi_getval($opts, 'related-taxonomy', 'post_tag'); echo '<label>' . __('Related taxonomy:', 'wdsi') . ' </label>'; echo '<div class="wpmudev-ui-select"><select name="wdsi-type[related-taxonomy]">'; foreach ($taxonomies as $tax => $item) { $selected = $tax == $related_tax ? 'selected="selected"' : ''; echo '<option value="' . esc_attr($tax) . '" ' . $selected . '>' . $item->label . '</option>'; } echo '</select></div><br />'; echo $this->_create_hint(__('Related posts will have common terms with displayed post from this taxonomy', 'wdsi')); $has_thumbnails = wdsi_getval($opts, 'related-has_thumbnails'); echo '' . '<input type="hidden" name="wdsi-type[related-has_thumbnails]" value="" />' . '<input type="checkbox" id="wdsi-has_thumbnails" name="wdsi-type[related-has_thumbnails]" value="1" ' . ($has_thumbnails ? 'checked="checked"' : '') . ' />' . ' ' . '<label for="wdsi-has_thumbnails">' . __('Show thumbnails?', 'wdsi') . '</label>' . '<br />'; echo '</div>'; // --- Widgets if ($data->get_option('allow_widgets')) { echo '<div id="wdsi-content_type-options-widgets" class="wdsi-content_type" style="display:none"></div>'; } echo '</div>'; }