/** * Alert in admin panel */ function alo_em_admin_notice() { global $pagenow; $page = isset($_GET['page']) ? $_GET['page'] : false; if ($pagenow == "edit.php" && isset($_GET['post_type']) && $_GET['post_type'] == 'newsletter' && $page != 'alo-easymail/alo-easymail_subscribers.php') { /* if ( get_option('alo_em_timeout_alert') != "hide" ) { echo '<div class="updated fade">'; echo '<p><img src="'.ALO_EM_PLUGIN_URL.'/images/12-exclamation.png" /> '. __("To enable the plugin work better you should increase the wp_cron and php timeouts", "alo-easymail") .". "; echo __("For more info you can use the Help button or visit the FAQ of the site", "alo-easymail"); echo ' <a href="http://www.eventualo.net/blog/wp-alo-easymail-newsletter-faq/#faq-3" target="_blank" title="'. __("For more info, visit the FAQ of the site.", "alo-easymail") .'">»</a></p>'; echo "<p>(<a href='". "edit.php?post_type=newsletter&page=alo-easymail/alo-easymail_options.php" ."&timeout_alert=stop' />". __('Do not show it again', 'alo-easymail') ."</a>)</p>"; echo '</div>'; } */ if (get_option('ALO_em_debug_newsletters') != "") { echo '<div class="updated fade">'; echo '<p><img src="' . ALO_EM_PLUGIN_URL . '/images/12-exclamation.png" /> <strong>' . __("Debug mode is activated", "alo-easymail") . "</strong>: "; if (get_option('ALO_em_debug_newsletters') == "to_author") { _e("all messages will be sent to the newsletter author", "alo-easymail"); } if (get_option('ALO_em_debug_newsletters') == "to_file") { _e("all messages will be recorded into a log file", "alo-easymail"); } echo ".</p>"; echo '</div>'; } } if (alo_em_db_tables_need_update()) { echo '<div class="error">'; echo '<p><img src="' . ALO_EM_PLUGIN_URL . '/images/12-exclamation.png" /> <strong><em>' . __("ALO Easymail Newsletter needs attention", "alo-easymail") . "!</em></strong><br />"; echo __("The plugin database tables have not properly installed", "alo-easymail") . ": <strong>" . __("you can try to deactivate and activate the plugin", "alo-easymail") . "</strong>."; echo "<br /><a href=\"http://www.eventualo.net/blog/wp-alo-easymail-newsletter-faq/\" target=\"_blank\">" . __("For more info, visit the FAQ of the site.", "alo-easymail") . "</a>"; echo ".</p>"; echo '</div>'; } }
/** * Install/update database tables */ function alo_em_install_db_tables() { global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; //------------------------------------------------------------------------- if (alo_em_db_tables_need_update()) { $charset_collate = ''; if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } // Create the table structure $sql = "CREATE TABLE {$wpdb->prefix}easymail_subscribers ( \n\t\t\t\t ID int(11) unsigned NOT NULL auto_increment , \n\t\t\t\t email varchar(100) NOT NULL , \n\t\t\t\t name varchar(100) NOT NULL , \n\t\t\t\t join_date datetime NOT NULL , \n\t\t\t\t active INT( 1 ) NOT NULL DEFAULT '0' , \n\t\t\t\t unikey varchar(24) NOT NULL , \n\t\t\t\t lists varchar(255) DEFAULT '|' , \n\t\t\t\t lang varchar(5) DEFAULT NULL , \n\t\t\t\t last_act datetime NULL ,\n\t\t\t\t ip_address varchar(50) NULL , \n\t\t\t\t PRIMARY KEY (ID) \n\t\t\t\t) {$charset_collate};\n\n\t\t\t\tCREATE TABLE {$wpdb->prefix}easymail_recipients ( \n\t\t\t\t\tID int(11) unsigned NOT NULL auto_increment , \n\t\t\t\t\tnewsletter int(11) unsigned NOT NULL , \n\t\t\t\t\temail varchar(100) NOT NULL , \n\t\t\t\t\tresult varchar(3) NOT NULL DEFAULT '0' , \n\t\t\t\t\tuser_id int(11) unsigned DEFAULT NULL , \n\t\t\t\t\tPRIMARY KEY (ID) \n\t\t\t\t) {$charset_collate};\n\n\t\t\t\tCREATE TABLE {$wpdb->prefix}easymail_stats (\n\t\t\t\t\tID int(11) unsigned NOT NULL auto_increment ,\n\t\t\t\t\trecipient int(11) unsigned NOT NULL ,\n\t\t\t\t\tnewsletter int(11) unsigned NOT NULL ,\n\t\t\t\t\tadded_on datetime NOT NULL ,\n\t\t\t\t\trequest text ,\n\t\t\t\t\tPRIMARY KEY (ID)\n\t\t\t\t) {$charset_collate};\n\t\t\t\t\t\n\t\t\t\tCREATE TABLE {$wpdb->prefix}easymail_unsubscribed (\n\t\t\t\t\temail varchar(100) NOT NULL , \n\t\t\t\t\tadded_on datetime NOT NULL ,\n\t\t\t\t\tPRIMARY KEY (email)\n\t\t\t\t) {$charset_collate};\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t "; dbDelta($sql); // Update the old "lists" field if upgrading from v. 1.x $installed_db = get_option('alo_em_db_version'); if ($installed_db < 2012) { $wpdb->query("UPDATE " . $wpdb->prefix . "easymail_subscribers SET lists = REPLACE( lists, '_', '|');"); $wpdb->query("UPDATE {$wpdb->options} SET option_name = REPLACE( option_name, 'ALO_em_', 'alo_em_');"); } // v.2016: Add table indexes if ($installed_db < 2016) { $wpdb->query("ALTER TABLE {$wpdb->prefix}easymail_recipients ADD INDEX ( `newsletter` ), ADD INDEX ( `email` )"); $wpdb->query("ALTER TABLE {$wpdb->prefix}easymail_stats ADD INDEX ( `newsletter` ), ADD INDEX ( `recipient` )"); } // Add 'email' index only if not exists (it exists in plugin versions older than 2.3) if (!$wpdb->get_row("SHOW INDEX FROM {$wpdb->prefix}easymail_subscribers WHERE Non_unique = 0 AND Column_name = 'email';")) { $wpdb->query("ALTER TABLE {$wpdb->prefix}easymail_subscribers ADD UNIQUE ( `email` )"); } // v.2017: Modify Request column, an index in new 'unsubscribed' table if ($installed_db < 2017) { $wpdb->query("ALTER TABLE {$wpdb->prefix}easymail_stats CHANGE `request` `request` text"); } // v.2019: the new 'last_act' column if empty has the same value of the 'join_date' if ($installed_db < 2019) { $wpdb->query("UPDATE " . $wpdb->prefix . "easymail_subscribers SET last_act = join_date WHERE last_act IS NULL;"); } update_option("alo_em_db_version", ALO_EM_DB_VERSION); } }