/**
  * Class constructor
  */
 function __construct()
 {
     global $pagenow;
     inboundrocket_set_wpdb_tables();
     inboundrocket_set_mysql_timezone_offset();
     $this->power_ups = self::get_available_power_ups();
     if (is_user_logged_in() && is_admin()) {
         add_action('admin_bar_menu', array($this, 'add_inboundrocket_link_to_admin_bar'), 999);
     }
     if (is_admin()) {
         if (!defined('DOING_AJAX') || !DOING_AJAX) {
             $ir_wp_admin = new WPInboundRocketAdmin($this->power_ups);
         }
     } else {
         if (in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) {
             add_action('login_enqueue_scripts', array($this, 'add_inboundrocket_frontend_scripts'));
         } else {
             add_action('wp_enqueue_scripts', array($this, 'add_inboundrocket_frontend_scripts'));
         }
     }
     add_action('wp_ajax_ir_ec_callback', array($this, 'inboundrocket_ec_callback'));
     add_action('wp_ajax_nopriv_ir_ec_callback', array($this, 'inboundrocket_ec_callback'));
 }
예제 #2
0
    }
    /**
     * Formats any timestamp to format like Feb 4 8:43pm
     *
     * @param   string
     * @return  string
     */
    function date_format_contact_stat($timestamp)
    {
        return date('M j, Y g:ia', strtotime($timestamp));
    }
}
/** Export functionality for the contacts list */
if (isset($_POST['export-all']) || isset($_POST['export-selected'])) {
    global $wpdb;
    inboundrocket_set_wpdb_tables();
    inboundrocket_set_mysql_timezone_offset();
    $sitename = sanitize_key(get_bloginfo('name'));
    if (!empty($sitename)) {
        $sitename .= '.';
    }
    $filename = $sitename . '.contacts.' . date('Y-m-d-H-i-s') . '.csv';
    header('Content-Description: File Transfer');
    header('Content-Disposition: attachment; filename=' . $filename);
    header('Content-Type: text/csv; charset=' . get_option('blog_charset'), TRUE);
    $column_headers = array('Email', 'First Name', 'Last Name', 'Original source', 'Visits', 'Page views', 'Forms', 'Shares', 'Last visit', 'Created on');
    $fields = array('lead_email', 'lead_first_name', 'lead_last_name', 'lead_source', 'visits', 'lead_pageviews', 'lead_form_submissions', 'lead_shares', 'last_visit', 'lead_date');
    $headers = array();
    foreach ($column_headers as $key => $field) {
        $headers[] = '"' . $field . '"';
    }
예제 #3
0
/**
 * Creates or updates the inboundrocket tables
 */
function inboundrocket_db_install()
{
    global $wpdb;
    $charset_collate = $wpdb->get_charset_collate();
    inboundrocket_set_wpdb_tables();
    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->ir_leads} (\n\t\t  `lead_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `lead_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t  `hashkey` varchar(16) DEFAULT NULL,\n\t\t  `lead_ip` varchar(40) DEFAULT NULL,\n\t\t  `lead_source` text,\n\t\t  `lead_email` varchar(255) DEFAULT NULL,\n\t\t  `lead_first_name` varchar(255) NOT NULL,\n  \t\t  `lead_last_name` varchar(255) NOT NULL,\n\t\t  `lead_status` set('leads','contact','contacted','customers','ambassadors','commenters','subscribers') NOT NULL DEFAULT 'leads',\n\t\t  `merged_hashkeys` text,\n\t\t  `lead_deleted` int(1) NOT NULL DEFAULT '0',\n\t\t  `blog_id` int(11) unsigned NOT NULL,\n\t\t  `company_data` mediumtext NOT NULL,\n  \t\t  `social_data` mediumtext NOT NULL,\n\t\t  PRIMARY KEY (`lead_id`),\n\t\t  KEY `hashkey` (`hashkey`)\n\t\t) {$charset_collate};";
    dbDelta($sql);
    $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->ir_pageviews} (\n\t\t  `pageview_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `pageview_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t  `lead_hashkey` varchar(16) NOT NULL,\n\t\t  `pageview_title` varchar(255) NOT NULL,\n\t\t  `pageview_url` text NOT NULL,\n\t\t  `pageview_source` text NOT NULL,\n\t\t  `pageview_session_start` int(1) NOT NULL,\n\t\t  `pageview_deleted` int(1) NOT NULL DEFAULT '0',\n\t\t  `blog_id` int(11) unsigned NOT NULL,\n\t\t  PRIMARY KEY (`pageview_id`),\n\t\t  KEY `lead_hashkey` (`lead_hashkey`)\n\t\t) {$charset_collate};";
    dbDelta($sql);
    $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->ir_submissions} (\n\t\t  `form_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `form_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t  `lead_hashkey` varchar(16) NOT NULL,\n\t\t  `form_page_title` varchar(255) NOT NULL,\n\t\t  `form_page_url` text NOT NULL,\n\t\t  `form_fields` text NOT NULL,\n\t\t  `form_selector_id` mediumtext NOT NULL,\n\t\t  `form_selector_classes` mediumtext NOT NULL,\n\t\t  `form_hashkey` varchar(16) NOT NULL,\n\t\t  `form_deleted` int(1) NOT NULL DEFAULT '0',\n\t\t  `blog_id` int(11) unsigned NOT NULL,\n\t\t  PRIMARY KEY (`form_id`),\n\t\t  KEY `lead_hashkey` (`lead_hashkey`)\n\t\t) {$charset_collate};";
    dbDelta($sql);
    $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->ir_shares} (\n\t\t  `share_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `share_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t  `lead_hashkey` varchar(16) NOT NULL,\n\t\t  `share_type` set('contact','ss-twitter-text','is-twitter-image','click-to-tweet','ss-email-text','ss-email-image','ss-facebook-text','is-facebook-image','ss-linkedin-text','is-pinterest-image') NOT NULL,\n\t\t  `share_deleted` int(1) NOT NULL DEFAULT '0',\n\t\t  `share` text NOT NULL,\n\t\t  `post_id` int(11) NOT NULL,\n\t\t  `blog_id` int(11) unsigned NOT NULL,\n\t\t  PRIMARY KEY (`share_id`),\n\t\t  KEY `lead_hashkey` (`lead_hashkey`)\n\t\t) {$charset_collate};";
    dbDelta($sql);
    $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->ir_sharer_stats} (\n\t\t\t`id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n   \t\t\t`share_id` int(11) unsigned NOT NULL,\n   \t\t\t`timestamp` timestamp NOT NULL,\n   \t\t\t`type` TEXT NOT NULL,\n   \t\t\tPRIMARY KEY (`id`),\n   \t\t\tCONSTRAINT `{$wpdb->ir_sharer_stats}` FOREIGN KEY (`share_id`) REFERENCES `{$wpdb->ir_shares}` (`id`) ON DELETE CASCADE\n   \t\t) {$charset_collate};";
    dbDelta($sql);
    $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->ir_tags} (\n\t\t  `tag_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `tag_text` varchar(255) NOT NULL,\n\t\t  `tag_slug` varchar(255) NOT NULL,\n\t\t  `tag_form_selectors` mediumtext NOT NULL,\n\t\t  `tag_synced_lists` mediumtext NOT NULL,\n\t\t  `tag_order` int(11) unsigned NOT NULL,\n\t\t  `blog_id` int(11) unsigned NOT NULL,\n\t\t  `tag_deleted` int(1) NOT NULL,\n\t\t  PRIMARY KEY (`tag_id`)\n\t\t) {$charset_collate};";
    dbDelta($sql);
    $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->ir_tag_relationships} (\n\t\t  `tag_relationship_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `tag_id` int(11) unsigned NOT NULL,\n\t\t  `contact_hashkey` varchar(16) NOT NULL,\n  \t\t  `form_hashkey` varchar(16) NOT NULL,\n\t\t  `tag_relationship_deleted` int(1) unsigned NOT NULL,\n\t\t  `blog_id` int(11) unsigned NOT NULL,\n\t\t  PRIMARY KEY (`tag_relationship_id`)\n\t\t) {$charset_collate};";
    dbDelta($sql);
    $sql = "CREATE TABLE IF NOT EXISTS {$wpdb->ir_emails} (\n\t\t  `email_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t  `email_subject` varchar(255) NOT NULL,\n\t\t  `email_text_content` varchar(255) NOT NULL,\n\t\t  `email_html_content` mediumtext NOT NULL,\n\t\t  `email_deleted` int(1) NOT NULL,\n\t\t  PRIMARY KEY (`email_id`)\n\t\t) {$charset_collate};";
    dbDelta($sql);
    inboundrocket_update_option('inboundrocket_options', 'ir_db_version', INBOUNDROCKET_DB_VERSION);
    inboundrocket_track_plugin_activity("Databases Installed");
}