/** * Create the tables if needed * * @param void * @return void * @author Nicolas Juen */ public static function activation() { /* @var $wpdb wpdb */ global $wpdb; // Charset if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } // Add one library admin function for next function require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // Campaign Table maybe_create_table($wpdb->bea_s_campaigns, "CREATE TABLE " . $wpdb->bea_s_campaigns . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`add_date` datetime NOT NULL,\n\t\t\t`scheduled_from` datetime NOT NULL,\n\t\t\t`current_status` varchar(10) NOT NULL,\n\t\t\t`from_name` varchar(255) NOT NULL,\n\t\t\t`from` varchar(255) NOT NULL,\n\t\t\t`subject` text NOT NULL\n\t\t) {$charset_collate};"); add_clean_index($wpdb->bea_s_campaigns, 'id'); add_clean_index($wpdb->bea_s_campaigns, 'current_status'); // Receiver Table maybe_create_table($wpdb->bea_s_receivers, "CREATE TABLE " . $wpdb->bea_s_receivers . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`email` varchar(255) NOT NULL,\n\t\t\t`current_status` varchar(10) NOT NULL,\n\t\t\t`bounce_cat` varchar(20) NOT NULL,\n\t\t\t`bounce_type` varchar(20) NOT NULL,\n\t\t\t`bounce_no` varchar(10) NOT NULL\n\t\t) {$charset_collate};"); maybe_add_column($wpdb->bea_s_receivers, 'bounce_cat', "ALTER TABLE {$wpdb->bea_s_receivers} ADD bounce_cat char(20)"); maybe_add_column($wpdb->bea_s_receivers, 'bounce_type', "ALTER TABLE {$wpdb->bea_s_receivers} ADD bounce_type char(20)"); maybe_add_column($wpdb->bea_s_receivers, 'bounce_no', "ALTER TABLE {$wpdb->bea_s_receivers} ADD bounce_no char(10)"); add_clean_index($wpdb->bea_s_receivers, 'email'); add_clean_index($wpdb->bea_s_receivers, 'current_status'); // Recesiver/campaign link table maybe_create_table($wpdb->bea_s_re_ca, "CREATE TABLE " . $wpdb->bea_s_re_ca . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`id_campaign` int NOT NULL,\n\t\t\t`id_receiver` int NOT NULL,\n\t\t\t`id_content` int NOT NULL,\n\t\t\t`current_status` varchar(10) NOT NULL,\n\t\t\t`response` varchar(10) NOT NULL\n\t\t) {$charset_collate};"); add_clean_index($wpdb->bea_s_re_ca, 'current_status'); add_clean_index($wpdb->bea_s_re_ca, 'id_campaign'); add_clean_index($wpdb->bea_s_re_ca, 'id_receiver'); // Content Table maybe_create_table($wpdb->bea_s_contents, "CREATE TABLE " . $wpdb->bea_s_contents . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`html` longtext NOT NULL,\n\t\t\t`text` longtext NOT NULL\n\t\t) {$charset_collate};"); add_clean_index($wpdb->bea_s_contents, 'id'); // Attachment Table maybe_create_table($wpdb->bea_s_attachments, "CREATE TABLE " . $wpdb->bea_s_attachments . " (\n\t\t\t`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`campaign_id` int NOT NULL,\n\t\t\t`path` longtext NOT NULL\n\t\t) {$charset_collate};"); add_clean_index($wpdb->bea_s_attachments, 'id'); add_clean_index($wpdb->bea_s_attachments, 'campaign_id'); }
function ratings_activate() { global $wpdb; // Create Post Ratings Table $create_sql = "CREATE TABLE {$wpdb->ratings} (" . "rating_id INT(11) NOT NULL auto_increment," . "rating_postid INT(11) NOT NULL ," . "rating_posttitle TEXT NOT NULL," . "rating_rating INT(2) NOT NULL ," . "rating_timestamp VARCHAR(15) NOT NULL ," . "rating_ip VARCHAR(40) NOT NULL ," . "rating_host VARCHAR(200) NOT NULL," . "rating_username VARCHAR(50) NOT NULL," . "rating_userid int(10) NOT NULL default '0'," . "PRIMARY KEY (rating_id));"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($create_sql); // Add In Options (4 Records) add_option('postratings_image', 'stars'); add_option('postratings_max', '5'); add_option('postratings_template_vote', '%RATINGS_IMAGES_VOTE% (<strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%)<br />%RATINGS_TEXT%'); add_option('postratings_template_text', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%' . __(',', 'wp-postratings') . ' <strong>' . __('rated', 'wp-postratings') . '</strong></em>)'); add_option('postratings_template_none', '%RATINGS_IMAGES_VOTE% (' . __('No Ratings Yet', 'wp-postratings') . ')<br />%RATINGS_TEXT%'); // Database Upgrade For WP-PostRatings 1.02 add_option('postratings_logging_method', '3'); add_option('postratings_allowtorate', '2'); // Database Uprade For WP-PostRatings 1.04 maybe_add_column($wpdb->ratings, 'rating_userid', "ALTER TABLE {$wpdb->ratings} ADD rating_userid INT( 10 ) NOT NULL DEFAULT '0';"); // Database Uprade For WP-PostRatings 1.05 add_option('postratings_ratingstext', array(__('1 Star', 'wp-postratings'), __('2 Stars', 'wp-postratings'), __('3 Stars', 'wp-postratings'), __('4 Stars', 'wp-postratings'), __('5 Stars', 'wp-postratings'))); add_option('postratings_template_highestrated', '<li><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a> %RATINGS_IMAGES% (%RATINGS_AVERAGE% ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%)</li>'); // Database Upgrade For WP-PostRatings 1.11 add_option('postratings_ajax_style', array('loading' => 1, 'fading' => 1)); // Database Upgrade For WP-PostRatings 1.20 add_option('postratings_ratingsvalue', array(1, 2, 3, 4, 5)); add_option('postratings_customrating', 0); add_option('postratings_template_permission', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%</em>)<br /><em>' . __('You need to be a registered member to rate this.', 'wp-postratings') . '</em>'); // Database Upgrade For WP-PostRatings 1.30 add_option('postratings_template_mostrated', '<li><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a> - %RATINGS_USERS% ' . __('votes', 'wp-postratings') . '</li>'); // Database Upgrade For WP-PostRatings 1.50 delete_option('widget_ratings_highest_rated'); delete_option('widget_ratings_most_rated'); // Set 'manage_ratings' Capabilities To Administrator $role = get_role('administrator'); $role->add_cap('manage_ratings'); }
function upgrade_100() { global $wpdb, $tableposts, $tablecomments, $tablecategories, $tableoptionvalues, $tableoptiongroups, $tableoptiongroup_options, $tableoptions, $tablepost2cat, $tablelinks, $tableusers; maybe_add_column($tableposts, 'post_name', "ALTER TABLE `{$tableposts}` ADD `post_name` VARCHAR(200) NOT NULL"); maybe_add_column($tableposts, 'to_ping', "ALTER TABLE {$tableposts} ADD `to_ping` TEXT NOT NULL"); maybe_add_column($tableposts, 'pinged', "ALTER TABLE {$tableposts} ADD `pinged` TEXT NOT NULL"); maybe_add_column($tableposts, 'post_modified', "ALTER TABLE {$tableposts} ADD `post_modified` DATETIME NOT NULL"); maybe_add_column($tableposts, 'post_content_filtered', "ALTER TABLE {$tableposts} ADD `post_content_filtered` TEXT NOT NULL"); maybe_add_column($tablecategories, 'category_nicename', "ALTER TABLE `{$tablecategories}` ADD `category_nicename` VARCHAR(200) NOT NULL"); maybe_add_column($tablecategories, 'category_description', "ALTER TABLE `{$tablecategories}` ADD `category_description` TEXT NOT NULL"); maybe_add_column($tablecategories, 'category_parent', "ALTER TABLE `{$tablecategories}` ADD `category_parent` INT(4) NOT NULL"); maybe_add_column($tablelinks, 'link_rss', "ALTER TABLE `{$tablelinks}` ADD `link_rss` VARCHAR( 255 ) NOT NULL;"); maybe_add_column($tableusers, 'user_description', "ALTER TABLE `{$tableusers}` ADD `user_description` TEXT NOT NULL"); maybe_add_column($tablecomments, 'comment_approved', "ALTER TABLE {$tablecomments} ADD COLUMN comment_approved ENUM('0', '1') DEFAULT '1' NOT NULL"); // Create indicies add_clean_index($tableposts, 'post_name'); add_clean_index($tablecategories, 'category_nicename'); add_clean_index($tablecomments, 'comment_approved'); // Options stuff if (!$wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'comment_moderation'")) { $wpdb->query("INSERT INTO {$tableoptions}\n\t\t\t(option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level)\n\t\t\tVALUES\n\t\t\t('0', '0', 'comment_moderation', 'Y', '5',' none', 20, 8, '_LANG_INST_BASE_VALUE88', 8)"); } $oid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'comment_moderation'"); $gid = $wpdb->get_var("SELECT group_id FROM {$tableoptiongroups} WHERE group_name = 'General blog settings'"); $seq = $wpdb->get_var("SELECT MAX(seq) FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}'"); ++$seq; if (!$wpdb->get_row("SELECT * FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}' AND option_id = '{$oid}'")) { $wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t(group_id, option_id, seq)\n\t\tVALUES\n\t\t('{$gid}', '{$oid}', '{$seq}')"); } if (!$wpdb->get_row("SELECT * FROM {$tableoptionvalues} WHERE option_id = {$oid} AND optionvalue = 'auto'")) { $wpdb->query("INSERT INTO {$tableoptionvalues}\n\t\t(option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)\n\t\tVALUES\n\t\t('{$oid}','auto', 'Automatic', NULL, NULL, 3)"); } if (!$wpdb->get_row("SELECT * FROM {$tableoptionvalues} WHERE option_id = {$oid} AND optionvalue = 'none'")) { $wpdb->query("INSERT INTO {$tableoptionvalues}\n\t\t(option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)\n\t\tVALUES\n\t\t('{$oid}', 'none', 'None', NULL, NULL, 1)"); } if (!$wpdb->get_row("SELECT * FROM {$tableoptionvalues} WHERE option_id = {$oid} AND optionvalue = 'manual'")) { $wpdb->query("INSERT INTO {$tableoptionvalues}\n\t\t(option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)\n\t\tVALUES\n\t\t('{$oid}', 'manual', 'Manual', NULL, NULL, 2)"); } if (!$wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'moderation_notify'")) { $wpdb->query("INSERT INTO {$tableoptions}\n\t\t\t(option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level)\n\t\t\tVALUES\n\t\t\t('0', '0', 'moderation_notify' , 'Y', '2', '1', 20, 8, '_LANG_INST_BASE_VALUE89', 8)"); } $oid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'moderation_notify'"); $seq = $wpdb->get_var("SELECT MAX(seq) FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}'"); ++$seq; if (!$wpdb->get_row("SELECT * FROM {$tableoptiongroup_options} WHERE group_id = '{$gid}' AND option_id = '{$oid}'")) { $wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t\t(group_id, option_id, seq)\n\t\t\tVALUES\n\t\t\t('{$gid}', '{$oid}', '{$seq}')"); } // Get the title and ID of every post, post_name to check if it already has a value $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM {$tableposts}"); foreach ($posts as $post) { if ('' == $post->post_name) { $newtitle = sanitize_title($post->post_title); $wpdb->query("UPDATE {$tableposts} SET post_name = '{$newtitle}' WHERE ID = '{$post->ID}'"); } } $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM {$tablecategories}"); foreach ($categories as $category) { if ('' == $category->category_nicename) { $newtitle = sanitize_title($category->cat_name); $wpdb->query("UPDATE {$tablecategories} SET category_nicename = '{$newtitle}' WHERE cat_ID = '{$category->cat_ID}'"); } } if (!$wpdb->get_var("SELECT option_name FROM {$tableoptions} WHERE option_name = 'permalink_structure'")) { // If it's not already there $wpdb->query("INSERT INTO `{$tableoptions}`\n\t\t\t(`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`)\n\t\t\tVALUES\n\t\t\t('', '0', 'permalink_structure', 'Y', '3', '', '20', '8', '_LANG_INST_BASE_VALUE90', '8');"); } if (!$wpdb->get_var("SELECT option_name FROM {$tableoptions} WHERE option_name = 'gzipcompression'")) { // If it's not already there $wpdb->query("INSERT INTO `{$tableoptions}`\n\t\t\t(`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`)\n\t\t\tVALUES\n\t\t\t('', '0', 'gzipcompression', 'Y', '2', '0', '20', '8', '_LANG_INST_BASE_VALUE91', '8');"); $optionid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'gzipcompression'"); $wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t\t(group_id, option_id, seq)\n\t\t\tVALUES\n\t\t\t(2, {$optionid}, 5)"); } if (!$wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'hack_file'")) { $wpdb->query("INSERT INTO `{$tableoptions}`\n\t\t\t( `option_id` , `blog_id` , `option_name` , `option_can_override` , `option_type` , `option_value` , `option_width` , `option_height` , `option_description` , `option_admin_level` )\n\t\t\tVALUES\n\t\t\t('', '0', 'hack_file', 'Y', '2', '0', '20', '8', '_LANG_INST_BASE_VALUE92', '8')"); $optionid = $wpdb->get_var("SELECT option_id FROM {$tableoptions} WHERE option_name = 'hack_file'"); $wpdb->query("INSERT INTO {$tableoptiongroup_options}\n\t\t\t(group_id, option_id, seq)\n\t\t\tVALUES\n\t\t\t(2, {$optionid}, 5)"); } $wpdb->query("UPDATE {$tableoptionvalues} SET optionvalue_max = 23 , optionvalue_min = -23 WHERE option_id = 51"); // fix upload users description $wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE37' WHERE option_id = 37"); // and file types $wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE34' WHERE option_id = 34"); // add link to php date format. this could be to a wordpress.org page in the future $wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE52' WHERE option_id = 52"); $wpdb->query("UPDATE {$tableoptions} SET option_description = '_LANG_INST_BASE_VALUE53' WHERE option_id = 53"); $wpdb->query("UPDATE {$tableoptions} SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')\n WHERE option_name LIKE 'links_rating_image%'\n AND option_value LIKE 'wp-links/links-images/%'"); $wpdb->query("DELETE FROM {$tableoptions} WHERE option_name = 'comment_allowed_tags'"); $wpdb->query("DELETE FROM {$tableoptions} WHERE option_name = 'use_preview'"); $wpdb->query("DELETE FROM {$tableoptions} WHERE option_name = 'search_engine_friendly_urls'"); // Multiple categories maybe_create_table($tablepost2cat, "\n\t\tCREATE TABLE `{$tablepost2cat}` (\n\t\t`rel_id` INT NOT NULL AUTO_INCREMENT ,\n\t\t`post_id` INT NOT NULL ,\n\t\t`category_id` INT NOT NULL ,\n\t\tPRIMARY KEY ( `rel_id` ) ,\n\t\tINDEX ( `post_id` , `category_id` )\n\t\t)\n\t\t"); $allposts = $wpdb->get_results("SELECT ID, post_category FROM {$tableposts}"); foreach ($allposts as $post) { // Check to see if it's already been imported $cat = $wpdb->get_row("SELECT * FROM {$tablepost2cat} WHERE post_id = {$post->ID} AND category_id = {$post->post_category}"); if (!$cat && 0 != $post->post_category) { // If there's no result $wpdb->query("\n\t\t\t\tINSERT INTO {$tablepost2cat}\n\t\t\t\t(post_id, category_id)\n\t\t\t\tVALUES\n\t\t\t\t('{$post->ID}', '{$post->post_category}')\n\t\t\t\t"); } } }
function configure_ftp($form) { global $PLOGGER_DBH; maybe_add_column(PLOGGER_TABLE_PREFIX . 'config', 'ftp_host', "varchar(64) NOT NULL"); maybe_add_column(PLOGGER_TABLE_PREFIX . 'config', 'ftp_user', "varchar(64) NOT NULL"); maybe_add_column(PLOGGER_TABLE_PREFIX . 'config', 'ftp_pass', "varchar(64) NOT NULL"); maybe_add_column(PLOGGER_TABLE_PREFIX . 'config', 'ftp_path', "varchar(255) NOT NULL"); $query = "UPDATE \"" . PLOGGER_TABLE_PREFIX . "config\" SET\n\t\t\"ftp_host\" = " . $PLOGGER_DBH->quote($form['ftp_host']) . ",\n\t\t\"ftp_user\" = " . $PLOGGER_DBH->quote($form['ftp_user']) . ",\n\t\t\"ftp_pass\" = " . $PLOGGER_DBH->quote($form['ftp_pass']) . ",\n\t\t\"ftp_path\" = " . $PLOGGER_DBH->quote($form['ftp_path']) . ""; run_query($query); }
} else { return false; } } } // we cannot directly tell that whether this succeeded! foreach ($wpdb->get_col("DESC {$table_name}", 0) as $column) { if ($column == $column_name) { return false; } } return true; } if (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) { include_once ABSPATH . '/wp-admin/upgrade-functions.php'; } elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) { include_once ABSPATH . '/wp-admin/includes/upgrade.php'; } else { die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\''); } header('Content-type: text/html; charset=utf-8'); if (maybe_add_column($wpdb->downloads, 'file_hash', "ALTER TABLE {$wpdb->downloads} ADD file_hash varchar(40) NOT NULL default '' AFTER file_des;")) { echo '<div style="margin:7em auto auto 10em;color:green;">成功添加file_hash列-_-!</div>'; } else { die('<div style="margin:7em auto auto 10em;color:red;">添加列file_hash出错!</div>'); } if (maybe_del_column($wpdb->downloads, 'file_category')) { echo '<div style="margin:7em auto auto 10em;color:green;">成功删除file_category列,现在你可以使用 hacklog-downloadmanager了-_-!</div>'; } else { die('<div style="margin:7em auto auto 10em;color:red;">删除列file_category出错!</div>'); }
<?php } else { ?> <p><em>It doesn't look like your database information is incorrect. Please re-edit this file and double-check all the settings.</em></p> <?php } break; case 1: ?> <h1>Step 1</h1> <p>First let's get posts and comments.</p> <?php // For people running this on .72 $query = "ALTER TABLE `{$tableposts}` ADD `post_name` VARCHAR(200) NOT NULL"; maybe_add_column($tableposts, 'post_name', $query); // Create post_name field $connection = @mysql_connect($tp_database_host, $tp_database_username, $tp_database_password); $database = @mysql_select_db($tp_database_name); // For now we're going to give everything the same author and same category $author = $wpdb->get_var("SELECT ID FROM {$tableusers} WHERE user_level = 10 LIMIT 1"); $category = $wpdb->get_var("SELECT cat_ID FROM {$tablecategories} LIMIT 1"); $posts = mysql_query('SELECT * FROM textpattern', $connection); while ($post = mysql_fetch_array($posts)) { // ID, AuthorID, LastMod, LastModID, Posted, Title, Body, Body_html, Abstract, Category1, Category2, Annotate, AnnotateInvite, Status, Listing1, Listing2, Section $posted = $post['Posted']; // 20030216162119 $year = substr($posted, 0, 4); $month = substr($posted, 4, 2); $day = substr($posted, 6, 2); $hour = substr($posted, 8, 2);
function eme_create_payments_table($charset, $collate) { global $wpdb; $db_version = get_option('eme_version'); $table_name = $wpdb->prefix . PAYMENTS_TBNAME; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "CREATE TABLE " . $table_name . " (\n id int(11) NOT NULL auto_increment,\n creation_date_gmt datetime NOT NULL DEFAULT '0000-00-00 00:00:00', \n booking_ids text NOT NULL,\n random_id tinytext NOT NULL,\n UNIQUE KEY (id)\n ) {$charset} {$collate};"; maybe_create_table($table_name, $sql); } else { maybe_add_column($table_name, 'random_id', "alter table {$table_name} add random_id tinytext NOT NULL;"); if ($db_version < 80) { $payment_ids = $wpdb->get_col("SELECT id FROM {$table_name}"); foreach ($payment_ids as $payment_id) { $random_id = eme_payment_random_id(); $sql = $wpdb->prepare("UPDATE {$table_name} SET random_id = %s WHERE id = %d", $random_id, $payment_id); $wpdb->query($sql); } } } }
maybe_add_column(TABLE_PREFIX . 'albums', 'path', "varchar(255) NOT NULL"); maybe_add_column(TABLE_PREFIX . 'collections', 'path', "varchar(255) NOT NULL"); // add ip and approved fields to comments table maybe_add_column(TABLE_PREFIX . 'comments', 'ip', "char(64)"); maybe_add_column(TABLE_PREFIX . 'comments', 'approved', "tinyint default 1"); maybe_add_column(TABLE_PREFIX . 'pictures', 'description', "text"); // user definable theme directory maybe_add_column(TABLE_PREFIX . 'config', 'theme_dir', "varchar(128) NOT NULL"); // add support for user defined sort order for albums and collections maybe_add_column(TABLE_PREFIX . 'config', 'album_sortby', "varchar(20) NOT NULL default 'id'"); maybe_add_column(TABLE_PREFIX . 'config', 'album_sortdir', "varchar(5) NOT NULL default 'DESC'"); maybe_add_column(TABLE_PREFIX . 'config', 'collection_sortby', "varchar(20) NOT NULL default 'id'"); maybe_add_column(TABLE_PREFIX . 'config', 'collection_sortdir', "varchar(5) NOT NULL default 'DESC'"); // add support for thumbnail configuration maybe_add_column(TABLE_PREFIX . 'config', 'enable_thumb_nav', "tinyint default 0"); maybe_add_column(TABLE_PREFIX . 'config', 'thumb_nav_range', "int(11) NOT NULL default 0"); // insert default value (default theme directory) $default_theme_dir = dirname(__FILE__) . "/" . 'themes/default/'; print "<li>Setting default theme directory to {$default_theme_dir}</li>"; $sql = 'UPDATE ' . TABLE_PREFIX . 'config SET `theme_dir` = \'' . $default_theme_dir . '\' WHERE 1'; mysql_query($sql); $sql = 'ALTER TABLE ' . TABLE_PREFIX . 'comments ADD INDEX approved_idx (`approved`)'; mysql_query($sql); // add ip and approved fields to comments table $sql = 'ALTER TABLE ' . TABLE_PREFIX . 'comments CHANGE `date` `date` datetime'; mysql_query($sql); /* // add field for timestamp refresh conditions $sql = 'ALTER TABLE '.TABLE_PREFIX.'config ADD (`small_lastmodified` datetime NOT NULL, `large_lastmodified` datetime NOT NULL, `rss_lastmodified` datetime NOT NULL)';
/** * Installation function, creates tables if needed **/ function install() { global $table_prefix, $wpdb; /*wordpress tables*/ $table_users = $table_prefix . "users"; $table_categories = $table_prefix . "categories"; $table_pages = $table_prefix . "posts"; //post_status must be "static" or the post_type must be "page" /*plugin tables*/ $table_groups = $table_prefix . "ug_Groups"; $table_groupsUsers = $table_prefix . "ug_GroupsUsers"; $table_groupsCategory = $table_prefix . "ug_GroupsCategory"; $table_groupsPage = $table_prefix . "ug_GroupsPage"; require_once ABSPATH . 'wp-admin/upgrade-functions.php'; /*Groups table*/ if (!userGroups::tableExists($table_groups)) { $sql = "CREATE TABLE " . $table_groups . " (\r\n id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,\r\n name tinytext NOT NULL,\r\n homepage text,\r\n\t\tdescription text,\r\n UNIQUE KEY id (id)\r\n );"; dbDelta($sql); } else { //add a column for the group description (updates from 1.0RC1) maybe_add_column($table_groups, "description", "ALTER TABLE {$table_groups} ADD description text;"); } /*Groups-Users relation table*/ if (!userGroups::tableExists($table_groupsUsers)) { $sql = "CREATE TABLE " . $table_groupsUsers . " (\r\n id_group bigint(20) UNSIGNED NOT NULL,\r\n id_user bigint(20) UNSIGNED NOT NULL,\r\n\t\t PRIMARY KEY(id_group, id_user)\r\n );"; dbDelta($sql); } /*Groups-Page relation table*/ if (!userGroups::tableExists($table_groupsPage)) { $sql = "CREATE TABLE " . $table_groupsPage . " (\r\n id_group bigint(20) UNSIGNED NOT NULL,\r\n id_page bigint(20) UNSIGNED NOT NULL,\r\n exc_read tinyint(1) NOT NULL,\r\n exc_write tinyint(1) NOT NULL,\r\n\t\t PRIMARY KEY(id_group, id_page)\r\n );"; dbDelta($sql); } /*other plugins support table*/ $table_groupsGeneric = $table_prefix . "ug_GroupsGeneric"; if (!userGroups::tableExists($table_groupsGeneric)) { $sql = "CREATE TABLE " . $table_groupsGeneric . " (\r\n\t\t\t\t\tid_group bigint(20) UNSIGNED NOT NULL,\r\n\t\t\t\t\tid_resource bigint(20) UNSIGNED NOT NULL,\r\n\t\t\t\t\tpermission text NOT NULL,\r\n\t\t\t\t\tplugin_name VARCHAR(128) NOT NULL,\r\n\t\t\t\t\tdescription text,\r\n\t\t\t\t\tPRIMARY KEY(id_group, id_resource, plugin_name)\t\t\t\t\t\r\n\t\t\t\t);"; dbDelta($sql); } }
/** * Create OpenID related tables in the WordPress database. */ function create_tables() { global $wp_version, $wpdb, $openid; if ($wp_version >= '2.3') { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; } else { require_once ABSPATH . 'wp-admin/admin-db.php'; require_once ABSPATH . 'wp-admin/upgrade-functions.php'; } // Create the SQL and call the WP schema upgrade function $statements = array($this->sql['nonce_table'], $this->sql['assoc_table'], "CREATE TABLE {$this->identity_table_name} (\n uurl_id bigint(20) NOT NULL auto_increment,\n user_id bigint(20) NOT NULL default '0',\n url text,\n hash char(32),\n PRIMARY KEY (uurl_id),\n UNIQUE KEY uurl (hash),\n KEY url (url(30)),\n KEY user_id (user_id)\n )"); $sql = implode(';', $statements); dbDelta($sql); // add column to comments table $result = maybe_add_column($this->comments_table_name, 'openid', "ALTER TABLE {$this->comments_table_name} ADD `openid` TINYINT(1) NOT NULL DEFAULT '0'"); if (!$result) { $openid->log->err('unable to add column `openid` to comments table.'); } // update old style of marking openid comments and users $wpdb->query("update {$this->comments_table_name} set `comment_type`='', `openid`=1 where `comment_type`='openid'"); $wpdb->query("update {$this->usermeta_table_name} set `meta_key`='has_openid' where `meta_key`='registered_with_openid'"); }
/** Upgrade the database */ function upgrade() { global $wpdb, $wp_version, $wpmu_version; // include upgrade-functions for maybe_create_table; if (!function_exists('maybe_create_table')) { require_once ABSPATH . 'wp-admin/install-helper.php'; } $date = date('Y-m-d'); maybe_add_column($this->public, 'date', "ALTER TABLE `{$this->public}` ADD `date` DATE DEFAULT '{$date}' NOT NULL AFTER `active`;"); // let's take the time to check process registered users // existing public subscribers are subscribed to all categories $users = $this->get_all_registered('ID'); if (!empty($users)) { foreach ($users as $user) { $this->register($user); } } // update the options table to serialized format $old_options = $wpdb->get_col("SELECT option_name from {$wpdb->options} where option_name LIKE 's2%' AND option_name != 's2_future_posts'"); if (!empty($old_options)) { foreach ($old_options as $option) { $value = get_option($option); $option_array = substr($option, 3); $this->subscribe2_options[$option_array] = $value; delete_option($option); } } $this->subscribe2_options['version'] = S2VERSION; //double check that the options are in the database require S2PATH . "include/options.php"; update_option('subscribe2_options', $this->subscribe2_options); // upgrade old wpmu user meta data to new if (isset($wpmu_version) || strpos($wp_version, 'wordpress-mu')) { $this->namechange_subscribe2_widget(); // loop through all users foreach ($users as $user) { // get categories which the user is subscribed to (old ones) $categories = get_usermeta($user, 's2_subscribed'); $categories = explode(',', $categories); // load blogs of user (only if we need them) $blogs = array(); if (count($categories) > 0 && !in_array('-1', $categories)) { $blogs = get_blogs_of_user($user, true); } foreach ($blogs as $blog_id => $blog) { switch_to_blog($blog_id); $blog_categories = (array) $wpdb->get_col("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'category'"); $subscribed_categories = array_intersect($categories, $blog_categories); if (!empty($subscribed_categories)) { foreach ($subscribed_categories as $subscribed_category) { update_usermeta($user, $this->get_usermeta_keyname('s2_cat') . $subscribed_category, $subscribed_category); } update_usermeta($user, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $subscribed_categories)); } restore_current_blog(); } // delete old user meta keys delete_usermeta($user, 's2_subscribed'); foreach ($categories as $cat) { delete_usermeta($user, 's2_cat' . $cat); } } } }
function cleverness_todo_install() { global $wpdb, $userdata; get_currentuserinfo(); $cleverness_todo_db_version = '1.3'; $table_name = $wpdb->prefix . 'todolist'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "CREATE TABLE " . $table_name . " (\r\n\t id bigint(20) UNIQUE NOT NULL AUTO_INCREMENT,\r\n\t author bigint(20) NOT NULL,\r\n\t status tinyint(1) DEFAULT '0' NOT NULL,\r\n\t priority tinyint(1) NOT NULL,\r\n todotext text NOT NULL,\r\n\t\t assign int(10),\r\n\t\t progress int(3),\r\n\t\t deadline varchar(30),\r\n\t\t completed timestamp\r\n\t );"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); $welcome_text = __('Add your first To-Do List item', 'cleverness-to-do-list'); $results = $wpdb->insert($table_name, array('author' => $userdata->ID, 'status' => 0, 'priority' => 1, 'todotext' => $welcome_text)); $new_options = array('list_view' => '0', 'dashboard_author' => '0', 'todo_author' => '0', 'assign' => '1', 'show_only_assigned' => '1', 'view_capability' => 'publish_posts', 'add_capability' => 'publish_posts', 'edit_capability' => 'publish_posts', 'delete_capability' => 'manage_options', 'purge_capability' => 'manage_options', 'complete_capability' => 'publish_posts', 'assign_capability' => 'manage_options', 'view_all_assigned_capability' => 'manage_options', 'dashboard_number' => '10', 'priority_0' => __('Important', 'cleverness-to-do-list'), 'priority_1' => __('Normal', 'cleverness-to-do-list'), 'priority_2' => __('Low', 'cleverness-to-do-list'), 'show_deadline' => '0', 'show_dashboard_deadline' => '0', 'show_progress' => '0', 'email_assigned' => '0', 'show_completed_date' => '0', 'date_format' => 'm-d-Y', 'user_roles' => 'contributor, author, editor, administrator'); add_option('cleverness_todo_settings', $new_options); add_option('cleverness_todo_db_version', $cleverness_todo_db_version); } $installed_ver = get_option('cleverness_todo_db_version'); if ($installed_ver != $cleverness_todo_db_version) { if (!function_exists('maybe_create_table')) { require_once ABSPATH . 'wp-admin/install-helper.php'; } maybe_add_column($table_name, 'assign', "ALTER TABLE `{$table_name}` ADD `assign` int(10);"); maybe_add_column($table_name, 'deadline', "ALTER TABLE `{$table_name}` ADD `deadline` varchar(30);"); maybe_add_column($table_name, 'progress', "ALTER TABLE `{$table_name}` ADD `progress` int(3);"); maybe_add_column($table_name, 'completed', "ALTER TABLE `{$table_name}` ADD `completed` timestamp;"); update_option('cleverness_todo_db_version', $cleverness_todo_db_version); delete_option('atd_db_version'); } }
/** Upgrade the database */ function upgrade() { global $wpdb; // include upgrade-functions for maybe_create_table; if (!function_exists('maybe_create_table')) { require_once ABSPATH . '/wp-admin/upgrade-functions.php'; } $date = date('Y-m-d'); maybe_add_column($this->public, 'date', "ALTER TABLE `{$this->public}` ADD `date` DATE DEFAULT '{$date}' NOT NULL AFTER `active`;"); update_option('s2_version', S2VERSION); // let's take this time to check whether any public subscribers // are also registered users of the blog, and convert them $check = $wpdb->get_results("SELECT {$wpdb->users}.ID FROM {$wpdb->users} INNER JOIN {$this->public} ON {$wpdb->users}.user_email = {$this->public}.email"); if (!empty($check)) { foreach ($check as $user) { $this->register($user); } } }
/** Upgrade the database */ function upgrade() { global $wpdb; // include upgrade-functions for maybe_create_table; if (!function_exists('maybe_create_table')) { require_once ABSPATH . 'wp-admin/install-helper.php'; } $date = date('Y-m-d'); maybe_add_column($this->public, 'date', "ALTER TABLE `{$this->public}` ADD `date` DATE DEFAULT '{$date}' NOT NULL AFTER `active`;"); // let's take the time to check process registered users // existing public subscribers are subscribed to all categories $users = $wpdb->get_col("SELECT ID FROM {$wpdb->users}"); if (!empty($users)) { foreach ($users as $user) { $this->register($user); } } // update the options table to serialized format $old_options = $wpdb->get_col("SELECT option_name from {$wpdb->options} where option_name LIKE 's2%' AND option_name != 's2_future_posts'"); if (!empty($old_options)) { foreach ($old_options as $option) { $value = get_option($option); $option_array = substr($option, 3); $this->subscribe2_options[$option_array] = $value; delete_option($option); } } $this->subscribe2_options['version'] = S2VERSION; //double check that the options are in the database require S2PATH . "include/options.php"; update_option('subscribe2_options', $this->subscribe2_options); }
function post_notification_install() { global $wpdb; $t_emails = $wpdb->prefix . 'post_notification_emails'; $t_posts = $wpdb->prefix . 'post_notification_posts'; $t_cats = $wpdb->prefix . 'post_notification_cats'; //******************************************// //** Create WPPRAEFIX_post_notification table **// //******************************************// if (!function_exists('maybe_create_table')) { require_once ABSPATH . 'wp-admin/install-helper.php'; } $sql = "CREATE TABLE {$t_emails} (\r\n\t\t\t\t id int( 11 ) NOT NULL auto_increment,\r\n\t\t\t\t email_addr varchar( 255 ) default NULL,\r\n\t\t\t\t gets_mail int( 11 ) default NULL,\r\n\t\t\t\t last_modified timestamp( 14 ) NOT NULL,\r\n\t\t\t\t date_subscribed datetime default NULL,\r\n\t\t\t\t act_code varchar( 32 ) default NULL,\r\n\t\t\t\t PRIMARY KEY ( id ) \r\n\t\t )"; maybe_create_table($t_posts, $sql); $sql = "ALTER TABLE {$t_emails} ADD subscribe_ip INT UNSIGNED NOT NULL default 0"; maybe_add_column($t_emails, 'subscribe_ip', $sql); //************************************************// //** Create WPPRAEFIX_post_notification_posts table **// //************************************************// # Add new table $sql = "CREATE TABLE {$t_posts} (\r\n\t\t\t\tpost_id bigint(20) NOT NULL default '0',\r\n\t\t\t\tnotification_sent int NOT NULL default '-1',\r\n\t\t\t\tPRIMARY KEY (post_ID)\r\n\t\t )"; maybe_create_table($t_posts, $sql); //Always adding this later keeps the code simple..... (Added in 2.2) $sql = "ALTER TABLE {$t_posts} ADD date_saved datetime NOT NULL default '0000-00-00 00:00:00'"; maybe_add_column($t_posts, 'date_saved', $sql); //This is in an if-statement, because auf the insert-statement. if ($wpdb->get_var("SHOW TABLES LIKE '{$t_cats}'") == NULL) { $sql = "CREATE TABLE {$t_cats} (\r\n\t\t\t\t\tid int( 11 ) NOT NULL,\r\n\t\t\t\t\tcat_id bigint(20) NOT NULL \r\n\t\t\t )"; maybe_create_table($t_cats, $sql); // Thanks to Karsten Tinnefeld for this nice query $wpdb->query("INSERT\r\n\t\t\t\t\tINTO {$t_cats} (id, cat_id)\r\n\t\t\t\t\tSELECT id, 0\r\n\t\t\t\t\tFROM {$t_emails} e\r\n\t\t\t\t\tWHERE NOT EXISTS (SELECT 1 \r\n\t\t\t\t\t\t\t\t\t\tFROM {$t_cats} c \r\n\t\t\t\t\t\t\t\t\t\tWHERE c.id = e.id )"); } //This actually belongs into the create statement but it's easyer to maintain this way $index = array(); $indexlist = $wpdb->get_results("SHOW INDEX FROM {$t_cats}"); foreach ($indexlist as $indexrow) { $index[] = $indexrow->Column_name; } if (!in_array('id', $index)) { $wpdb->query(" ALTER TABLE {$t_cats} ADD INDEX ( id )"); } if (!in_array('cat_id', $index)) { $wpdb->query(" ALTER TABLE {$t_cats} ADD INDEX ( cat_id )"); } $index = array(); $indexlist = $wpdb->get_results("SHOW INDEX FROM {$t_emails}"); foreach ($indexlist as $indexrow) { $index[] = $indexrow->Column_name; } if (!in_array('gets_mail', $index)) { $wpdb->query(" ALTER TABLE {$t_emails} ADD INDEX ( id , gets_mail )"); } if (!in_array('email_addr', $index)) { $wpdb->query(" ALTER TABLE {$t_emails} ADD INDEX ( email_addr )"); } $index = array(); $indexlist = $wpdb->get_results("SHOW INDEX FROM {$t_posts}"); foreach ($indexlist as $indexrow) { $index[] = $indexrow->Column_name; } if (!in_array('notification_sent', $index)) { $wpdb->query(" ALTER TABLE {$t_posts} ADD INDEX ( notification_sent )"); } //} //************************************************// //** Add Options //************************************************// load_plugin_textdomain('post_notification', POST_NOTIFICATION_PATH_REL); add_option('post_notification_show_content', 'no', 'Whether to mail the content', 'no'); add_option('post_notification_read_more', '...', 'What to put in more-tag-text', 'no'); add_option('post_notification_send_default', 'yes', 'Whether to send normal posts', 'no'); add_option('post_notification_send_private', 'no', 'Whether to send private posts', 'no'); add_option('post_notification_send_page', 'no', 'Whether to send private posts', 'no'); add_option('post_notification_hdr_nl', "n", 'What kind of header', 'no'); add_option('post_notification_from_email', get_option('admin_email'), 'The adress used as sender', 'no'); add_option('post_notification_from_name', '@@blogname', 'The name used as sender', 'no'); add_option('post_notification_subject', '@@blogname: @@title', 'The subject of the mail', 'no'); add_option('post_notification_url', '', 'The URl to the main page', 'no'); add_option('post_notification_template', "email_template.txt", 'The Template to use', 'no'); add_option('post_notification_maxsend', "20", 'Number of Mails to send at once.', 'no'); add_option('post_notification_pause', "10", 'Time between bursts of Mails', 'no'); add_option('post_notification_nervous', "360", 'Nervous finger option'); add_option('post_notification_nextsend', time(), 'When to send the next mail', 'yes'); add_option('post_notification_lastsend', time(), 'When to send the last mail was sent.', 'no'); add_option('post_notification_lastpost', time(), 'When the last post was published.', 'no'); add_option('post_notification_page_meta', 'no', 'Whether to add a link to Meta', 'yes'); //autoload is set to yes, because meta might need it. add_option('post_notification_page_name', __('Subscribe to Posts', 'post_notification'), 'Name of the Post Notification page.', 'yes'); add_option('post_notification_uninstall', 'no', 'Uninstall on deaktivation', 'no'); add_option('post_notification_captcha', '0', 'Number of captcha-cahars', 'no'); add_option('post_notification_lock', 'file', 'Lockingtype', 'yes'); add_option('post_notification_filter_include', 'yes', 'Include PN via filters', 'yes'); add_option('post_notification_selected_cats', '0', 'The category preselection list.', 'no'); add_option('post_notification_debug', 'no', 'Turn debugging on.', 'no'); add_option('post_notification_the_content_exclude', serialize(array()), 'Include PN via filters', 'no'); add_option('post_notification_empty_cats', 'no', 'Whether to show empty cats', 'no'); add_option('post_notification_show_cats', 'yes', 'Whether to show cats', 'no'); add_option('post_notification_subscribers', '0', 'Number of Subscibers', 'yes'); add_option('post_notification_auto_subscribe', 'yes', 'Auto Subscribe when regist new user', 'no'); if (is_dir(POST_NOTIFICATION_PATH . WPLANG)) { $profile = WPLANG; } else { $profile = 'en_US'; } add_option('post_notification_profile', $profile, 'The Profile-dir to use'); }
function upgrade_database() { global $config, $thumbnail_config; $default_charset = get_default_charset(); $output = array(); /** plogger_thumbnail_config **/ $thumb_table = maybe_add_table(PLOGGER_TABLE_PREFIX . 'thumbnail_config', "`id` int(10) unsigned NOT NULL auto_increment,\n\t\t`update_timestamp` int(10) unsigned default NULL,\n\t\t`max_size` int(10) unsigned default NULL,\n\t\t`disabled` tinyint default 0,\n\t\tPRIMARY KEY (`id`)"); if ($thumb_table === true) { $output[] = plog_tr('Added new table') . ': ' . PLOGGER_TABLE_PREFIX . 'thumbnail_config'; // Use a random timestamp from the past to keep the existing thumbnails $long_ago = 1096396500; if (!isset($config['max_thumbnail_size'])) { $config['max_thumbnail_size'] = 100; } if (!isset($thumbnail_config[THUMB_SMALL]) || empty($thumbnail_config[THUMB_SMALL]['size'])) { $sql = "INSERT INTO `" . PLOGGER_TABLE_PREFIX . "thumbnail_config` (id, update_timestamp, max_size)\n\t\t\t\tVALUES('" . THUMB_SMALL . "', '" . $long_ago . "', '" . $config['max_thumbnail_size'] . "')"; mysql_query($sql); } if (!isset($config['max_display_size'])) { $config['max_display_size'] = 500; } if (!isset($thumbnail_config[THUMB_LARGE]) || empty($thumbnail_config[THUMB_LARGE]['size'])) { $sql = "INSERT INTO `" . PLOGGER_TABLE_PREFIX . "thumbnail_config` (id, update_timestamp, max_size)\n\t\t\t\tVALUES('" . THUMB_LARGE . "', '" . $long_ago . "', '" . $config['max_display_size'] . "')"; mysql_query($sql); } if (!isset($config['rss_thumbsize'])) { $config['rss_thumbsize'] = 400; } if (!isset($thumbnail_config[THUMB_RSS]) || empty($thumbnail_config[THUMB_RSS]['size'])) { $sql = "INSERT INTO `" . PLOGGER_TABLE_PREFIX . "thumbnail_config` (id, update_timestamp, max_size)\n\t\t\t\tVALUES('" . THUMB_RSS . "', '" . $long_ago . "', '" . $config['rss_thumbsize'] . "')"; mysql_query($sql); } if (!isset($config['nav_thumbsize'])) { $config['nav_thumbsize'] = 60; } if (!isset($thumbnail_config[THUMB_NAV]) || empty($thumbnail_config[THUMB_NAV]['size'])) { $sql = "INSERT INTO `" . PLOGGER_TABLE_PREFIX . "thumbnail_config` (id, update_timestamp, max_size)\n\t\t\t\tVALUES('" . THUMB_NAV . "', '" . $long_ago . "', '" . $config['nav_thumbsize'] . "')"; mysql_query($sql); } } $thumbnail_add_list = array('disabled' => "tinyint default 0", 'resize_option' => "tinyint default 2"); foreach ($thumbnail_add_list as $key => $value) { $result = maybe_add_column(PLOGGER_TABLE_PREFIX . 'thumbnail_config', $key, $value); if (!empty($result)) { $output[] = $result; } } // Make sure to set the resize_option to square for small thumbs if previously set if (isset($config['square_thumbs']) && $config['square_thumbs'] == 1) { $sql = "UPDATE `" . PLOGGER_TABLE_PREFIX . "thumbnail_config` SET `resize_option` = '3' WHERE `id` = '" . THUMB_SMALL . "'"; mysql_query($sql); } // Move enable_thumb_nav setting to plogger_thumbnail_config table if (isset($config['enable_thumb_nav'])) { $disabled = $config['enable_thumb_nav'] == 0 ? 1 : 0; $sql = "UPDATE `" . PLOGGER_TABLE_PREFIX . "thumbnail_config` SET `disabled` = '{$disabled}' WHERE `id` = '" . THUMB_NAV . "'"; mysql_query($sql); } // set navigation thumbnails to square $sql = "UPDATE `" . PLOGGER_TABLE_PREFIX . "thumbnail_config` SET `resize_option` = '3' WHERE `id` = '" . THUMB_NAV . "'"; mysql_query($sql); /** plogger_config **/ $config_drop_list = array('max_thumbnail_size', 'max_display_size', 'rss_thumbsize', 'feed_language', 'enable_thumb_nav', 'square_thumbs'); foreach ($config_drop_list as $value) { $result = maybe_drop_column(PLOGGER_TABLE_PREFIX . 'config', $value); if (!empty($result)) { $output[] = $result; } } $config_add_list = array('gallery_url' => "varchar(255) NOT NULL", 'feed_num_entries' => "int(15) NOT NULL default '15'", 'feed_title' => "varchar(255) NOT NULL default 'Plogger Photo Feed'", 'feed_content' => "tinyint default '1'", 'use_mod_rewrite' => "smallint NOT NULL default '0'", 'default_sortdir' => "varchar(5) NOT NULL", 'default_sortby' => "varchar(20) NOT NULL", 'admin_email' => "varchar(50) NOT NULL", 'allow_fullpic' => "tinyint NOT NULL default '1'", 'comments_notify' => "tinyint NOT NULL", 'comments_moderate' => "tinyint NOT NULL default 0", 'theme_dir' => "varchar(128) NOT NULL", 'album_sortby' => "varchar(20) NOT NULL default 'id'", 'album_sortdir' => "varchar(5) NOT NULL default 'DESC'", 'collection_sortby' => "varchar(20) NOT NULL default 'id'", 'collection_sortdir' => "varchar(5) NOT NULL default 'DESC'", 'thumb_nav_range' => "int(11) NOT NULL default 0", 'activation_key' => "varchar(64) NOT NULL default ''"); foreach ($config_add_list as $key => $value) { $result = maybe_add_column(PLOGGER_TABLE_PREFIX . 'config', $key, $value); if (!empty($result)) { $output[] = $result; } } // Insert the gallery_url if not already set if (!isset($config['gallery_url']) || empty($config['gallery_url'])) { $config['baseurl'] = 'http://' . $_SERVER['HTTP_HOST'] . dirname(dirname($_SERVER['PHP_SELF'])) . '/'; $output[] = plog_tr('Setting gallery url to ') . $config['baseurl']; $sql = "UPDATE `" . PLOGGER_TABLE_PREFIX . "config` SET gallery_url = '" . $config['baseurl'] . "'"; mysql_query($sql); } // Insert default theme directory if not already set if (!isset($config['theme_dir']) || empty($config['theme_dir'])) { $output[] = plog_tr('Setting default theme directory to \'default\''); $sql = "UPDATE " . PLOGGER_TABLE_PREFIX . "config SET `theme_dir` = 'default' WHERE 1"; mysql_query($sql); } /** plogger_collections **/ $collections_add_list = array('thumbnail_id' => "int(11) NOT NULL default 0", 'path' => "varchar(255) NOT NULL"); foreach ($collections_add_list as $key => $value) { $result = maybe_add_column(PLOGGER_TABLE_PREFIX . 'collections', $key, $value); if (!empty($result)) { $output[] = $result; } } /** plogger_albums **/ $albums_add_list = array('thumbnail_id' => "int(11) NOT NULL default 0", 'path' => "varchar(255) NOT NULL"); foreach ($albums_add_list as $key => $value) { $result = maybe_add_column(PLOGGER_TABLE_PREFIX . 'albums', $key, $value); if (!empty($result)) { $output[] = $result; } } /** plogger_pictures **/ $pictures_add_list = array('description' => "text", 'EXIF_iso' => "varchar(64) NOT NULL default ''"); foreach ($pictures_add_list as $key => $value) { $result = maybe_add_column(PLOGGER_TABLE_PREFIX . 'pictures', $key, $value); if (!empty($result)) { $output[] = $result; } } /** plogger_comments **/ $comments_add_list = array('ip' => "char(64)", 'approved' => "tinyint default 1"); foreach ($comments_add_list as $key => $value) { $result = maybe_add_column(PLOGGER_TABLE_PREFIX . 'comments', $key, $value); if (!empty($result)) { $output[] = $result; } } /*$output[] = maybe_add_table(PLOGGER_TABLE_PREFIX.'tag2picture'," `tag_id` bigint(20) unsigned NOT NULL default '0', `picture_id` bigint(20) unsigned NOT NULL default '0', `tagdate` datetime default NULL, KEY `tag_id` (`tag_id`), KEY `picture_id` (`picture_id`) "); $output[] = maybe_add_table(PLOGGER_TABLE_PREFIX.'tags'," `id` bigint(20) unsigned NOT NULL auto_increment, `tag` char(50) NOT NULL default '', `tagdate` datetime NOT NULL default '0000-00-00 00:00:00', `urlified` char(50) NOT NULL default '', PRIMARY KEY (`id`), UNIQUE `tag` (`tag`), UNIQUE `urlified` (`urlified`) ");*/ $sql = 'ALTER TABLE ' . PLOGGER_TABLE_PREFIX . 'comments ADD INDEX approved_idx (`approved`)'; mysql_query($sql); // Add ip and approved fields to comments table $sql = 'ALTER TABLE ' . PLOGGER_TABLE_PREFIX . 'comments CHANGE `date` `date` datetime'; mysql_query($sql); // Convert charsets // Since 4.1 MySQL has support for specifying character encoding for tables // and I really want to use it if available. So we need figure out what version // we are running on and to the right hting $mysql_version = mysql_get_server_info(); $mysql_charset_support = '4.1'; $default_charset = ''; if (1 == version_compare($mysql_version, $mysql_charset_support)) { $charset = 'utf8'; $tables = array('collections', 'albums', 'pictures', 'comments', 'config', 'thumbnail_config'); foreach ($tables as $table) { $tablename = PLOGGER_TABLE_PREFIX . $table; $sql = "ALTER TABLE {$tablename} DEFAULT CHARACTER SET {$charset}"; if (!mysql_query($sql)) { $output[] = "failed to convert {$tablename} to {$charset}<br />" . mysql_error(); } } } return $output; }
function upgrade88() { // to ensure compulsory category collects all users we need there to be s2_subscribed meta-keys for all users global $mysubscribe2; if (version_compare($mysubscribe2->wp_release, '3.5', '<')) { $all_registered = $mysubscribe2->get_all_registered('ID'); if (!empty($all_registered)) { foreach ($all_registered as $user_ID) { $check_subscribed = get_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), true); if (empty($check_subscribed)) { update_user_meta($user_ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), ''); } } } } else { $args = array('meta_query' => array(array('key' => $mysubscribe2->get_usermeta_keyname('s2_subscribed'), 'compare' => 'NOT EXISTS'))); $user_query = new WP_User_Query($args); $users = $user_query->get_results(); if (!empty($users)) { foreach ($users as $user) { update_user_meta($user->ID, $mysubscribe2->get_usermeta_keyname('s2_subscribed'), ''); } } } // check the time column again as the upgrade86() function contained a bug // include upgrade-functions for maybe_add_column; if (!function_exists('maybe_add_column')) { require_once ABSPATH . 'wp-admin/install-helper.php'; } maybe_add_column($mysubscribe2->public, 'time', "ALTER TABLE {$mysubscribe2->public} ADD time TIME DEFAULT '00:00:00' NOT NULL AFTER date"); }
<p>Everything seems dandy so far, <a href="?step=1">let's get started</a>!</p> <?php } else { ?> <p><em>It looks like your database information is incorrect. Please re-edit this file and double-check all the settings.</em></p> <?php } break; case 1: ?> <h1>Step 1</h1> <p>First let's get posts and comments.</p> <?php // For people running this on .72 $query = "ALTER TABLE `{$wpdb->posts}` ADD `post_name` VARCHAR(200) NOT NULL"; maybe_add_column($wpdb->posts, 'post_name', $query); // Create post_name field $connection = @mysql_connect($tp_database_host, $tp_database_username, $tp_database_password); $database = @mysql_select_db($tp_database_name); // For now we're going to give everything the same author and same category $author = $wpdb->get_var("SELECT ID FROM {$wpdb->users} WHERE user_level = 10 LIMIT 1"); $category = $wpdb->get_var("SELECT cat_ID FROM {$wpdb->categories} LIMIT 1"); $posts = mysql_query('SELECT * FROM textpattern', $connection); while ($post = mysql_fetch_array($posts)) { // ID, AuthorID, LastMod, LastModID, Posted, Title, Body, Body_html, Abstract, Category1, Category2, Annotate, AnnotateInvite, Status, Listing1, Listing2, Section $posted = $post['Posted']; // 20030216162119 $year = substr($posted, 0, 4); $month = substr($posted, 4, 2); $day = substr($posted, 6, 2); $hour = substr($posted, 8, 2);
function downloadmanager_activate() { global $wpdb, $blog_id; if (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) { include_once ABSPATH . '/wp-admin/upgrade-functions.php'; } elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) { include_once ABSPATH . '/wp-admin/includes/upgrade.php'; } else { die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\''); } $charset_collate = ''; if ($wpdb->supports_collation()) { if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } } // Create WP-Downloads Table $create_table = "CREATE TABLE {$wpdb->downloads} (" . "file_id int(10) NOT NULL auto_increment," . "file tinytext NOT NULL," . "file_name text character set utf8 NOT NULL," . "file_des text character set utf8 NOT NULL," . "file_size varchar(20) NOT NULL default ''," . "file_category int(2) NOT NULL default '0'," . "file_date varchar(20) NOT NULL default ''," . "file_updated_date varchar(20) NOT NULL default ''," . "file_last_downloaded_date varchar(20) NOT NULL default ''," . "file_hits int(10) NOT NULL default '0'," . "file_permission TINYINT(2) NOT NULL default '0'," . "PRIMARY KEY (file_id)) {$charset_collate};"; maybe_create_table($wpdb->downloads, $create_table); // WP-Downloads Options if (function_exists('is_site_admin')) { add_option('download_path', WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . '/files', 'Download Path'); add_option('download_path_url', WP_CONTENT_URL . '/blogs.dir/' . $blog_id . '/files', 'Download Path URL'); } else { add_option('download_path', WP_CONTENT_DIR . '/files', 'Download Path'); add_option('download_path_url', content_url('files'), 'Download Path URL'); } add_option('download_page_url', site_url('downloads'), 'Download Page URL'); add_option('download_method', 1, 'Download Type'); add_option('download_categories', array('General'), 'Download Categories'); add_option('download_sort', array('by' => 'file_name', 'order' => 'asc', 'perpage' => 20, 'group' => 1), 'Download Sorting Options'); add_option('download_template_header', '<p>' . __('There are <strong>%TOTAL_FILES_COUNT% files</strong>, weighing <strong>%TOTAL_SIZE%</strong> with <strong>%TOTAL_HITS% hits</strong> in <strong>%FILE_CATEGORY_NAME%</strong>.</p><p>Displaying <strong>%RECORD_START%</strong> to <strong>%RECORD_END%</strong> of <strong>%TOTAL_FILES_COUNT%</strong> files.', 'wp-downloadmanager') . '</p>', 'Download Page Header Template'); add_option('download_template_footer', '<form action="%DOWNLOAD_PAGE_URL%" method="get"><p><input type="hidden" name="dl_cat" value="%CATEGORY_ID%" /><input type="text" name="dl_search" value="%FILE_SEARCH_WORD%" /> <input type="submit" value="' . __('Search', 'wp-downloadmanager') . '" /></p></form>', 'Download Page Footer Template'); add_option('download_template_category_header', '<h2 id="downloadcat-%CATEGORY_ID%"><a href="%CATEGORY_URL%" title="' . __('View all downloads in %FILE_CATEGORY_NAME%', 'wp-downloadmanager') . '">%FILE_CATEGORY_NAME%</a></h2>', 'Download Category Header Template'); add_option('download_template_category_footer', '', 'Download Category Footer Template'); add_option('download_template_listing', array('<p><img src="' . plugins_url('wp-downloadmanager/images/ext') . '/%FILE_ICON%" alt="" title="" style="vertical-align: middle;" /> <strong><a href="%FILE_DOWNLOAD_URL%">%FILE_NAME%</a></strong><br /><strong>» %FILE_SIZE% - %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ' - %FILE_DATE%</strong><br />%FILE_DESCRIPTION%</p>', '<p><img src="' . plugins_url('wp-downloadmanager/images/ext') . '/%FILE_ICON%" alt="" title="" style="vertical-align: middle;" /> <strong>%FILE_NAME%</strong><br /><strong>» %FILE_SIZE% - %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ' - %FILE_DATE%</strong><br /><i>' . __('You do not have permission to download this file.', 'wp-downloadmanager') . '</i><br />%FILE_DESCRIPTION%</p>'), 'Download Listing Template'); add_option('download_template_embedded', array('<p><img src="' . plugins_url('wp-downloadmanager/images/ext') . '/%FILE_ICON%" alt="" title="" style="vertical-align: middle;" /> <strong><a href="%FILE_DOWNLOAD_URL%">%FILE_NAME%</a></strong> (%FILE_SIZE%' . __(',', 'wp-downloadmanager') . ' %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ')</p>', '<p><img src="' . plugins_url('wp-downloadmanager/images/ext') . '/%FILE_ICON%" alt="" title="" style="vertical-align: middle;" /> <strong>%FILE_NAME%</strong> (%FILE_SIZE%' . __(',', 'wp-downloadmanager') . ' %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ')<br /><i>' . __('You do not have permission to download this file.', 'wp-downloadmanager') . '</i></p>'), 'Download Embedded Template'); add_option('download_template_most', array('<li><a href="%FILE_DOWNLOAD_URL%">%FILE_NAME%</a> (%FILE_SIZE%' . __(',', 'wp-downloadmanager') . ' %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ')</li>', '<li>%FILE_NAME% (%FILE_SIZE%' . __(',', 'wp-downloadmanager') . ' %FILE_HITS% ' . __('hits', 'wp-downloadmanager') . ')<br /><i>' . __('You do not have permission to download this file.', 'wp-downloadmanager') . '</i></li>'), 'Most Download Template'); // Database Upgrade For WP-DownloadManager 1.30 $check_for_130 = $wpdb->get_var("SELECT option_value FROM {$wpdb->options} WHERE option_name = 'download_nice_permalink'"); if (!$check_for_130) { maybe_add_column($wpdb->downloads, 'file_updated_date', "ALTER TABLE {$wpdb->downloads} ADD file_updated_date VARCHAR(20) NOT NULL AFTER file_date;"); $wpdb->query("UPDATE {$wpdb->downloads} SET file_updated_date = file_date;"); maybe_add_column($wpdb->downloads, 'file_last_downloaded_date', "ALTER TABLE {$wpdb->downloads} ADD file_last_downloaded_date VARCHAR(20) NOT NULL AFTER file_updated_date;"); $wpdb->query("UPDATE {$wpdb->downloads} SET file_last_downloaded_date = file_date;"); } add_option('download_template_pagingheader', '', 'Displayed Before Paging In The Downloads Page'); add_option('download_template_pagingfooter', '', 'Displayed After Paging In The Downloads Page'); add_option('download_nice_permalink', 1, 'Use Download Nice Permalink'); add_option('download_template_download_page_link', '<p><a href="%DOWNLOAD_PAGE_URL%" title="' . __('Downloads Page', 'wp-downloadmanager') . '">' . __('Downloads Page', 'wp-downloadmanager') . '</a></p>', 'Template For Download Page Link'); add_option('download_template_none', '<p style="text-align: center;">' . __('No Files Found.', 'wp-downloadmanager') . '</p>', 'Template For No Downloads Found'); // Database Upgrade For WP-DownloadManager 1.50 $check_for_150 = $wpdb->get_var("SELECT option_value FROM {$wpdb->options} WHERE option_name = 'download_options'"); if (!$check_for_150) { $update_permission_1 = $wpdb->query("UPDATE {$wpdb->downloads} SET file_permission = -2 WHERE file_permission = -1;"); if ($update_permission_1) { $update_permission_2 = $wpdb->query("UPDATE {$wpdb->downloads} SET file_permission = -1 WHERE file_permission = 0;"); if ($update_permission_2) { $wpdb->query("UPDATE {$wpdb->downloads} SET file_permission = 0 WHERE file_permission = 1;"); } } } add_option('download_options', array('use_filename' => 0, 'rss_sortby' => 'file_date', 'rss_limit' => 20), 'Download Options'); // Create Files Folder if (function_exists('is_site_admin')) { if (!is_dir(WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . '/files/') && is_writable(WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . '/files/')) { mkdir(WP_CONTENT_DIR . '/blogs.dir/' . $blog_id . '/files/', 0777, true); } } else { if (!is_dir(WP_CONTENT_DIR . '/files/') && is_writable(WP_CONTENT_DIR . '/files/')) { mkdir(WP_CONTENT_DIR . '/files/', 0777, true); } } delete_option('widget_download_recent_downloads'); delete_option('widget_download_most_downloaded'); // Set 'manage_downloads' Capabilities To Administrator $role = get_role('administrator'); if (!$role->has_cap('manage_downloads')) { $role->add_cap('manage_downloads'); } }
/** Upgrade function for the database and settings */ function upgrade() { global $wpdb, $wp_version, $wpmu_version; // include upgrade-functions for maybe_add_column; if (!function_exists('maybe_add_column')) { require_once ABSPATH . 'wp-admin/install-helper.php'; } $date = date('Y-m-d'); maybe_add_column($this->public, 'date', "ALTER TABLE {$this->public} ADD date DATE DEFAULT '{$date}' NOT NULL AFTER active"); maybe_add_column($this->public, 'ip', "ALTER TABLE {$this->public} ADD ip char(64) DEFAULT 'admin' NOT NULL AFTER date"); maybe_add_column($this->public, 'time', "ALTER TABLE {$this->public} ADD time TIME DEFAULT '00:00:00' NOT NULL AFTER date"); // let's take the time to check process registered users // existing public subscribers are subscribed to all categories $users = $this->get_all_registered('ID'); if (!empty($users)) { foreach ($users as $user_ID) { $check_format = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), true); // if user is already registered update format remove 's2_excerpt' field and update 's2_format' if ('html' == $check_format) { delete_user_meta($user_ID, 's2_excerpt'); } elseif ('text' == $check_format) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), get_user_meta($user_ID, 's2_excerpt')); delete_user_meta($user_ID, 's2_excerpt'); } elseif (empty($check_format)) { // no prior settings so create them $this->register($user_ID); } $subscribed = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), true); if (strstr($subscribed, '-1')) { // make sure we remove '-1' from any settings $old_cats = explode(',', $subscribed); $pos = array_search('-1', $old_cats); unset($old_cats[$pos]); $cats = implode(',', $old_cats); update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), $cats); } $check_authors = get_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), true); if (empty($check_authors)) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_authors'), ''); } } } // update the options table to serialized format $old_options = $wpdb->get_col("SELECT option_name from {$wpdb->options} where option_name LIKE 's2%' AND option_name != 's2_future_posts'"); if (!empty($old_options)) { foreach ($old_options as $option) { $value = get_option($option); $option_array = substr($option, 3); $this->subscribe2_options[$option_array] = $value; delete_option($option); } } $this->subscribe2_options['version'] = S2VERSION; // ensure that the options are in the database require S2PATH . "include/options.php"; // correct autoformat to upgrade from pre 5.6 if ($this->subscribe2_options['autoformat'] == 'text') { $this->subscribe2_options['autoformat'] = 'excerpt'; } if ($this->subscribe2_options['autoformat'] == 'full') { $this->subscribe2_options['autoformat'] = 'post'; } // change old CAPITALISED keywords to those in {PARENTHESES}; since version 6.4 $keywords = array('BLOGNAME', 'BLOGLINK', 'TITLE', 'POST', 'POSTTIME', 'TABLE', 'TABLELINKS', 'PERMALINK', 'TINYLINK', 'DATE', 'TIME', 'MYNAME', 'EMAIL', 'AUTHORNAME', 'LINK', 'CATS', 'TAGS', 'COUNT', 'ACTION'); $keyword = implode('|', $keywords); $regex = '/(?<!\\{)\\b(' . $keyword . ')\\b(?!\\{)/xm'; $replace = '{\\1}'; $this->subscribe2_options['mailtext'] = preg_replace($regex, $replace, $this->subscribe2_options['mailtext']); $this->subscribe2_options['notification_subject'] = preg_replace($regex, $replace, $this->subscribe2_options['notification_subject']); $this->subscribe2_options['confirm_email'] = preg_replace($regex, $replace, $this->subscribe2_options['confirm_email']); $this->subscribe2_options['confirm_subject'] = preg_replace($regex, $replace, $this->subscribe2_options['confirm_subject']); $this->subscribe2_options['remind_email'] = preg_replace($regex, $replace, $this->subscribe2_options['remind_email']); $this->subscribe2_options['remind_subject'] = preg_replace($regex, $replace, $this->subscribe2_options['remind_subject']); update_option('subscribe2_options', $this->subscribe2_options); // upgrade old wpmu user meta data to new if ($this->s2_mu === true) { global $s2class_multisite; $s2class_multisite->namechange_subscribe2_widget(); // loop through all users foreach ($users as $user_ID) { // get categories which the user is subscribed to (old ones) $categories = get_user_meta($user_ID, 's2_subscribed', true); $categories = explode(',', $categories); $format = get_user_meta($user_ID, 's2_format', true); $autosub = get_user_meta($user_ID, 's2_autosub', true); // load blogs of user (only if we need them) $blogs = array(); if (count($categories) > 0 && !in_array('-1', $categories)) { $blogs = get_blogs_of_user($user_ID, true); } foreach ($blogs as $blog) { switch_to_blog($blog->userblog_id); $blog_categories = (array) $wpdb->get_col("SELECT term_id FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'category'"); $subscribed_categories = array_intersect($categories, $blog_categories); if (!empty($subscribed_categories)) { foreach ($subscribed_categories as $subscribed_category) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_cat') . $subscribed_category, $subscribed_category); } update_user_meta($user_ID, $this->get_usermeta_keyname('s2_subscribed'), implode(',', $subscribed_categories)); } if (!empty($format)) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_format'), $format); } if (!empty($autosub)) { update_user_meta($user_ID, $this->get_usermeta_keyname('s2_autosub'), $autosub); } restore_current_blog(); } // delete old user meta keys delete_user_meta($user_ID, 's2_subscribed'); delete_user_meta($user_ID, 's2_format'); delete_user_meta($user_ID, 's2_autosub'); foreach ($categories as $cat) { delete_user_meta($user_ID, 's2_cat' . $cat); } } } // ensure existing public subscriber emails are all sanitized $confirmed = $this->get_public(); $unconfirmed = $this->get_public(0); $public_subscribers = array_merge((array) $confirmed, (array) $unconfirmed); foreach ($public_subscribers as $email) { $new_email = $this->sanitize_email($email); if ($email !== $new_email) { $wpdb->get_results($wpdb->prepare("UPDATE {$this->public} SET email=%s WHERE CAST(email as binary)=%s", $new_email, $email)); } } // update postmeta field to a protected name, from version 8.5 $sql = $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_key = '_s2mail' WHERE meta_key = 's2mail'"); $wpdb->query($sql); return; }
function create_ratinglogs_table() { global $wpdb; postratings_textdomain(); if (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) { include_once ABSPATH . '/wp-admin/upgrade-functions.php'; } elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) { include_once ABSPATH . '/wp-admin/includes/upgrade.php'; } else { die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\''); } $charset_collate = ''; if ($wpdb->supports_collation()) { if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } } // Create Post Ratings Table $create_ratinglogs_sql = "CREATE TABLE {$wpdb->ratings} (" . "rating_id INT(11) NOT NULL auto_increment," . "rating_postid INT(11) NOT NULL ," . "rating_posttitle TEXT NOT NULL," . "rating_rating INT(2) NOT NULL ," . "rating_timestamp VARCHAR(15) NOT NULL ," . "rating_ip VARCHAR(40) NOT NULL ," . "rating_host VARCHAR(200) NOT NULL," . "rating_username VARCHAR(50) NOT NULL," . "rating_userid int(10) NOT NULL default '0'," . "PRIMARY KEY (rating_id)) {$charset_collate};"; maybe_create_table($wpdb->ratings, $create_ratinglogs_sql); // Add In Options (4 Records) add_option('postratings_image', 'stars', 'Your Ratings Image'); add_option('postratings_max', '5', 'Your Max Ratings'); add_option('postratings_template_vote', '%RATINGS_IMAGES_VOTE% (<strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%)<br />%RATINGS_TEXT%', 'Ratings Vote Template Text'); add_option('postratings_template_text', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%' . __(',', 'wp-postratings') . ' <strong>' . __('rated', 'wp-postratings') . '</strong></em>)', 'Ratings Template Text'); add_option('postratings_template_none', '%RATINGS_IMAGES_VOTE% (' . __('No Ratings Yet', 'wp-postratings') . ')<br />%RATINGS_TEXT%', 'Ratings Template For No Ratings'); // Database Upgrade For WP-PostRatings 1.02 add_option('postratings_logging_method', '3', 'Logging Method Of User Rated\'s Answer'); add_option('postratings_allowtorate', '2', 'Who Is Allowed To Rate'); // Database Uprade For WP-PostRatings 1.04 maybe_add_column($wpdb->ratings, 'rating_userid', "ALTER TABLE {$wpdb->ratings} ADD rating_userid INT( 10 ) NOT NULL DEFAULT '0';"); // Database Uprade For WP-PostRatings 1.05 add_option('postratings_ratingstext', array(__('1 Star', 'wp-postratings'), __('2 Stars', 'wp-postratings'), __('3 Stars', 'wp-postratings'), __('4 Stars', 'wp-postratings'), __('5 Stars', 'wp-postratings')), 'Individual Post Rating Text'); add_option('postratings_template_highestrated', '<li><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a> %RATINGS_IMAGES% (%RATINGS_AVERAGE% ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%)</li>', 'Template For Highest Rated'); // Database Upgrade For WP-PostRatings 1.11 add_option('postratings_ajax_style', array('loading' => 1, 'fading' => 1), 'Ratings AJAX Style'); // Database Upgrade For WP-PostRatings 1.20 add_option('postratings_ratingsvalue', array(1, 2, 3, 4, 5), 'Individual Post Rating Value'); add_option('postratings_customrating', 0, 'Use Custom Ratings'); add_option('postratings_template_permission', '%RATINGS_IMAGES% (<em><strong>%RATINGS_USERS%</strong> ' . __('votes', 'wp-postratings') . __(',', 'wp-postratings') . ' ' . __('average', 'wp-postratings') . ': <strong>%RATINGS_AVERAGE%</strong> ' . __('out of', 'wp-postratings') . ' %RATINGS_MAX%</em>)<br /><em>' . __('You need to be a registered member to rate this post.', 'wp-postratings') . '</em>', 'Ratings Template Text'); // Database Upgrade For WP-PostRatings 1.30 add_option('postratings_template_mostrated', '<li><a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a> - %RATINGS_USERS% ' . __('votes', 'wp-postratings') . '</li>', 'Most Rated Template Text'); // Database Upgrade For WP-PostRatings 1.50 delete_option('widget_ratings_highest_rated'); delete_option('widget_ratings_most_rated'); // Set 'manage_ratings' Capabilities To Administrator $role = get_role('administrator'); if (!$role->has_cap('manage_ratings')) { $role->add_cap('manage_ratings'); } }
function create_poll_table() { global $wpdb; polls_textdomain(); if (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) { include_once ABSPATH . '/wp-admin/includes/upgrade.php'; } elseif (@is_file(ABSPATH . '/wp-admin/upgrade-functions.php')) { include_once ABSPATH . '/wp-admin/upgrade-functions.php'; } elseif (@is_file(ABSPATH . '/wp-admin/includes/upgrade.php')) { include_once ABSPATH . '/wp-admin/includes/upgrade.php'; } else { die('We have problem finding your \'/wp-admin/upgrade-functions.php\' and \'/wp-admin/includes/upgrade.php\''); } // Create Poll Tables (3 Tables) $charset_collate = ''; if ($wpdb->supports_collation()) { if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } } $create_table = array(); $create_table['pollsq'] = "CREATE TABLE {$wpdb->pollsq} (" . "pollq_id int(10) NOT NULL auto_increment," . "pollq_question varchar(200) character set utf8 NOT NULL default ''," . "pollq_timestamp varchar(20) NOT NULL default ''," . "pollq_totalvotes int(10) NOT NULL default '0'," . "pollq_active tinyint(1) NOT NULL default '1'," . "pollq_expiry varchar(20) NOT NULL default ''," . "pollq_multiple tinyint(3) NOT NULL default '0'," . "pollq_totalvoters int(10) NOT NULL default '0'," . "PRIMARY KEY (pollq_id)) {$charset_collate};"; $create_table['pollsa'] = "CREATE TABLE {$wpdb->pollsa} (" . "polla_aid int(10) NOT NULL auto_increment," . "polla_qid int(10) NOT NULL default '0'," . "polla_answers varchar(200) character set utf8 NOT NULL default ''," . "polla_votes int(10) NOT NULL default '0'," . "PRIMARY KEY (polla_aid)) {$charset_collate};"; $create_table['pollsip'] = "CREATE TABLE {$wpdb->pollsip} (" . "pollip_id int(10) NOT NULL auto_increment," . "pollip_qid varchar(10) NOT NULL default ''," . "pollip_aid varchar(10) NOT NULL default ''," . "pollip_ip varchar(100) NOT NULL default ''," . "pollip_host VARCHAR(200) NOT NULL default ''," . "pollip_timestamp varchar(20) NOT NULL default '0000-00-00 00:00:00'," . "pollip_user tinytext NOT NULL," . "pollip_userid int(10) NOT NULL default '0'," . "PRIMARY KEY (pollip_id)," . "KEY pollip_ip (pollip_id)," . "KEY pollip_qid (pollip_qid)" . ") {$charset_collate};"; maybe_create_table($wpdb->pollsq, $create_table['pollsq']); maybe_create_table($wpdb->pollsa, $create_table['pollsa']); maybe_create_table($wpdb->pollsip, $create_table['pollsip']); // Check Whether It is Install Or Upgrade $first_poll = $wpdb->get_var("SELECT pollq_id FROM {$wpdb->pollsq} LIMIT 1"); // If Install, Insert 1st Poll Question With 5 Poll Answers if (empty($first_poll)) { // Insert Poll Question (1 Record) $insert_pollq = $wpdb->query("INSERT INTO {$wpdb->pollsq} VALUES (1, '" . __('How Is My Site?', 'wp-polls') . "', '" . current_time('timestamp') . "', 0, 1, '', 0, 0);"); if ($insert_pollq) { // Insert Poll Answers (5 Records) $wpdb->query("INSERT INTO {$wpdb->pollsa} VALUES (1, 1, '" . __('Good', 'wp-polls') . "', 0);"); $wpdb->query("INSERT INTO {$wpdb->pollsa} VALUES (2, 1, '" . __('Excellent', 'wp-polls') . "', 0);"); $wpdb->query("INSERT INTO {$wpdb->pollsa} VALUES (3, 1, '" . __('Bad', 'wp-polls') . "', 0);"); $wpdb->query("INSERT INTO {$wpdb->pollsa} VALUES (4, 1, '" . __('Can Be Improved', 'wp-polls') . "', 0);"); $wpdb->query("INSERT INTO {$wpdb->pollsa} VALUES (5, 1, '" . __('No Comments', 'wp-polls') . "', 0);"); } } // Add In Options (16 Records) add_option('poll_template_voteheader', '<p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p>' . '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">' . '<ul class="wp-polls-ul">'); add_option('poll_template_votebody', '<li><input type="%POLL_CHECKBOX_RADIO%" id="poll-answer-%POLL_ANSWER_ID%" name="poll_%POLL_ID%" value="%POLL_ANSWER_ID%" /> <label for="poll-answer-%POLL_ANSWER_ID%">%POLL_ANSWER%</label></li>'); add_option('poll_template_votefooter', '</ul>' . '<p style="text-align: center;"><input type="button" name="vote" value=" ' . __('Vote', 'wp-polls') . ' " class="Buttons" onclick="poll_vote(%POLL_ID%);" /></p>' . '<p style="text-align: center;"><a href="#ViewPollResults" onclick="poll_result(%POLL_ID%); return false;" title="' . __('View Results Of This Poll', 'wp-polls') . '">' . __('View Results', 'wp-polls') . '</a></p>' . '</div>'); add_option('poll_template_resultheader', '<p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p>' . '<div id="polls-%POLL_ID%-ans" class="wp-polls-ans">' . '<ul class="wp-polls-ul">'); add_option('poll_template_resultbody', '<li>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%' . __(',', 'wp-polls') . ' %POLL_ANSWER_VOTES% ' . __('Votes', 'wp-polls') . ')</small><div class="pollbar" style="width: %POLL_ANSWER_IMAGEWIDTH%%;" title="%POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% ' . __('Votes', 'wp-polls') . ')"></div></li>'); add_option('poll_template_resultbody2', '<li><strong><i>%POLL_ANSWER% <small>(%POLL_ANSWER_PERCENTAGE%%' . __(',', 'wp-polls') . ' %POLL_ANSWER_VOTES% ' . __('Votes', 'wp-polls') . ')</small></i></strong><div class="pollbar" style="width: %POLL_ANSWER_IMAGEWIDTH%%;" title="' . __('You Have Voted For This Choice', 'wp-polls') . ' - %POLL_ANSWER_TEXT% (%POLL_ANSWER_PERCENTAGE%% | %POLL_ANSWER_VOTES% ' . __('Votes', 'wp-polls') . ')"></div></li>'); add_option('poll_template_resultfooter', '</ul>' . '<p style="text-align: center;">' . __('Total Voters', 'wp-polls') . ': <strong>%POLL_TOTALVOTERS%</strong></p>' . '</div>'); add_option('poll_template_resultfooter2', '</ul>' . '<p style="text-align: center;">' . __('Total Voters', 'wp-polls') . ': <strong>%POLL_TOTALVOTERS%</strong></p>' . '<p style="text-align: center;"><a href="#VotePoll" onclick="poll_booth(%POLL_ID%); return false;" title="' . __('Vote For This Poll', 'wp-polls') . '">' . __('Vote', 'wp-polls') . '</a></p>' . '</div>'); add_option('poll_template_disable', __('Sorry, there are no polls available at the moment.', 'wp-polls')); add_option('poll_template_error', __('An error has occurred when processing your poll.', 'wp-polls')); add_option('poll_currentpoll', 0); add_option('poll_latestpoll', 1); add_option('poll_archive_perpage', 5); add_option('poll_ans_sortby', 'polla_aid'); add_option('poll_ans_sortorder', 'asc'); add_option('poll_ans_result_sortby', 'polla_votes'); add_option('poll_ans_result_sortorder', 'desc'); // Database Upgrade For WP-Polls 2.1 add_option('poll_logging_method', '3'); add_option('poll_allowtovote', '2'); maybe_add_column($wpdb->pollsq, 'pollq_active', "ALTER TABLE {$wpdb->pollsq} ADD pollq_active TINYINT( 1 ) NOT NULL DEFAULT '1';"); // Database Upgrade For WP-Polls 2.12 maybe_add_column($wpdb->pollsip, 'pollip_userid', "ALTER TABLE {$wpdb->pollsip} ADD pollip_userid INT( 10 ) NOT NULL DEFAULT '0';"); add_option('poll_archive_url', site_url('pollsarchive')); // Database Upgrade For WP-Polls 2.13 add_option('poll_bar', array('style' => 'default', 'background' => 'd8e1eb', 'border' => 'c8c8c8', 'height' => 8)); // Database Upgrade For WP-Polls 2.14 maybe_add_column($wpdb->pollsq, 'pollq_expiry', "ALTER TABLE {$wpdb->pollsq} ADD pollq_expiry varchar(20) NOT NULL default '';"); add_option('poll_close', 1); // Database Upgrade For WP-Polls 2.20 add_option('poll_ajax_style', array('loading' => 1, 'fading' => 1)); add_option('poll_template_pollarchivelink', '<ul>' . '<li><a href="%POLL_ARCHIVE_URL%">' . __('Polls Archive', 'wp-polls') . '</a></li>' . '</ul>'); add_option('poll_archive_displaypoll', 2); add_option('poll_template_pollarchiveheader', ''); add_option('poll_template_pollarchivefooter', '<p>' . __('Start Date:', 'wp-polls') . ' %POLL_START_DATE%<br />' . __('End Date:', 'wp-polls') . ' %POLL_END_DATE%</p>'); maybe_add_column($wpdb->pollsq, 'pollq_multiple', "ALTER TABLE {$wpdb->pollsq} ADD pollq_multiple TINYINT( 3 ) NOT NULL DEFAULT '0';"); $pollq_totalvoters = maybe_add_column($wpdb->pollsq, 'pollq_totalvoters', "ALTER TABLE {$wpdb->pollsq} ADD pollq_totalvoters INT( 10 ) NOT NULL DEFAULT '0';"); if ($pollq_totalvoters) { $pollq_totalvoters = intval($wpdb->get_var("SELECT SUM(pollq_totalvoters) FROM {$wpdb->pollsq}")); if ($pollq_totalvoters == 0) { $wpdb->query("UPDATE {$wpdb->pollsq} SET pollq_totalvoters = pollq_totalvotes"); } } // Database Upgrade For WP-Polls 2.30 add_option('poll_cookielog_expiry', 0); add_option('poll_template_pollarchivepagingheader', ''); add_option('poll_template_pollarchivepagingfooter', ''); // Database Upgrade For WP-Polls 2.50 delete_option('poll_archive_show'); // Database Upgrade For WP-Polls 2.61 $wpdb->query("ALTER TABLE {$wpdb->pollsip} ADD INDEX pollip_ip (pollip_id);"); $wpdb->query("ALTER TABLE {$wpdb->pollsip} ADD INDEX pollip_qid (pollip_qid);"); // Set 'manage_polls' Capabilities To Administrator $role = get_role('administrator'); if (!$role->has_cap('manage_polls')) { $role->add_cap('manage_polls'); } cron_polls_place(); }
/** * Execute changes made in ClassiPress 3.1.0. * * @since 3.1.0 */ function cp_upgrade_310() { global $wpdb, $app_abbr, $app_version; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; maybe_add_column($wpdb->cp_ad_meta, 'field_search', "ALTER TABLE {$wpdb->cp_ad_meta} ADD `field_search` int(10) NOT NULL"); maybe_add_column($wpdb->cp_ad_fields, 'field_min_length', "ALTER TABLE {$wpdb->cp_ad_fields} ADD `field_min_length` int(11) NOT NULL"); maybe_add_column($wpdb->cp_ad_fields, 'field_validation', "ALTER TABLE {$wpdb->cp_ad_fields} ADD `field_validation` longtext DEFAULT NULL"); maybe_add_column($wpdb->cp_ad_packs, 'pack_type', "ALTER TABLE {$wpdb->cp_ad_packs} ADD `pack_type` varchar(255) NOT NULL"); maybe_add_column($wpdb->cp_ad_packs, 'pack_membership_price', "ALTER TABLE {$wpdb->cp_ad_packs} ADD `pack_membership_price` decimal(10,2) unsigned NOT NULL DEFAULT '0'"); if (get_option($app_abbr . '_distance_unit') == false) { update_option($app_abbr . '_distance_unit', 'mi'); } if (get_option('embed_size_w') == false) { update_option('embed_size_w', 500); } // set the WP maximum embed size width if (get_option($app_abbr . '_membership_purchase_url') == false) { update_option($app_abbr . '_membership_purchase_url', 'membership'); } if (get_option($app_abbr . '_membership_purchase_confirm_url') == false) { update_option($app_abbr . '_membership_purchase_confirm_url', 'membership-confirm'); } /** * create and set new membership page templates */ $cur_ex_pages = array(); $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = 'membership' LIMIT 1"); if ($wpdb->num_rows == 0) { $my_page = array('post_status' => 'publish', 'post_type' => 'page', 'post_author' => 1, 'post_name' => 'membership', 'post_title' => 'Memberships'); $page_id = wp_insert_post($my_page); update_post_meta($page_id, '_wp_page_template', 'tpl-membership-purchase.php'); $cur_ex_pages[] = $page_id; } $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_name = 'membership-confirm' LIMIT 1"); if ($wpdb->num_rows == 0) { $my_page = array('post_status' => 'publish', 'post_type' => 'page', 'post_author' => 1, 'post_name' => 'membership-confirm', 'post_title' => 'Membership Confirmation'); $page_id = wp_insert_post($my_page); update_post_meta($page_id, '_wp_page_template', 'tpl-membership-confirm.php'); $cur_ex_pages[] = $page_id; } // check to see if array of page ids is empty // if not, add them to the pages to be excluded from the nav meta option. if (!empty($cur_ex_pages)) { $all_ex_pages = array(); // get all excluded pages $ex_pages = get_option($app_abbr . '_excluded_pages'); if ($ex_pages == true) { // put page ids into an array $ex_pages = explode(',', $ex_pages); // merge them with the new page ids $all_ex_pages = array_merge($ex_pages, $cur_ex_pages); // convert back to a comma separated string for saving $all_ex_pages = implode(',', $all_ex_pages); } else { // option doesn't exist so no existing page ids $all_ex_pages = implode(',', $cur_ex_pages); } // update with the new list of excluded page ids update_option($app_abbr . '_excluded_pages', appthemes_clean($all_ex_pages)); } update_option('cp_db_version', 1200); update_option($app_abbr . '_version', $app_version); }
function dbem_create_events_table() { global $wpdb, $user_level; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $old_table_name = $wpdb->prefix . "events"; $table_name = $wpdb->prefix . EVENTS_TBNAME; if (!($wpdb->get_var("SHOW TABLES LIKE '{$old_table_name}'") != $old_table_name)) { // upgrading from previous versions $sql = "ALTER TABLE {$old_table_name} RENAME {$table_name};"; $wpdb->query($sql); } if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { // check the user is allowed to make changes // get_currentuserinfo(); // if ($user_level < 8) { return; } // Creating the events table /* Marcus Begin Edit*/ //Added Category FK Field $sql = "CREATE TABLE " . $table_name . " (\n\t\t\tevent_id mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\t\tevent_author mediumint(9) DEFAULT NULL,\n\t\t\tevent_name tinytext NOT NULL,\n\t\t\tevent_start_time time NOT NULL,\n\t\t\tevent_end_time time NOT NULL,\n\t\t\tevent_start_date date NOT NULL,\n\t\t\tevent_end_date date NULL, \n\t\t\tevent_notes text DEFAULT NULL,\n\t\t\tevent_rsvp bool NOT NULL DEFAULT 0,\n\t\t\tevent_seats tinyint,\n\t\t\tevent_contactperson_id mediumint(9) NULL, \n\t\t\tlocation_id mediumint(9) NOT NULL,\n\t\t\trecurrence_id mediumint(9) NULL,\n \t\t\tevent_category_id int(11) default NULL,\n\t\t\tUNIQUE KEY (event_id)\n\t\t\t);"; /* Marcus End Edit */ dbDelta($sql); //-------------- DEBUG CODE to insert a few events n the new table // get the current timestamp into an array $timestamp = time(); $date_time_array = getdate($timestamp); $hours = $date_time_array['hours']; $minutes = $date_time_array['minutes']; $seconds = $date_time_array['seconds']; $month = $date_time_array['mon']; $day = $date_time_array['mday']; $year = $date_time_array['year']; // use mktime to recreate the unix timestamp // adding 19 hours to $hours $in_one_week = strftime('%Y-%m-%d', mktime($hours, $minutes, $seconds, $month, $day + 7, $year)); $in_four_weeks = strftime('%Y-%m-%d', mktime($hours, $minutes, $seconds, $month, $day + 28, $year)); $in_one_year = strftime('%Y-%m-%d', mktime($hours, $minutes, $seconds, $month, $day, $year + 1)); $wpdb->query("INSERT INTO " . $table_name . " (event_name, event_start_date, event_start_time, event_end_time, location_id)\n\t\t\t\tVALUES ('Orality in James Joyce Conference', '{$in_one_week}', '16:00:00', '18:00:00', 1)"); $wpdb->query("INSERT INTO " . $table_name . " (event_name, event_start_date, event_start_time, event_end_time, location_id)\n\t\t\t\tVALUES ('Traditional music session', '{$in_four_weeks}', '20:00:00', '22:00:00', 2)"); $wpdb->query("INSERT INTO " . $table_name . " (event_name, event_start_date, event_start_time, event_end_time, location_id)\n\t\t\t\t\tVALUES ('6 Nations, Italy VS Ireland', '{$in_one_year}','22:00:00', '24:00:00', 3)"); } else { // eventual maybe_add_column() for later versions maybe_add_column($table_name, 'event_start_date', "alter table {$table_name} add event_start_date date NOT NULL;"); maybe_add_column($table_name, 'event_end_date', "alter table {$table_name} add event_end_date date NULL;"); maybe_add_column($table_name, 'event_start_time', "alter table {$table_name} add event_start_time time NOT NULL;"); maybe_add_column($table_name, 'event_end_time', "alter table {$table_name} add event_end_time time NOT NULL;"); maybe_add_column($table_name, 'event_rsvp', "alter table {$table_name} add event_rsvp BOOL NOT NULL;"); maybe_add_column($table_name, 'event_seats', "alter table {$table_name} add event_seats tinyint NULL;"); maybe_add_column($table_name, 'location_id', "alter table {$table_name} add location_id mediumint(9) NOT NULL;"); maybe_add_column($table_name, 'recurrence_id', "alter table {$table_name} add recurrence_id mediumint(9) NULL;"); maybe_add_column($table_name, 'event_contactperson_id', "alter table {$table_name} add event_contactperson_id mediumint(9) NULL;"); // Fix buggy columns $wpdb->query("ALTER TABLE {$table_name} MODIFY event_notes text ;"); $wpdb->query("ALTER TABLE {$table_name} MODIFY event_author mediumint(9);"); } }
function dbem_create_bookings_table() { global $wpdb, $user_level; $table_name = $wpdb->prefix . BOOKINGS_TBNAME; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "CREATE TABLE " . $table_name . " (\r\n\t\t\tbooking_id mediumint(9) NOT NULL AUTO_INCREMENT,\r\n\t\t\tevent_id tinyint NOT NULL,\r\n\t\t\tperson_id tinyint NOT NULL, \r\n\t\t\tbooking_seats tinyint NOT NULL,\r\n\t\t\tbooking_comment text DEFAULT NULL,\r\n\t\t\tUNIQUE KEY (booking_id)\r\n\t\t\t);"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); } else { maybe_add_column($table_name, 'booking_comment', "ALTER TABLE {$table_name} add booking_comment text DEFAULT NULL;"); } }