<div class="wrap"> <div id="easypie-cs-options" class="inside"> <?php $_wpnonce = wp_create_nonce('easy-pie-cs-change-subscribers'); $current_page_idx = 0; $prev_page_idx = 0; $next_page_idx = 1; if (isset($_GET['page_idx'])) { $current_page_idx = $_GET['page_idx']; $prev_page_idx = $current_page_idx > 0 ? $current_page_idx - 1 : 0; $next_page_idx = $current_page_idx + 1; } $subscribers = EZP_CS_Query_Utility::get_subscriber_list($current_page_idx); ?> <div class="postbox" style="margin-top:12px;" > <div class="inside" id="easy-pie-cs-postbox-inside" > <h2>Create a newsletter using your subscriber list</h2> <h3 style="margin-top:25px; margin-bottom:10px;">Step 1. Save subscriber list as a CSV file to your local hard drive.</h3> <button style="margin:0px; font-size:1.1em; font-weight:bold;" id="btn-export" type="button" onclick="location.href = ajaxurl + '?action=EZP_CS_export_all_subscribers&_wpnonce=<?php echo $_wpnonce; ?> '; return false;"><?php EZP_CS_Utility::_e('Save'); ?> </button> <h3 style="margin-top:40px;margin-bottom:10px;">Step 2. Import CSV file into an email marketing service.</h3> <p>Import the saved CSV file into one of the following providers or use your own.</p>
function ws_export_all_subscribers() { if (isset($_REQUEST['_wpnonce'])) { $_wpnonce = $_REQUEST['_wpnonce']; if (wp_verify_nonce($_wpnonce, 'easy-pie-cs-change-subscribers')) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"subscribers.csv\";"); header("Content-Transfer-Encoding: binary"); $subscribers = EZP_CS_Query_Utility::get_subscriber_list(-1); echo "Name, Email Address, Date\r\n"; foreach ($subscribers as $subscriber) { if ($subscriber->subscription_date != '') { // $localized_date = date_i18n(get_option('date_format'), strtotime($subscriber->subscription_date)); $date_text = date('n/j/Y', strtotime($subscriber->subscription_date)); } else { // $localized_date = ''; $date_text = ''; } echo "{$subscriber->friendly_name}, {$subscriber->email_address}, {$date_text}\r\n"; } exit; } else { EZP_CS_Utility::debug("ws_export_all_subscribers: Security violation. Nonce doesn't properly match!"); } } else { EZP_CS_Utility::debug("ws_export_all_subscribers: Security violation. Nonce doesn't exist!"); } }