* 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' ); defined( 'DS' ) or define('DS', DIRECTORY_SEPARATOR); if( ! is_admin() ){ return; } class chimpexpress { public $_settings; private $_errors = array(); private $_notices = array(); static $instance = false; private $_optionsName = 'chimpexpress'; private $_optionsGroup = 'chimpexpress-options'; private $_url = "https://us1.api.mailchimp.com/1.3/"; private $_listener_query_var = 'chimpexpressListener'; private $_timeout = 30; private $MCAPI = false; // public $_api = false; function __construct() { require_once( WP_PLUGIN_DIR . DS . 'chimpexpress' . DS . 'class-MCAPI.php' ); if( ! $this->MCAPI ){ $this->MCAPI = new chimpexpressMCAPI; 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(); // Get the datacenter from the API key $datacenter = substr( strrchr($this->_settings['apikey'], '-'), 1 ); if ( empty( $datacenter ) ) { $datacenter = "us1"; } // Put the datacenter and version into the url $this->_url = "https://{$datacenter}.api.mailchimp.com/{$this->_settings['version']}/"; // include cache library require_once( WP_PLUGIN_DIR . DS . 'chimpexpress' . 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', array( $this, 'chimpexpressLoadLanguage') ); add_action( 'admin_init', array($this, 'registerOptions') ); add_action( 'admin_menu', array($this, 'adminMenu') ); add_action( 'admin_menu', array($this, 'chimpexpress_add_box') ); add_action( 'template_redirect', array( $this, 'listener' )); // add_filter( 'query_vars', array( $this, 'addMailChimpListenerVar' )); register_activation_hook( __FILE__, array( $this, 'activatePlugin' ) ); add_filter( 'pre_update_option_' . $this->_optionsName, array( $this, 'optionUpdate' ), null, 2 ); // add_action( 'admin_notices', array($this->MCAPI, 'showMessages') ); // add css files wp_enqueue_style( 'chimpexpress', plugins_url( 'css' . DS . 'chimpexpress.css', __FILE__ ) ); wp_enqueue_style( 'colorbox', plugins_url( 'css' . DS . 'colorbox.css', __FILE__ ) ); // add js files wp_enqueue_script( 'chimpexpress', plugins_url( 'js' . DS . 'jquery.colorbox-min.js', __FILE__ ) ); // compose ajax callbacks add_action('wp_ajax_compose_clear_cache', array($this,'compose_clear_cache_callback')); add_action('wp_ajax_compose_gotoStep', array($this,'compose_gotoStep_callback')); add_action('wp_ajax_compose_removeDraft', array($this,'compose_removeDraft_callback')); add_action('wp_ajax_sanitize', array($this,'sanitize_callback')); // import ajax callbacks add_action('wp_ajax_import', array($this,'import_callback')); // archive ajax callbacks add_action('wp_ajax_archive_deleteLP', array($this,'archive_deleteLP_callback')); // archive post box callback add_action('wp_ajax_load_campaigns', array($this,'load_campaigns_callback')); add_action('wp_ajax_ftp_find_root', array($this,'ftp_find_root')); add_action('wp_ajax_ftp_test', array($this,'ftp_test_callback')); // add_filter('admin_head', array($this,'ShowTinyMCE')); } function ShowTinyMCE() { // conditions here 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'); if (function_exists('wp_tiny_mce')) wp_tiny_mce(); wp_admin_css(); wp_enqueue_script('utils'); do_action("admin_print_styles-post-php"); do_action('admin_print_styles'); } public function optionUpdate( $newvalue, $oldvalue ) { if ( !empty( $_POST['get-apikey'] ) ) { unset( $_POST['get-apikey'] ); // If the user set their username at the same time as they requested an API key or changes the username if ( empty($this->_settings['username']) || $oldvalue['username'] != $newvalue['username'] ) { $this->_settings['username'] = $newvalue['username']; $this->_updateSettings(); } // If the user set their password at the same time as they requested an API key or changed the password if ( empty($this->_settings['password']) || $oldvalue['password'] != $newvalue['password'] ) { $this->_settings['password'] = $newvalue['password']; $this->_updateSettings(); } $this->_getSettings(); // Get API keys, if one doesn't exist, the login will create one $keys = $this->MCAPI->apikeys(); // var_dump($keys);die; // Set the API key if ( is_array($keys) && !empty( $keys ) && !is_wp_error($keys) ) { $newvalue['apikey'] = $keys[0]['apikey']; $this->MCAPI->_addNotice( __('API Key saved', 'chimpexpress').": {$newvalue['apikey']}"); } } elseif ( !empty( $_POST['expire-apikey'] ) ) { unset( $_POST['expire-apikey'] ); // If the user set their username at the same time as they requested to expire the API key if ( empty($this->_settings['username']) ) { $this->_settings['username'] = $newvalue['username']; } // If the user set their password at the same time as they requested to expire the API key if ( empty($this->_settings['password']) ) { $this->_settings['password'] = $newvalue['password']; } // Get API keys, if one doesn't exist, the login will create one $expired = $this->MCAPI->apikeyExpire( $this->_settings['username'], $this->_settings['password'] ); // Empty the API key and add a notice if ( empty($expired['error']) ) { $newvalue['apikey'] = ''; $this->MCAPI->_addNotice( __('API Key expired', 'chimpexpress').": {$oldvalue['apikey']}"); } } /* elseif ( !empty( $_POST['regenerate-security-key']) ) { unset( $_POST['expire-apikey'] ); $newvalue['listener_security_key'] = $this->_generateSecurityKey(); $this->MCAPI->_addNotice("New Security Key: {$newvalue['listener_security_key']}"); } */ // clear error messages $this->MCAPI->_emptyErrors(); $this->MCAPI->_emptyNotices(); // clear cache if present $cacheDir = 'wp-content' .DS. 'plugins' .DS. 'chimpexpress' .DS. 'cache'; if( is_dir( ABSPATH . $cacheDir ) ){ $cache = new chimpexpressJG_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 = array(); } $defaults = array( 'username' => '', 'password' => '', 'apikey' => '', 'CEaccess' => 'manage_options', 'debugging' => 'off', 'debugging_email' => '', 'listener_security_key' => $this->_generateSecurityKey(), 'version' => '1.3', '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() { add_menu_page( __('Dashboard', 'chimpexpress'), 'ChimpExpress', $this->_settings['CEaccess'], 'ChimpExpressDashboard', array($this, 'main'), plugins_url( 'images' . DS . 'logo_16.png', __FILE__ ), 26 ); add_submenu_page( 'ChimpExpressDashboard', __('Import', 'chimpexpress'), __('Import', 'chimpexpress'), $this->_settings['CEaccess'], 'ChimpExpressImport', array($this, 'import'), '', 27 ); add_submenu_page( 'ChimpExpressDashboard', __('Compose', 'chimpexpress'), __('Compose', 'chimpexpress'), $this->_settings['CEaccess'], 'ChimpExpressCompose', array($this, 'compose'), '', 27 ); add_submenu_page( 'ChimpExpressDashboard', __('Landing Page Archive', 'chimpexpress'), __('Landing Pages', 'chimpexpress'), $this->_settings['CEaccess'], 'ChimpExpressArchive', array($this, 'archive'), '', 27 ); // invisible menus add_submenu_page( 'ChimpExpressArchive', __('Edit Landing Page', 'chimpexpress'), __('Edit Landing Page', 'chimpexpress'), $this->_settings['CEaccess'], 'ChimpExpressEditLandingPage', array($this, 'editLP'), '', 27 ); add_options_page( __('Settings', 'chimpexpress'), 'ChimpExpress', 'manage_options', 'ChimpExpressConfig', array($this, 'options') ); } function compose_clear_cache_callback(){ global $wp_filesystem; if( $wp_filesystem->method == 'direct' ){ $wp_filesystem->delete( ABSPATH . 'wp-content' .DS. 'plugins' .DS. 'chimpexpress' .DS. 'cache', true); } else { $ftpstream = @ftp_connect( $this->_settings['ftpHost'] ); $login = @ftp_login($ftpstream, $this->_settings['ftpUser'], $this->_settings['ftpPasswd']); @ftp_chdir($ftpstream, $this->_settings['ftpPath'] ); $dir = 'wp-content' .DS. 'plugins' .DS. 'chimpexpress' .DS. 'cache'; $this->ftp_delAll($ftpstream, $dir); @ftp_close($ftpstream); } return; } function compose_gotoStep_callback() { include( WP_PLUGIN_DIR . DS . 'chimpexpress' . DS . 'compose.php' ); exit; } function compose_removeDraft_callback() { $cid = $_POST['cid']; $this->MCAPI->campaignDelete($cid); if ( is_dir( WP_PLUGIN_DIR . DS . 'chimpexpress' .DS. 'tmp' ) ){ global $wp_filesystem; if( $wp_filesystem->method == 'direct' ){ $wp_filesystem->delete( WP_PLUGIN_DIR . DS . 'chimpexpress' .DS. 'tmp', true); } else { $ftpstream = @ftp_connect( $this->_settings['ftpHost'] ); $login = @ftp_login($ftpstream, $this->_settings['ftpUser'], $this->_settings['ftpPasswd']); @ftp_chdir($ftpstream, $this->_settings['ftpPath'] ); $this->ftp_delAll($ftpstream, 'wp-content' .DS. 'plugins' .DS. 'chimpexpress' .DS. 'tmp' ); @ftp_close($ftpstream); } } exit; } function sanitize_callback(){ $string = explode('*|@|*', $_POST['string'] ); foreach( $string as $s ){ if( sanitize_title( $s ) == '' ){ echo ''; exit; } } echo 1; exit; } function import_callback() { global $wpdb, $current_user; $type = $_POST['type']; $cid = $_POST['cid']; $subject = html_entity_decode( $_POST['subject'] ); $fileName = html_entity_decode( $_POST['fileName'] ); // get next post/page id $table_status = $wpdb->get_results( $wpdb->prepare("SHOW TABLE STATUS LIKE '$wpdb->posts'") ); $next_increment = $table_status[0]->Auto_increment; if($type=='post'){ // create permalink $guid = get_option('home') . '/?p=' . $next_increment; // var_dump($campaignContent['html']);die; if( $_POST['datatype'] == 'html' ){ // get campaign contents $campaignContent = $this->MCAPI->campaignContent( $cid, false ); // process html contents $html = $campaignContent['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( array('',''), '', $html ); $style = ''; for($i=0;$isetHTML( $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( array('',''), '', $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 $campaignContent = $this->MCAPI->campaignContent( $cid, true ); // process html contents $html = $campaignContent['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 = array( 'post_author' => $current_user->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 $next_increment; die; } else { // create landing page $safeSubject = sanitize_title( $fileName ); // throw error if page title is empty or consists only of special characters if( $safeSubject == '' ){ $result['error'] = 1; $result['msg'] = ''.__('Page title must not be empty or consist exclusively of special characters!', 'chimpexpress').''; header("Content-type: application/json"); echo json_encode( $result ); exit; } if( !$_POST['force'] && file_exists( ABSPATH . 'archive' .DS. $safeSubject . '.html' ) ){ $result['error'] = 1; $result['msg'] = ''.__('A landing page with the supplied name already exists!', 'chimpexpress').'
'.__('Click here to overwrite the existing landing page', 'chimpexpress').'
'; header("Content-type: application/json"); echo json_encode( $result ); exit; } // create permalink $guid = get_option('home') . '/?page_id=' . $next_increment; // get campaign content $campaign = $this->MCAPI->campaignContent( $cid, false ); $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'] ); $login = @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(); fwrite($temp, $html); rewind($temp); @ftp_fput($ftpstream, 'archive' .DS. $safeSubject . '.html', $temp, FTP_ASCII); @ftp_close($ftpstream); } $fileName = $archiveDirRel . $safeSubject . '.html'; echo $fileName; die; } echo $next_increment; exit; } function load_campaigns_callback(){ $page = ( is_numeric($_POST['nextPage']) ) ? $_POST['nextPage'] : 1; require_once( WP_PLUGIN_DIR . DS . 'chimpexpress' . DS . 'class-MCAPI.php' ); $MCAPI = new chimpexpressMCAPI; $campaigns = $MCAPI->campaigns( array('status' => 'sent'), $page, 10 ); $result = array(); if( isset($campaigns['data'][0]) ){ $result['again'] = 1; $result['page'] = $page + 1; $result['html'] = ''; $i = 0; foreach($campaigns['data'] as $c){ $result['html'] .= '
  • '.$c['title'].' ('.$c['subject'].")
  • \n"; $i++; } if( $i < 10 ){ $result['again'] = 0; } } else { $result['again'] = 0; } header("Content-type: application/json"); echo json_encode( $result ); exit; } function archive_deleteLP_callback(){ global $wp_filesystem; if( $wp_filesystem->method != 'direct' ){ $ftpstream = @ftp_connect( $this->_settings['ftpHost'] ); $login = @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); } return; } function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir."/".$object) == "dir") $this->rrmdir($dir."/".$object); else unlink($dir."/".$object); } } reset($objects); 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'.__('Invalid FTP host!', 'chimpexpress').''; } else if( ! $ftplogin ){ echo ''.__('Invalid username / password!', 'chimpexpress').''; } else if( ! $ftproot || ! $adminDir ){ echo ''.__('Invalid FTP path!', 'chimpexpress').''; } else { echo ''.__('FTP test successful!', 'chimpexpress').''; } @ftp_close($ftpstream); exit; } public function main(){ require_once( WP_PLUGIN_DIR . DS . 'chimpexpress' . DS . 'main.php' ); } function compose(){ global $wp_filesystem; $handler = $wp_filesystem; $cacheDir = 'wp-content' .DS. 'plugins' .DS. 'chimpexpress' .DS. 'cache'; echo '
    '; if ( ! is_dir( ABSPATH . $cacheDir ) ){ if( $wp_filesystem->method == 'direct' ){ $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); } } else { if( $wp_filesystem->method != 'direct' ){ $handler = @ftp_connect( $this->_settings['ftpHost'] ); $login = @ftp_login($handler, $this->_settings['ftpUser'], $this->_settings['ftpPasswd']); @ftp_chdir($handler, $this->_settings['ftpPath'] ); } } $useFTP = ($wp_filesystem->method == 'direct') ? false : true; $cache = new chimpexpressJG_Cache( $cacheDir, $useFTP, $handler ); $templates = $cache->get('templates'); if ($templates === FALSE){ echo '
    '.__('Retrieving templates and lists ...', 'chimpexpress').'
    '; } require_once( WP_PLUGIN_DIR . DS . 'chimpexpress' . DS . 'compose.php' ); echo '
    '; @ftp_close($handler); } function import(){ require_once( WP_PLUGIN_DIR . DS . 'chimpexpress' . DS . 'import.php' ); } function archive(){ require_once( WP_PLUGIN_DIR . DS . 'chimpexpress' . DS . 'archive.php' ); } function editLP(){ require_once( WP_PLUGIN_DIR . DS . 'chimpexpress' . DS . 'editLP.php' ); } public function options() { ?>

    ChimpExpress

    MCAPI->showMessages(); ?>
    _optionsGroup ); ?> */ ?> */ ?> MCAPI->ping() ){ ?>
    _settings['apikey']) ) { ?>
    _settings['debugging']); ?> />
    _settings['debugging']); ?> />
    _settings['debugging']); ?> />
    _getListenerUrl(); ?>
    MCAPI->ping()) ? ''.$this->MCAPI->ping().'' : ''.__('Not connected', 'chimpexpress').''; ?>
      
    _listener_query_var.'='.urlencode($this->_settings['listener_security_key']); } public function setTimeout($seconds){ $this->_timeout = absint($seconds); return true; } public function getTimeout(){ return $this->timeout; } public static function getInstance() { if ( !self::$instance ) { self::$instance = new self; } return self::$instance; } // load language files function chimpexpressLoadLanguage() { if (function_exists('load_plugin_textdomain')) { $currentlocale = get_locale(); if(!empty($currentlocale)) { $moFile = dirname(__FILE__) . DS . "languages" . DS . $currentlocale . "-" . $this->_optionsName . ".mo"; if(@file_exists($moFile) && is_readable($moFile)) { load_textdomain( $this->_optionsName, $moFile); } } } } // Add meta box function chimpexpress_add_box() { // add meta box to blog post edit page $meta_box = array( 'id' => 'chimpexpress-meta-box', 'title' => __('Import from MailChimp campaign', 'chimpexpress'), 'page' => 'post', 'context' => 'side', 'priority' => 'default' ); add_meta_box($meta_box['id'], $meta_box['title'], array( $this, 'chimpexpress_show_box'), $meta_box['page'], $meta_box['context'], $meta_box['priority']); // add meta box to page edit page $meta_box = array( 'id' => 'chimpexpress-meta-box', 'title' => __('Import from MailChimp campaign', 'chimpexpress'), 'page' => 'page', 'context' => 'side', 'priority' => 'default' ); add_meta_box($meta_box['id'], $meta_box['title'], array( $this, 'chimpexpress_show_box'), $meta_box['page'], $meta_box['context'], $meta_box['priority']); } function chimpexpress_show_box() { require_once( WP_PLUGIN_DIR . DS . 'chimpexpress' . DS . 'class-MCAPI.php' ); $MCAPI = new chimpexpressMCAPI; $campaigns = $MCAPI->campaigns( array('status' => 'sent'), 0, 10 ); echo '
    '; echo '

    '.__('Choose a campaign to copy content into your post', 'chimpexpress').':

    '; echo '
    '; echo ''; echo '
    '; echo '
    '; echo ''; echo ''.__('more', 'chimpexpress').''; echo '
    '; echo ''; echo '
    '; return; } } $chimpexpress = chimpexpress::getInstance();