* or write to the Free Software Foundation, Inc., 51 Franklin St, * Fifth Floor, Boston, MA 02110-1301 USA **/ // no direct access defined('ABSPATH') or die('Restricted Access'); if ($_SERVER['REQUEST_METHOD'] == 'POST' && !wp_verify_nonce($_REQUEST['_wpnonce'], 'chimpxpress-compose')) { die('Invalid request!'); } if (isset($_POST['step'])) { $step = (int)$_POST['step']; } else if (isset($_GET['step'])) { $step = (int)$_GET['step']; } else { $step = 1; wp_enqueue_media(); /*wp_enqueue_script( 'common' ); wp_enqueue_script( 'jquery-color' ); wp_print_scripts('editor'); if (function_exists('add_thickbox')) add_thickbox(); wp_print_scripts('media-upload'); wp_enqueue_script('media-upload'); wp_enqueue_script('utils'); wp_admin_css(); do_action("admin_print_styles-post-php"); do_action('admin_print_styles'); */ } echo ''; echo ''; echo ''; require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'class-MCAPI.php'); $MCAPI = new chimpxpressMCAPI(); ?>
true]); ?>

chimpXpress

method != 'direct') { $chimpxpress = new chimpxpress; $ftpstream = ftp_connect($chimpxpress->settings['ftpHost']); $login = ftp_login($ftpstream, $chimpxpress->settings['ftpUser'], $chimpxpress->settings['ftpPasswd']); $ftproot = ftp_chdir($ftpstream, $chimpxpress->settings['ftpPath']); $adminDir = ftp_chdir($ftpstream, 'wp-admin'); if ($wp_filesystem->method != 'direct' && (!$chimpxpress->settings['ftpHost'] || !$chimpxpress->settings['ftpUser'] || !$chimpxpress->settings['ftpPasswd'] || !$ftpstream || !$login || !$ftproot || !$adminDir)) { ?>


1
((int)$_POST['sections'] + 1)) { stepSubmit(); } else { stepContent($step); } function step1() { if ($_SERVER['REQUEST_METHOD'] == 'POST' && !wp_verify_nonce($_REQUEST['_wpnonce'], 'chimpxpress-compose')) { die('Invalid request!'); } global $wp_filesystem; $MCAPI = new chimpxpressMCAPI(); $cacheDir = 'wp-content' . DS . 'plugins' . DS . 'chimpxpress' . DS . 'cache'; if ($wp_filesystem->method == 'direct') { $useFTP = false; $handler = $wp_filesystem; if (!is_dir(ABSPATH . $cacheDir)) { $wp_filesystem->mkdir(ABSPATH . $cacheDir); } } else { $useFTP = true; $chimpxpress = new chimpxpress(); $handler = ftp_connect($chimpxpress->settings['ftpHost']); ftp_login($handler, $chimpxpress->settings['ftpUser'], $chimpxpress->settings['ftpPasswd']); ftp_chdir($handler, $chimpxpress->settings['ftpPath']); if (!is_dir(ABSPATH . $cacheDir)) { ftp_mkdir($handler, 'wp-content' . DS . 'plugins' . DS . 'chimpxpress' . DS . 'cache'); } } $cache = new chimpxpressJG_Cache($cacheDir, $useFTP, $handler); $templates = $cache->get('templates'); if ($templates === false) { $templates = $MCAPI->templates(); $cache->set('templates', $templates); } $templateInfo = []; if (isset($templates['templates'])) { foreach ($templates['templates'] as $t) { $templateInfo[$t['id']] = $cache->get('templateInfo_' . $t['id']); if (empty($templateInfo[$t['id']])) { $templateInfo = $MCAPI->templateInfo($t['id']); $defaultContent = $MCAPI->templateDefaultContent($t['id']); $templateInfo[$t['id']] = array_merge($templateInfo ?: [], $defaultContent ?: []); $cache->set('templateInfo_' . $t['id'], $templateInfo[$t['id']]); } } } $lists = $cache->get('lists'); if (empty($lists)) { $MCAPI = new chimpxpressMCAPI(); $lists = $MCAPI->lists(); $cache->set('lists', $lists); } if (!$templates || !$lists) { esc_html_e('Templates and lists could not be retrieved! Please make sure you have set up templates and lists in Mailchimp. Click here to re-try.', 'chimpxpress'); exit; } ?>











"/>

: Reload cache if an expected entry does not appear in the list.', 'chimpxpress'); ?>

100)) ? 15 : $rows; wp_editor($content, $editorId, [ 'tab_index' => '2', 'teeny' => true, 'textarea_rows' => $rows, 'media_buttons' => true, 'tinymce' => [ 'plugins' => 'fullscreen, wordpress, wplink, wpdialogs' ] ]); ?>
get_results("SELECT {$wpdb->posts}.* FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_status = 'publish' AND {$wpdb->posts}.post_type = 'post' AND {$wpdb->posts}.post_date < NOW() ORDER BY {$wpdb->posts}.post_date DESC"); ?>
:
"/> _addError(["error" => esc_html__('Campaign name and subject line must be supplied!', 'chimpxpress'), "code" => "-99"]); $MCAPI->showMessages(); return; } $title = html_entity_decode($_POST['campaignName']); $subject = html_entity_decode($_POST['campaignSubject']); $replace = [''', '&']; $with = ["'", '&']; $title = str_replace($replace, $with, $title); $subject = str_replace($replace, $with, $subject); // create or update campaign if (empty($_POST['CX_campaignId'])) { $params = [ 'type' => 'regular', 'recipients' => [ 'list_id' => $_POST['CX_listId'] ], 'settings' => [ 'title' => $title, 'subject_line' => $subject, 'template_id' => (int)$_POST['CX_template'], 'from_name' => $_POST['CX_default_from_name'], 'inline_css' => true ] ]; $campaign = $MCAPI->campaigns($params, 'POST'); $campaignId = $campaign['id'] ?? false; } else { $campaignId = preg_replace('/[^a-z0-9]/', '', $_POST['CX_campaignId']); } if (empty($campaignId)) { $MCAPI->_addError(["error" => esc_html__('Campaign could not be created!', 'chimpxpress'), "code" => "-99"]); $MCAPI->showMessages(); return; } // set campaign content $sections = []; $sectionNames = explode('|###|', $_POST['sectionNames']); $editorContent = explode('|###|', $_POST['editorContent']); for ($i = 0; $i < count($sectionNames); $i++) { if (!in_array(strtolower($sectionNames[$i]), ['header', 'footer']) /*&& strpos($sectionNames[$i], 'header_') !== 0 && strpos($sectionNames[$i], 'footer_') !== 0*/ && strpos($sectionNames[$i], 'repeat_') !== 0 ) { $sections[$sectionNames[$i]] = trim(str_replace(['\\', '\"', "\'"], ['', '"', "'"], $editorContent[$i])); } } $params = [ 'template' => [ 'id' => (int)$_POST['CX_template'], 'sections' => $sections ] ]; $campaignContent = $MCAPI->campaignsContent($campaignId, $params, 'PUT'); if (!isset($campaignContent['html'])) { $MCAPI->_addError(["error" => esc_html__('Campaign could not be created!', 'chimpxpress'), "code" => "-99"]); $MCAPI->showMessages(); return; } $iframeUrl = false; if ($campaignContent) { // create preview file global $wp_filesystem; $tmpDirAbs = WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'tmp'; $tmpDirRel = get_option('home') . '/wp-content/plugins/chimpxpress/tmp/'; if ($wp_filesystem->method == 'direct') { // remove tmp folder if (is_dir($tmpDirAbs)) { $wp_filesystem->delete($tmpDirAbs, true); } // create new (empty) tmp folder $wp_filesystem->mkdir($tmpDirAbs); // write preview file $wp_filesystem->put_contents($tmpDirAbs . DS . sanitize_title($_POST['campaignSubject']) . '.html', $campaignContent['html']); } else { $chimpxpress = new chimpxpress(); $ftpstream = ftp_connect($chimpxpress->settings['ftpHost']); ftp_login($ftpstream, $chimpxpress->settings['ftpUser'], $chimpxpress->settings['ftpPasswd']); ftp_chdir($ftpstream, $chimpxpress->settings['ftpPath']); // remove tmp folder if (is_dir($tmpDirAbs)) { chimpxpress::ftp_delAll($ftpstream, 'wp-content' . DS . 'plugins' . DS . 'chimpxpress' . DS . 'tmp'); } // create new (empty) tmp folder ftp_mkdir($ftpstream, 'wp-content' . DS . 'plugins' . DS . 'chimpxpress' . DS . 'tmp'); // write preview file $temp = tmpfile(); $wp_filesystem->put_contents($temp, $campaignContent['html']); rewind($temp); ftp_chdir($ftpstream, 'wp-content' . DS . 'plugins' . DS . 'chimpxpress' . DS . 'tmp'); ftp_fput($ftpstream, sanitize_title($_POST['campaignSubject']) . '.html', $temp, FTP_ASCII); ftp_close($ftpstream); } $iframeUrl = $tmpDirRel . sanitize_title($_POST['campaignSubject']) . '.html'; } $dc = $MCAPI->getDc(); ?>

Note:

*/ ?> " /> showMessages();