.
**/
// no direct access
defined('ABSPATH') or die('Restricted Access');
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
if (!is_admin()) {
return;
}
class chimpxpress {
public $settings;
private $_errors = [];
private $_notices = [];
static $instance = false;
private $optionsName = 'chimpxpress';
private $optionsGroup = 'chimpxpress-options';
private $_listener_query_var = 'chimpxpressListener';
private $MCAPI = false;
// public $_api = false;
function __construct() {
require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'class-MCAPI.php');
if (!$this->MCAPI) {
$this->MCAPI = new chimpxpressMCAPI;
if (!isset($_SESSION['MCping']) || !$_SESSION['MCping']) {
$ping = $this->MCAPI->ping();
$_SESSION['MCping'] = $ping;
if ($ping) {
$MCname = $this->MCAPI->getAccountDetails();
$_SESSION['MCusername'] = $MCname['username'] ?? '-';
}
}
}
$this->getSettings();
// include cache library
require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'class-JG_Cache.php');
// include WP filesystem
if (!function_exists('WP_Filesystem')) {
require(ABSPATH . DS . 'wp-admin' . DS . 'includes' . DS . 'file.php');
WP_Filesystem();
}
global $wp_filesystem;
/**
* Add filters and actions
*/
add_filter('init', [$this, 'chimpxpressLoadLanguage']);
add_action('admin_init', [$this, 'registerOptions']);
add_action('admin_menu', [$this, 'adminMenu']);
add_action('admin_menu', [$this, 'chimpxpress_add_box']);
add_action('template_redirect', [$this, 'listener']);
// add_filter( 'query_vars', array( $this, 'addMailchimpListenerVar' ));
register_activation_hook(__FILE__, [$this, 'activatePlugin']);
add_filter('pre_update_option_' . $this->optionsName, [$this, 'optionUpdate'], null, 2);
// add_action( 'admin_notices', array($this->MCAPI, 'showMessages') );
// compose ajax callbacks
add_action('wp_ajax_compose_clear_cache', [$this, 'compose_clear_cache_callback']);
add_action('wp_ajax_compose_gotoStep', [$this, 'compose_gotoStep_callback']);
add_action('wp_ajax_compose_removeDraft', [$this, 'compose_removeDraft_callback']);
add_action('wp_ajax_sanitize', [$this, 'sanitize_callback']);
// import ajax callbacks
add_action('wp_ajax_import', [$this, 'import_callback']);
// archive ajax callbacks
add_action('wp_ajax_archive_deleteLP', [$this, 'archive_deleteLP_callback']);
// archive post box callback
add_action('wp_ajax_load_campaigns', [$this, 'load_campaigns_callback']);
add_action('wp_ajax_ftp_find_root', [$this, 'ftp_find_root']);
add_action('wp_ajax_ftp_test', [$this, 'ftp_test_callback']);
}
public function optionUpdate($newvalue, $oldvalue) {
// clear error messages
$this->MCAPI->_emptyErrors();
$this->MCAPI->_emptyNotices();
// clear cache if present
$cacheDir = 'wp-content' . DS . 'plugins' . DS . 'chimpxpress' . DS . 'cache';
if (is_dir(ABSPATH . $cacheDir)) {
$cache = new chimpxpressJG_Cache($cacheDir);
$templates = $cache->get('templates');
if ($templates) {
$this->compose_clear_cache_callback();
}
}
return $newvalue;
}
public function activatePlugin() {
$this->updateSettings();
}
public function getSetting($settingName, $default = false) {
if (empty($this->settings)) {
$this->getSettings();
}
if (isset($this->settings[$settingName])) {
return $this->settings[$settingName];
} else {
return $default;
}
}
public function getSettings() {
if (empty($this->settings)) {
$this->settings = get_option($this->optionsName);
}
if (!is_array($this->settings)) {
$this->settings = [];
}
$defaults = [
'username' => '',
'password' => '',
'apiKey' => '',
'CEaccess' => 'manage_options',
'debugging' => 'off',
'debugging_email' => '',
'listener_security_key' => $this->generateSecurityKey(),
'version' => $this->MCAPI->apiVersion,
'GAprofile' => '',
'ftpHost' => '',
'ftpUser' => '',
'ftpPasswd' => '',
'ftpPath' => ''
];
$this->settings = wp_parse_args($this->settings, $defaults);
}
private function generateSecurityKey() {
return sha1(time());
}
private function updateSettings() {
update_option($this->optionsName, $this->settings);
}
public function registerOptions() {
register_setting($this->optionsGroup, $this->optionsName);
}
public function adminMenu() {
$pages = [];
$pages[] = add_menu_page(
esc_html__('Dashboard', 'chimpxpress'),
'chimpXpress',
$this->settings['CEaccess'],
'chimpXpressDashboard',
[$this, 'main'],
plugins_url('images' . DS . 'logo_16.png', __FILE__)
);
$pages[] = add_submenu_page(
'chimpXpressDashboard',
esc_html__('Import', 'chimpxpress'),
esc_html__('Import', 'chimpxpress'),
$this->settings['CEaccess'],
'chimpXpressImport',
[$this, 'import'],
null
);
$pages[] = add_submenu_page(
'chimpXpressDashboard',
esc_html__('Compose', 'chimpxpress'),
esc_html__('Compose', 'chimpxpress'),
$this->settings['CEaccess'],
'chimpXpressCompose',
[$this, 'compose'],
null
);
$pages[] = add_submenu_page(
'chimpXpressDashboard',
esc_html__('Landing Page Archive', 'chimpxpress'),
esc_html__('Landing Pages', 'chimpxpress'),
$this->settings['CEaccess'],
'chimpXpressArchive',
[$this, 'archive'],
null
);
// invisible menus
$pages[] = add_submenu_page(
'chimpXpressArchive',
esc_html__('Edit Landing Page', 'chimpxpress'),
esc_html__('Edit Landing Page', 'chimpxpress'),
$this->settings['CEaccess'],
'chimpXpressEditLandingPage',
[$this, 'editLP'],
null
);
$pages[] = add_options_page(
esc_html__('Settings', 'chimpxpress'),
'chimpXpress',
'manage_options',
'chimpXpressConfig',
[$this, 'options'],
null
);
// enqueue css and js files
foreach ($pages as $page) {
add_action('admin_print_styles-' . $page, [$this, 'chimpxpressAddAdminHead']);
}
}
function chimpxpressAddAdminHead() {
// add css files
wp_enqueue_style('chimpxpress', plugins_url('css' . DS . 'chimpxpress.css', __FILE__));
wp_enqueue_style('colorbox', plugins_url('css' . DS . 'colorbox.css', __FILE__));
// add js files
wp_enqueue_script('chimpxpress', plugins_url('js' . DS . 'jquery.colorbox-min.js', __FILE__));
}
function compose_clear_cache_callback() {
global $wp_filesystem;
if ($wp_filesystem->method == 'direct') {
$wp_filesystem->delete(ABSPATH . 'wp-content' . DS . 'plugins' . DS . 'chimpxpress' . DS . 'cache', true);
} else {
$ftpstream = ftp_connect($this->settings['ftpHost']);
ftp_login($ftpstream, $this->settings['ftpUser'], $this->settings['ftpPasswd']);
ftp_chdir($ftpstream, $this->settings['ftpPath']);
$dir = 'wp-content' . DS . 'plugins' . DS . 'chimpxpress' . DS . 'cache';
$this->ftp_delAll($ftpstream, $dir);
ftp_close($ftpstream);
}
return;
}
public function compose_gotoStep_callback() {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], $this->optionsName . '-compose')) {
die('Invalid request!');
}
include(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'compose.php');
exit;
}
public function compose_removeDraft_callback() {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], $this->optionsName . '-compose')) {
die('Invalid request!');
}
// get campaign ID and remove anything except lower case letters and numbers
$cid = preg_replace('/[^a-z0-9]/', '', $_POST['cid']);
$this->MCAPI->campaigns(['campaign_id' => $cid], 'DELETE');
if (is_dir(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'tmp')) {
global $wp_filesystem;
if ($wp_filesystem->method == 'direct') {
$wp_filesystem->delete(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'tmp', true);
} else {
$ftpstream = ftp_connect($this->settings['ftpHost']);
ftp_login($ftpstream, $this->settings['ftpUser'], $this->settings['ftpPasswd']);
ftp_chdir($ftpstream, $this->settings['ftpPath']);
$this->ftp_delAll($ftpstream, 'wp-content' . DS . 'plugins' . DS . 'chimpxpress' . DS . 'tmp');
ftp_close($ftpstream);
}
}
exit;
}
function sanitize_callback() {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], $this->optionsName . '-compose')) {
die('Invalid request!');
}
$string = explode('*|@|*', $_POST['string']);
foreach ($string as $s) {
if (sanitize_title($s) == '') {
echo '';
exit;
}
}
echo 1;
exit;
}
function import_callback() {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], $this->optionsName . '-import')) {
header('Content-type: application/json');
$result = [
'error' => 1,
'msg' => '' . esc_html__('Invalid request!', 'chimpxpress') . ''
];
echo wp_json_encode($result);
exit;
}
global $wpdb;
$currentUser = wp_get_current_user();
$type = $_POST['type'];
$cid = preg_replace('/[^a-z0-9]/', '', $_POST['cid']);
$subject = html_entity_decode($_POST['subject']);
$fileName = html_entity_decode($_POST['fileName']);
// get next post/page id
$tableStatus = $wpdb->get_row($wpdb->prepare("SHOW TABLE STATUS LIKE %s", $wpdb->posts));
$nextIncrement = $tableStatus->Auto_increment;
if ($type == 'post') {
// create permalink
$guid = get_option('home') . '/?p=' . $nextIncrement;
// var_dump($campaignContent['html']);die;
if ($_POST['datatype'] == 'html') {
// get campaign contents
$campaign = $this->MCAPI->campaignsContent($cid);
if (empty($campaign) || empty($campaign['html'])) {
header('Content-type: application/json');
$result = [
'error' => 1,
'msg' => '' . esc_html__('Campaign could not be retrieved. Please try again.', 'chimpxpress') . ''
];
echo wp_json_encode($result);
exit;
}
// process html contents
$html = $campaign['html'];
preg_match('##is', $html, $styles);
$html = preg_replace('/]*?>/is', '', $html);
$html = preg_replace('!
(.*)!is', '', $html);
$html = preg_replace('!]*>!is', '', $html);
$html = preg_replace('!!is', '', $html);
$html = str_replace(['', ''], '', $html);
$style = '';
for ($i = 0; $i < count($styles); $i++) {
$style .= $styles[$i];
}
// move style declarations inline
require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'class-css_to_inline_styles.php');
$CSSToInlineStyles = new CSSToInlineStyles;
$CSSToInlineStyles->setHTML($html);
$CSSToInlineStyles->setCSS($style);
$html = $CSSToInlineStyles->convert();
$html = preg_replace('/]*?>/is', '', $html);
$html = preg_replace('!(.*)!is', '', $html);
$html = preg_replace('!]*>!is', '', $html);
$html = preg_replace('!!is', '', $html);
$html = str_replace(['', ''], '', $html);
// remove MERGE tags
// anchors containing a merge tag
$html = preg_replace('!!', '', $html);
// all other merge tags
$html = preg_replace('!\*(\||%7C)(.*)(\||%7C)\*!', '', $html);
} else {
// get campaign contents
$campaign = $this->MCAPI->campaignsContent($cid);
if (empty($campaign) || empty($campaign['plain_text'])) {
$result['error'] = 1;
$result['msg'] = '' . esc_html__('Campaign could not be retrieved. Please try again.', 'chimpxpress') . '';
header("Content-type: application/json");
echo wp_json_encode($result);
exit;
}
// process html contents
$html = $campaign['plain_text'];
// convert links to html anchors
$html = preg_replace('!(http://(.*)(<|\s))!isU', '$1', $html);
// remove MERGE tags
$html = preg_replace('!\*(\||%7C)(.*)(\||%7C)\*!', '', $html);
}
/*
$campaignTemplateContent = $this->MCAPI->campaignTemplateContent( $cid );
if($campaignTemplateContent){
$html = $campaignTemplateContent['main'];
// append sidecolumn content if exists
if( isset($campaignTemplateContent['sidecolumn']) && $campaignTemplateContent['sidecolumn'] != '' ){
$html .= '
'.$campaignTemplateContent['sidecolumn'];
}
} else {
// clear errors (we dont need to be notified that this campaign doesn't use a template)
$this->MCAPI->_emptyErrors();
// campaign didn't use a template so we have to use the text version
$html = $this->MCAPI->generateText( 'cid', $cid );
// convert links to html anchors
$html = preg_replace( '!(http://(.*)(<|\s))!isU', '$1', $html);
// remove MERGE tags
// sentences containing a merge tag
$html = preg_replace( '!\.\s(.*)\*\|(.*)\|\*(.*)\.!sU', '.', $html);
$html = preg_replace( '!\.\s(.*)\*%7C(.*)%7C\*(.*)\.!sU', '.', $html);
$html = preg_replace( '!>(.*)\*\|(.*)\|\*(.*)\.!sU', '>', $html);
$html = preg_replace( '!>(.*)\*%7C(.*)%7C\*(.*)\.!sU', '>', $html);
// anchors containing a merge tag
$html = preg_replace( '!)?!isU', '', $html);
$html = preg_replace( '!)?!isU', '', $html);
// all other merge tags
$html = preg_replace( '!\*\|(.*)\|\*!isU', '', $html);
$html = preg_replace( '!(\*%7C)(.*)(%7C\*)!isU', '', $html);
}
*/
$now = date('Y-m-d H:i:s');
$now_gmt = gmdate('Y-m-d H:i:s');
$data = [
'post_author' => $currentUser->ID,
'post_date' => $now,
'post_date_gmt' => $now_gmt,
'post_content' => $html,
'post_excerpt' => '',
'post_status' => 'draft',
'post_title' => $subject,
'post_type' => $type,
'post_name' => sanitize_title($subject),
'post_modified' => $now,
'post_modified_gmt' => $now_gmt,
'guid' => $guid,
'comment_count' => 0,
'to_ping' => '',
'pinged' => '',
'post_content_filtered' => ''
];
$wpdb->insert($wpdb->posts, $data);
echo esc_attr($nextIncrement);
exit;
} else {
// create landing page
// throw error if page title is empty or consists only of special characters
$safeSubject = sanitize_title($fileName);
if ($safeSubject == '') {
$result['error'] = 1;
$result['msg'] = '' . esc_html__('Page title must not be empty or consist exclusively of special characters!', 'chimpxpress') . '';
header("Content-type: application/json");
echo wp_json_encode($result);
exit;
}
if (!$_POST['force'] && file_exists(ABSPATH . 'archive' . DS . $safeSubject . '.html')) {
$result['error'] = 1;
$result['msg'] = '' . esc_html__('A landing page with the supplied name already exists!', 'chimpxpress') . '
' . esc_html__('Click here to overwrite the existing landing page', 'chimpxpress') . '';
header("Content-type: application/json");
echo wp_json_encode($result);
exit;
}
// get campaign content
$campaign = $this->MCAPI->campaignsContent($cid);
if (empty($campaign) || empty($campaign['html'])) {
$result['error'] = 1;
$result['msg'] = '' . esc_html__('Campaign could not be retrieved. Please try again.', 'chimpxpress') . '';
header("Content-type: application/json");
echo wp_json_encode($result);
exit;
}
$html = $campaign['html'];
// set page title
if (!preg_match('!(.*)!i', $html)) {
$html = str_replace('', "" . $fileName . "\n", $html);
} else {
$html = preg_replace('!(.*)!i', '' . $fileName . '', $html);
}
// insert google analytics
if ($this->settings['GAprofile']) {
$script = "\n";
$html = str_replace('', $script . "\n", $html);
}
// remove MERGE tags
// sentences containing a merge tag
// $html = preg_replace( '!\.\s(.*)\*(\||%7C)(.*)(\||%7C)\*(.*)\.!sU', '###', $html);
// $html = preg_replace( '!>(.*)\*(\||%7C)(.*)(\||%7C)\*(.*)\.!sU', '>', $html);
// anchors containing a merge tag
$html = preg_replace('!!', '', $html);
// all other merge tags
$html = preg_replace('!\*(\||%7C)(.*)(\||%7C)\*!', '', $html);
// create html file
$archiveDirAbs = ABSPATH . 'archive/';
$archiveDirRel = get_option('home') . '/archive/';
global $wp_filesystem;
if ($wp_filesystem->method == 'direct') {
if (!is_dir($archiveDirAbs)) {
$wp_filesystem->mkdir(ABSPATH . 'archive');
}
$wp_filesystem->put_contents(ABSPATH . 'archive' . DS . $safeSubject . '.html', $html);
} else {
$ftpstream = ftp_connect($this->settings['ftpHost']);
ftp_login($ftpstream, $this->settings['ftpUser'], $this->settings['ftpPasswd']);
ftp_chdir($ftpstream, $this->settings['ftpPath']);
// create archive directory if it doesn't exist
if (!is_dir($archiveDirAbs)) {
ftp_mkdir($ftpstream, 'archive');
}
// write landing page html file
$temp = tmpfile();
$wp_filesystem->put_contents($temp, $html);
rewind($temp);
ftp_fput($ftpstream, 'archive' . DS . $safeSubject . '.html', $temp, FTP_ASCII);
ftp_close($ftpstream);
}
$fileName = $archiveDirRel . $safeSubject . '.html';
echo esc_attr($fileName);
exit;
}
echo esc_attr($nextIncrement);
exit;
}
function load_campaigns_callback() {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], $this->optionsName . '-load-campaigns')) {
die('Invalid request!');
}
$page = (is_numeric($_POST['nextPage'])) ? $_POST['nextPage'] : 1;
require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'class-MCAPI.php');
$MCAPI = new chimpxpressMCAPI;
$campaigns = $MCAPI->campaigns(['status' => 'sent']);
$result = [];
if (isset($campaigns['campaigns'][0])) {
$result['again'] = 1;
$result['page'] = $page + 1;
$result['html'] = '';
$i = 0;
foreach ($campaigns['campaigns'] as $c) {
$result['html'] .= '' . $c['settings']['title'] . ' (' . $c['settings']['subject_line'] . ")\n";
$i++;
}
if ($i < 10) {
$result['again'] = 0;
}
} else {
$result['again'] = 0;
}
header('Content-type: application/json');
echo wp_json_encode($result);
exit;
}
function archive_deleteLP_callback() {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], $this->optionsName . '-archive')) {
die('Invalid request!');
}
global $wp_filesystem;
if ($wp_filesystem->method != 'direct') {
$ftpstream = ftp_connect($this->settings['ftpHost']);
ftp_login($ftpstream, $this->settings['ftpUser'], $this->settings['ftpPasswd']);
ftp_chdir($ftpstream, $this->settings['ftpPath']);
}
$filenames = $_POST['filenames'];
foreach ($filenames as $name) {
if ($wp_filesystem->method == 'direct') {
$wp_filesystem->delete(ABSPATH . 'archive' . DS . $name);
} else {
$this->ftp_delAll($ftpstream, 'archive' . DS . $name);
}
}
if ($wp_filesystem->method != 'direct') {
ftp_close($ftpstream);
}
}
function rrmdir($dir) {
global $wp_filesystem;
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir . "/" . $object) == "dir") {
$this->rrmdir($dir . "/" . $object);
} else {
wp_delete_file($dir . "/" . $object);
}
}
}
reset($objects);
$wp_filesystem->rmdir($dir);
}
}
function ftp_delAll($ftpstream, $dst_dir) {
$ar_files = ftp_nlist($ftpstream, $dst_dir);
if (is_array($ar_files)) { // makes sure there are files
for ($i = 0; $i < sizeof($ar_files); $i++) { // for each file
$st_file = basename($ar_files[$i]);
if ($st_file == '.' || $st_file == '..') {
continue;
}
if (ftp_size($ftpstream, $dst_dir . '/' . $st_file) == -1) { // check if it is a directory
ftp_delAll($ftpstream, $dst_dir . '/' . $st_file); // if so, use recursion
} else {
ftp_delete($ftpstream, $dst_dir . '/' . $st_file); // if not, delete the file
}
}
sleep(1);
}
$flag = ftp_rmdir($ftpstream, $dst_dir); // delete empty directories
return $flag;
}
public function ftp_find_root() {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], $this->optionsGroup . '-options')) {
die('Invalid request!');
}
if (empty($_POST['ftpHost']) || empty($_POST['ftpUser']) || empty($_POST['ftpPasswd'])) {
esc_html_e('Invalid ftp credentials!', 'chimpxpress');
exit;
}
try {
$ftpStream = ftp_connect($_POST['ftpHost']);
if (!$ftpStream) {
esc_html_e('Invalid ftp credentials!', 'chimpxpress');
exit;
}
$ftplogin = ftp_login($ftpStream, $_POST['ftpUser'], $_POST['ftpPasswd']);
if (!$ftplogin) {
esc_html_e('Invalid ftp credentials!', 'chimpxpress');
ftp_close($ftpStream);
exit;
}
$paths = explode(DS, ABSPATH);
$paths = array_filter($paths);
for ($i = 0; $i < count($paths); $i++) {
if (ftp_chdir($ftpStream, $paths[$i])) {
break;
}
}
for ($x = $i; $x <= count($paths); $x++) {
ftp_chdir($ftpStream, $paths[$x]);
}
echo esc_attr(ftp_pwd($ftpStream));
ftp_close($ftpStream);
exit;
} catch (Throwable $e) {
echo esc_html($e->getMessage());
die;
}
}
function ftp_test_callback() {
if (!wp_verify_nonce($_REQUEST['_wpnonce'], $this->optionsGroup . '-options')) {
die('Invalid request!');
}
$ftpStream = ftp_connect($_POST['ftpHost']);
if (!$ftpStream) {
echo '' . esc_html__('Invalid FTP host!', 'chimpxpress') . '';
exit;
}
$ftpLogin = ftp_login($ftpStream, $_POST['ftpUser'], $_POST['ftpPasswd']);
if (!$ftpLogin) {
echo '' . esc_html__('Invalid username / password!', 'chimpxpress') . '';
ftp_close($ftpStream);
exit;
}
$ftproot = ftp_chdir($ftpStream, $_POST['ftpPath']);
$adminDir = ftp_chdir($ftpStream, 'wp-admin');
ftp_close($ftpStream);
if (!$ftproot || !$adminDir) {
echo '' . esc_html__('Invalid FTP path!', 'chimpxpress') . '';
exit;
}
echo '' . esc_html__('FTP test successful!', 'chimpxpress') . '';
exit;
}
public function main() {
require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'main.php');
}
function compose() {
global $wp_filesystem;
$useFTP = ($wp_filesystem->method == 'direct') ? false : true;
$handler = $wp_filesystem;
$cacheDir = 'wp-content' . DS . 'plugins' . DS . 'chimpxpress' . DS . 'cache';
echo '';
if (!is_dir(ABSPATH . $cacheDir)) {
if (!$useFTP) {
$wp_filesystem->mkdir(ABSPATH . $cacheDir);
} else {
$handler = ftp_connect($this->settings['ftpHost']);
$login = ftp_login($handler, $this->settings['ftpUser'], $this->settings['ftpPasswd']);
ftp_chdir($handler, $this->settings['ftpPath']);
ftp_mkdir($handler, $cacheDir);
ftp_close($handler);
}
} else {
if ($useFTP) {
$handler = ftp_connect($this->settings['ftpHost']);
$login = ftp_login($handler, $this->settings['ftpUser'], $this->settings['ftpPasswd']);
ftp_chdir($handler, $this->settings['ftpPath']);
}
}
$cache = new chimpxpressJG_Cache($cacheDir, $useFTP, $handler);
$templates = $cache->get('templates');
if ($templates === false) {
echo '
' . esc_html__('Retrieving templates and lists ...', 'chimpxpress') . '
';
}
require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'compose.php');
echo '
';
}
function import() {
require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'import.php');
}
function archive() {
require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'archive.php');
}
function editLP() {
require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'editLP.php');
}
public function options() { ?>
chimpXpress
MCAPI->showMessages();
?>
_listener_query_var . '=' . urlencode($this->settings['listener_security_key']);
}
public static function getInstance() {
if (!self::$instance) {
self::$instance = new self;
}
return self::$instance;
}
// load language files
function chimpxpressLoadLanguage() {
if (function_exists('load_plugin_textdomain')) {
load_plugin_textdomain($this->optionsName, false, 'chimpxpress' . DS . 'languages');
}
}
// Add meta box
function chimpxpress_add_box() {
// add meta box to blog post edit page
$meta_box = [
'id' => 'chimpxpress-meta-box',
'title' => esc_html__('Import from Mailchimp campaign', 'chimpxpress'),
'page' => 'post',
'context' => 'side',
'priority' => 'default'
];
add_meta_box($meta_box['id'], $meta_box['title'], [$this, 'chimpxpress_show_box'], $meta_box['page'], $meta_box['context'], $meta_box['priority']);
// add meta box to page edit page
$meta_box = [
'id' => 'chimpxpress-meta-box',
'title' => esc_html__('Import from Mailchimp campaign', 'chimpxpress'),
'page' => 'page',
'context' => 'side',
'priority' => 'default'
];
add_meta_box($meta_box['id'], $meta_box['title'], [$this, 'chimpxpress_show_box'], $meta_box['page'], $meta_box['context'], $meta_box['priority']);
}
function chimpxpress_show_box() {
require_once(WP_PLUGIN_DIR . DS . 'chimpxpress' . DS . 'class-MCAPI.php');
$MCAPI = new chimpxpressMCAPI();
$campaigns = $MCAPI->campaigns(['status' => 'sent']);
echo '';
echo '
' . esc_html__('Choose a campaign to copy content into your post', 'chimpxpress') . ':
';
echo '
';
echo '
';
wp_nonce_field('chimpxpress-load-campaigns', 'CX_nonce');
echo '';
echo '
';
return;
}
}
$chimpxpress = chimpxpress::getInstance();