2 // Here we keep the DB structure and option values
4 $wp_queries="CREATE TABLE $wpdb->categories (
5 cat_ID bigint(20) NOT NULL auto_increment,
6 cat_name varchar(55) NOT NULL default '',
7 category_nicename varchar(200) NOT NULL default '',
8 category_description longtext NOT NULL,
9 category_parent bigint(20) NOT NULL default '0',
10 category_count bigint(20) NOT NULL default '0',
12 KEY category_nicename (category_nicename)
14 CREATE TABLE $wpdb->comments (
15 comment_ID bigint(20) unsigned NOT NULL auto_increment,
16 comment_post_ID int(11) NOT NULL default '0',
17 comment_author tinytext NOT NULL,
18 comment_author_email varchar(100) NOT NULL default '',
19 comment_author_url varchar(200) NOT NULL default '',
20 comment_author_IP varchar(100) NOT NULL default '',
21 comment_date datetime NOT NULL default '0000-00-00 00:00:00',
22 comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
23 comment_content text NOT NULL,
24 comment_karma int(11) NOT NULL default '0',
25 comment_approved enum('0','1','spam') NOT NULL default '1',
26 comment_agent varchar(255) NOT NULL default '',
27 comment_type varchar(20) NOT NULL default '',
28 comment_parent bigint(20) NOT NULL default '0',
29 user_id bigint(20) NOT NULL default '0',
30 PRIMARY KEY (comment_ID),
31 KEY comment_approved (comment_approved),
32 KEY comment_post_ID (comment_post_ID)
34 CREATE TABLE $wpdb->linkcategories (
35 cat_id bigint(20) NOT NULL auto_increment,
36 cat_name tinytext NOT NULL,
37 auto_toggle enum('Y','N') NOT NULL default 'N',
38 show_images enum('Y','N') NOT NULL default 'Y',
39 show_description enum('Y','N') NOT NULL default 'N',
40 show_rating enum('Y','N') NOT NULL default 'Y',
41 show_updated enum('Y','N') NOT NULL default 'Y',
42 sort_order varchar(64) NOT NULL default 'rand',
43 sort_desc enum('Y','N') NOT NULL default 'N',
44 text_before_link varchar(128) NOT NULL default '<li>',
45 text_after_link varchar(128) NOT NULL default '<br />',
46 text_after_all varchar(128) NOT NULL default '</li>',
47 list_limit int(11) NOT NULL default '-1',
50 CREATE TABLE $wpdb->links (
51 link_id bigint(20) NOT NULL auto_increment,
52 link_url varchar(255) NOT NULL default '',
53 link_name varchar(255) NOT NULL default '',
54 link_image varchar(255) NOT NULL default '',
55 link_target varchar(25) NOT NULL default '',
56 link_category bigint(20) NOT NULL default '0',
57 link_description varchar(255) NOT NULL default '',
58 link_visible enum('Y','N') NOT NULL default 'Y',
59 link_owner int(11) NOT NULL default '1',
60 link_rating int(11) NOT NULL default '0',
61 link_updated datetime NOT NULL default '0000-00-00 00:00:00',
62 link_rel varchar(255) NOT NULL default '',
63 link_notes mediumtext NOT NULL,
64 link_rss varchar(255) NOT NULL default '',
65 PRIMARY KEY (link_id),
66 KEY link_category (link_category),
67 KEY link_visible (link_visible)
69 CREATE TABLE $wpdb->options (
70 option_id bigint(20) NOT NULL auto_increment,
71 blog_id int(11) NOT NULL default '0',
72 option_name varchar(64) NOT NULL default '',
73 option_can_override enum('Y','N') NOT NULL default 'Y',
74 option_type int(11) NOT NULL default '1',
75 option_value longtext NOT NULL,
76 option_width int(11) NOT NULL default '20',
77 option_height int(11) NOT NULL default '8',
78 option_description tinytext NOT NULL,
79 option_admin_level int(11) NOT NULL default '1',
80 autoload enum('yes','no') NOT NULL default 'yes',
81 PRIMARY KEY (option_id,blog_id,option_name),
82 KEY option_name (option_name)
84 CREATE TABLE $wpdb->post2cat (
85 rel_id bigint(20) NOT NULL auto_increment,
86 post_id bigint(20) NOT NULL default '0',
87 category_id bigint(20) NOT NULL default '0',
89 KEY post_id (post_id,category_id)
91 CREATE TABLE $wpdb->postmeta (
92 meta_id bigint(20) NOT NULL auto_increment,
93 post_id bigint(20) NOT NULL default '0',
94 meta_key varchar(255) default NULL,
96 PRIMARY KEY (meta_id),
97 KEY post_id (post_id),
98 KEY meta_key (meta_key)
100 CREATE TABLE $wpdb->posts (
101 ID bigint(20) unsigned NOT NULL auto_increment,
102 post_author bigint(20) NOT NULL default '0',
103 post_date datetime NOT NULL default '0000-00-00 00:00:00',
104 post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
105 post_content longtext NOT NULL,
106 post_title text NOT NULL,
107 post_category int(4) NOT NULL default '0',
108 post_excerpt text NOT NULL,
109 post_status enum('publish','draft','private','static','object','attachment') NOT NULL default 'publish',
110 comment_status enum('open','closed','registered_only') NOT NULL default 'open',
111 ping_status enum('open','closed') NOT NULL default 'open',
112 post_password varchar(20) NOT NULL default '',
113 post_name varchar(200) NOT NULL default '',
114 to_ping text NOT NULL,
115 pinged text NOT NULL,
116 post_modified datetime NOT NULL default '0000-00-00 00:00:00',
117 post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
118 post_content_filtered text NOT NULL,
119 post_parent bigint(20) NOT NULL default '0',
120 guid varchar(255) NOT NULL default '',
121 menu_order int(11) NOT NULL default '0',
122 post_type varchar(100) NOT NULL default '',
123 post_mime_type varchar(100) NOT NULL default '',
124 comment_count bigint(20) NOT NULL default '0',
126 KEY post_name (post_name)
128 CREATE TABLE $wpdb->users (
129 ID bigint(20) unsigned NOT NULL auto_increment,
130 user_login varchar(60) NOT NULL default '',
131 user_pass varchar(64) NOT NULL default '',
132 user_nicename varchar(50) NOT NULL default '',
133 user_email varchar(100) NOT NULL default '',
134 user_url varchar(100) NOT NULL default '',
135 user_registered datetime NOT NULL default '0000-00-00 00:00:00',
136 user_activation_key varchar(60) NOT NULL default '',
137 user_status int(11) NOT NULL default '0',
138 display_name varchar(250) NOT NULL default '',
140 KEY user_login_key (user_login)
142 CREATE TABLE $wpdb->usermeta (
143 umeta_id bigint(20) NOT NULL auto_increment,
144 user_id bigint(20) NOT NULL default '0',
145 meta_key varchar(255) default NULL,
147 PRIMARY KEY (umeta_id),
148 KEY user_id (user_id),
149 KEY meta_key (meta_key)
152 function populate_options() {
153 global $wpdb, $wp_db_version;
155 $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
156 $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
157 add_option('siteurl', $guessurl, __('WordPress web address'));
158 add_option('blogname', __('My Weblog'), __('Blog title'));
159 add_option('blogdescription', __('Just another WordPress weblog'), __('Short tagline'));
160 add_option('new_users_can_blog', 0);
161 add_option('users_can_register', 0);
162 add_option('admin_email', 'you@example.com');
163 add_option('start_of_week', 1);
164 add_option('use_balanceTags', 0);
165 add_option('use_smilies', 1);
166 add_option('require_name_email', 1);
167 add_option('comments_notify', 1);
168 add_option('posts_per_rss', 10);
169 add_option('rss_excerpt_length', 50);
170 add_option('rss_use_excerpt', 0);
171 add_option('mailserver_url', 'mail.example.com');
172 add_option('mailserver_login', 'login@example.com');
173 add_option('mailserver_pass', 'password');
174 add_option('mailserver_port', 110);
175 add_option('default_category', 1);
176 add_option('default_comment_status', 'open');
177 add_option('default_ping_status', 'open');
178 add_option('default_pingback_flag', 1);
179 add_option('default_post_edit_rows', 10);
180 add_option('posts_per_page', 10);
181 add_option('what_to_show', 'posts');
182 add_option('date_format', __('F j, Y'));
183 add_option('time_format', __('g:i a'));
184 add_option('links_updated_date_format', __('F j, Y g:i a'));
185 add_option('links_recently_updated_prepend', '<em>');
186 add_option('links_recently_updated_append', '</em>');
187 add_option('links_recently_updated_time', 120);
188 add_option('comment_moderation', 0);
189 add_option('moderation_notify', 1);
190 add_option('permalink_structure');
191 add_option('gzipcompression', 0);
192 add_option('hack_file', 0);
193 add_option('blog_charset', 'UTF-8');
194 add_option('moderation_keys');
195 add_option('active_plugins');
196 add_option('home', $guessurl);
197 // in case it is set, but blank, update "home"
198 if ( !__get_option('home') ) update_option('home', $guessurl);
199 add_option('category_base');
200 add_option('ping_sites', 'http://rpc.pingomatic.com/');
201 add_option('advanced_edit', 0);
202 add_option('comment_max_links', 2);
203 add_option('gmt_offset', date('Z') / 3600);
205 add_option('default_email_category', 1, __('Posts by email go to this category'));
206 add_option('recently_edited');
207 add_option('use_linksupdate', 0);
208 add_option('template', 'default');
209 add_option('stylesheet', 'default');
210 add_option('comment_whitelist', 1);
211 add_option('page_uris');
212 add_option('blacklist_keys');
213 add_option('comment_registration', 0);
214 add_option('open_proxy_check', 1);
215 add_option('rss_language', 'en');
216 add_option('html_type', 'text/html');
218 add_option('use_trackback', 0);
220 add_option('default_role', 'subscriber');
221 add_option('rich_editing', 'true');
222 add_option('db_version', $wp_db_version);
224 if ( ini_get('safe_mode') ) {
225 // Safe mode screws up mkdir(), so we must use a flat structure.
226 add_option('uploads_use_yearmonth_folders', 0);
227 add_option('upload_path', 'wp-content');
229 add_option('uploads_use_yearmonth_folders', 1);
230 add_option('upload_path', 'wp-content/uploads');
233 // Delete unused options
234 $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
235 foreach ($unusedoptions as $option) :
236 delete_option($option);
239 // Set up a few options not to load by default
240 $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
241 foreach ($fatoptions as $fatoption) :
242 $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
246 function populate_roles() {
247 populate_roles_160();
250 function populate_roles_160() {
254 add_role('administrator', __('Administrator'));
255 add_role('editor', __('Editor'));
256 add_role('author', __('Author'));
257 add_role('contributor', __('Contributor'));
258 add_role('subscriber', __('Subscriber'));
260 // Add caps for Administrator role
261 $role = get_role('administrator');
262 $role->add_cap('switch_themes');
263 $role->add_cap('edit_themes');
264 $role->add_cap('activate_plugins');
265 $role->add_cap('edit_plugins');
266 $role->add_cap('edit_users');
267 $role->add_cap('edit_files');
268 $role->add_cap('manage_options');
269 $role->add_cap('moderate_comments');
270 $role->add_cap('manage_categories');
271 $role->add_cap('manage_links');
272 $role->add_cap('upload_files');
273 $role->add_cap('import');
274 $role->add_cap('unfiltered_html');
275 $role->add_cap('edit_posts');
276 $role->add_cap('edit_others_posts');
277 $role->add_cap('edit_published_posts');
278 $role->add_cap('publish_posts');
279 $role->add_cap('edit_pages');
280 $role->add_cap('read');
281 $role->add_cap('level_10');
282 $role->add_cap('level_9');
283 $role->add_cap('level_8');
284 $role->add_cap('level_7');
285 $role->add_cap('level_6');
286 $role->add_cap('level_5');
287 $role->add_cap('level_4');
288 $role->add_cap('level_3');
289 $role->add_cap('level_2');
290 $role->add_cap('level_1');
291 $role->add_cap('level_0');
293 // Add caps for Editor role
294 $role = get_role('editor');
295 $role->add_cap('moderate_comments');
296 $role->add_cap('manage_categories');
297 $role->add_cap('manage_links');
298 $role->add_cap('upload_files');
299 $role->add_cap('unfiltered_html');
300 $role->add_cap('edit_posts');
301 $role->add_cap('edit_others_posts');
302 $role->add_cap('edit_published_posts');
303 $role->add_cap('publish_posts');
304 $role->add_cap('edit_pages');
305 $role->add_cap('read');
306 $role->add_cap('level_7');
307 $role->add_cap('level_6');
308 $role->add_cap('level_5');
309 $role->add_cap('level_4');
310 $role->add_cap('level_3');
311 $role->add_cap('level_2');
312 $role->add_cap('level_1');
313 $role->add_cap('level_0');
315 // Add caps for Author role
316 $role = get_role('author');
317 $role->add_cap('upload_files');
318 $role->add_cap('edit_posts');
319 $role->add_cap('edit_published_posts');
320 $role->add_cap('publish_posts');
321 $role->add_cap('read');
322 $role->add_cap('level_2');
323 $role->add_cap('level_1');
324 $role->add_cap('level_0');
326 // Add caps for Contributor role
327 $role = get_role('contributor');
328 $role->add_cap('edit_posts');
329 $role->add_cap('read');
330 $role->add_cap('level_1');
331 $role->add_cap('level_0');
333 // Add caps for Subscriber role
334 $role = get_role('subscriber');
335 $role->add_cap('read');
336 $role->add_cap('level_0');