summaryrefslogtreecommitdiffstats
path: root/wp-admin
diff options
context:
space:
mode:
Diffstat (limited to 'wp-admin')
-rw-r--r--wp-admin/admin-ajax.php30
-rw-r--r--wp-admin/admin-db.php693
-rw-r--r--wp-admin/admin-footer.php7
-rw-r--r--wp-admin/admin-functions.php2388
-rw-r--r--wp-admin/admin-header.php15
-rw-r--r--wp-admin/admin.php23
-rw-r--r--wp-admin/bookmarklet.php2
-rw-r--r--wp-admin/categories.php9
-rw-r--r--wp-admin/comment.php6
-rw-r--r--wp-admin/css/install-rtl.css (renamed from wp-admin/install-rtl.css)2
-rw-r--r--wp-admin/css/install.css (renamed from wp-admin/install.css)0
-rw-r--r--wp-admin/css/upload-rtl.css12
-rw-r--r--wp-admin/css/upload.css (renamed from wp-admin/upload.css)0
-rw-r--r--wp-admin/css/widgets-rtl.css38
-rw-r--r--wp-admin/css/widgets.css (renamed from wp-admin/widgets.css)82
-rw-r--r--wp-admin/custom-header.php6
-rw-r--r--wp-admin/edit-category-form.php10
-rw-r--r--wp-admin/edit-comments.php29
-rw-r--r--wp-admin/edit-form-advanced.php53
-rw-r--r--wp-admin/edit-form-comment.php15
-rw-r--r--wp-admin/edit-form.php5
-rw-r--r--wp-admin/edit-link-categories.php93
-rw-r--r--wp-admin/edit-link-category-form.php43
-rw-r--r--wp-admin/edit-link-form.php9
-rw-r--r--wp-admin/edit-page-form.php2
-rw-r--r--wp-admin/edit-pages.php73
-rw-r--r--wp-admin/edit-post-rows.php117
-rw-r--r--wp-admin/edit.php339
-rw-r--r--wp-admin/export.php125
-rw-r--r--wp-admin/images/logo-ghost.pngbin0 -> 992 bytes
-rw-r--r--wp-admin/import.php5
-rw-r--r--wp-admin/import/blogger.php33
-rw-r--r--wp-admin/import/blogware.php11
-rw-r--r--wp-admin/import/btt.php115
-rw-r--r--wp-admin/import/dotclear.php53
-rw-r--r--wp-admin/import/greymatter.php7
-rw-r--r--wp-admin/import/jkw.php178
-rw-r--r--wp-admin/import/livejournal.php12
-rw-r--r--wp-admin/import/mt.php460
-rw-r--r--wp-admin/import/rss.php10
-rw-r--r--wp-admin/import/stp.php155
-rw-r--r--wp-admin/import/textpattern.php42
-rw-r--r--wp-admin/import/utw.php276
-rw-r--r--wp-admin/import/wordpress.php176
-rw-r--r--wp-admin/import/wp-cat2tag.php240
-rw-r--r--wp-admin/includes/admin.php22
-rw-r--r--wp-admin/includes/bookmark.php177
-rw-r--r--wp-admin/includes/comment.php68
-rw-r--r--wp-admin/includes/file.php189
-rw-r--r--wp-admin/includes/image.php192
-rw-r--r--wp-admin/includes/import.php45
-rw-r--r--wp-admin/includes/misc.php178
-rw-r--r--wp-admin/includes/mu.php202
-rw-r--r--wp-admin/includes/plugin.php382
-rw-r--r--wp-admin/includes/post.php471
-rw-r--r--wp-admin/includes/schema.php474
-rw-r--r--wp-admin/includes/taxonomy.php148
-rw-r--r--wp-admin/includes/template.php626
-rw-r--r--wp-admin/includes/theme.php52
-rw-r--r--wp-admin/includes/update.php122
-rw-r--r--wp-admin/includes/upgrade.php1271
-rw-r--r--wp-admin/includes/upload.php381
-rw-r--r--wp-admin/includes/user.php284
-rw-r--r--wp-admin/index-extra.php12
-rw-r--r--wp-admin/index.php39
-rw-r--r--wp-admin/js/cat.js (renamed from wp-admin/cat.js)3
-rw-r--r--wp-admin/js/categories.js (renamed from wp-admin/categories.js)32
-rw-r--r--wp-admin/js/custom-fields.js (renamed from wp-admin/custom-fields.js)0
-rw-r--r--wp-admin/js/dbx-admin-key.js (renamed from wp-admin/dbx-admin-key.js)0
-rw-r--r--wp-admin/js/edit-comments.js (renamed from wp-admin/edit-comments.js)0
-rw-r--r--wp-admin/js/link-cat.js10
-rw-r--r--wp-admin/js/upload.js (renamed from wp-admin/upload.js)114
-rw-r--r--wp-admin/js/users.js (renamed from wp-admin/users.js)0
-rw-r--r--wp-admin/js/xfn.js (renamed from wp-admin/xfn.js)2
-rw-r--r--wp-admin/link-add.php2
-rw-r--r--wp-admin/link-category.php71
-rw-r--r--wp-admin/link-manager.php17
-rw-r--r--wp-admin/link.php2
-rw-r--r--wp-admin/menu.php3
-rw-r--r--wp-admin/moderation.php344
-rw-r--r--wp-admin/options-discussion.php100
-rw-r--r--wp-admin/options-general.php34
-rw-r--r--wp-admin/options-permalink.php44
-rw-r--r--wp-admin/options-reading.php84
-rw-r--r--wp-admin/options-writing.php36
-rw-r--r--wp-admin/options.php10
-rw-r--r--wp-admin/page-new.php4
-rw-r--r--wp-admin/page.php4
-rw-r--r--wp-admin/plugins.php28
-rw-r--r--wp-admin/post-new.php87
-rw-r--r--wp-admin/post.php7
-rw-r--r--wp-admin/profile.php8
-rw-r--r--wp-admin/rtl.css250
-rw-r--r--wp-admin/setup-config.php23
-rw-r--r--wp-admin/sidebar.php4
-rw-r--r--wp-admin/templates.php161
-rw-r--r--wp-admin/theme-editor.php153
-rw-r--r--wp-admin/themes.php4
-rw-r--r--wp-admin/update-links.php2
-rw-r--r--wp-admin/upgrade-functions.php1136
-rw-r--r--wp-admin/upgrade-schema.php471
-rw-r--r--wp-admin/upgrade.php11
-rw-r--r--wp-admin/upload-rtl.css50
-rw-r--r--wp-admin/upload.php9
-rw-r--r--wp-admin/users.php2
-rw-r--r--wp-admin/widgets-rtl.css40
-rw-r--r--wp-admin/widgets.php256
-rw-r--r--wp-admin/wp-admin.css93
108 files changed, 8381 insertions, 6664 deletions
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index 1bd5480..013e375 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -1,7 +1,6 @@
<?php
require_once('../wp-config.php');
-require_once('admin-functions.php');
-require_once('admin-db.php');
+require_once('includes/admin.php');
define('DOING_AJAX', true);
@@ -126,6 +125,28 @@ case 'add-category' : // On the Fly
}
$x->send();
break;
+case 'add-link-category' : // On the Fly
+ if ( !current_user_can( 'manage_categories' ) )
+ die('-1');
+ $names = explode(',', $_POST['newcat']);
+ $x = new WP_Ajax_Response();
+ foreach ( $names as $cat_name ) {
+ $cat_name = trim($cat_name);
+ if ( !$slug = sanitize_title($cat_name) )
+ die('0');
+ if ( !$cat_id = is_term( $cat_name, 'link_category' ) ) {
+ $cat_id = wp_insert_term( $cat_name, 'link_category' );
+ $cat_id = $cat_id['term_id'];
+ }
+ $cat_name = wp_specialchars(stripslashes($cat_name));
+ $x->add( array(
+ 'what' => 'link-category',
+ 'id' => $cat_id,
+ 'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>"
+ ) );
+ }
+ $x->send();
+ break;
case 'add-cat' : // From Manage->Categories
if ( !current_user_can( 'manage_categories' ) )
die('-1');
@@ -183,8 +204,11 @@ case 'add-meta' :
$now = current_time('timestamp', 1);
if ( $pid = wp_insert_post( array(
'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now))
- ) ) )
+ ) ) ) {
+ if ( is_wp_error( $pid ) )
+ return $pid;
$mid = add_meta( $pid );
+ }
else
die('0');
} else if ( !$mid = add_meta( $id ) ) {
diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php
deleted file mode 100644
index 662d56f..0000000
--- a/wp-admin/admin-db.php
+++ /dev/null
@@ -1,693 +0,0 @@
-<?php
-
-function get_users_drafts( $user_id ) {
- global $wpdb;
- $user_id = (int) $user_id;
- $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = $user_id ORDER BY ID DESC";
- $query = apply_filters('get_users_drafts', $query);
- return $wpdb->get_results( $query );
-}
-
-function get_others_drafts( $user_id ) {
- global $wpdb;
- $user = get_userdata( $user_id );
- $level_key = $wpdb->prefix . 'user_level';
-
- $editable = get_editable_user_ids( $user_id );
-
- if( !$editable ) {
- $other_drafts = '';
- } else {
- $editable = join(',', $editable);
- $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' ");
- }
-
- return apply_filters('get_others_drafts', $other_drafts);
-}
-
-function get_editable_authors( $user_id ) {
- global $wpdb;
-
- $editable = get_editable_user_ids( $user_id );
-
- if( !$editable ) {
- return false;
- } else {
- $editable = join(',', $editable);
- $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
- }
-
- return apply_filters('get_editable_authors', $authors);
-}
-
-function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
- global $wpdb;
-
- $user = new WP_User( $user_id );
-
- if ( ! $user->has_cap('edit_others_posts') ) {
- if ( $user->has_cap('edit_posts') || $exclude_zeros == false )
- return array($user->id);
- else
- return false;
- }
-
- // wpmu site admins don't have user_levels
- $level_key = $wpdb->prefix . 'capabilities';
-
- $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'";
- if ( $exclude_zeros )
- $query .= " AND meta_value != 'a:1:{s:10:\"subscriber\";b:1;}'";
-
- return $wpdb->get_col( $query );
-}
-
-function get_author_user_ids() {
- global $wpdb;
- $level_key = $wpdb->prefix . 'user_level';
-
- $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value != '0'";
-
- return $wpdb->get_col( $query );
-}
-
-function get_nonauthor_user_ids() {
- global $wpdb;
- $level_key = $wpdb->prefix . 'user_level';
-
- $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value = '0'";
-
- return $wpdb->get_col( $query );
-}
-
-function wp_insert_category($catarr) {
- global $wpdb;
-
- extract($catarr, EXTR_SKIP);
-
- if( trim( $cat_name ) == '' )
- return 0;
-
- $cat_ID = (int) $cat_ID;
-
- // Are we updating or creating?
- if (!empty ($cat_ID))
- $update = true;
- else
- $update = false;
-
- $cat_name = apply_filters('pre_category_name', $cat_name);
-
- if ( !$update && category_exists($cat_name) )
- return 0;
-
- if (empty ($category_nicename))
- $category_nicename = sanitize_title($cat_name);
- else
- $category_nicename = sanitize_title($category_nicename);
- $category_nicename = apply_filters('pre_category_nicename', $category_nicename);
-
- if (empty ($category_description))
- $category_description = '';
- $category_description = apply_filters('pre_category_description', $category_description);
-
- $category_parent = (int) $category_parent;
- if ( empty($category_parent) || !get_category( $category_parent ) || ($cat_ID && cat_is_ancestor_of($cat_ID, $category_parent) ) )
- $category_parent = 0;
-
- if ( isset($posts_private) )
- $posts_private = (int) $posts_private;
- else
- $posts_private = 0;
-
- if ( isset($links_private) )
- $links_private = (int) $links_private;
- else
- $links_private = 0;
-
- if (!$update) {
- $maxcat = $wpdb->get_var( "SELECT max(cat_ID) FROM {$wpdb->categories}" );
- $cat_ID = mt_rand( $maxcat+100, $maxcat+4000 );
- $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('$cat_ID', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
- } else {
- $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
- }
-
- if ( $category_nicename == '' ) {
- $category_nicename = sanitize_title($cat_name, $cat_ID );
- $wpdb->query( "UPDATE $wpdb->categories SET category_nicename = '$category_nicename' WHERE cat_ID = '$cat_ID'" );
- }
-
- // Keep in mind when using this filter and altering the cat_ID that the two queries above
- // have already taken place with the OLD cat_ID
- // Also note that you may have post2cat entries with the old cat_ID if this is an update
-
- if ($update) {
- do_action('edit_category', $cat_ID);
- } else {
- do_action('create_category', $cat_ID);
- do_action('add_category', $cat_ID);
- }
-
- $cat_ID = apply_filters('cat_id_filter', $cat_ID, $update);
-
- clean_category_cache($cat_ID);
-
- if ($update)
- do_action('edited_category', $cat_ID);
- else
- do_action('created_category', $cat_ID);
-
- return $cat_ID;
-}
-
-function wp_update_category($catarr) {
- global $wpdb;
-
- $cat_ID = (int) $catarr['cat_ID'];
-
- if( $cat_ID == $catarr['category_parent'] )
- return false;
-
- // First, get all of the original fields
- $category = get_category($cat_ID, ARRAY_A);
-
- // Escape data pulled from DB.
- $category = add_magic_quotes($category);
-
- // Merge old and new fields with new fields overwriting old ones.
- $catarr = array_merge($category, $catarr);
-
- return wp_insert_category($catarr);
-}
-
-function wp_delete_category($cat_ID) {
- global $wpdb;
-
- $cat_ID = (int) $cat_ID;
- $default_cat = get_option('default_category');
- $default_link_cat = get_option('default_link_category');
-
- // Don't delete either of the default cats
- if ( $cat_ID == $default_cat || $cat_ID == $default_link_cat )
- return 0;
-
- $category = get_category($cat_ID);
-
- $parent = $category->category_parent;
-
- // Delete the category
- if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") )
- return 0;
-
- // Update children to point to new parent
- $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'");
-
- // Only set posts and links to the default category if they're not in another category already
- $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
- foreach ( (array) $posts as $post_id ) {
- $cats = wp_get_post_categories($post_id);
- if ( 1 == count($cats) )
- $cats = array($default_cat);
- else
- $cats = array_diff($cats, array($cat_ID));
- wp_set_post_categories($post_id, $cats);
- }
-
- $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
- foreach ( (array) $links as $link_id ) {
- $cats = wp_get_link_cats($link_id);
- if ( 1 == count($cats) )
- $cats = array($default_link_cat);
- else
- $cats = array_diff($cats, array($cat_ID));
- wp_set_link_cats($link_id, $cats);
- }
-
- clean_category_cache($cat_ID);
- do_action('delete_category', $cat_ID);
- return 1;
-}
-
-function wp_create_category($cat_name) {
- $cat_array = compact('cat_name');
- return wp_insert_category($cat_array);
-}
-
-function wp_create_categories($categories, $post_id = '') {
- $cat_ids = array ();
- foreach ($categories as $category) {
- if ($id = category_exists($category))
- $cat_ids[] = $id;
- else
- if ($id = wp_create_category($category))
- $cat_ids[] = $id;
- }
-
- if ($post_id)
- wp_set_post_categories($post_id, $cat_ids);
-
- return $cat_ids;
-}
-
-function category_exists($cat_name) {
- global $wpdb;
- if (!$category_nicename = sanitize_title($cat_name))
- return 0;
-
- return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
-}
-
-function wp_delete_user($id, $reassign = 'novalue') {
- global $wpdb;
-
- $id = (int) $id;
- $user = get_userdata($id);
-
- if ($reassign == 'novalue') {
- $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
-
- if ($post_ids) {
- foreach ($post_ids as $post_id)
- wp_delete_post($post_id);
- }
-
- // Clean links
- $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
- } else {
- $reassign = (int) $reassign;
- $wpdb->query("UPDATE $wpdb->posts SET post_author = {$reassign} WHERE post_author = {$id}");
- $wpdb->query("UPDATE $wpdb->links SET link_owner = {$reassign} WHERE link_owner = {$id}");
- }
-
- // FINALLY, delete user
- do_action('delete_user', $id);
-
- $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$wpdb->prefix}capabilities'");
-
- wp_cache_delete($id, 'users');
- wp_cache_delete($user->user_login, 'userlogins');
-
- return true;
-}
-
-function wp_revoke_user($id) {
- $id = (int) $id;
-
- $user = new WP_User($id);
- $user->remove_all_caps();
-}
-
-function wp_insert_link($linkdata) {
- global $wpdb, $current_user;
-
- extract($linkdata, EXTR_SKIP);
-
- $update = false;
-
- if ( !empty($link_id) )
- $update = true;
-
- $link_id = (int) $link_id;
-
- if( trim( $link_name ) == '' )
- return 0;
- $link_name = apply_filters('pre_link_name', $link_name);
-
- if( trim( $link_url ) == '' )
- return 0;
- $link_url = apply_filters('pre_link_url', $link_url);
-
- if ( empty($link_rating) )
- $link_rating = 0;
- else
- $link_rating = (int) $link_rating;
-
- if ( empty($link_image) )
- $link_image = '';
- $link_image = apply_filters('pre_link_image', $link_image);
-
- if ( empty($link_target) )
- $link_target = '';
- $link_target = apply_filters('pre_link_target', $link_target);
-
- if ( empty($link_visible) )
- $link_visible = 'Y';
- $link_visibile = preg_replace('/[^YNyn]/', '', $link_visible);
-
- if ( empty($link_owner) )
- $link_owner = $current_user->id;
- else
- $link_owner = (int) $link_owner;
-
- if ( empty($link_notes) )
- $link_notes = '';
- $link_notes = apply_filters('pre_link_notes', $link_notes);
-
- if ( empty($link_description) )
- $link_description = '';
- $link_description = apply_filters('pre_link_description', $link_description);
-
- if ( empty($link_rss) )
- $link_rss = '';
- $link_rss = apply_filters('pre_link_rss', $link_rss);
-
- if ( empty($link_rel) )
- $link_rel = '';
- $link_rel = apply_filters('pre_link_rel', $link_rel);
-
- // Make sure we set a valid category
- if (0 == count($link_category) || !is_array($link_category)) {
- $link_category = array(get_option('default_link_category'));
- }
-
- if ( $update ) {
- $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url',
- link_name='$link_name', link_image='$link_image',
- link_target='$link_target',
- link_visible='$link_visible', link_description='$link_description',
- link_rating='$link_rating', link_rel='$link_rel',
- link_notes='$link_notes', link_rss = '$link_rss'
- WHERE link_id='$link_id'");
- } else {
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
- $link_id = (int) $wpdb->insert_id;
- }
-
- wp_set_link_cats($link_id, $link_category);
-
- if ( $update )
- do_action('edit_link', $link_id);
- else
- do_action('add_link', $link_id);
-
- return $link_id;
-}
-
-function wp_update_link($linkdata) {
- global $wpdb;
-
- $link_id = (int) $linkdata['link_id'];
-
- $link = get_link($link_id, ARRAY_A);
-
- // Escape data pulled from DB.
- $link = add_magic_quotes($link);
-
- // Passed link category list overwrites existing category list if not empty.
- if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
- && 0 != count($linkdata['link_category']) )
- $link_cats = $linkdata['link_category'];
- else
- $link_cats = $link['link_category'];
-
- // Merge old and new fields with new fields overwriting old ones.
- $linkdata = array_merge($link, $linkdata);
- $linkdata['link_category'] = $link_cats;
-
- return wp_insert_link($linkdata);
-}
-
-function wp_delete_link($link_id) {
- global $wpdb;
-
- do_action('delete_link', $link_id);
-
- $categories = wp_get_link_cats($link_id);
- if( is_array( $categories ) ) {
- foreach ( $categories as $category ) {
- $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'");
- wp_cache_delete($category, 'category');
- do_action('edit_category', $cat_id);
- }
- }
-
- $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'");
- $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
-
- do_action('deleted_link', $link_id);
-
- return true;
-}
-
-function wp_get_link_cats($link_ID = 0) {
- global $wpdb;
-
- $sql = "SELECT category_id
- FROM $wpdb->link2cat
- WHERE link_id = $link_ID
- ORDER BY category_id";
-
- $result = $wpdb->get_col($sql);
-
- if ( !$result )
- $result = array();
-
- return array_unique($result);
-}
-
-function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
- global $wpdb;
- // If $link_categories isn't already an array, make it one:
- if (!is_array($link_categories) || 0 == count($link_categories))
- $link_categories = array(get_option('default_link_category'));
-
- $link_categories = array_unique($link_categories);
-
- // First the old categories
- $old_categories = $wpdb->get_col("
- SELECT category_id
- FROM $wpdb->link2cat
- WHERE link_id = '$link_ID'");
-
- if (!$old_categories) {
- $old_categories = array();
- } else {
- $old_categories = array_unique($old_categories);
- }
-
- // Delete any?
- $delete_cats = array_diff($old_categories,$link_categories);
-
- if ($delete_cats) {
- foreach ($delete_cats as $del) {
- $del = (int) $del;
- $wpdb->query("
- DELETE FROM $wpdb->link2cat
- WHERE category_id = '$del'
- AND link_id = '$link_ID'
- ");
- }
- }
-
- // Add any?
- $add_cats = array_diff($link_categories, $old_categories);
-
- if ($add_cats) {
- foreach ($add_cats as $new_cat) {
- $new_cat = (int) $new_cat;
- if ( !empty($new_cat) )
- $wpdb->query("
- INSERT INTO $wpdb->link2cat (link_id, category_id)
- VALUES ('$link_ID', '$new_cat')");
- }
- }
-
- // Update category counts.
- $all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
- foreach ( $all_affected_cats as $cat_id ) {
- $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
- $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
- wp_cache_delete($cat_id, 'category');
- clean_category_cache($cat_id);
- do_action('edit_category', $cat_id);
- }
-
-} // wp_set_link_cats()
-
-function post_exists($title, $content = '', $post_date = '') {
- global $wpdb;
-
- if (!empty ($post_date))
- $post_date = "AND post_date = '$post_date'";
-
- if (!empty ($title))
- return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' $post_date");
- else
- if (!empty ($content))
- return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' $post_date");
-
- return 0;
-}
-
-function comment_exists($comment_author, $comment_date) {
- global $wpdb;
-
- return $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments
- WHERE comment_author = '$comment_author' AND comment_date = '$comment_date'");
-}
-
-function wpmu_delete_blog($blog_id, $drop = false) {
- global $wpdb, $wpmuBaseTablePrefix;
-
- if ( $blog_id != $wpdb->blogid ) {
- $switch = true;
- switch_to_blog($blog_id);
- }
-
- do_action('delete_blog', $blog_id, $drop);
-
- $users = get_users_of_blog($blog_id);
-
- // Remove users from this blog.
- if ( !empty($users) ) foreach ($users as $user) {
- remove_user_from_blog($user->user_id, $blog_id);
- }
-
- update_blog_status( $wpdb->blogid, 'deleted', 1 );
-
- if ( $drop ) {
- $drop_tables = array( $wpmuBaseTablePrefix . $blog_id . "_categories",
- $wpmuBaseTablePrefix . $blog_id . "_comments",
- $wpmuBaseTablePrefix . $blog_id . "_linkcategories",
- $wpmuBaseTablePrefix . $blog_id . "_links",
- $wpmuBaseTablePrefix . $blog_id . "_link2cat",
- $wpmuBaseTablePrefix . $blog_id . "_options",
- $wpmuBaseTablePrefix . $blog_id . "_post2cat",
- $wpmuBaseTablePrefix . $blog_id . "_postmeta",
- $wpmuBaseTablePrefix . $blog_id . "_posts",
- $wpmuBaseTablePrefix . $blog_id . "_referer_visitLog",
- $wpmuBaseTablePrefix . $blog_id . "_referer_blacklist" );
- reset( $drop_tables );
-
- foreach ($drop_tables as $drop_table)
- $wpdb->query( "DROP TABLE IF EXISTS $drop_table" );
-
- $wpdb->query( "DELETE FROM $wpdb->blogs WHERE blog_id = '$blog_id'" );
- $dir = constant( "ABSPATH" ) . "wp-content/blogs.dir/" . $blog_id ."/files/";
- $dir = rtrim($dir, DIRECTORY_SEPARATOR);
- $top_dir = $dir;
- $stack = array($dir);
- $index = 0;
-
- while ($index < count($stack)) {
- # Get indexed directory from stack
- $dir = $stack[$index];
-
- $dh = @ opendir($dir);
- if ($dh) {
- while (($file = @ readdir($dh)) !== false) {
- if ($file == '.' or $file == '..')
- continue;
-
- if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
- $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
- else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file))
- @ unlink($dir . DIRECTORY_SEPARATOR . $file);
- }
- }
- $index++;
- }
-
- $stack = array_reverse($stack); // Last added dirs are deepest
- foreach($stack as $dir) {
- if ( $dir != $top_dir)
- @ rmdir($dir);
- }
- }
- $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key='wp_{$blog_id}_autosave_draft_ids'");
-
- if ( $switch )
- restore_current_blog();
-}
-
-function wpmu_delete_user($id) {
- global $wpdb;
-
- $id = (int) $id;
- $user = get_userdata($id);
-
- do_action('wpmu_delete_user', $id);
-
- $blogs = get_blogs_of_user($id);
-
- if ( ! empty($blogs) ) foreach ($blogs as $blog) {
- switch_to_blog($blog->userblog_id);
- remove_user_from_blog($id, $blog->userblog_id);
-
- $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
-
- if ($post_ids) {
- foreach ($post_ids as $post_id)
- wp_delete_post($post_id);
- }
-
- // Clean links
- $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
-
- restore_current_blog();
- }
-
- $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id");
- $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$id'");
-
- wp_cache_delete($id, 'users');
- wp_cache_delete($user->user_login, 'userlogins');
-
- return true;
-}
-
-function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
- $themes = get_themes();
- if( $blog_id == 0 )
- $blog_allowed_themes = get_option( "allowedthemes" );
- else
- $blog_allowed_themes = get_blog_option( $blog_id, "allowedthemes" );
- if( !is_array( $blog_allowed_themes ) || empty( $blog_allowed_themes ) ) { // convert old allowed_themes to new allowedthemes
- if( $blog_id == 0 )
- $blog_allowed_themes = get_option( "allowed_themes" );
- else
- $blog_allowed_themes = get_blog_option( $blog_id, "allowed_themes" );
- if( is_array( $blog_allowed_themes ) ) {
- foreach( $themes as $key => $theme ) {
- $theme_key = wp_specialchars( $theme[ 'Stylesheet' ] );
- if( isset( $blog_allowed_themes[ $key ] ) == true ) {
- $blog_allowedthemes[ $theme_key ] = 1;
- }
- }
- $blog_allowed_themes = $blog_allowedthemes;
- if( $blog_id == 0 ) {
- add_option( "allowedthemes", $blog_allowed_themes );
- delete_option( "allowed_themes" );
- } else {
- add_blog_option( $blog_id, "allowedthemes", $blog_allowed_themes );
- delete_blog_option( $blog_id, "allowed_themes" );
- }
- }
- }
-
- return $blog_allowed_themes;
-}
-
-function get_site_allowed_themes() {
- $themes = get_themes();
- $allowed_themes = get_site_option( 'allowedthemes' );
- if( !is_array( $allowed_themes ) || empty( $allowed_themes ) ) {
- $allowed_themes = get_site_option( "allowed_themes" ); // convert old allowed_themes format
- if( !is_array( $allowed_themes ) ) {
- $allowed_themes = array();
- } else {
- foreach( $themes as $key => $theme ) {
- $theme_key = wp_specialchars( $theme[ 'Stylesheet' ] );
- if( isset( $allowed_themes[ $key ] ) == true ) {
- $allowedthemes[ $theme_key ] = 1;
- }
- }
- $allowed_themes = $allowedthemes;
- }
- }
-
- return $allowed_themes;
-}
-
-?>
diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php
index 8e30631..c3ef7c4 100644
--- a/wp-admin/admin-footer.php
+++ b/wp-admin/admin-footer.php
@@ -1,8 +1,9 @@
<div id="footer">
-<p class="logo"><a href="http://wordpress.org/" id="wordpress-logo"><img src="images/wordpress-logo.png" alt="WordPress" /></a></p>
-<p class="docs"><?php _e('<a href="http://codex.wordpress.org/">Documentation</a>'); ?> &#8212; <?php _e('<a href="http://wordpress.org/support/">Support Forums</a>'); ?><br />
-<?php bloginfo('version'); ?> &#8212; <?php printf(__('%s seconds'), timer_stop(0, 2)); ?></p>
+<p><?php
+
+$upgrade = apply_filters( 'update_footer', '' );
+echo __('Thank you for creating with <a href="http://mu.wordpress.org/">WordPress MU</a>').' | '.__('<a href="http://codex.wordpress.org/">Documentation</a>') ?></p>
</div>
<?php do_action('admin_footer', ''); ?>
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index cb53fd3..9064d19 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -1,2388 +1,4 @@
<?php
-
-function write_post() {
- $result = wp_write_post();
- if( is_wp_error( $result ) )
- wp_die( $result->get_error_message() );
- else
- return $result;
-}
-
-// Creates a new post from the "Write Post" form using $_POST information.
-function wp_write_post() {
- global $user_ID;
-
- if ( 'page' == $_POST['post_type'] ) {
- if ( !current_user_can( 'edit_pages' ) )
- return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this blog.' ) );
- } else {
- if ( !current_user_can( 'edit_posts' ) )
- return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) );
- }
-
-
- // Check for autosave collisions
- $temp_id = false;
- if ( isset($_POST['temp_ID']) ) {
- $temp_id = (int) $_POST['temp_ID'];
- if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
- $draft_ids = array();
- foreach ( $draft_ids as $temp => $real )
- if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then )
- unset($draft_ids[$temp]);
-
- if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write
- $_POST['post_ID'] = $draft_ids[$temp_id];
- unset($_POST['temp_ID']);
- update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
- return edit_post();
- }
- }
-
- // Rename.
- $_POST['post_content'] = $_POST['content'];
- $_POST['post_excerpt'] = $_POST['excerpt'];
- $_POST['post_parent'] = $_POST['parent_id'];
- $_POST['to_ping'] = $_POST['trackback_url'];
-
- if (!empty ( $_POST['post_author_override'] ) ) {
- $_POST['post_author'] = (int) $_POST['post_author_override'];
- } else {
- if (!empty ( $_POST['post_author'] ) ) {
- $_POST['post_author'] = (int) $_POST['post_author'];
- } else {
- $_POST['post_author'] = (int) $_POST['user_ID'];
- }
-
- }
-
- if ( $_POST['post_author'] != $_POST['user_ID'] ) {
- if ( 'page' == $_POST['post_type'] ) {
- if ( !current_user_can( 'edit_others_pages' ) )
- return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
- } else {
- if ( !current_user_can( 'edit_others_posts' ) )
- return new WP_Error( 'edit_others_posts', __( 'You are not allowed to post as this user.' ) );
-
- }
- }
-
- // What to do based on which button they pressed
- if ('' != $_POST['saveasdraft'] )
- $_POST['post_status'] = 'draft';
- if ('' != $_POST['saveasprivate'] )
- $_POST['post_status'] = 'private';
- if ('' != $_POST['publish'] )
- $_POST['post_status'] = 'publish';
- if ('' != $_POST['advanced'] )
- $_POST['post_status'] = 'draft';
-
- if ( 'page' == $_POST['post_type'] ) {
- if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) )
- $_POST['post_status'] = 'draft';
- } else {
- if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) )
- $_POST['post_status'] = 'draft';
- }
-
- if (!isset( $_POST['comment_status'] ))
- $_POST['comment_status'] = 'closed';
-
- if (!isset( $_POST['ping_status'] ))
- $_POST['ping_status'] = 'closed';
-
- if (!empty ( $_POST['edit_date'] ) ) {
- $aa = $_POST['aa'];
- $mm = $_POST['mm'];
- $jj = $_POST['jj'];
- $hh = $_POST['hh'];
- $mn = $_POST['mn'];
- $ss = $_POST['ss'];
- $jj = ($jj > 31 ) ? 31 : $jj;
- $hh = ($hh > 23 ) ? $hh -24 : $hh;
- $mn = ($mn > 59 ) ? $mn -60 : $mn;
- $ss = ($ss > 59 ) ? $ss -60 : $ss;
- $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
- $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date'] );
- }
-
- unset($_POST['no_filter']);
-
- // Create the post.
- $post_ID = wp_insert_post( $_POST );
-
- add_meta( $post_ID );
-
- // Reunite any orphaned attachments with their parent
- if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
- $draft_ids = array();
- if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
- relocate_children( $draft_temp_id, $post_ID );
- if ( $temp_id && $temp_id != $draft_temp_id )
- relocate_children( $temp_id, $post_ID );
-
- // Update autosave collision detection
- if ( $temp_id ) {
- $draft_ids[$temp_id] = $post_ID;
- update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
- }
-
- // Now that we have an ID we can fix any attachment anchor hrefs
- fix_attachment_links( $post_ID );
-
- return $post_ID;
-}
-
-// Move child posts to a new parent
-function relocate_children( $old_ID, $new_ID ) {
- global $wpdb;
- $old_ID = (int) $old_ID;
- $new_ID = (int) $new_ID;
- return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" );
-}
-
-// Replace hrefs of attachment anchors with up-to-date permalinks.
-function fix_attachment_links( $post_ID ) {
- global $wp_rewrite;
-
- $post = & get_post( $post_ID, ARRAY_A );
-
- $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
-
- // See if we have any rel="attachment" links
- if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) )
- return;
-
- $i = 0;
- $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i";
- foreach ( $anchor_matches[0] as $anchor ) {
- if ( 0 == preg_match( $search, $anchor, $id_matches ) )
- continue;
-
- $id = (int) $id_matches[3];
-
- // While we have the attachment ID, let's adopt any orphans.
- $attachment = & get_post( $id, ARRAY_A );
- if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) {
- $attachment['post_parent'] = $post_ID;
- // Escape data pulled from DB.
- $attachment = add_magic_quotes( $attachment);
- wp_update_post( $attachment);
- }
-
- $post_search[$i] = $anchor;
- $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor );
- ++$i;
- }
-
- $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] );
-
- // Escape data pulled from DB.
- $post = add_magic_quotes( $post);
-
- return wp_update_post( $post);
-}
-
-// Update an existing post with values provided in $_POST.
-function edit_post() {
- global $user_ID;
-
- $post_ID = (int) $_POST['post_ID'];
-
- if ( 'page' == $_POST['post_type'] ) {
- if ( !current_user_can( 'edit_page', $post_ID ) )
- wp_die( __('You are not allowed to edit this page.' ));
- } else {
- if ( !current_user_can( 'edit_post', $post_ID ) )
- wp_die( __('You are not allowed to edit this post.' ));
- }
-
- // Autosave shouldn't save too soon after a real save
- if ( 'autosave' == $_POST['action'] ) {
- $post =& get_post( $post_ID );
- $now = time();
- $then = strtotime($post->post_date_gmt . ' +0000');
- // Keep autosave_interval in sync with autosave-js.php.
- $delta = apply_filters( 'autosave_interval', 120 ) / 2;
- if ( ($now - $then) < $delta )
- return $post_ID;
- }
-
- // Rename.
- $_POST['ID'] = (int) $_POST['post_ID'];
- $_POST['post_content'] = $_POST['content'];
- $_POST['post_excerpt'] = $_POST['excerpt'];
- $_POST['post_parent'] = $_POST['parent_id'];
- $_POST['to_ping'] = $_POST['trackback_url'];
-
- if (!empty ( $_POST['post_author_override'] ) ) {
- $_POST['post_author'] = (int) $_POST['post_author_override'];
- } else
- if (!empty ( $_POST['post_author'] ) ) {
- $_POST['post_author'] = (int) $_POST['post_author'];
- } else {
- $_POST['post_author'] = (int) $_POST['user_ID'];
- }
-
- if ( $_POST['post_author'] != $_POST['user_ID'] ) {
- if ( 'page' == $_POST['post_type'] ) {
- if ( !current_user_can( 'edit_others_pages' ) )
- wp_die( __('You are not allowed to edit pages as this user.' ));
- } else {
- if ( !current_user_can( 'edit_others_posts' ) )
- wp_die( __('You are not allowed to edit posts as this user.' ));
-
- }
- }
-
- // What to do based on which button they pressed
- if ('' != $_POST['saveasdraft'] )
- $_POST['post_status'] = 'draft';
- if ('' != $_POST['saveasprivate'] )
- $_POST['post_status'] = 'private';
- if ('' != $_POST['publish'] )
- $_POST['post_status'] = 'publish';
- if ('' != $_POST['advanced'] )
- $_POST['post_status'] = 'draft';
-
- if ( 'page' == $_POST['post_type'] ) {
- if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' ))
- $_POST['post_status'] = 'draft';
- } else {
- if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' ))
- $_POST['post_status'] = 'draft';
- }
-
- if (!isset( $_POST['comment_status'] ))
- $_POST['comment_status'] = 'closed';
-
- if (!isset( $_POST['ping_status'] ))
- $_POST['ping_status'] = 'closed';
-
- if (!empty ( $_POST['edit_date'] ) ) {
- $aa = $_POST['aa'];
- $mm = $_POST['mm'];
- $jj = $_POST['jj'];
- $hh = $_POST['hh'];
- $mn = $_POST['mn'];
- $ss = $_POST['ss'];
- $jj = ($jj > 31 ) ? 31 : $jj;
- $hh = ($hh > 23 ) ? $hh -24 : $hh;
- $mn = ($mn > 59 ) ? $mn -60 : $mn;
- $ss = ($ss > 59 ) ? $ss -60 : $ss;
- $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
- $_POST['post_date_gmt'] = get_gmt_from_date( "$aa-$mm-$jj $hh:$mn:$ss" );
- }
-
- // Meta Stuff
- if ( $_POST['meta'] ) {
- foreach ( $_POST['meta'] as $key => $value )
- update_meta( $key, $value['key'], $value['value'] );
- }
-
- if ( $_POST['deletemeta'] ) {
- foreach ( $_POST['deletemeta'] as $key => $value )
- delete_meta( $key );
- }
-
- unset($_POST['no_filter']);
-
- add_meta( $post_ID );
-
- wp_update_post( $_POST );
-
- // Reunite any orphaned attachments with their parent
- if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
- $draft_ids = array();
- if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
- relocate_children( $draft_temp_id, $post_ID );
-
- // Now that we have an ID we can fix any attachment anchor hrefs
- fix_attachment_links( $post_ID );
-
- return $post_ID;
-}
-
-function edit_comment() {
- global $user_ID;
-
- $comment_ID = (int) $_POST['comment_ID'];
- $comment_post_ID = (int) $_POST['comment_post_ID'];
-
- if (!current_user_can( 'edit_post', $comment_post_ID ))
- wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' ));
-
- $_POST['comment_author'] = $_POST['newcomment_author'];
- $_POST['comment_author_email'] = $_POST['newcomment_author_email'];
- $_POST['comment_author_url'] = $_POST['newcomment_author_url'];
- $_POST['comment_approved'] = $_POST['comment_status'];
- $_POST['comment_content'] = $_POST['content'];
- $_POST['comment_ID'] = (int) $_POST['comment_ID'];
-
- if (!empty ( $_POST['edit_date'] ) ) {
- $aa = $_POST['aa'];
- $mm = $_POST['mm'];
- $jj = $_POST['jj'];
- $hh = $_POST['hh'];
- $mn = $_POST['mn'];
- $ss = $_POST['ss'];
- $jj = ($jj > 31 ) ? 31 : $jj;
- $hh = ($hh > 23 ) ? $hh -24 : $hh;
- $mn = ($mn > 59 ) ? $mn -60 : $mn;
- $ss = ($ss > 59 ) ? $ss -60 : $ss;
- $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
- }
-
- wp_update_comment( $_POST);
-}
-
-// Get an existing post and format it for editing.
-function get_post_to_edit( $id ) {
-
- $post = get_post( $id );
-
- $post->post_content = format_to_edit( $post->post_content, user_can_richedit() );
- $post->post_content = apply_filters( 'content_edit_pre', $post->post_content);
-
- $post->post_excerpt = format_to_edit( $post->post_excerpt);
- $post->post_excerpt = apply_filters( 'excerpt_edit_pre', $post->post_excerpt);
-
- $post->post_title = format_to_edit( $post->post_title );
- $post->post_title = apply_filters( 'title_edit_pre', $post->post_title );
-
- $post->post_password = format_to_edit( $post->post_password );
-
- $post->menu_order = (int) $post->menu_order;
-
- if ( $post->post_type == 'page' )
- $post->page_template = get_post_meta( $id, '_wp_page_template', true );
-
- return $post;
-}
-
-// Default post information to use when populating the "Write Post" form.
-function get_default_post_to_edit() {
- if ( !empty( $_REQUEST['post_title'] ) )
- $post_title = wp_specialchars( stripslashes( $_REQUEST['post_title'] ));
- else if ( !empty( $_REQUEST['popuptitle'] ) ) {
- $post_title = wp_specialchars( stripslashes( $_REQUEST['popuptitle'] ));
- $post_title = funky_javascript_fix( $post_title );
- } else {
- $post_title = '';
- }
-
- if ( !empty( $_REQUEST['content'] ) )
- $post_content = wp_specialchars( stripslashes( $_REQUEST['content'] ));
- else if ( !empty( $post_title ) ) {
- $text = wp_specialchars( stripslashes( urldecode( $_REQUEST['text'] ) ) );
- $text = funky_javascript_fix( $text);
- $popupurl = clean_url($_REQUEST['popupurl']);
- $post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\n$text";
- }
-
- if ( !empty( $_REQUEST['excerpt'] ) )
- $post_excerpt = wp_specialchars( stripslashes( $_REQUEST['excerpt'] ));
- else
- $post_excerpt = '';
-
- $post->post_status = 'draft';
- $post->comment_status = get_option( 'default_comment_status' );
- $post->ping_status = get_option( 'default_ping_status' );
- $post->post_pingback = get_option( 'default_pingback_flag' );
- $post->post_category = get_option( 'default_category' );
- $post->post_content = apply_filters( 'default_content', $post_content);
- $post->post_title = apply_filters( 'default_title', $post_title );
- $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);
- $post->page_template = 'default';
- $post->post_parent = 0;
- $post->menu_order = 0;
-
- return $post;
-}
-
-function get_comment_to_edit( $id ) {
- $comment = get_comment( $id );
-
- $comment->comment_ID = (int) $comment->comment_ID;
- $comment->comment_post_ID = (int) $comment->comment_post_ID;
-
- $comment->comment_content = format_to_edit( $comment->comment_content );
- $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content);
-
- $comment->comment_author = format_to_edit( $comment->comment_author );
- $comment->comment_author_email = format_to_edit( $comment->comment_author_email );
- $comment->comment_author_url = clean_url($comment->comment_author_url);
- $comment->comment_author_url = format_to_edit( $comment->comment_author_url );
-
- return $comment;
-}
-
-function get_category_to_edit( $id ) {
- $category = get_category( $id );
-
- $category->term_id = (int) $category->term_id;
- $category->parent = (int) $category->parent;
-
- return $category;
-}
-
-function wp_dropdown_roles( $default = false ) {
- global $wp_roles;
- $r = '';
- foreach( $wp_roles->role_names as $role => $name )
- if ( $default == $role ) // Make default first in list
- $p = "\n\t<option selected='selected' value='$role'>$name</option>";
- else
- $r .= "\n\t<option value='$role'>$name</option>";
- echo $p . $r;
-}
-
-
-function get_user_to_edit( $user_id ) {
- $user = new WP_User( $user_id );
- $user->user_login = attribute_escape($user->user_login);
- $user->user_email = attribute_escape($user->user_email);
- $user->user_url = clean_url($user->user_url);
- $user->first_name = attribute_escape($user->first_name);
- $user->last_name = attribute_escape($user->last_name);
- $user->display_name = attribute_escape($user->display_name);
- $user->nickname = attribute_escape($user->nickname);
- $user->aim = attribute_escape($user->aim);
- $user->yim = attribute_escape($user->yim);
- $user->jabber = attribute_escape($user->jabber);
- $user->description = wp_specialchars($user->description);
-
- return $user;
-}
-
-// Creates a new user from the "Users" form using $_POST information.
-
-function add_user() {
- if ( func_num_args() ) { // The hackiest hack that ever did hack
- global $current_user, $wp_roles;
- $user_id = (int) func_get_arg( 0 );
-
- if ( isset( $_POST['role'] ) ) {
- if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap( 'edit_users' ) ) {
- $user = new WP_User( $user_id );
- $user->set_role( $_POST['role'] );
- }
- }
- } else {
- add_action( 'user_register', 'add_user' ); // See above
- return edit_user();
- }
-}
-
-function edit_user( $user_id = 0 ) {
- global $current_user, $wp_roles, $wpdb;
- if ( $user_id != 0 ) {
- $update = true;
- $user->ID = (int) $user_id;
- $userdata = get_userdata( $user_id );
- $user->user_login = $wpdb->escape( $userdata->user_login );
- } else {
- $update = false;
- $user = '';
- }
-
- if ( isset( $_POST['user_login'] ))
- $user->user_login = wp_specialchars( trim( $_POST['user_login'] ));
-
- $pass1 = $pass2 = '';
- if ( isset( $_POST['pass1'] ))
- $pass1 = $_POST['pass1'];
- if ( isset( $_POST['pass2'] ))
- $pass2 = $_POST['pass2'];
-
- if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) {
- if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap( 'edit_users' ))
- $user->role = $_POST['role'];
- }
-
- if ( isset( $_POST['email'] ))
- $user->user_email = wp_specialchars( trim( $_POST['email'] ));
- if ( isset( $_POST['url'] ) ) {
- $user->user_url = clean_url( trim( $_POST['url'] ));
- $user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
- }
- if ( isset( $_POST['first_name'] ))
- $user->first_name = wp_specialchars( trim( $_POST['first_name'] ));
- if ( isset( $_POST['last_name'] ))
- $user->last_name = wp_specialchars( trim( $_POST['last_name'] ));
- if ( isset( $_POST['nickname'] ))
- $user->nickname = wp_specialchars( trim( $_POST['nickname'] ));
- if ( isset( $_POST['display_name'] ))
- $user->display_name = wp_specialchars( trim( $_POST['display_name'] ));
- if ( isset( $_POST['description'] ))
- $user->description = trim( $_POST['description'] );
- if ( isset( $_POST['jabber'] ))
- $user->jabber = wp_specialchars( trim( $_POST['jabber'] ));
- if ( isset( $_POST['aim'] ))
- $user->aim = wp_specialchars( trim( $_POST['aim'] ));
- if ( isset( $_POST['yim'] ))
- $user->yim = wp_specialchars( trim( $_POST['yim'] ));
- if ( !$update )
- $user->rich_editing = 'true'; // Default to true for new users.
- else if ( isset( $_POST['rich_editing'] ) )
- $user->rich_editing = $_POST['rich_editing'];
- else
- $user->rich_editing = 'false';
-
- $errors = new WP_Error();
-
- /* checking that username has been typed */
- if ( $user->user_login == '' )
- $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ));
-
- /* checking the password has been typed twice */
- do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 ));
-
- if (!$update ) {
- if ( $pass1 == '' || $pass2 == '' )
- $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' ));
- } else {
- if ((empty ( $pass1 ) && !empty ( $pass2 ) ) || (empty ( $pass2 ) && !empty ( $pass1 ) ) )
- $errors->add( 'pass', __( "<strong>ERROR</strong>: you typed your new password only once." ));
- }
-
- /* Check for "\" in password */
- if( strpos( " ".$pass1, "\\" ) )
- $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ));
-
- /* checking the password has been typed twice the same */
- if ( $pass1 != $pass2 )
- $errors->add( 'pass', __( '<strong>ERROR</strong>: Please type the same password in the two password fields.' ));
-
- if (!empty ( $pass1 ))
- $user->user_pass = $pass1;
-
- if ( !$update && !validate_username( $user->user_login ) )
- $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' ));
-
- if (!$update && username_exists( $user->user_login ))
- $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered, please choose another one.' ));
-
- /* checking e-mail address */
- if ( empty ( $user->user_email ) ) {
- $errors->add( 'user_email', __( "<strong>ERROR</strong>: please type an e-mail address" ));
- } else
- if (!is_email( $user->user_email ) ) {
- $errors->add( 'user_email', __( "<strong>ERROR</strong>: the email address isn't correct" ));
- }
-
- if ( $errors->get_error_codes() )
- return $errors;
-
- if ( $update ) {
- $user_id = wp_update_user( get_object_vars( $user ));
- } else {
- $user_id = wp_insert_user( get_object_vars( $user ));
- wp_new_user_notification( $user_id );
- }
- return $user_id;
-}
-
-
-function get_link_to_edit( $link_id ) {
- $link = get_link( $link_id );
-
- $link->link_url = clean_url($link->link_url);
- $link->link_name = attribute_escape($link->link_name);
- $link->link_image = attribute_escape($link->link_image);
- $link->link_description = attribute_escape($link->link_description);
- $link->link_rss = clean_url($link->link_rss);
- $link->link_rel = attribute_escape($link->link_rel);
- $link->link_notes = wp_specialchars($link->link_notes);
- $link->post_category = $link->link_category;
-
- return $link;
-}
-
-function get_default_link_to_edit() {
- if ( isset( $_GET['linkurl'] ) )
- $link->link_url = clean_url( $_GET['linkurl']);
- else
- $link->link_url = '';
-
- if ( isset( $_GET['name'] ) )
- $link->link_name = attribute_escape( $_GET['name']);
- else
- $link->link_name = '';
-
- $link->link_visible = 'Y';
-
- return $link;
-}
-
-function add_link() {
- return edit_link();
-}
-
-function edit_link( $link_id = '' ) {
- if (!current_user_can( 'manage_links' ))
- wp_die( __( 'Cheatin&#8217; uh?' ));
-
- $_POST['link_url'] = wp_specialchars( $_POST['link_url'] );
- $_POST['link_url'] = clean_url($_POST['link_url']);
- $_POST['link_name'] = wp_specialchars( $_POST['link_name'] );
- $_POST['link_image'] = wp_specialchars( $_POST['link_image'] );
- $_POST['link_rss'] = clean_url($_POST['link_rss']);
- $_POST['link_category'] = $_POST['post_category'];
-
- if ( !empty( $link_id ) ) {
- $_POST['link_id'] = $link_id;
- return wp_update_link( $_POST);
- } else {
- return wp_insert_link( $_POST);
- }
-}
-
-function url_shorten( $url ) {
- $short_url = str_replace( 'http://', '', stripslashes( $url ));
- $short_url = str_replace( 'www.', '', $short_url );
- if ('/' == substr( $short_url, -1 ))
- $short_url = substr( $short_url, 0, -1 );
- if ( strlen( $short_url ) > 35 )
- $short_url = substr( $short_url, 0, 32 ).'...';
- return $short_url;
-}
-
-function selected( $selected, $current) {
- if ( $selected == $current)
- echo ' selected="selected"';
-}
-
-function checked( $checked, $current) {
- if ( $checked == $current)
- echo ' checked="checked"';
-}
-
-function return_categories_list( $parent = 0 ) {
- global $wpdb;
- return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( link_count = 0 OR category_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY category_count DESC" );
-}
-
-function sort_cats( $cat1, $cat2 ) {
- if ( $cat1['checked'] || $cat2['checked'] )
- return ( $cat1['checked'] && !$cat2['checked'] ) ? -1 : 1;
- else
- return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] );
-}
-
-function get_nested_categories( $default = 0, $parent = 0 ) {
- global $post_ID, $link_id, $mode, $wpdb;
-
- if ( $post_ID ) {
- $checked_categories = $wpdb->get_col( "
- SELECT category_id
- FROM $wpdb->categories, $wpdb->post2cat
- WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID'
- " );
-
- if ( count( $checked_categories ) == 0 ) {
- // No selected categories, strange
- $checked_categories[] = $default;
- }
- } else if ( $link_id ) {
- $checked_categories = $wpdb->get_col( "
- SELECT category_id
- FROM $wpdb->categories, $wpdb->link2cat
- WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
- " );
-
- if ( count( $checked_categories ) == 0 ) {
- // No selected categories, strange
- $checked_categories[] = $default;
- }
- } else {
- $checked_categories[] = $default;
- }
-
- $cats = return_categories_list( $parent);
- $result = array ();
-
- if ( is_array( $cats ) ) {
- foreach ( $cats as $cat) {
- if ( $cat == 0 ) { // HACK, added 2006-05-13
- $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0");
- continue;
- }
- $result[$cat]['children'] = get_nested_categories( $default, $cat);
- $result[$cat]['cat_ID'] = $cat;
- $result[$cat]['checked'] = in_array( $cat, $checked_categories );
- $result[$cat]['cat_name'] = get_the_category_by_ID( $cat);
- }
- }
-
- $result = apply_filters('get_nested_categories', $result);
- usort( $result, 'sort_cats' );
-
- return $result;
-}
-
-function write_nested_categories( $categories ) {
- foreach ( $categories as $category ) {
- echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( apply_filters('the_category', $category['cat_name'] )), "</label></li>";
-
- if ( $category['children'] ) {
- echo "<ul>\n";
- write_nested_categories( $category['children'] );
- echo "</ul>\n";
- }
- }
-}
-
-function dropdown_categories( $default = 0 ) {
- write_nested_categories( get_nested_categories( $default) );
-}
-
-function return_link_categories_list( $parent = 0 ) {
- global $wpdb;
- return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent AND ( category_count = 0 OR link_count != 0 OR ( link_count = 0 AND category_count = 0 ) ) ORDER BY link_count DESC" );
-}
-
-function get_nested_link_categories( $default = 0, $parent = 0 ) {
- global $post_ID, $link_id, $mode, $wpdb;
-
- if ( $link_id ) {
- $checked_categories = $wpdb->get_col( "
- SELECT category_id
- FROM $wpdb->categories, $wpdb->link2cat
- WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
- " );
-
- if ( count( $checked_categories ) == 0 ) {
- // No selected categories, strange
- $checked_categories[] = $default;
- }
- } else {
- $checked_categories[] = $default;
- }
-
- $cats = return_link_categories_list( $parent);
- $result = array ();
-
- if ( is_array( $cats ) ) {
- foreach ( $cats as $cat) {
- $result[$cat]['children'] = get_nested_link_categories( $default, $cat);
- $result[$cat]['cat_ID'] = $cat;
- $result[$cat]['checked'] = in_array( $cat, $checked_categories );
- $result[$cat]['cat_name'] = get_the_category_by_ID( $cat);
- }
- }
-
- usort( $result, 'sort_cats' );
-
- return $result;
-}
-
-function dropdown_link_categories( $default = 0 ) {
- write_nested_categories( get_nested_link_categories( $default) );
-}
-
-// Dandy new recursive multiple category stuff.
-function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
- global $wpdb;
-
- if (!$categories )
- $categories = get_categories( 'hide_empty=0' );
-
- $children = _get_category_hierarchy();
-
- if ( $categories ) {
- ob_start();
- foreach ( $categories as $category ) {
- if ( $category->cat_ID == 0 ) { // HACK, added 2006-05-13
- $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0");
- continue;
- }
- if ( $category->category_parent == $parent) {
- echo "\t" . _cat_row( $category, $level );
- if ( isset($children[$category->cat_ID]) )
- cat_rows( $category->cat_ID, $level +1, $categories );
- }
- }
- $output = ob_get_contents();
- ob_end_clean();
-
- $output = apply_filters('cat_rows', $output);
-
- echo $output;
- } else {
- return false;
- }
-}
-
-function _cat_row( $category, $level, $name_override = false ) {
- global $class;
-
- $pad = str_repeat( '&#8212; ', $level );
- if ( current_user_can( 'manage_categories' ) ) {
- $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__( 'Edit' )."</a></td>";
- $default_cat_id = (int) get_option( 'default_category' );
- $default_link_cat_id = (int) get_option( 'default_link_category' );
-
- if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id ) )
- $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->cat_name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>";
- else
- $edit .= "<td style='text-align:center'>".__( "Default" );
- } else
- $edit = '';
-
- $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
-
- $category->category_count = number_format( $category->category_count );
- $category->link_count = number_format( $category->link_count );
- $posts_count = ( $category->category_count > 0 ) ? "<a href='edit.php?cat=$category->cat_ID'>$category->category_count</a>" : $category->category_count;
- return "<tr id='cat-$category->cat_ID'$class>
- <th scope='row' style='text-align: center'>$category->cat_ID</th>
- <td>" . ( $name_override ? $name_override : $pad . ' ' . $category->cat_name ) . "</td>
- <td>$category->category_description</td>
- <td align='center'>$posts_count</td>
- <td align='center'>$category->link_count</td>
- <td>$edit</td>\n\t</tr>\n";
-}
-
-function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) {
- global $wpdb, $class, $post;
-
- if (!$pages )
- $pages = get_pages( 'sort_column=menu_order' );
-
- if (! $pages )
- return false;
-
- foreach ( $pages as $post) {
- setup_postdata( $post);
- if ( $hierarchy && ($post->post_parent != $parent) )
- continue;
-
- $post->post_title = wp_specialchars( $post->post_title );
- $pad = str_repeat( '&#8212; ', $level );
- $id = (int) $post->ID;
- $class = ('alternate' == $class ) ? '' : 'alternate';
-?>
- <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
- <th scope="row" style="text-align: center"><?php echo $post->ID; ?></th>
- <td>
- <?php echo $pad; ?><?php the_title() ?>
- </td>
- <td><?php the_author() ?></td>
- <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $post->post_modified ); ?></td>
- <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e( 'View' ); ?></a></td>
- <td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td>
- <td><?php if ( current_user_can( 'delete_page', $id ) ) { echo "<a href='" . wp_nonce_url( "page.php?action=delete&amp;post=$id", 'delete-page_' . $id ) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . js_escape(sprintf( __("You are about to delete the '%s' page.\n'OK' to delete, 'Cancel' to stop." ), get_the_title() ) ) . "' );\">" . __( 'Delete' ) . "</a>"; } ?></td>
- </tr>
-
-<?php
- if ( $hierarchy ) page_rows( $id, $level + 1, $pages );
- }
-}
-
-function user_row( $user_object, $style = '' ) {
- global $current_user;
-
- if ( !(is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
- $user_object = new WP_User( (int) $user_object );
- $email = $user_object->user_email;
- $url = $user_object->user_url;
- $short_url = str_replace( 'http://', '', $url );
- $short_url = str_replace( 'www.', '', $short_url );
- if ('/' == substr( $short_url, -1 ))
- $short_url = substr( $short_url, 0, -1 );
- if ( strlen( $short_url ) > 35 )
- $short_url = substr( $short_url, 0, 32 ).'...';
- $numposts = get_usernumposts( $user_object->ID );
- $r = "<tr id='user-$user_object->ID'$style>
- <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
- <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
- <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
- <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>
- <td><a href='$url' title='website: $url'>$short_url</a></td>";
- $r .= "\n\t\t<td align='center'>";
- if ( $numposts > 0 ) {
- $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
- $r .= sprintf(__ngettext( 'View %s post', 'View %s posts', $numposts ), $numposts);
- $r .= '</a>';
- }
- $r .= "</td>\n\t\t<td>";
- if ( ( is_site_admin() || $current_user->ID == $user_object->ID ) && current_user_can( 'edit_user', $user_object->ID ) ) {
- $edit_link = add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" );
- $r .= "<a href='$edit_link' class='edit'>".__( 'Edit' )."</a>";
- }
- $r .= "</td>\n\t</tr>";
- return $r;
-}
-
-function _wp_get_comment_list( $s = false, $start, $num ) {
- global $wpdb;
-
- $start = abs( (int) $start );
- $num = (int) $num;
-
- if ( $s ) {
- $s = $wpdb->escape($s);
- $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
- (comment_author LIKE '%$s%' OR
- comment_author_email LIKE '%$s%' OR
- comment_author_url LIKE ('%$s%') OR
- comment_author_IP LIKE ('%$s%') OR
- comment_content LIKE ('%$s%') ) AND
- comment_approved != 'spam'
- ORDER BY comment_date DESC LIMIT $start, $num");
- } else {
- $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" );
- }
-
- $total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
-
- return array($comments, $total);
-}
-
-function _wp_comment_list_item( $id, $alt = 0 ) {
- global $authordata, $comment, $wpdb;
- $id = (int) $id;
- $comment =& get_comment( $id );
- $class = '';
- $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
- $comment_status = wp_get_comment_status($comment->comment_ID);
- if ( 'unapproved' == $comment_status )
- $class .= ' unapproved';
- if ( $alt % 2 )
- $class .= ' alternate';
- echo "<li id='comment-$comment->comment_ID' class='$class'>";
-?>
-<p><strong><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
-
-<?php comment_text() ?>
-
-<p><?php comment_date(__('M j, g:i A')); ?> &#8212; [
-<?php
-if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
- echo " <a href='comment.php?action=editcomment&amp;c=".$comment->comment_ID."'>" . __('Edit') . '</a>';
- echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
- if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
- echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
- echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
- }
- echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;dt=spam&amp;p=" . $comment->comment_post_ID . "&amp;c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> ";
-}
-$post = get_post($comment->comment_post_ID);
-$post_title = wp_specialchars( $post->post_title, 'double' );
-$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
-?>
- ] &#8212; <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p>
- </li>
-<?php
-}
-
-function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
- global $wpdb;
- if (!$categories )
- $categories = get_categories( 'hide_empty=0' );
-
- if ( $categories ) {
- foreach ( $categories as $category ) {
- if ( $currentcat != $category->cat_ID && $parent == $category->category_parent) {
- $pad = str_repeat( '&#8211; ', $level );
- $category->cat_name = wp_specialchars( $category->cat_name );
- echo "\n\t<option value='$category->cat_ID'";
- if ( $currentparent == $category->cat_ID )
- echo " selected='selected'";
- echo ">$pad$category->cat_name</option>";
- wp_dropdown_cats( $currentcat, $currentparent, $category->cat_ID, $level +1, $categories );
- }
- }
- } else {
- return false;
- }
-}
-
-// Some postmeta stuff
-function has_meta( $postid ) {
- global $wpdb;
-
- return $wpdb->get_results( "
- SELECT meta_key, meta_value, meta_id, post_id
- FROM $wpdb->postmeta
- WHERE post_id = '$postid'
- ORDER BY meta_key,meta_id", ARRAY_A );
-
-}
-
-function list_meta( $meta ) {
- global $post_ID;
- // Exit if no meta
- if (!$meta ) {
- echo '<tbody id="the-list"><tr style="display: none;"><td>&nbsp;</td></tr></tbody>'; //TBODY needed for list-manipulation JS
- return;
- }
- $count = 0;
-?>
- <thead>
- <tr>
- <th><?php _e( 'Key' ) ?></th>
- <th><?php _e( 'Value' ) ?></th>
- <th colspan='2'><?php _e( 'Action' ) ?></th>
- </tr>
- </thead>
-<?php
- $r ="\n\t<tbody id='the-list'>";
- foreach ( $meta as $entry ) {
- ++ $count;
- if ( $count % 2 )
- $style = 'alternate';
- else
- $style = '';
- if ('_' == $entry['meta_key'] { 0 } )
- $style .= ' hidden';
-
- if ( is_serialized( $entry['meta_value'] ) ) {
- if ( is_serialized_string( $entry['meta_value'] ) ) {
- // this is a serialized string, so we should display it
- $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
- } else {
- // this is a serialized array/object so we should NOT display it
- --$count;
- continue;
- }
- }
-
- $key_js = js_escape( $entry['meta_key'] );
- $entry['meta_key'] = attribute_escape($entry['meta_key']);
- $entry['meta_value'] = attribute_escape($entry['meta_value']);
- $entry['meta_id'] = (int) $entry['meta_id'];
- $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
- $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>";
- $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>";
- $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".attribute_escape(__( 'Update' ))."' /><br />";
- $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '";
- $r .= js_escape(sprintf( __("You are about to delete the '%s' custom field on this post.\n'OK' to delete, 'Cancel' to stop." ), $key_js ) );
- $r .= "' );\" class='deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' /></td>";
- $r .= "\n\t</tr>";
- }
- echo $r;
- echo "\n\t</tbody>";
-}
-
-// Get a list of previously defined keys
-function get_meta_keys() {
- global $wpdb;
-
- $keys = $wpdb->get_col( "
- SELECT meta_key
- FROM $wpdb->postmeta
- GROUP BY meta_key
- ORDER BY meta_key" );
-
- return $keys;
-}
-
-function meta_form() {
- global $wpdb;
- $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
- $keys = $wpdb->get_col( "
- SELECT meta_key
- FROM $wpdb->postmeta
- GROUP BY meta_key
- ORDER BY meta_id DESC
- LIMIT $limit" );
- if ( $keys )
- natcasesort($keys);
-?>
-<h3><?php _e( 'Add a new custom field:' ) ?></h3>
-<table id="newmeta" cellspacing="3" cellpadding="3">
- <tr>
-<th colspan="2"><?php _e( 'Key' ) ?></th>
-<th><?php _e( 'Value' ) ?></th>
-</tr>
- <tr valign="top">
- <td align="right" width="18%">
-<?php if ( $keys ) : ?>
-<select id="metakeyselect" name="metakeyselect" tabindex="7">
-<option value="#NONE#"><?php _e( '- Select -' ); ?></option>
-<?php
-
- foreach ( $keys as $key ) {
- $key = attribute_escape( $key );
- echo "\n\t<option value='$key'>$key</option>";
- }
-?>
-</select> <?php _e( 'or' ); ?>
-<?php endif; ?>
-</td>
-<td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td>
- <td><textarea id="metavalue" name="metavalue" rows="3" cols="25" tabindex="8"></textarea></td>
- </tr>
-
-</table>
-<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e( 'Add Custom Field &raquo;' ) ?>" /></p>
-<?php
-
-}
-
-function add_meta( $post_ID ) {
- global $wpdb;
- $post_ID = (int) $post_ID;
-
- $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
-
- $metakeyselect = $wpdb->escape( stripslashes( trim( $_POST['metakeyselect'] ) ) );
- $metakeyinput = $wpdb->escape( stripslashes( trim( $_POST['metakeyinput'] ) ) );
- $metavalue = maybe_serialize( stripslashes( (trim( $_POST['metavalue'] ) ) ));
- $metavalue = $wpdb->escape( $metavalue );
-
- if ( ('0' === $metavalue || !empty ( $metavalue ) ) && ((('#NONE#' != $metakeyselect) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput) ) ) {
- // We have a key/value pair. If both the select and the
- // input for the key have data, the input takes precedence:
-
- if ('#NONE#' != $metakeyselect)
- $metakey = $metakeyselect;
-
- if ( $metakeyinput)
- $metakey = $metakeyinput; // default
-
- if ( in_array($metakey, $protected) )
- return false;
-
- $result = $wpdb->query( "
- INSERT INTO $wpdb->postmeta
- (post_id,meta_key,meta_value )
- VALUES ('$post_ID','$metakey','$metavalue' )
- " );
- return $wpdb->insert_id;
- }
- return false;
-} // add_meta
-
-function delete_meta( $mid ) {
- global $wpdb;
- $mid = (int) $mid;
-
- return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'" );
-}
-
-function update_meta( $mid, $mkey, $mvalue ) {
- global $wpdb;
-
- $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
-
- if ( in_array($mkey, $protected) )
- return false;
-
- $mvalue = maybe_serialize( stripslashes( $mvalue ));
- $mvalue = $wpdb->escape( $mvalue );
- $mid = (int) $mid;
- return $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'" );
-}
-
-function get_post_meta_by_id( $mid ) {
- global $wpdb;
- $mid = (int) $mid;
-
- $meta = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'" );
- if ( is_serialized_string( $meta->meta_value ) )
- $meta->meta_value = maybe_unserialize( $meta->meta_value );
- return $meta;
-}
-
-function touch_time( $edit = 1, $for_post = 1 ) {
- global $wp_locale, $post, $comment;
-
- if ( $for_post )
- $edit = ( ('draft' == $post->post_status ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
-
- echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>';
-
- $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
- $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
- $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
- $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
- $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
- $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
- $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
- $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
-
- echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\n";
- for ( $i = 1; $i < 13; $i = $i +1 ) {
- echo "\t\t\t<option value=\"$i\"";
- if ( $i == $mm )
- echo ' selected="selected"';
- echo '>' . $wp_locale->get_month( $i ) . "</option>\n";
- }
-?>
-</select>
-<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"/>
-<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true" /> @
-<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> :
-<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
-<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
-<?php
- if ( $edit ) {
- printf( __('Existing timestamp: %1$s %2$s, %3$s @ %4$s:%5$s' ), $wp_locale->get_month( $mm ), $jj, $aa, $hh, $mn );
- }
-?>
-</fieldset>
- <?php
-
-}
-
-// insert_with_markers: Owen Winkler, fixed by Eric Anderson
-// Inserts an array of strings into a file (.htaccess ), placing it between
-// BEGIN and END markers. Replaces existing marked info. Retains surrounding
-// data. Creates file if none exists.
-// Returns true on write success, false on failure.
-function insert_with_markers( $filename, $marker, $insertion ) {
- return true;
- if (!file_exists( $filename ) || is_writeable( $filename ) ) {
- if (!file_exists( $filename ) ) {
- $markerdata = '';
- } else {
- $markerdata = explode( "\n", implode( '', file( $filename ) ) );
- }
-
- $f = fopen( $filename, 'w' );
- $foundit = false;
- if ( $markerdata ) {
- $state = true;
- foreach ( $markerdata as $n => $markerline ) {
- if (strpos($markerline, '# BEGIN ' . $marker) !== false)
- $state = false;
- if ( $state ) {
- if ( $n + 1 < count( $markerdata ) )
- fwrite( $f, "{$markerline}\n" );
- else
- fwrite( $f, "{$markerline}" );
- }
- if (strpos($markerline, '# END ' . $marker) !== false) {
- fwrite( $f, "# BEGIN {$marker}\n" );
- if ( is_array( $insertion ))
- foreach ( $insertion as $insertline )
- fwrite( $f, "{$insertline}\n" );
- fwrite( $f, "# END {$marker}\n" );
- $state = true;
- $foundit = true;
- }
- }
- }
- if (!$foundit) {
- fwrite( $f, "# BEGIN {$marker}\n" );
- foreach ( $insertion as $insertline )
- fwrite( $f, "{$insertline}\n" );
- fwrite( $f, "# END {$marker}\n" );
- }
- fclose( $f );
- return true;
- } else {
- return false;
- }
-}
-
-// extract_from_markers: Owen Winkler
-// Returns an array of strings from a file (.htaccess ) from between BEGIN
-// and END markers.
-function extract_from_markers( $filename, $marker ) {
- $result = array ();
-
- if (!file_exists( $filename ) ) {
- return $result;
- }
-
- if ( $markerdata = explode( "\n", implode( '', file( $filename ) ) ));
- {
- $state = false;
- foreach ( $markerdata as $markerline ) {
- if (strpos($markerline, '# END ' . $marker) !== false)
- $state = false;
- if ( $state )
- $result[] = $markerline;
- if (strpos($markerline, '# BEGIN ' . $marker) !== false)
- $state = true;
- }
- }
-
- return $result;
-}
-
-function got_mod_rewrite() {
- global $is_apache;
-
- // take 3 educated guesses as to whether or not mod_rewrite is available
- if ( !$is_apache )
- return false;
-
- if ( function_exists( 'apache_get_modules' ) ) {
- if ( !in_array( 'mod_rewrite', apache_get_modules() ) )
- return false;
- }
-
- return true;
-}
-
-function save_mod_rewrite_rules() {
- global $is_apache, $wp_rewrite;
- $home_path = get_home_path();
-
- if (!$wp_rewrite->using_mod_rewrite_permalinks() )
- return false;
-
- if (!((!file_exists( $home_path.'.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path.'.htaccess' ) ) )
- return false;
-
- if (! got_mod_rewrite() )
- return false;
-
- $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
- return insert_with_markers( $home_path.'.htaccess', 'WordPress', $rules );
-}
-
-function get_broken_themes() {
- global $wp_broken_themes;
-
- get_themes();
- return $wp_broken_themes;
-}
-
-function get_page_templates() {
- $themes = get_themes();
- $theme = get_current_theme();
- $templates = $themes[$theme]['Template Files'];
- $page_templates = array ();
-
- if ( is_array( $templates ) ) {
- foreach ( $templates as $template ) {
- $template_data = implode( '', file( ABSPATH.$template ));
- preg_match( "|Template Name:(.*)|i", $template_data, $name );
- preg_match( "|Description:(.*)|i", $template_data, $description );
-
- $name = $name[1];
- $description = $description[1];
-
- if (!empty ( $name ) ) {
- $page_templates[trim( $name )] = basename( $template );
- }
- }
- }
-
- return $page_templates;
-}
-
-function page_template_dropdown( $default = '' ) {
- $templates = get_page_templates();
- foreach (array_keys( $templates ) as $template )
- : if ( $default == $templates[$template] )
- $selected = " selected='selected'";
- else
- $selected = '';
- echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
- endforeach;
-}
-
-function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
- global $wpdb, $post_ID;
- $items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order" );
-
- if ( $items ) {
- foreach ( $items as $item ) {
- // A page cannot be its own parent.
- if (!empty ( $post_ID ) ) {
- if ( $item->ID == $post_ID ) {
- continue;
- }
- }
- $pad = str_repeat( '&nbsp;', $level * 3 );
- if ( $item->ID == $default)
- $current = ' selected="selected"';
- else
- $current = '';
-
- echo "\n\t<option value='$item->ID'$current>$pad $item->post_title</option>";
- parent_dropdown( $default, $item->ID, $level +1 );
- }
- } else {
- return false;
- }
-}
-
-function user_can_access_admin_page() {
- global $pagenow;
- global $menu;
- global $submenu;
- global $_wp_menu_nopriv;
- global $_wp_submenu_nopriv;
- global $plugin_page;
-
- $parent = get_admin_page_parent();
-
- if ( isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
- return false;
-
- if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
- return false;
-
- if ( empty( $parent) ) {
- if ( isset( $_wp_menu_nopriv[$pagenow] ) )
- return false;
- if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) )
- return false;
- if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) )
- return false;
- foreach (array_keys( $_wp_submenu_nopriv ) as $key ) {
- if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )
- return false;
- if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
- return false;
- }
- return true;
- }
-
- if ( isset( $submenu[$parent] ) ) {
- foreach ( $submenu[$parent] as $submenu_array ) {
- if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) {
- if ( current_user_can( $submenu_array[1] ))
- return true;
- else
- return false;
- } else if ( $submenu_array[2] == $pagenow ) {
- if ( current_user_can( $submenu_array[1] ))
- return true;
- else
- return false;
- }
- }
- }
-
- foreach ( $menu as $menu_array ) {
- if ( $menu_array[2] == $parent) {
- if ( current_user_can( $menu_array[1] ))
- return true;
- else
- return false;
- }
- }
-
- return true;
-}
-
-function get_admin_page_title() {
- global $title;
- global $menu;
- global $submenu;
- global $pagenow;
- global $plugin_page;
-
- if ( isset( $title ) && !empty ( $title ) ) {
- return $title;
- }
-
- $hook = get_plugin_page_hook( $plugin_page, $pagenow );
-
- $parent = $parent1 = get_admin_page_parent();
- if ( empty ( $parent) ) {
- foreach ( $menu as $menu_array ) {
- if ( isset( $menu_array[3] ) ) {
- if ( $menu_array[2] == $pagenow ) {
- $title = $menu_array[3];
- return $menu_array[3];
- } else
- if ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) {
- $title = $menu_array[3];
- return $menu_array[3];
- }
- } else {
- $title = $menu_array[0];
- return $title;
- }
- }
- } else {
- foreach (array_keys( $submenu ) as $parent) {
- foreach ( $submenu[$parent] as $submenu_array ) {
- if ( isset( $plugin_page ) &&
- ($plugin_page == $submenu_array[2] ) &&
- (($parent == $pagenow ) || ($parent == $plugin_page ) || ($plugin_page == $hook ) || (($pagenow == 'admin.php' ) && ($parent1 != $submenu_array[2] ) ) )
- ) {
- $title = $submenu_array[3];
- return $submenu_array[3];
- }
-
- if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page
- continue;
-
- if ( isset( $submenu_array[3] ) ) {
- $title = $submenu_array[3];
- return $submenu_array[3];
- } else {
- $title = $submenu_array[0];
- return $title;
- }
- }
- }
- }
-
- return $title;
-}
-
-function get_admin_page_parent() {
- global $parent_file;
- global $menu;
- global $submenu;
- global $pagenow;
- global $plugin_page;
- global $_wp_real_parent_file;
- global $_wp_menu_nopriv;
- global $_wp_submenu_nopriv;
-
- if ( !empty ( $parent_file ) ) {
- if ( isset( $_wp_real_parent_file[$parent_file] ) )
- $parent_file = $_wp_real_parent_file[$parent_file];
-
- return $parent_file;
- }
-
- if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
- foreach ( $menu as $parent_menu ) {
- if ( $parent_menu[2] == $plugin_page ) {
- $parent_file = $plugin_page;
- if ( isset( $_wp_real_parent_file[$parent_file] ) )
- $parent_file = $_wp_real_parent_file[$parent_file];
- return $parent_file;
- }
- }
- if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) {
- $parent_file = $plugin_page;
- if ( isset( $_wp_real_parent_file[$parent_file] ) )
- $parent_file = $_wp_real_parent_file[$parent_file];
- return $parent_file;
- }
- }
-
- if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) {
- $parent_file = $pagenow;
- if ( isset( $_wp_real_parent_file[$parent_file] ) )
- $parent_file = $_wp_real_parent_file[$parent_file];
- return $parent_file;
- }
-
- foreach (array_keys( $submenu ) as $parent) {
- foreach ( $submenu[$parent] as $submenu_array ) {
- if ( isset( $_wp_real_parent_file[$parent] ) )
- $parent = $_wp_real_parent_file[$parent];
- if ( $submenu_array[2] == $pagenow ) {
- $parent_file = $parent;
- return $parent;
- } else
- if ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {
- $parent_file = $parent;
- return $parent;
- }
- }
- }
-
- $parent_file = '';
- return '';
-}
-
-function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
- global $menu, $admin_page_hooks;
-
- $file = plugin_basename( $file );
-
- $menu[] = array ( $menu_title, $access_level, $file, $page_title );
-
- $admin_page_hooks[$file] = sanitize_title( $menu_title );
-
- $hookname = get_plugin_page_hookname( $file, '' );
- if (!empty ( $function ) && !empty ( $hookname ))
- add_action( $hookname, $function );
-
- return $hookname;
-}
-
-function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function = '' ) {
- global $submenu;
- global $menu;
- global $_wp_real_parent_file;
- global $_wp_submenu_nopriv;
- global $_wp_menu_nopriv;
-
- $file = plugin_basename( $file );
-
- $parent = plugin_basename( $parent);
- if ( isset( $_wp_real_parent_file[$parent] ) )
- $parent = $_wp_real_parent_file[$parent];
-
- if ( !current_user_can( $access_level ) ) {
- $_wp_submenu_nopriv[$parent][$file] = true;
- return false;
- }
-
- // If the parent doesn't already have a submenu, add a link to the parent
- // as the first item in the submenu. If the submenu file is the same as the
- // parent file someone is trying to link back to the parent manually. In
- // this case, don't automatically add a link back to avoid duplication.
- if (!isset( $submenu[$parent] ) && $file != $parent ) {
- foreach ( $menu as $parent_menu ) {
- if ( $parent_menu[2] == $parent && current_user_can( $parent_menu[1] ) )
- $submenu[$parent][] = $parent_menu;
- }
- }
-
- $submenu[$parent][] = array ( $menu_title, $access_level, $file, $page_title );
-
- $hookname = get_plugin_page_hookname( $file, $parent);
- if (!empty ( $function ) && !empty ( $hookname ))
- add_action( $hookname, $function );
-
- return $hookname;
-}
-
-function add_options_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
- return add_submenu_page( 'options-general.php', $page_title, $menu_title, $access_level, $file, $function );
-}
-
-function add_management_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
- return add_submenu_page( 'edit.php', $page_title, $menu_title, $access_level, $file, $function );
-}
-
-function add_theme_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
- return add_submenu_page( 'themes.php', $page_title, $menu_title, $access_level, $file, $function );
-}
-
-function add_users_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
- if ( current_user_can('edit_users') )
- $parent = 'users.php';
- else
- $parent = 'profile.php';
- return add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function );
-}
-
-function validate_file( $file, $allowed_files = '' ) {
- if ( false !== strpos( $file, './' ))
- return 1;
-
- if (':' == substr( $file, 1, 1 ))
- return 2;
-
- if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) )
- return 3;
-
- return 0;
-}
-
-function validate_file_to_edit( $file, $allowed_files = '' ) {
- $file = stripslashes( $file );
-
- $code = validate_file( $file, $allowed_files );
-
- if (!$code )
- return $file;
-
- switch ( $code ) {
- case 1 :
- wp_die( __('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.' ));
-
- case 2 :
- wp_die( __('Sorry, can&#8217;t call files with their real path.' ));
-
- case 3 :
- wp_die( __('Sorry, that file cannot be edited.' ));
- }
-}
-
-function get_home_path() {
- $home = get_option( 'home' );
- if ( $home != '' && $home != get_option( 'siteurl' ) ) {
- $home_path = parse_url( $home );
- $home_path = $home_path['path'];
- $root = str_replace( $_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"] );
- $home_path = trailingslashit( $root.$home_path );
- } else {
- $home_path = ABSPATH;
- }
-
- return $home_path;
-}
-
-function get_real_file_to_edit( $file ) {
- if ('index.php' == $file || '.htaccess' == $file ) {
- $real_file = get_home_path().$file;
- } else {
- $real_file = ABSPATH.$file;
- }
-
- return $real_file;
-}
-
-$wp_file_descriptions = array ('index.php' => __( 'Main Index Template' ), 'style.css' => __( 'Stylesheet' ), 'comments.php' => __( 'Comments' ), 'comments-popup.php' => __( 'Popup Comments' ), 'footer.php' => __( 'Footer' ), 'header.php' => __( 'Header' ), 'sidebar.php' => __( 'Sidebar' ), 'archive.php' => __( 'Archives' ), 'category.php' => __( 'Category Template' ), 'page.php' => __( 'Page Template' ), 'search.php' => __( 'Search Results' ), 'single.php' => __( 'Single Post' ), '404.php' => __( '404 Template' ), 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), '.htaccess' => __( '.htaccess (for rewrite rules )' ),
- // Deprecated files
- 'wp-layout.css' => __( 'Stylesheet' ), 'wp-comments.php' => __( 'Comments Template' ), 'wp-comments-popup.php' => __( 'Popup Comments Template' ));
-
-function get_file_description( $file ) {
- global $wp_file_descriptions;
-
- if ( isset( $wp_file_descriptions[basename( $file )] ) ) {
- return $wp_file_descriptions[basename( $file )];
- }
- elseif ( file_exists( ABSPATH . $file ) && is_file( ABSPATH . $file ) ) {
- $template_data = implode( '', file( ABSPATH . $file ) );
- if ( preg_match( "|Template Name:(.*)|i", $template_data, $name ))
- return $name[1];
- }
-
- return basename( $file );
-}
-
-function update_recently_edited( $file ) {
- $oldfiles = (array ) get_option( 'recently_edited' );
- if ( $oldfiles ) {
- $oldfiles = array_reverse( $oldfiles );
- $oldfiles[] = $file;
- $oldfiles = array_reverse( $oldfiles );
- $oldfiles = array_unique( $oldfiles );
- if ( 5 < count( $oldfiles ))
- array_pop( $oldfiles );
- } else {
- $oldfiles[] = $file;
- }
- update_option( 'recently_edited', $oldfiles );
-}
-
-function get_plugin_data( $plugin_file ) {
- $plugin_data = implode( '', file( $plugin_file ));
- preg_match( "|Plugin Name:(.*)|i", $plugin_data, $plugin_name );
- preg_match( "|Plugin URI:(.*)|i", $plugin_data, $plugin_uri );
- preg_match( "|Description:(.*)|i", $plugin_data, $description );
- preg_match( "|Author:(.*)|i", $plugin_data, $author_name );
- preg_match( "|Author URI:(.*)|i", $plugin_data, $author_uri );
- if ( preg_match( "|Version:(.*)|i", $plugin_data, $version ))
- $version = trim( $version[1] );
- else
- $version = '';
-
- $description = wptexturize( trim( $description[1] ));
-
- $name = $plugin_name[1];
- $name = trim( $name );
- $plugin = $name;
- if ('' != $plugin_uri[1] && '' != $name ) {
- $plugin = '<a href="' . trim( $plugin_uri[1] ) . '" title="'.__( 'Visit plugin homepage' ).'">'.$plugin.'</a>';
- }
-
- if ('' == $author_uri[1] ) {
- $author = trim( $author_name[1] );
- } else {
- $author = '<a href="' . trim( $author_uri[1] ) . '" title="'.__( 'Visit author homepage' ).'">' . trim( $author_name[1] ) . '</a>';
- }
-
- return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version);
-}
-
-function get_plugins() {
- global $wp_plugins;
-
- if ( isset( $wp_plugins ) ) {
- return $wp_plugins;
- }
-
- $wp_plugins = array ();
- $plugin_root = ABSPATH . PLUGINDIR;
-
- // Files in wp-content/plugins directory
- $plugins_dir = @ dir( $plugin_root);
- if ( $plugins_dir ) {
- while (($file = $plugins_dir->read() ) !== false ) {
- if ( substr($file, 0, 1) == '.' )
- continue;
- if ( is_dir( $plugin_root.'/'.$file ) ) {
- $plugins_subdir = @ dir( $plugin_root.'/'.$file );
- if ( $plugins_subdir ) {
- while (($subfile = $plugins_subdir->read() ) !== false ) {
- if ( substr($subfile, 0, 1) == '.' )
- continue;
- if ( substr($subfile, -4) == '.php' )
- $plugin_files[] = "$file/$subfile";
- }
- }
- } else {
- if ( substr($file, -4) == '.php' )
- $plugin_files[] = $file;
- }
- }
- }
-
- if ( !$plugins_dir || !$plugin_files )
- return $wp_plugins;
-
- foreach ( $plugin_files as $plugin_file ) {
- if ( !is_readable( "$plugin_root/$plugin_file" ) )
- continue;
-
- $plugin_data = get_plugin_data( "$plugin_root/$plugin_file" );
-
- if ( empty ( $plugin_data['Name'] ) )
- continue;
-
- $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data;
- }
-
- uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));
-
- return $wp_plugins;
-}
-
-function get_plugin_page_hookname( $plugin_page, $parent_page ) {
- global $admin_page_hooks;
-
- $parent = get_admin_page_parent();
-
- if ( empty ( $parent_page ) || 'admin.php' == $parent_page ) {
- if ( isset( $admin_page_hooks[$plugin_page] ))
- $page_type = 'toplevel';
- else
- if ( isset( $admin_page_hooks[$parent] ))
- $page_type = $admin_page_hooks[$parent];
- } else
- if ( isset( $admin_page_hooks[$parent_page] ) ) {
- $page_type = $admin_page_hooks[$parent_page];
- } else {
- $page_type = 'admin';
- }
-
- $plugin_name = preg_replace( '!\.php!', '', $plugin_page );
-
- return $page_type.'_page_'.$plugin_name;
-}
-
-function get_plugin_page_hook( $plugin_page, $parent_page ) {
- global $wp_filter;
-
- $hook = get_plugin_page_hookname( $plugin_page, $parent_page );
- if ( isset( $wp_filter[$hook] ))
- return $hook;
- else
- return '';
-}
-
-function browse_happy() {
- $getit = __( 'WordPress recommends a better browser' );
- echo '
- <p id="bh" style="text-align: center;"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></p>
- ';
-}
-
-if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
- add_action( 'admin_footer', 'browse_happy' );
-
-function documentation_link( $for ) {
- return;
-}
-
-function register_importer( $id, $name, $description, $callback ) {
- global $wp_importers;
-
- $wp_importers[$id] = array ( $name, $description, $callback );
-}
-
-function get_importers() {
- global $wp_importers;
- uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
- return $wp_importers;
-}
-
-function current_theme_info() {
- $themes = get_themes();
- $current_theme = get_current_theme();
- $ct->name = $current_theme;
- $ct->title = $themes[$current_theme]['Title'];
- $ct->version = $themes[$current_theme]['Version'];
- $ct->parent_theme = $themes[$current_theme]['Parent Theme'];
- $ct->template_dir = $themes[$current_theme]['Template Dir'];
- $ct->stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
- $ct->template = $themes[$current_theme]['Template'];
- $ct->stylesheet = $themes[$current_theme]['Stylesheet'];
- $ct->screenshot = $themes[$current_theme]['Screenshot'];
- $ct->description = $themes[$current_theme]['Description'];
- $ct->author = $themes[$current_theme]['Author'];
- return $ct;
-}
-
-
-// array wp_handle_upload ( array &file [, array overrides] )
-// file: reference to a single element of $_FILES. Call the function once for each uploaded file.
-// overrides: an associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
-// On success, returns an associative array of file attributes.
-// On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
-function wp_handle_upload( &$file, $overrides = false ) {
- // The default error handler.
- if (! function_exists( 'wp_handle_upload_error' ) ) {
- function wp_handle_upload_error( &$file, $message ) {
- return array( 'error'=>$message );
- }
- }
-
- // You may define your own function and pass the name in $overrides['upload_error_handler']
- $upload_error_handler = 'wp_handle_upload_error';
-
- // $_POST['action'] must be set and its value must equal $overrides['action'] or this:
- $action = 'wp_handle_upload';
-
- // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
- $upload_error_strings = array( false,
- __( "The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>." ),
- __( "The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form." ),
- __( "The uploaded file was only partially uploaded." ),
- __( "No file was uploaded." ),
- __( "Missing a temporary folder." ),
- __( "Failed to write file to disk." ));
-
- // All tests are on by default. Most can be turned off by $override[{test_name}] = false;
- $test_form = true;
- $test_size = true;
-
- // If you override this, you must provide $ext and $type!!!!
- $test_type = true;
-
- // Install user overrides. Did we mention that this voids your warranty?
- if ( is_array( $overrides ) )
- extract( $overrides, EXTR_OVERWRITE );
-
- // A correct form post will pass this test.
- if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) )
- return $upload_error_handler( $file, __( 'Invalid form submission.' ));
-
- // A successful upload will pass this test. It makes no sense to override this one.
- if ( $file['error'] > 0 )
- return $upload_error_handler( $file, $upload_error_strings[$file['error']] );
-
- // A non-empty file will pass this test.
- if ( $test_size && !($file['size'] > 0 ) )
- return $upload_error_handler( $file, __( 'File is empty. Please upload something more substantial.' ));
-
- // A properly uploaded file will pass this test. There should be no reason to override this one.
- if (! @ is_uploaded_file( $file['tmp_name'] ) )
- return $upload_error_handler( $file, __( 'Specified file failed upload test.' ));
-
- // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
- if ( $test_type ) {
- $wp_filetype = wp_check_filetype( $file['name'], $mimes );
-
- extract( $wp_filetype );
-
- if ( !$type || !$ext )
- return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' ));
- }
-
- // A writable uploads dir will pass this test. Again, there's no point overriding this one.
- if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
- return $upload_error_handler( $file, $uploads['error'] );
-
- // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied.
- if ( isset( $unique_filename_callback ) && function_exists( $unique_filename_callback ) ) {
- $filename = $unique_filename_callback( $uploads['path'], $file['name'] );
- } else {
- $number = '';
- $filename = str_replace( '#', '_', $file['name'] );
- $filename = str_replace( array( '\\', "'" ), '', $filename );
- if ( empty( $ext) )
- $ext = '';
- else
- $ext = ".$ext";
- while ( file_exists( $uploads['path'] . "/$filename" ) ) {
- if ( '' == "$number$ext" )
- $filename = $filename . ++$number . $ext;
- else
- $filename = str_replace( "$number$ext", ++$number . $ext, $filename );
- }
- $filename = str_replace( $ext, '', $filename );
- $filename = sanitize_title_with_dashes( $filename ) . $ext;
- }
-
- // Move the file to the uploads dir
- $new_file = $uploads['path'] . "/$filename";
- if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
- wp_die( printf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ));
-
- // Set correct file permissions
- $stat = stat( dirname( $new_file ));
- $perms = $stat['mode'] & 0000666;
- @ chmod( $new_file, $perms );
-
- // Compute the URL
- $url = $uploads['url'] . "/$filename";
-
- $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) );
-
- return $return;
-}
-
-function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
- if ( $height <= $hmax && $width <= $wmax )
- return array( $width, $height);
- elseif ( $width / $height > $wmax / $hmax )
- return array( $wmax, (int) ($height / $width * $wmax ));
- else
- return array( (int) ($width / $height * $hmax ), $hmax );
-}
-
-function wp_import_cleanup( $id ) {
- wp_delete_attachment( $id );
-}
-
-function wp_import_upload_form( $action ) {
- $size = strtolower( ini_get( 'upload_max_filesize' ) );
- $bytes = 0;
- if (strpos($size, 'k') !== false)
- $bytes = $size * 1024;
- if (strpos($size, 'm') !== false)
- $bytes = $size * 1024 * 1024;
- if (strpos($size, 'g') !== false)
- $bytes = $size * 1024 * 1024 * 1024;
- $size = apply_filters( 'import_upload_size_limit', $size );
-?>
-<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>">
-<p>
-<?php wp_nonce_field('import-upload'); ?>
-<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?> )
-<input type="file" id="upload" name="import" size="25" />
-<input type="hidden" name="action" value="save" />
-<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
-</p>
-<p class="submit">
-<input type="submit" value="<?php _e( 'Upload file and import' ); ?> &raquo;" />
-</p>
-</form>
-<?php
-}
-
-function wp_import_handle_upload() {
- $overrides = array( 'test_form' => false, 'test_type' => false );
- $file = wp_handle_upload( $_FILES['import'], $overrides );
-
- if ( isset( $file['error'] ) )
- return $file;
-
- $url = $file['url'];
- $type = $file['type'];
- $file = addslashes( $file['file'] );
- $filename = basename( $file );
-
- // Construct the object array
- $object = array( 'post_title' => $filename,
- 'post_content' => $url,
- 'post_mime_type' => $type,
- 'guid' => $url
- );
-
- // Save the data
- $id = wp_insert_attachment( $object, $file );
-
- return array( 'file' => $file, 'id' => $id );
-}
-
-function the_attachment_links( $id = false ) {
- $id = (int) $id;
- $post = & get_post( $id );
-
- if ( $post->post_type != 'attachment' )
- return false;
-
- $icon = get_attachment_icon( $post->ID );
- $attachment_data = wp_get_attachment_metadata( $id );
- $thumb = isset( $attachment_data['thumb'] );
-?>
-<form id="the-attachment-links">
-<table>
- <col />
- <col class="widefat" />
- <tr>
- <th scope="row"><?php _e( 'URL' ) ?></th>
- <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
- </tr>
-<?php if ( $icon ) : ?>
- <tr>
- <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
- <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td>
- </tr>
- <tr>
- <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
- <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
- </tr>
-<?php else : ?>
- <tr>
- <th scope="row"><?php _e( 'Link to file' ) ?></th>
- <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td>
- </tr>
- <tr>
- <th scope="row"><?php _e( 'Link to page' ) ?></th>
- <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
- </tr>
-<?php endif; ?>
-</table>
-</form>
-<?php
-}
-
-function get_udims( $width, $height) {
- if ( $height <= 96 && $width <= 128 )
- return array( $width, $height);
- elseif ( $width / $height > 4 / 3 )
- return array( 128, (int) ($height / $width * 128 ));
- else
- return array( (int) ($width / $height * 96 ), 96 );
-}
-
-function wp_reset_vars( $vars ) {
- for ( $i=0; $i<count( $vars ); $i += 1 ) {
- $var = $vars[$i];
- global $$var;
-
- if (!isset( $$var ) ) {
- if ( empty( $_POST["$var"] ) ) {
- if ( empty( $_GET["$var"] ) )
- $$var = '';
- else
- $$var = $_GET["$var"];
- } else {
- $$var = $_POST["$var"];
- }
- }
- }
-}
-
-
-function wp_remember_old_slug() {
- global $post;
- $name = attribute_escape($post->post_name); // just in case
- if ( strlen($name) )
- echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
-}
-
-
-// If siteurl or home changed, reset cookies and flush rewrite rules.
-function update_home_siteurl( $old_value, $value ) {
- global $wp_rewrite, $user_login, $user_pass_md5;
-
- if ( defined( "WP_INSTALLING" ) )
- return;
-
- // If home changed, write rewrite rules to new location.
- $wp_rewrite->flush_rules();
- // Clear cookies for old paths.
- wp_clearcookie();
- // Set cookies for new paths.
- wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' ));
-}
-
-add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
-add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
-
-function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
- if ( ctype_digit( $src_file ) ) // Handle int as attachment ID
- $src_file = get_attached_file( $src_file );
-
- $src = wp_load_image( $src_file );
-
- if ( !is_resource( $src ))
- return $src;
-
- $dst = imagecreatetruecolor( $dst_w, $dst_h );
-
- if ( $src_abs ) {
- $src_w -= $src_x;
- $src_h -= $src_y;
- }
-
- if (function_exists('imageantialias'))
- imageantialias( $dst, true );
-
- imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );
-
- if ( !$dst_file )
- $dst_file = str_replace( basename( $src_file ), 'cropped-'.basename( $src_file ), $src_file );
-
- $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file );
-
- if ( imagejpeg( $dst, $dst_file ) )
- return $dst_file;
- else
- return false;
-}
-
-function wp_load_image( $file ) {
- if ( ctype_digit( $file ) )
- $file = get_attached_file( $file );
-
- if ( !file_exists( $file ) )
- return sprintf(__("File '%s' doesn't exist?"), $file);
-
- if ( ! function_exists('imagecreatefromstring') )
- return __('The GD image library is not installed.');
-
- $contents = file_get_contents( $file );
-
- $image = imagecreatefromstring( $contents );
-
- if ( !is_resource( $image ) )
- return sprintf(__("File '%s' is not an image."), $file);
-
- return $image;
-}
-
-function wp_generate_attachment_metadata( $attachment_id, $file ) {
- $attachment = get_post( $attachment_id );
-
- $metadata = array();
- if ( preg_match('!^image/!', get_post_mime_type( $attachment )) ) {
- $imagesize = getimagesize($file);
- $metadata['width'] = $imagesize['0'];
- $metadata['height'] = $imagesize['1'];
- list($uwidth, $uheight) = get_udims($metadata['width'], $metadata['height']);
- $metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
- $metadata['file'] = $file;
-
- $max = apply_filters( 'wp_thumbnail_creation_size_limit', 3 * 1024 * 1024, $attachment_id, $file );
-
- if ( $max < 0 || $metadata['width'] * $metadata['height'] < $max ) {
- $max_side = apply_filters( 'wp_thumbnail_max_side_length', 128, $attachment_id, $file );
- $thumb = wp_create_thumbnail( $file, $max_side );
-
- if ( @file_exists($thumb) )
- $metadata['thumb'] = basename($thumb);
- }
- }
- return apply_filters( 'wp_generate_attachment_metadata', $metadata );
-}
-
-function wp_create_thumbnail( $file, $max_side, $effect = '' ) {
-
- // 1 = GIF, 2 = JPEG, 3 = PNG
-
- if ( file_exists( $file ) ) {
- $type = getimagesize( $file );
-
- // if the associated function doesn't exist - then it's not
- // handle. duh. i hope.
-
- if (!function_exists( 'imagegif' ) && $type[2] == 1 ) {
- $error = __( 'Filetype not supported. Thumbnail not created.' );
- }
- elseif (!function_exists( 'imagejpeg' ) && $type[2] == 2 ) {
- $error = __( 'Filetype not supported. Thumbnail not created.' );
- }
- elseif (!function_exists( 'imagepng' ) && $type[2] == 3 ) {
- $error = __( 'Filetype not supported. Thumbnail not created.' );
- } else {
-
- // create the initial copy from the original file
- if ( $type[2] == 1 ) {
- $image = imagecreatefromgif( $file );
- }
- elseif ( $type[2] == 2 ) {
- $image = imagecreatefromjpeg( $file );
- }
- elseif ( $type[2] == 3 ) {
- $image = imagecreatefrompng( $file );
- }
-
- if ( function_exists( 'imageantialias' ))
- imageantialias( $image, TRUE );
-
- $image_attr = getimagesize( $file );
-
- // figure out the longest side
-
- if ( $image_attr[0] > $image_attr[1] ) {
- $image_width = $image_attr[0];
- $image_height = $image_attr[1];
- $image_new_width = $max_side;
-
- $image_ratio = $image_width / $image_new_width;
- $image_new_height = $image_height / $image_ratio;
- //width is > height
- } else {
- $image_width = $image_attr[0];
- $image_height = $image_attr[1];
- $image_new_height = $max_side;
-
- $image_ratio = $image_height / $image_new_height;
- $image_new_width = $image_width / $image_ratio;
- //height > width
- }
-
- $thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height);
- @ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1] );
-
- // If no filters change the filename, we'll do a default transformation.
- if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) )
- $thumb = preg_replace( '!(\.[^.]+)?$!', '.thumbnail' . '$1', basename( $file ), 1 );
-
- $thumbpath = str_replace( basename( $file ), $thumb, $file );
-
- // move the thumbnail to its final destination
- if ( $type[2] == 1 ) {
- if (!imagegif( $thumbnail, $thumbpath ) ) {
- $error = __( "Thumbnail path invalid" );
- }
- }
- elseif ( $type[2] == 2 ) {
- if (!imagejpeg( $thumbnail, $thumbpath ) ) {
- $error = __( "Thumbnail path invalid" );
- }
- }
- elseif ( $type[2] == 3 ) {
- if (!imagepng( $thumbnail, $thumbpath ) ) {
- $error = __( "Thumbnail path invalid" );
- }
- }
-
- }
- } else {
- $error = __( 'File not found' );
- }
-
- if (!empty ( $error ) ) {
- return $error;
- } else {
- return apply_filters( 'wp_create_thumbnail', $thumbpath );
- }
-}
-
-function update_blog_public($old_value, $value) {
- global $wpdb;
- $value = (int) $value;
- do_action('update_blog_public');
- update_blog_status( $wpdb->blogid, 'public', $value );
-}
-
-add_action('update_option_blog_public', 'update_blog_public', 10, 2);
-
-function update_option_new_admin_email($old_value, $value) {
- if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
- return;
-
- $hash = md5( $value.time().mt_rand() );
- $newadminemail = array(
- "hash" => $hash,
- "newemail" => $value
- );
- update_option( 'adminhash', $newadminemail );
-
- $content = __("Dear user,\n\n
-You recently requested to have the administration email address on
-your blog changed.\n
-If this is correct, please click on the following link to change it:\n
-###ADMIN_URL###\n\n
-You can safely ignore and delete this email if you do not want to take this action.\n\n
-This email has been sent to ###EMAIL###\n\n
-Regards,\n
-The Webmaster");
-
- $content = str_replace('###ADMIN_URL###', get_option( "siteurl" ).'/wp-admin/options.php?adminhash='.$hash, $content);
- $content = str_replace('###EMAIL###', $value, $content);
-
- wp_mail( $value, sprintf(__('[%s] New Admin Email Address'), get_option('blogname')), $content );
-}
-
-add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2);
+// Deprecated. Use includes/admin.php.
+require_once(ABSPATH . 'wp-admin/includes/admin.php');
?>
diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php
index d6ff2ef..a75fe7b 100644
--- a/wp-admin/admin-header.php
+++ b/wp-admin/admin-header.php
@@ -1,5 +1,5 @@
<?php
-@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
if (!isset($_GET["page"])) require_once('admin.php');
if ( $editing ) {
wp_enqueue_script( array('dbx-admin-key?pagenow=' . attribute_escape($pagenow),'admin-custom-fields') );
@@ -17,10 +17,7 @@ get_admin_page_title();
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php bloginfo('name') ?> &rsaquo; <?php echo wp_specialchars( strip_tags( $title ) ); ?> &#8212; WordPress</title>
-<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
-<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
-<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
-<?php endif; ?>
+<?php wp_admin_css(); ?>
<script type="text/javascript">
//<![CDATA[
function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
@@ -42,16 +39,16 @@ else if ( isset($plugin_page) )
do_action('admin_head');
?>
</head>
-<body>
+<body class="wp-admin <?php echo apply_filters( 'admin_body_class', '' ); ?>">
<div id="wphead">
-<h1><?php bloginfo('name'); ?> <span>(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site &raquo;') ?></a>)</span></h1>
+<h1><?php bloginfo('name'); ?> <span id="viewsite">(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site &raquo;') ?></a>)</span></h1>
</div>
<div id="user_info"><p><?php printf(__('Howdy, <strong>%s</strong>.'), $user_identity) ?> [<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php _e('Sign Out'); ?></a>, <a href="profile.php"><?php _e('My Profile'); ?></a>] </p></div>
<?php
-require(ABSPATH . '/wp-admin/menu-header.php');
+require(ABSPATH . 'wp-admin/menu-header.php');
if ( $parent_file == 'options-general.php' ) {
- require(ABSPATH . '/wp-admin/options-head.php');
+ require(ABSPATH . 'wp-admin/options-head.php');
}
?>
diff --git a/wp-admin/admin.php b/wp-admin/admin.php
index 772b710..ee5f9a9 100644
--- a/wp-admin/admin.php
+++ b/wp-admin/admin.php
@@ -15,9 +15,7 @@ if ( get_option('db_version') != $wp_db_version ) {
}
}
-require_once(ABSPATH . 'wp-admin/admin-functions.php');
-require_once(ABSPATH . 'wp-admin/admin-db.php');
-require_once(ABSPATH . WPINC . '/registration.php');
+require_once(ABSPATH . 'wp-admin/includes/admin.php');
auth_redirect();
@@ -43,7 +41,7 @@ if (isset($_GET['page'])) {
$plugin_page = plugin_basename($plugin_page);
}
-require(ABSPATH . '/wp-admin/menu.php');
+require(ABSPATH . 'wp-admin/menu.php');
// Handle plugin admin pages.
if (isset($plugin_page)) {
@@ -52,7 +50,7 @@ if (isset($plugin_page)) {
if ( $page_hook ) {
do_action('load-' . $page_hook);
if (! isset($_GET['noheader']))
- require_once(ABSPATH . '/wp-admin/admin-header.php');
+ require_once(ABSPATH . 'wp-admin/admin-header.php');
do_action($page_hook);
} else {
@@ -88,10 +86,15 @@ if (isset($plugin_page)) {
wp_die(__('Invalid importer.'));
}
- if (! file_exists(ABSPATH . "wp-admin/import/$importer.php"))
- wp_die(__('Cannot load importer.'));
-
- include(ABSPATH . "wp-admin/import/$importer.php");
+ // Allow plugins to define importers as well
+ if (! is_callable($wp_importers[$importer][2]))
+ {
+ if (! file_exists(ABSPATH . "wp-admin/import/$importer.php"))
+ {
+ wp_die(__('Cannot load importer.'));
+ }
+ include(ABSPATH . "wp-admin/import/$importer.php");
+ }
$parent_file = 'edit.php';
$submenu_file = 'import.php';
@@ -100,7 +103,7 @@ if (isset($plugin_page)) {
if (! isset($_GET['noheader']))
require_once(ABSPATH . 'wp-admin/admin-header.php');
- require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
define('WP_IMPORTING', true);
kses_init_filters(); // Always filter imported data with kses.
diff --git a/wp-admin/bookmarklet.php b/wp-admin/bookmarklet.php
index e84b5d9..fca99e1 100644
--- a/wp-admin/bookmarklet.php
+++ b/wp-admin/bookmarklet.php
@@ -51,7 +51,7 @@ if ( !empty($content) ) {
<head>
<title><?php bloginfo('name') ?> &rsaquo; Bookmarklet &#8212; WordPress</title>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
-<link rel="stylesheet" href="wp-admin.css" type="text/css" />
+<?php wp_admin_css(); ?>
<style type="text/css">
<!--
diff --git a/wp-admin/categories.php b/wp-admin/categories.php
index 5e77e0f..59ff4eb 100644
--- a/wp-admin/categories.php
+++ b/wp-admin/categories.php
@@ -63,9 +63,9 @@ case 'editedcat':
wp_die(__('Cheatin&#8217; uh?'));
if ( wp_update_category($_POST) )
- wp_redirect('categories.php?message=3');
+ wp_redirect('categories.php?message=3');
else
- wp_redirect('categories.php?message=5');
+ wp_redirect('categories.php?message=5');
exit;
break;
@@ -99,7 +99,6 @@ $messages[5] = __('Category not updated.');
<th scope="col"><?php _e('Name') ?></th>
<th scope="col"><?php _e('Description') ?></th>
<th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
- <th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th>
<th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
</tr>
</thead>
@@ -114,10 +113,12 @@ cat_rows();
<?php if ( current_user_can('manage_categories') ) : ?>
<div class="wrap">
-<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and links in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong> and links that were only assigned to the deleted category are set to <strong>%s</strong>.'), apply_filters('the_category', get_catname(get_option('default_category'))), apply_filters('the_category', get_catname(get_option('default_link_category')))) ?></p>
+<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), apply_filters('the_category', get_catname(get_option('default_category')))) ?></p>
+<p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'admin.php?import=wp-cat2tag') ?></p>
</div>
<?php include('edit-category-form.php'); ?>
+
<?php endif; ?>
<?php
diff --git a/wp-admin/comment.php b/wp-admin/comment.php
index 4390571..eee6a12 100644
--- a/wp-admin/comment.php
+++ b/wp-admin/comment.php
@@ -91,7 +91,7 @@ case 'mac':
<?php if ( $comment->comment_author_url ) { ?>
<tr>
<th scope="row"><?php _e('URL:'); ?></th>
-<td><?php echo $comment->comment_author_url; ?></td>
+<td><a href='<?php echo $comment->comment_author_url; ?>'><?php echo $comment->comment_author_url; ?></a></td>
</tr>
<?php } ?>
<tr>
@@ -155,7 +155,7 @@ case 'unapprovecomment':
if ((wp_get_referer() != "") && (false == $noredir)) {
wp_redirect(wp_get_referer());
} else {
- wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='. (int) $comment->comment_post_ID.'&c=1#comments');
+ wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p=' . (int) $comment->comment_post_ID.'&c=1#comments');
}
exit();
break;
@@ -185,7 +185,7 @@ case 'approvecomment':
if ((wp_get_referer() != "") && (false == $noredir)) {
wp_redirect(wp_get_referer());
} else {
- wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='. (int) $comment->comment_post_ID.'&c=1#comments');
+ wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p=' . (int) $comment->comment_post_ID.'&c=1#comments');
}
exit();
break;
diff --git a/wp-admin/install-rtl.css b/wp-admin/css/install-rtl.css
index 9ab4a20..6912736 100644
--- a/wp-admin/install-rtl.css
+++ b/wp-admin/css/install-rtl.css
@@ -12,4 +12,4 @@ input { font-family: "Times New Roman", Times, serif; padding: 1px }
#admin_email {direction: ltr; text-align: left; }
-#footer { font-style: normal; }
+#footer { font-style: normal; } \ No newline at end of file
diff --git a/wp-admin/install.css b/wp-admin/css/install.css
index 5eb85cd..5eb85cd 100644
--- a/wp-admin/install.css
+++ b/wp-admin/css/install.css
diff --git a/wp-admin/css/upload-rtl.css b/wp-admin/css/upload-rtl.css
new file mode 100644
index 0000000..dc13a4b
--- /dev/null
+++ b/wp-admin/css/upload-rtl.css
@@ -0,0 +1,12 @@
+html {
+ direction: ltr;
+ }
+#uploadoptions, table {
+ direction: rtl;
+ }
+td {
+ padding: 1px 6px 0;
+ }
+.submit {
+ text-align: left;
+ } \ No newline at end of file
diff --git a/wp-admin/upload.css b/wp-admin/css/upload.css
index 009986c..009986c 100644
--- a/wp-admin/upload.css
+++ b/wp-admin/css/upload.css
diff --git a/wp-admin/css/widgets-rtl.css b/wp-admin/css/widgets-rtl.css
new file mode 100644
index 0000000..d76cc9f
--- /dev/null
+++ b/wp-admin/css/widgets-rtl.css
@@ -0,0 +1,38 @@
+.dropzone,
+#palettediv,
+.handle,
+.controlform {
+ direction: rtl;
+ text-align: justify;
+ }
+.dropzone {
+ float: right;
+ margin-left: 10px;
+ margin-right: auto;
+ width: 240px;
+ }
+* html .dropzone ul {
+ margin-right: 0;
+ }
+* .handle, #lastmodule span {
+ border-left: 1px solid #e8e8e8;
+ border-right: 1px solid #f2f2f2;
+ }
+* .popper {
+ right: auto;
+ left: 3px;
+ }
+#palettediv .module, #lastmodule {
+ margin-right: auto;
+ margin-left: 10px;
+ float: right;
+ }
+#palettediv ul {
+ padding: 0 10px 0 0;
+ margin-right: 0;
+ width: 100%;
+ }
+.placemat {
+ margin-right: 0;
+ float: right;
+ } \ No newline at end of file
diff --git a/wp-admin/widgets.css b/wp-admin/css/widgets.css
index f78dbe5..f46c4ce 100644
--- a/wp-admin/widgets.css
+++ b/wp-admin/css/widgets.css
@@ -14,10 +14,10 @@ body {
}
.dropzone {
+ border: 1px solid #bbb;
float: left;
margin-right: 10px;
padding: 5px;
- border: 1px solid #bbb;
background-color: #f0f8ff;
}
@@ -26,15 +26,21 @@ body {
color: #333;
}
+.dropzone input {
+ display: none;
+}
+
.dropzone ul {
+ float: left;
list-style-type: none;
width: 240px;
- float: left;
margin: 0;
+ min-height: 200px;
padding: 0;
+ display: block;
}
-* .module, #lastmodule {
+* .module {
width: 238px;
padding: 0;
margin: 5px 0;
@@ -42,14 +48,16 @@ body {
display: block;
border: 1px solid #ccc;
background-color: #fbfbfb;
+ position: relative;
text-align: left;
line-height: 25px;
}
-* .handle, #lastmodule span {
+* .handle {
display: block;
width: 216px;
padding: 0 10px;
+ position: relative;
border-top: 1px solid #f2f2f2;
border-right: 1px solid #e8e8e8;
border-bottom: 1px solid #e8e8e8;
@@ -70,7 +78,7 @@ body {
cursor: pointer;
padding: 0 3px 1px;
border-top: 4px solid #6da6d1;
- background: url( images/fade-butt.png ) -5px 0px;
+ background: url( ../images/fade-butt.png ) -5px 0px;
}
* html .popper {
@@ -83,53 +91,67 @@ body {
clear: left;
}
-.placematt {
+.placemat {
cursor: default;
- margin: 10px 0 0;
+ margin: 0;
padding: 0;
- width: 238px;
- float:left;
- background-color: #ffe;
-}
-
-* html .placematt {
- margin-top: 5px;
+ position: relative;
}
-.placematt h4 {
+.placemat h4 {
text-align: center;
- margin-bottom: 5px;
}
-.placematt span {
+.placemat span {
+ background-color: #ffe;
+ border: 1px solid #ccc;
padding: 0 10px 10px;
+ position: absolute;
text-align: justify;
}
-
#palettediv {
border: 1px solid #bbb;
background-color: #f0f8ff;
height:auto;
margin-top: 10px;
+ padding-bottom: 10px;
+}
+
+#palettediv:after, #zones:after, .dropzone:after {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+}
+
+#palettediv, #zones, .dropzone {
+ display: block;
+ min-height: 1px;
+}
+
+* html #palettediv, * html #zones, * html .dropzone {
+ height: 1%;
}
#palettediv h3 {
text-align: center;
color: #333;
+ min-height: 1px;
}
#palettediv ul {
padding: 0 0 0 10px;
}
-#palettediv .module, #lastmodule {
+#palettediv .module {
margin-right: 10px;
float: left;
width: 120px;
}
-#palettediv .handle, #lastmodule span {
+#palettediv .handle {
height: 40px;
font-size: 90%;
width: 110px;
@@ -140,20 +162,11 @@ body {
visibility: hidden;
}
-#lastmodule {
- visibility: hidden;
-}
-
* html #palettediv ul {
margin: 0;
padding: 0 0 0 10px;
}
-* html #palettediv .module {
- float: none;
- display: inline;
-}
-
#controls {
height: 0px;
}
@@ -211,4 +224,13 @@ body {
top: 0px;
left: 0px;
width: 100%;
-} \ No newline at end of file
+}
+
+#dragHelper {
+ position: absolute;
+}
+
+#dragHelper li.module {
+ display: block;
+ float: left;
+}
diff --git a/wp-admin/custom-header.php b/wp-admin/custom-header.php
index d18ed87..8d60565 100644
--- a/wp-admin/custom-header.php
+++ b/wp-admin/custom-header.php
@@ -160,7 +160,7 @@ Event.observe( window, 'load', hide_text );
<h2><?php _e('Your Header Image'); ?></h2>
<p><?php _e('This is your header image. You can change the text color or upload and crop a new image.'); ?></p>
-<div id="headimg" style="background: url(<?php clean_url(header_image()) ?>) no-repeat;">
+<div id="headimg" style="background-image: url(<?php clean_url(header_image()) ?>);">
<h1><a onclick="return false;" href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>" id="name"><?php bloginfo('name'); ?></a></h1>
<div id="desc"><?php bloginfo('description');?></div>
</div>
@@ -169,7 +169,7 @@ Event.observe( window, 'load', hide_text );
<input type="button" value="<?php _e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" />
<input type="button" value="<?php _e('Select a Text Color'); ?>" onclick="colorSelect($('textcolor'), 'pickcolor')" id="pickcolor" /><input type="button" value="<?php _e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" />
<?php wp_nonce_field('custom-header') ?>
-<input type="hidden" name="textcolor" id="textcolor" value="#<?php attribute_escape(header_textcolor()) ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?> &raquo;" /></form>
+<input type="hidden" name="textcolor" id="textcolor" value="#<?php attribute_escape(header_textcolor()) ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes &raquo;'); ?>" /></form>
<?php } ?>
<div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
@@ -183,7 +183,7 @@ Event.observe( window, 'load', hide_text );
<input type="hidden" name="action" value="save" />
<?php wp_nonce_field('custom-header') ?>
<p class="submit">
-<input type="submit" value="<?php _e('Upload'); ?> &raquo;" />
+<input type="submit" value="<?php _e('Upload &raquo;'); ?>" />
</p>
</form>
diff --git a/wp-admin/edit-category-form.php b/wp-admin/edit-category-form.php
index 63f4d20..4696129 100644
--- a/wp-admin/edit-category-form.php
+++ b/wp-admin/edit-category-form.php
@@ -21,22 +21,22 @@ if ( ! empty($cat_ID) ) {
<div id="ajax-response"></div>
<?php echo $form ?>
<input type="hidden" name="action" value="<?php echo $action ?>" />
-<input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" />
+<input type="hidden" name="cat_ID" value="<?php echo $category->term_id ?>" />
<?php wp_nonce_field($nonce_action); ?>
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
<tr>
<th width="33%" scope="row" valign="top"><label for="cat_name"><?php _e('Category name:') ?></label></th>
- <td width="67%"><input name="cat_name" id="cat_name" type="text" value="<?php echo attribute_escape($category->cat_name); ?>" size="40" /></td>
+ <td width="67%"><input name="cat_name" id="cat_name" type="text" value="<?php echo attribute_escape($category->name); ?>" size="40" /></td>
</tr>
<tr>
<th scope="row" valign="top"><label for="category_parent"><?php _e('Category parent:') ?></label></th>
- <td>
- <?php wp_dropdown_categories('hide_empty=0&name=category_parent&orderby=name&selected=' . $category->category_parent . '&hierarchical=1&show_option_none=' . __('None')); ?>
+ <td>
+ <?php wp_dropdown_categories('hide_empty=0&name=category_parent&orderby=name&selected=' . $category->parent . '&hierarchical=1&show_option_none=' . __('None')); ?>
</td>
</tr>
<tr>
<th scope="row" valign="top"><label for="category_description"><?php _e('Description: (optional)') ?></label></th>
- <td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description); ?></textarea></td>
+ <td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->description); ?></textarea></td>
</tr>
</table>
<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index ea718b9..ab1bdbc 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -39,14 +39,14 @@ function getNumChecked(form)
</script>
<div class="wrap">
<h2><?php _e('Comments'); ?></h2>
-<form name="searchform" action="" method="get" id="editcomments">
- <fieldset>
- <legend><?php _e('Show Comments That Contain...') ?></legend>
- <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" />
- <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+<form name="searchform" action="" method="get" id="editcomments">
+ <fieldset>
+ <legend><?php _e('Show Comments That Contain...') ?></legend>
+ <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" />
+ <input type="submit" name="submit" value="<?php _e('Search') ?>" />
<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
<?php _e('(Searches within comment text, e-mail, URL, and IP address.)') ?>
- </fieldset>
+ </fieldset>
</form>
<p><a href="?mode=view"><?php _e('View Mode') ?></a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p>
<?php
@@ -88,7 +88,7 @@ $comments = array_slice($_comments, 0, 20);
$extra_comments = array_slice($_comments, 20);
$page_links = paginate_links( array(
- 'base' => add_query_arg( 'apage', '%#%' ),
+ 'base' => add_query_arg( 'apage', '%#%' ),
'format' => '',
'total' => ceil($total / 20),
'current' => $page
@@ -151,21 +151,22 @@ if ( $extra_comments ) : ?>
</tr>
</thead>';
foreach ($comments as $comment) {
- $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
+ $post = get_post($comment->comment_post_ID);
+ $authordata = get_userdata($post->post_author);
$comment_status = wp_get_comment_status($comment->comment_ID);
$class = ('alternate' == $class) ? '' : 'alternate';
$class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
?>
<tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
- <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
+ <td style="text-align: center"><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
<td><?php comment_author_link() ?></td>
<td><?php comment_author_email_link() ?></td>
- <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
+ <td><a href="edit-comments.php?s=<?php comment_author_IP() ?>&amp;mode=edit"><?php comment_author_IP() ?></a></td>
<td><?php comment_excerpt(); ?></td>
<td>
- <?php if ('unapproved' == $comment_status) { ?>
- (Unapproved)
- <?php } else { ?>
+ <?php if ('unapproved' == $comment_status) {
+ _e('Unapproved');
+ } else { ?>
<a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a>
<?php } ?>
</td>
@@ -175,7 +176,7 @@ if ( $extra_comments ) : ?>
echo "<a href=\"comment.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;c=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'. \n 'Cancel' to stop, 'OK' to delete."), $comment->comment_author )) . "', theCommentList );\" class='delete'>" . __('Delete') . "</a> ";
} ?></td>
</tr>
- <?php
+ <?php
} // end foreach
?></table>
<p class="submit"><input type="submit" name="delete_button" class="delete" value="<?php _e('Delete Checked Comments &raquo;') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php echo js_escape(__("Please select some comments to delete")); ?>'); return false } return confirm('<?php echo sprintf(js_escape(__("You are about to delete %s comments permanently \n 'Cancel' to stop, 'OK' to delete.")), "' + numchecked + '"); ?>')" />
diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php
index 81a998b..ab3adff 100644
--- a/wp-admin/edit-form-advanced.php
+++ b/wp-admin/edit-form-advanced.php
@@ -1,6 +1,6 @@
<?php
if ( isset($_GET['message']) )
- $_GET['message'] = (int) $_GET['message'];
+ $_GET['message'] = (int) $_GET['message'];
$messages[1] = __('Post updated');
$messages[2] = __('Custom field updated');
$messages[3] = __('Custom field deleted.');
@@ -57,7 +57,7 @@ if (empty($post->post_status)) $post->post_status = 'draft';
<input type="hidden" id="post_type" name="post_type" value="post" />
<?php echo $form_extra ?>
-<?php if (isset($_GET['message']) && 2 > $_GET['message']) : ?>
+<?php if ((isset($post->post_title) && '' == $post->post_title) || (isset($_GET['message']) && 2 > $_GET['message'])) : ?>
<script type="text/javascript">
function focusit() {
// focus on first input field
@@ -84,26 +84,28 @@ addLoadEvent(focusit);
<input name="advanced_view" type="hidden" value="1" />
<label for="comment_status" class="selectit">
<input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> />
-<?php _e('Allow Comments') ?></label>
+<?php _e('Allow Comments') ?></label>
<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php _e('Allow Pings') ?></label>
</div>
</fieldset>
<fieldset id="passworddiv" class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Post Password') ?></h3>
+<h3 class="dbx-handle"><?php _e('Post Password') ?></h3>
<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></div>
</fieldset>
<fieldset id="slugdiv" class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Post Slug') ?></h3>
+<h3 class="dbx-handle"><?php _e('Post Slug') ?></h3>
<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /></div>
</fieldset>
<fieldset id="poststatusdiv" class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Post Status') ?></h3>
-<div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?>
-<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
+<h3 class="dbx-handle"><?php _e('Post Status') ?></h3>
+<div class="dbx-content">
+<?php if ( current_user_can('publish_posts') ) : ?>
+ <label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
<?php endif; ?>
+ <label for="post_status_pending" class="selectit"><input id="post_status_pending" name="post_status" type="radio" value="pending" <?php checked($post->post_status, 'pending'); ?> /> <?php _e('Pending Review') ?></label>
<label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label>
<label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="radio" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></div>
</fieldset>
@@ -115,23 +117,16 @@ addLoadEvent(focusit);
</fieldset>
<?php endif; ?>
-<?php
-$authors = get_editable_authors( $current_user->id ); // TODO: ROLE SYSTEM
+<?php
+$authors = get_editable_user_ids( $current_user->id ); // TODO: ROLE SYSTEM
+if ( $post->post_author && !in_array($post->post_author, $authors) )
+ $authors[] = $post->post_author;
if ( $authors && count( $authors ) > 1 ) :
?>
<fieldset id="authordiv" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Post Author'); ?></h3>
<div class="dbx-content">
-<select name="post_author_override" id="post_author_override">
-<?php
-foreach ($authors as $o) :
-$o = get_userdata( $o->ID );
-if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"';
-else $selected = '';
-echo "<option value='" . (int) $o->ID . "' $selected>" . wp_specialchars( $o->display_name ) . "</option>";
-endforeach;
-?>
-</select>
+<?php wp_dropdown_users( array('include' => $authors, 'name' => 'post_author_override', 'selected' => empty($post_ID) ? $user_ID : $post->post_author) ); ?>
</div>
</fieldset>
<?php endif; ?>
@@ -162,21 +157,27 @@ endforeach;
<?php echo $form_pingback ?>
<?php echo $form_prevstatus ?>
+<fieldset id="tagdiv">
+ <legend><?php _e('Tags (separate multiple tags with commas: cats, pet food, dogs)'); ?></legend>
+ <div><input type="text" name="tags_input" class="tags-input" id="tags-input" size="30" tabindex="3" value="<?php echo get_tags_to_edit( $post_ID ); ?>" /></div>
+</fieldset>
<p class="submit">
<span id="autosave"></span>
<?php echo $saveasdraft; ?>
-<input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" />
-<?php
-if ('publish' != $post->post_status || 0 == $post_ID) {
+<input type="submit" name="submit" value="<?php _e('Save'); ?>" style="font-weight: bold;" tabindex="4" />
+<?php
+if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post_ID ) {
?>
<?php if ( current_user_can('publish_posts') ) : ?>
- <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish'); ?>" />
+ <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
+<?php else : ?>
+ <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Submit for Review') ?>" />
<?php endif; ?>
<?php
}
?>
-<input name="referredby" type="hidden" id="referredby" value="<?php
+<input name="referredby" type="hidden" id="referredby" value="<?php
if ( !empty($_REQUEST['popupurl']) )
echo clean_url(stripslashes($_REQUEST['popupurl']));
else if ( url_to_postid(wp_get_referer()) == $post_ID )
@@ -193,7 +194,7 @@ if (current_user_can('upload_files')) {
$uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
- echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
+ echo '<iframe id="uploading" name="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
?>
diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php
index 5d6f448..2f06909 100644
--- a/wp-admin/edit-form-comment.php
+++ b/wp-admin/edit-form-comment.php
@@ -6,6 +6,7 @@ $form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment-
?>
<form name="post" action="comment.php" method="post" id="post">
+<h2><?php echo $toprow_title; ?></h2>
<?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?>
<div class="wrap">
<input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" />
@@ -32,7 +33,7 @@ addLoadEvent(focusit);
<fieldset id="uridiv">
<legend><label for="newcomment_author_url"><?php _e('URL:') ?></label></legend>
<div>
- <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo attribute_escape( $comment->comment_author_url ); ?>" tabindex="3" />
+ <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo attribute_escape( $comment->comment_author_url ); ?>" tabindex="2" />
</div>
</fieldset>
@@ -53,21 +54,21 @@ addLoadEvent(focusit);
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr>
<th scope="row" valign="top"><?php _e('Comment Status') ?>:</th>
- <td><label for="comment_status_approved" class="selectit"><input id="comment_status_approved" name="comment_status" type="radio" value="1" <?php checked($comment->comment_approved, '1'); ?> /> <?php _e('Approved') ?></label><br />
- <label for="comment_status_moderated" class="selectit"><input id="comment_status_moderated" name="comment_status" type="radio" value="0" <?php checked($comment->comment_approved, '0'); ?> /> <?php _e('Moderated') ?></label><br />
- <label for="comment_status_spam" class="selectit"><input id="comment_status_spam" name="comment_status" type="radio" value="spam" <?php checked($comment->comment_approved, 'spam'); ?> /> <?php _e('Spam') ?></label></td>
+ <td><label for="comment_status_approved" class="selectit"><input id="comment_status_approved" name="comment_status" type="radio" value="1" <?php checked($comment->comment_approved, '1'); ?> tabindex="4" /> <?php _e('Approved') ?></label> &nbsp;
+ <label for="comment_status_moderated" class="selectit"><input id="comment_status_moderated" name="comment_status" type="radio" value="0" <?php checked($comment->comment_approved, '0'); ?> tabindex="4" /> <?php _e('Moderated') ?></label> &nbsp;
+ <label for="comment_status_spam" class="selectit"><input id="comment_status_spam" name="comment_status" type="radio" value="spam" <?php checked($comment->comment_approved, 'spam'); ?> tabindex="4" /> <?php _e('Spam') ?></label></td>
</tr>
<?php if ( current_user_can('edit_posts') ) : ?>
<tr>
<th scope="row" valign="top"><?php _e('Edit time'); ?>:</th>
- <td><?php touch_time(('editcomment' == $action), 0); ?> </td>
+ <td><?php touch_time(('editcomment' == $action), 0, 5); ?> </td>
</tr>
<?php endif; ?>
<tr>
- <th scope="row" valign="top"><?php _e('Delete'); $delete_nonce = wp_create_nonce( 'delete-comment_' . $comment->comment_ID ); ?>:</th>
- <td><input name="deletecomment" class="button delete" type="submit" id="deletecomment" tabindex="10" value="<?php _e('Delete this comment') ?>" <?php echo "onclick=\"if ( confirm('" . js_escape(__("You are about to delete this comment. \n 'Cancel' to stop, 'OK' to delete.")) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true; } return false;\""; ?> />
+ <th scope="row" valign="top">&nbsp;</th>
+ <td><input name="deletecomment" class="button delete" type="submit" id="deletecomment" tabindex="10" value="<?php _e('Delete this comment') ?>" <?php echo "onclick=\"if ( confirm('" . js_escape(__("You are about to delete this comment. \n 'Cancel' to stop, 'OK' to delete.")) . "') ) { document.forms.post._wpnonce.value = '" . wp_create_nonce( 'delete-comment_' . $comment->comment_ID ) . "'; return true; } return false;\""; ?> />
<input type="hidden" name="c" value="<?php echo $comment->comment_ID ?>" />
<input type="hidden" name="p" value="<?php echo $comment->comment_post_ID ?>" />
<input type="hidden" name="noredir" value="1" />
diff --git a/wp-admin/edit-form.php b/wp-admin/edit-form.php
index 3945e3c..00e4932 100644
--- a/wp-admin/edit-form.php
+++ b/wp-admin/edit-form.php
@@ -20,19 +20,18 @@ addLoadEvent(focusit);
<div id="poststuff">
<fieldset id="titlediv">
- <legend><a href="http://wordpress.org/docs/reference/post/#title" title="<?php _e('Help on titles') ?>"><?php _e('Title') ?></a></legend>
+ <legend><a href="http://wordpress.org/docs/reference/post/#title" title="<?php _e('Help on titles') ?>"><?php _e('Title') ?></a></legend>
<div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" /></div>
</fieldset>
<fieldset id="categorydiv">
- <legend><a href="http://wordpress.org/docs/reference/post/#category" title="<?php _e('Help on categories') ?>"><?php _e('Categories') ?></a></legend>
+ <legend><a href="http://wordpress.org/docs/reference/post/#category" title="<?php _e('Help on categories') ?>"><?php _e('Categories') ?></a></legend>
<div><?php dropdown_categories($post->post_category); ?></div>
</fieldset>
<br />
<fieldset id="postdiv">
<legend><a href="http://wordpress.org/docs/reference/post/#post" title="<?php _e('Help with post field') ?>"><?php _e('Post') ?></a></legend>
-<?php the_quicktags(); ?>
<?php
$rows = get_option('default_post_edit_rows');
if (($rows < 3) || ($rows > 100)) {
diff --git a/wp-admin/edit-link-categories.php b/wp-admin/edit-link-categories.php
new file mode 100644
index 0000000..3e05f5a
--- /dev/null
+++ b/wp-admin/edit-link-categories.php
@@ -0,0 +1,93 @@
+<?php
+require_once('admin.php');
+
+$title = __('Categories');
+$parent_file = 'link-manager.php';
+
+//wp_enqueue_script( 'admin-categories' ); TODO: Fix AJAX
+require_once ('admin-header.php');
+
+$messages[1] = __('Category added.');
+$messages[2] = __('Category deleted.');
+$messages[3] = __('Category updated.');
+$messages[4] = __('Category not added.');
+$messages[5] = __('Category not updated.');
+
+function link_cat_row($category) {
+ global $class;
+
+ if ( current_user_can( 'manage_categories' ) ) {
+ $edit = "<a href='link-category.php?action=edit&amp;cat_ID=$category->term_id' class='edit'>".__( 'Edit' )."</a></td>";
+ $default_cat_id = (int) get_option( 'default_link_category' );
+
+ if ( $category->term_id != $default_cat_id )
+ $edit .= "<td><a href='" . wp_nonce_url( "link-category.php?action=delete&amp;cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id ) . "' onclick=\"return deleteSomething( 'cat', $category->term_id, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->name, get_term_field( 'name', $default_cat_id, 'link_category' ))) . "' );\" class='delete'>".__( 'Delete' )."</a>";
+ else
+ $edit .= "<td style='text-align:center'>".__( "Default" );
+ } else {
+ $edit = '';
+ }
+
+ $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
+
+ $category->count = number_format_i18n( $category->count );
+ $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
+ return "<tr id='cat-$category->term_id'$class>
+ <th scope='row' style='text-align: center'>$category->term_id</th>
+ <td>" . ( $name_override ? $name_override : $pad . ' ' . $category->name ) . "</td>
+ <td>$category->description</td>
+ <td align='center'>$count</td>
+ <td>$edit</td>\n\t</tr>\n";
+}
+?>
+
+<?php if (isset($_GET['message'])) : ?>
+<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php endif; ?>
+
+<div class="wrap">
+<?php if ( current_user_can('manage_categories') ) : ?>
+ <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
+<?php else : ?>
+ <h2><?php _e('Categories') ?> </h2>
+<?php endif; ?>
+<table class="widefat">
+ <thead>
+ <tr>
+ <th scope="col" style="text-align: center"><?php _e('ID') ?></th>
+ <th scope="col"><?php _e('Name') ?></th>
+ <th scope="col"><?php _e('Description') ?></th>
+ <th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th>
+ <th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
+ </tr>
+ </thead>
+ <tbody id="the-list">
+<?php
+$categories = get_terms( 'link_category', 'hide_empty=0' );
+if ( $categories ) {
+ $output = '';
+ foreach ( $categories as $category ) {
+ $category = sanitize_term($category, 'link_category', 'display');
+ $output .= link_cat_row($category);
+ }
+ $output = apply_filters('cat_rows', $output);
+ echo $output;
+ unset($category);
+}
+
+?>
+ </tbody>
+</table>
+
+</div>
+
+<?php if ( current_user_can('manage_categories') ) : ?>
+<div class="wrap">
+<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the links in that category. Instead, links that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), get_term_field('name', get_option('default_link_category'), 'link_category')) ?></p>
+</div>
+
+<?php include('edit-link-category-form.php'); ?>
+
+<?php endif; ?>
+
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/edit-link-category-form.php b/wp-admin/edit-link-category-form.php
new file mode 100644
index 0000000..51bbcda
--- /dev/null
+++ b/wp-admin/edit-link-category-form.php
@@ -0,0 +1,43 @@
+<?php
+if ( ! empty($cat_ID) ) {
+ $heading = __('Edit Category');
+ $submit_text = __('Edit Category &raquo;');
+ $form = '<form name="editcat" id="editcat" method="post" action="link-category.php">';
+ $action = 'editedcat';
+ $nonce_action = 'update-link-category_' . $cat_ID;
+ do_action('edit_link_category_form_pre', $category);
+} else {
+ $heading = __('Add Category');
+ $submit_text = __('Add Category &raquo;');
+ $form = '<form name="addcat" id="addcat" method="post" action="link-category.php">';
+ $action = 'addcat';
+ $nonce_action = 'add-link-category';
+ do_action('add_link_category_form_pre', $category);
+}
+?>
+
+<div class="wrap">
+<h2><?php echo $heading ?></h2>
+<div id="ajax-response"></div>
+<?php echo $form ?>
+<input type="hidden" name="action" value="<?php echo $action ?>" />
+<input type="hidden" name="cat_ID" value="<?php echo $category->term_id ?>" />
+<?php wp_nonce_field($nonce_action); ?>
+ <table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="33%" scope="row" valign="top"><label for="name"><?php _e('Category name:') ?></label></th>
+ <td width="67%"><input name="name" id="name" type="text" value="<?php echo $category->name; ?>" size="40" /></td>
+ </tr>
+ <tr>
+ <th scope="row" valign="top"><label for="slug"><?php _e('Category slug:') ?></label></th>
+ <td><input name="slug" id="slug" type="text" value="<?php echo $category->slug; ?>" size="40" /></td>
+ </tr>
+ <tr>
+ <th scope="row" valign="top"><label for="description"><?php _e('Description: (optional)') ?></label></th>
+ <td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo $category->description; ?></textarea></td>
+ </tr>
+ </table>
+<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
+<?php do_action('edit_link_category_form', $category); ?>
+</form>
+</div>
diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php
index bd226e7..e281d30 100644
--- a/wp-admin/edit-link-form.php
+++ b/wp-admin/edit-link-form.php
@@ -43,7 +43,7 @@ function xfn_check($class, $value = '', $type = 'check') {
<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
<div class="dbx-content">
<p id="jaxcat"></p>
-<ul id="categorychecklist"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul>
+<ul id="linkcategorychecklist"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul>
</div>
</fieldset>
@@ -80,15 +80,15 @@ function xfn_check($class, $value = '', $type = 'check') {
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
<tr>
<th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th>
-<td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
+<td><input type="text" name="link_name" id="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
</tr>
<tr>
<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('Address:') ?></label></th>
-<td width="80%"><input type="text" name="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td>
+<td width="80%"><input type="text" name="link_url" id="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td>
</tr>
<tr>
<th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th>
-<td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
+<td><input type="text" name="link_description" id="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
</tr>
</table>
@@ -241,6 +241,7 @@ function xfn_check($class, $value = '', $type = 'check') {
</td>
</tr>
</table>
+</div>
</fieldset>
</div>
diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php
index 93a6837..e3a039e 100644
--- a/wp-admin/edit-page-form.php
+++ b/wp-admin/edit-page-form.php
@@ -170,7 +170,7 @@ if (current_user_can('upload_files')) {
$uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
- echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
+ echo '<iframe id="uploading" name="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
}
?>
diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php
index 627a031..f263348 100644
--- a/wp-admin/edit-pages.php
+++ b/wp-admin/edit-pages.php
@@ -4,31 +4,74 @@ $title = __('Pages');
$parent_file = 'edit.php';
wp_enqueue_script( 'listman' );
require_once('admin-header.php');
+
+$post_stati = array( // array( adj, noun )
+ 'publish' => array(__('Published'), __('Published pages')),
+ 'draft' => array(__('Draft'), __('Draft pages')),
+ 'private' => array(__('Private'), __('Private pages'))
+ );
+
+
+$post_status_label = __('Pages');
+$post_status_q = '';
+if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
+ $post_status_label = $post_stati[$_GET['post_status']][1];
+ $post_status_q = '&post_status=' . $_GET['post_status'];
+}
+
?>
<div class="wrap">
-<h2><?php _e('Page Management'); ?></h2>
+
+<h2><?php
+// Use $_GET instead of is_ since they can override each other
+$h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : '';
+$h2_author = '';
+if ( isset($_GET['author']) && $_GET['author'] ) {
+ $author_user = get_userdata( (int) $_GET['author'] );
+ $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
+}
+printf( _c( '%1$s%2$s%3$s|You can reorder these: 1: Pages, 2: by {s}, 3: matching {s}' ), $post_status_label, $h2_author, $h2_search );
+?></h2>
+
<p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page &raquo;'); ?></a></p>
-<form name="searchform" action="" method="get">
- <fieldset>
- <legend><?php _e('Search Pages&hellip;') ?></legend>
- <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" />
- <input type="submit" name="submit" value="<?php _e('Search') ?>" />
+<form name="searchform" id="searchform" action="" method="get">
+ <fieldset><legend><?php _e('Search Terms&hellip;') ?></legend>
+ <input type="text" name="s" id="s" value="<?php echo attribute_escape( stripslashes( $_GET['s'] ) ); ?>" size="17" />
+ </fieldset>
+
+
+ <fieldset><legend><?php _e('Page Type&hellip;'); ?></legend>
+ <select name='post_status'>
+ <option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option>
+<?php foreach ( $post_stati as $status => $label ) : ?>
+ <option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option>
+<?php endforeach; ?>
+ </select>
</fieldset>
+
+<?php $editable_ids = get_editable_user_ids( $user_ID ); if ( $editable_ids && count( $editable_ids ) > 1 ) : ?>
+
+ <fieldset><legend><?php _e('Author&hellip;'); ?></legend>
+ <?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?>
+ </fieldset>
+
+<?php endif; ?>
+
+ <input type="submit" id="post-query-submit" value="<?php _e('Filter &#187;'); ?>" class="button" />
</form>
+<br style="clear:both;" />
+
<?php
-wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1&order=asc');
+wp("post_type=page&orderby=menu_order&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc");
-if ( $_GET['s'] )
- $all = false;
-else
- $all = true;
+$all = !( $h2_search || $post_status_q );
if ($posts) {
?>
-<table class="widefat">
+<table class="widefat">
<thead>
<tr>
<th scope="col" style="text-align: center"><?php _e('ID') ?></th>
@@ -39,9 +82,7 @@ if ($posts) {
</tr>
</thead>
<tbody id="the-list">
-<?php
-page_rows(0, 0, $posts, $all);
-?>
+<?php page_rows(0, 0, $posts, $all); ?>
</tbody>
</table>
@@ -50,7 +91,7 @@ page_rows(0, 0, $posts, $all);
<?php
} else {
?>
-<p><?php _e('No pages yet.') ?></p>
+<p><?php _e('No pages found.') ?></p>
<?php
} // end if ($posts)
?>
diff --git a/wp-admin/edit-post-rows.php b/wp-admin/edit-post-rows.php
new file mode 100644
index 0000000..b3dc1e9
--- /dev/null
+++ b/wp-admin/edit-post-rows.php
@@ -0,0 +1,117 @@
+<table class="widefat">
+ <thead>
+ <tr>
+
+<?php foreach($posts_columns as $column_display_name) { ?>
+ <th scope="col"><?php echo $column_display_name; ?></th>
+<?php } ?>
+
+ </tr>
+ </thead>
+ <tbody id="the-list">
+<?php
+if ( have_posts() ) {
+$bgcolor = '';
+add_filter('the_title','wp_specialchars');
+while (have_posts()) : the_post();
+$class = ('alternate' == $class) ? '' : 'alternate';
+global $current_user;
+$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
+?>
+ <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $class . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>'>
+
+<?php
+
+foreach($posts_columns as $column_name=>$column_display_name) {
+
+ switch($column_name) {
+
+ case 'id':
+ ?>
+ <th scope="row" style="text-align: center"><?php echo $id ?></th>
+ <?php
+ break;
+ case 'modified':
+ ?>
+ <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Never'); else the_modified_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td>
+ <?php
+ break;
+ case 'date':
+ ?>
+ <td><?php if ( '0000-00-00 00:00:00' ==$post->post_date) _e('Unpublished'); else the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td>
+ <?php
+ break;
+ case 'title':
+ ?>
+ <td><?php the_title() ?>
+ <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
+ <?php
+ break;
+
+ case 'categories':
+ ?>
+ <td><?php the_category(','); ?></td>
+ <?php
+ break;
+
+ case 'comments':
+ ?>
+ <td style="text-align: center">
+ <?php
+ $left = get_pending_comments_num( $post->ID );
+ $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
+ if ( $left )
+ echo '<strong>';
+ comments_number("<a href='edit.php?p=$id&amp;c=1' title='$pending_phrase'>" . __('0') . '</a>', "<a href='edit.php?p=$id&amp;c=1' title='$pending_phrase'>" . __('1') . '</a>', "<a href='edit.php?p=$id&amp;c=1' title='$pending_phrase'>" . __('%') . '</a>');
+ if ( $left )
+ echo '</strong>';
+ ?>
+ </td>
+ <?php
+ break;
+
+ case 'author':
+ ?>
+ <td><?php the_author() ?></td>
+ <?php
+ break;
+
+ case 'control_view':
+ ?>
+ <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
+ <?php
+ break;
+
+ case 'control_edit':
+ ?>
+ <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
+ <?php
+ break;
+
+ case 'control_delete':
+ ?>
+ <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . js_escape(sprintf(__("You are about to delete this post '%s'.\n'OK' to delete, 'Cancel' to stop."), get_the_title())) . "' );\">" . __('Delete') . "</a>"; } ?></td>
+ <?php
+ break;
+
+ default:
+ ?>
+ <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
+ <?php
+ break;
+ }
+}
+?>
+ </tr>
+<?php
+endwhile;
+} else {
+?>
+ <tr style='background-color: <?php echo $bgcolor; ?>'>
+ <td colspan="8"><?php _e('No posts found.') ?></td>
+ </tr>
+<?php
+} // end if ( have_posts() )
+?>
+ </tbody>
+</table>
diff --git a/wp-admin/edit.php b/wp-admin/edit.php
index 47f5ad8..ba4cc04 100644
--- a/wp-admin/edit.php
+++ b/wp-admin/edit.php
@@ -6,134 +6,58 @@ $parent_file = 'edit.php';
wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' );
require_once('admin-header.php');
-$_GET['m'] = (int) $_GET['m'];
-
-$drafts = get_users_drafts( $user_ID );
-$other_drafts = get_others_drafts( $user_ID);
-
-if ($drafts || $other_drafts) {
+$_GET['m'] = (int) $_GET['m'];
+$_GET['cat'] = (int) $_GET['cat'];
+$post_stati = array( // array( adj, noun )
+ 'publish' => array(__('Published'), __('Published posts')),
+ 'future' => array(__('Scheduled'), __('Scheduled posts')),
+ 'pending' => array(__('Pending Review'), __('Pending posts')),
+ 'draft' => array(__('Draft'), _c('Drafts|manage posts header')),
+ 'private' => array(__('Private'), __('Private posts'))
+ );
+
+$avail_post_stati = $wpdb->get_col("SELECT DISTINCT post_status FROM $wpdb->posts WHERE post_type = 'post'");
+
+$post_status_q = '';
+$post_status_label = __('Posts');
+if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
+ $post_status_label = $post_stati[$_GET['post_status']][1];
+ $post_status_q = '&post_status=' . $_GET['post_status'];
+}
?>
-<div class="wrap">
-<?php if ($drafts) { ?>
- <p><strong><?php _e('Your Drafts:') ?></strong>
- <?php
- $i = 0;
- foreach ($drafts as $draft) {
- if (0 != $i)
- echo ', ';
- $draft->post_title = apply_filters('the_title', stripslashes($draft->post_title));
- if ($draft->post_title == '')
- $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
- echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
- ++$i;
- }
- ?>
-.</p>
-<?php } ?>
-
-<?php if ($other_drafts) { ?>
- <p><strong><?php _e('Other&#8217;s Drafts:') ?></strong>
- <?php
- $i = 0;
- foreach ($other_drafts as $draft) {
- if (0 != $i)
- echo ', ';
- $draft->post_title = apply_filters('the_title', stripslashes($draft->post_title));
- if ($draft->post_title == '')
- $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
- echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
- ++$i;
- }
- ?>
- .</p>
-
-<?php } ?>
-
-</div>
-<?php } ?>
<div class="wrap">
-<h2>
-<?php
-wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1');
+<?php
-if ( is_month() ) {
- single_month_title(' ');
-} elseif ( is_search() ) {
- printf(__('Search for &#8220;%s&#8221;'), wp_specialchars($_GET['s']) );
+if ( 'pending' === $_GET['post_status'] ) {
+ $order = 'ASC';
+ $orderby = 'modified';
+} elseif ( 'draft' === $_GET['post_status'] ) {
+ $order = 'DESC';
+ $orderby = 'modified';
} else {
- if ( is_single() )
- printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title));
- elseif ( ! is_paged() || get_query_var('paged') == 1 )
- _e('Last 15 Posts');
- else
- _e('Previous Posts');
+ $order = 'DESC';
+ $orderby = 'date';
}
-?>
-</h2>
-<form name="searchform" id="searchform" action="" method="get">
- <fieldset>
- <legend><?php _e('Search Posts&hellip;') ?></legend>
- <input type="text" name="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" />
- <input type="submit" name="submit" value="<?php _e('Search') ?>" class="button" />
- </fieldset>
-</form>
+wp("what_to_show=posts$post_status_q&posts_per_page=15&order=$order&orderby=$orderby");
-<?php $arc_result = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC");
-
-if ( count($arc_result) ) { ?>
-
-<form name="viewarc" id="viewarc" action="" method="get">
- <fieldset>
- <legend><?php _e('Browse Month&hellip;') ?></legend>
- <select name='m'>
- <?php
- foreach ($arc_result as $arc_row) {
- if ( $arc_row->yyear == 0 )
- continue;
- $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
-
- if( isset($_GET['m']) && $arc_row->yyear . $arc_row->mmonth == (int) $_GET['m'] )
- $default = 'selected="selected"';
- else
- $default = null;
-
- echo "<option $default value='$arc_row->yyear$arc_row->mmonth'>";
- echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
- echo "</option>\n";
- }
- ?>
- </select>
- <input type="submit" name="submit" value="<?php _e('Show Month') ?>" class="button" />
- </fieldset>
-</form>
-
-<?php } ?>
-
-<form name="viewcat" id="viewcat" action="" method="get">
- <fieldset>
- <legend><?php _e('Browse Category&hellip;') ?></legend>
- <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?>
- <input type="submit" name="submit" value="<?php _e('Show Category') ?>" class="button" />
- </fieldset>
-</form>
-
-<?php do_action('restrict_manage_posts'); ?>
-
-<br style="clear:both;" />
-
-<?php
// define the columns to display, the syntax is 'internal name' => 'display name'
-$posts_columns = array(
- 'id' => '<div style="text-align: center">' . __('ID') . '</div>',
- 'date' => __('When'),
- 'title' => __('Title'),
- 'categories' => __('Categories'),
- 'comments' => '<div style="text-align: center">' . __('Comments') . '</div>',
- 'author' => __('Author')
-);
+$posts_columns = array();
+$posts_columns['id'] = '<div style="text-align: center">' . __('ID') . '</div>';
+if ( 'draft' === $_GET['post_status'] )
+ $posts_columns['modified'] = __('Modified');
+elseif ( 'pending' === $_GET['post_status'] )
+ $posts_columns['modified'] = __('Submitted');
+else
+ $posts_columns['date'] = __('When');
+$posts_columns['title'] = __('Title');
+$posts_columns['categories'] = __('Categories');
+if ( !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
+ $posts_columns['comments'] = '<div style="text-align: center">' . __('Comments') . '</div>';
+$posts_columns['author'] = __('Author');
+
$posts_columns = apply_filters('manage_posts_columns', $posts_columns);
// you can not edit these at the moment
@@ -143,109 +67,100 @@ $posts_columns['control_delete'] = '';
?>
-<table class="widefat">
- <thead>
- <tr>
+<h2><?php
+if ( is_single() ) {
+ printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title));
+} else {
+ if ( $post_listing_pageable && !is_archive() && !is_search() )
+ $h2_noun = is_paged() ? sprintf(__( 'Previous %s' ), $post_status_label) : sprintf(__('Latest %s'), $post_status_label);
+ else
+ $h2_noun = $post_status_label;
+ // Use $_GET instead of is_ since they can override each other
+ $h2_author = '';
+ $_GET['author'] = (int) $_GET['author'];
+ if ( $_GET['author'] != 0 ) {
+ if ( $_GET['author'] == '-' . $user_ID ) { // author exclusion
+ $h2_author = ' ' . __('by other authors');
+ } else {
+ $author_user = get_userdata( get_query_var( 'author' ) );
+ $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
+ }
+ }
+ $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( get_search_query() ) ) : '';
+ $h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in &#8220;%s&#8221;'), single_cat_title('', false) ) : '';
+ $h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : '';
+ printf( _c( '%1$s%2$s%3$s%4$s%5$s|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_month );
+}
+?></h2>
-<?php foreach($posts_columns as $column_display_name) { ?>
- <th scope="col"><?php echo $column_display_name; ?></th>
-<?php } ?>
+<form name="searchform" id="searchform" action="" method="get">
+ <fieldset><legend><?php _e('Search terms&hellip;'); ?></legend>
+ <input type="text" name="s" id="s" value="<?php the_search_query(); ?>" size="17" />
+ </fieldset>
+
+ <fieldset><legend><?php _e('Status&hellip;'); ?></legend>
+ <select name='post_status'>
+ <option<?php selected( @$_GET['post_status'], 0 ); ?> value='0'><?php _e('Any'); ?></option>
+<?php foreach ( $post_stati as $status => $label ) : if ( !in_array($status, $avail_post_stati) ) continue; ?>
+ <option<?php selected( @$_GET['post_status'], $status ); ?> value='<?php echo $status; ?>'><?php echo $label[0]; ?></option>
+<?php endforeach; ?>
+ </select>
+ </fieldset>
- </tr>
- </thead>
- <tbody id="the-list">
<?php
-if ($posts) {
-$bgcolor = '';
-while (have_posts()) : the_post();
-add_filter('the_title','wp_specialchars');
-$class = ('alternate' == $class) ? '' : 'alternate';
+$editable_ids = get_editable_user_ids( $user_ID );
+if ( $editable_ids && count( $editable_ids ) > 1 ) :
?>
- <tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'>
+ <fieldset><legend><?php _e('Author&hellip;'); ?></legend>
+ <?php wp_dropdown_users( array('include' => $editable_ids, 'show_option_all' => __('Any'), 'name' => 'author', 'selected' => isset($_GET['author']) ? $_GET['author'] : 0) ); ?>
+ </fieldset>
<?php
+endif;
-foreach($posts_columns as $column_name=>$column_display_name) {
+$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";
- switch($column_name) {
+$arc_result = $wpdb->get_results( $arc_query );
- case 'id':
- ?>
- <th scope="row" style="text-align: center"><?php echo $id ?></th>
- <?php
- break;
+$month_count = count($arc_result);
- case 'date':
- ?>
- <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td>
- <?php
- break;
- case 'title':
- ?>
- <td><?php the_title() ?>
- <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
- <?php
- break;
+if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>
- case 'categories':
- ?>
- <td><?php the_category(','); ?></td>
+ <fieldset><legend><?php _e('Month&hellip;') ?></legend>
+ <select name='m'>
+ <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Any'); ?></option>
<?php
- break;
+ foreach ($arc_result as $arc_row) {
+ if ( $arc_row->yyear == 0 )
+ continue;
+ $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
- case 'comments':
- ?>
- <td style="text-align: center">
- <?php comments_number(__('0'), "<a href='edit.php?p=$id&amp;c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&amp;c=1'>" . __('%') . '</a>') ?>
- </td>
- <?php
- break;
+ if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] )
+ $default = ' selected="selected"';
+ else
+ $default = '';
- case 'author':
+ echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>";
+ echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
+ echo "</option>\n";
+ }
?>
- <td><?php the_author() ?></td>
- <?php
- break;
+ </select>
+ </fieldset>
- case 'control_view':
- ?>
- <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
- <?php
- break;
+<?php } ?>
- case 'control_edit':
- ?>
- <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
- <?php
- break;
+ <fieldset><legend><?php _e('Category&hellip;') ?></legend>
+ <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?>
+ </fieldset>
+ <input type="submit" id="post-query-submit" value="<?php _e('Filter &#187;'); ?>" class="button" />
+</form>
- case 'control_delete':
- ?>
- <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . js_escape(sprintf(__("You are about to delete this post '%s'.\n'OK' to delete, 'Cancel' to stop."), get_the_title())) . "' );\">" . __('Delete') . "</a>"; } ?></td>
- <?php
- break;
+<?php do_action('restrict_manage_posts'); ?>
- default:
- ?>
- <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
- <?php
- break;
- }
-}
-?>
- </tr>
-<?php
-endwhile;
-} else {
-?>
- <tr style='background-color: <?php echo $bgcolor; ?>'>
- <td colspan="8"><?php _e('No posts found.') ?></td>
- </tr>
-<?php
-} // end if ($posts)
-?>
- </tbody>
-</table>
+<br style="clear:both;" />
+
+<?php include( 'edit-post-rows.php' ); ?>
<div id="ajax-response"></div>
@@ -255,10 +170,12 @@ endwhile;
</div>
<?php
+
if ( 1 == count($posts) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
if ($comments) {
+ update_comment_cache($comments);
?>
<h3 id="comments"><?php _e('Comments') ?></h3>
<ol id="the-comment-list" class="commentlist">
@@ -267,7 +184,8 @@ $i = 0;
foreach ($comments as $comment) {
++$i; $class = '';
- $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
+ $post = get_post($comment->comment_post_ID);
+ $authordata = get_userdata($post->post_author);
$comment_status = wp_get_comment_status($comment->comment_ID);
if ('unapproved' == $comment_status)
$class .= ' unapproved';
@@ -275,22 +193,22 @@ foreach ($comments as $comment) {
$class .= ' alternate';
echo "<li id='comment-$comment->comment_ID' class='$class'>";
?>
-<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
+<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="edit-comments.php?s=<?php comment_author_IP() ?>&amp;mode=edit"><?php comment_author_IP() ?></a></p>
<?php comment_text() ?>
-<p><?php comment_date(__('M j, g:i A')); ?> &#8212; [
+<p><?php comment_date(__('M j, g:i A')); ?> &#8212; [
<?php
if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
- echo " <a href='comment.php?action=editcomment&amp;c=".$comment->comment_ID."'>" . __('Edit') . '</a>';
+ echo " <a href='comment.php?action=editcomment&amp;c=".$comment->comment_ID."'>" . __('Edit') . '</a>';
echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
}
- echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;dt=spam&amp;p=" . $comment->comment_post_ID . "&amp;c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> ";
+ echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;dt=spam&amp;p=" . $comment->comment_post_ID . "&amp;c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> ";
}
-?>
+?> ]
</p>
</li>
@@ -301,6 +219,5 @@ if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
?>
<?php } ?>
</div>
-<?php
- include('admin-footer.php');
-?>
+
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/export.php b/wp-admin/export.php
index 33ec633..69741bc 100644
--- a/wp-admin/export.php
+++ b/wp-admin/export.php
@@ -25,7 +25,7 @@ require_once ('admin-header.php');
<select name="author">
<option value="all" selected="selected"><?php _e('All'); ?></option>
<?php
-$authors = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" );
+$authors = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" );
foreach ( $authors as $id ) {
$o = get_userdata( $id );
echo "<option value='$o->ID'>$o->display_name</option>";
@@ -46,13 +46,15 @@ foreach ( $authors as $id ) {
<?php
function export_wp() {
-global $wpdb, $posts, $post;
+global $wpdb, $post_ids, $post;
+
+do_action('export_wp');
$filename = 'wordpress.' . date('Y-m-d') . '.xml';
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename=$filename");
-header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
+header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
$where = '';
if ( isset( $_GET['author'] ) && $_GET['author'] != 'all' ) {
@@ -60,16 +62,18 @@ if ( isset( $_GET['author'] ) && $_GET['author'] != 'all' ) {
$where = " WHERE post_author = '$author_id' ";
}
-$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
+// grab a snapshot of post IDs, just in case it changes during the export
+$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
-$categories = (array) $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, posts_private, links_private FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (category_id = cat_id) LEFT JOIN $wpdb->posts ON (post_id <=> id) $where GROUP BY cat_id");
+$categories = (array) get_categories('get=all');
+$tags = (array) get_tags('get=all');
function wxr_missing_parents($categories) {
if ( !is_array($categories) || empty($categories) )
return array();
foreach ( $categories as $category )
- $parents[$category->cat_ID] = $category->category_parent;
+ $parents[$category->term_id] = $category->parent;
$parents = array_unique(array_diff($parents, array_keys($parents)));
@@ -80,7 +84,7 @@ function wxr_missing_parents($categories) {
}
while ( $parents = wxr_missing_parents($categories) ) {
- $found_parents = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, posts_private, links_private FROM $wpdb->categories WHERE cat_ID IN (" . join(', ', $parents) . ")");
+ $found_parents = get_categories("include=" . join(', ', $parents));
if ( is_array($found_parents) && count($found_parents) )
$categories = array_merge($categories, $found_parents);
else
@@ -91,8 +95,8 @@ while ( $parents = wxr_missing_parents($categories) ) {
$pass = 0;
$passes = 1000 + count($categories);
while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) {
- if ( $cat->category_parent == 0 || isset($cats[$cat->category_parent]) ) {
- $cats[$cat->cat_ID] = $cat;
+ if ( $cat->parent == 0 || isset($cats[$cat->parent]) ) {
+ $cats[$cat->term_id] = $cat;
} else {
$categories[] = $cat;
}
@@ -111,42 +115,72 @@ function wxr_cdata($str) {
}
function wxr_cat_name($c) {
- if ( empty($c->cat_name) )
+ if ( empty($c->name) )
return;
- echo '<wp:cat_name>' . wxr_cdata($c->cat_name) . '</wp:cat_name>';
+ echo '<wp:cat_name>' . wxr_cdata($c->name) . '</wp:cat_name>';
}
function wxr_category_description($c) {
- if ( empty($c->category_description) )
+ if ( empty($c->description) )
return;
- echo '<wp:category_description>' . wxr_cdata($c->category_description) . '</wp:category_description>';
+ echo '<wp:category_description>' . wxr_cdata($c->description) . '</wp:category_description>';
}
-print '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
+function wxr_tag_name($t) {
+ if ( empty($t->name) )
+ return;
-?>
+ echo '<wp:tag_name>' . wxr_cdata($t->name) . '</wp:tag_name>';
+}
+
+function wxr_tag_description($t) {
+ if ( empty($t->description) )
+ return;
+
+ echo '<wp:tag_description>' . wxr_cdata($t->description) . '</wp:tag_description>';
+}
+
+function wxr_post_taxonomy() {
+ $categories = get_the_category();
+ $tags = get_the_tags();
+ $cat_names = array();
+ $tag_names = array();
+ $the_list = '';
+ $filter = 'rss';
+
+ if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
+ $cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
+ $the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n";
+ }
+
+ if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
+ $tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
+ $the_list .= "\n\t\t<category domain=\"tag\"><![CDATA[$tag_name]]></category>\n";
+ }
+
+ echo $the_list;
+}
-<!--
- This is a WordPress eXtended RSS file generated by WordPress as an export of
- your blog. It contains information about your blog's posts, comments, and
- categories. You may use this file to transfer that content from one site to
- another. This file is not intended to serve as a complete backup of your
- blog.
-
- To import this information into a WordPress blog follow these steps:
-
- 1. Log into that blog as an administrator.
- 2. Go to Manage > Import in the blog's admin.
- 3. Choose "WordPress" from the list of importers.
- 4. Upload this file using the form provided on that page.
- 5. You will first be asked to map the authors in this export file to users
- on the blog. For each author, you may choose to map an existing user on
- the blog or to create a new user.
- 6. WordPress will then import each of the posts, comments, and categories
- contained in this file onto your blog.
--->
+echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
+
+?>
+<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->
+<!-- It contains information about your blog's posts, comments, and categories. -->
+<!-- You may use this file to transfer that content from one site to another. -->
+<!-- This file is not intended to serve as a complete backup of your blog. -->
+
+<!-- To import this information into a WordPress blog follow these steps. -->
+<!-- 1. Log into that blog as an administrator. -->
+<!-- 2. Go to Manage: Import in the blog's admin panels. -->
+<!-- 3. Choose "WordPress" from the list. -->
+<!-- 4. Upload this file using the form provided on that page. -->
+<!-- 5. You will first be asked to map the authors in this export file to users -->
+<!-- on the blog. For each author, you may choose to map to an -->
+<!-- existing user on the blog or to create a new user -->
+<!-- 6. WordPress will then import each of the posts, comments, and categories -->
+<!-- contained in this file into your blog -->
<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:i'); ?>"-->
<rss version="2.0"
@@ -164,16 +198,27 @@ print '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
<language><?php echo get_option('rss_language'); ?></language>
<?php if ( $cats ) : foreach ( $cats as $c ) : ?>
- <wp:category><wp:category_nicename><?php echo $c->category_nicename; ?></wp:category_nicename><wp:category_parent><?php echo $c->category_parent ? $cats[$c->category_parent]->cat_name : ''; ?></wp:category_parent><wp:posts_private><?php echo $c->posts_private ? '1' : '0'; ?></wp:posts_private><wp:links_private><?php echo $c->links_private ? '1' : '0'; ?></wp:links_private><?php wxr_cat_name($c); ?><?php wxr_category_description($c); ?></wp:category>
+ <wp:category><wp:category_nicename><?php echo $c->slug; ?></wp:category_nicename><wp:category_parent><?php echo $c->parent ? $cats[$c->parent]->name : ''; ?></wp:category_parent><?php wxr_cat_name($c); ?><?php wxr_category_description($c); ?></wp:category>
+<?php endforeach; endif; ?>
+<?php if ( $tags ) : foreach ( $tags as $t ) : ?>
+ <wp:tag><wp:tag_slug><?php echo $t->slug; ?></wp:tag_slug><?php wxr_tag_name($t); ?><?php wxr_tag_description($t); ?></wp:tag>
<?php endforeach; endif; ?>
<?php do_action('rss2_head'); ?>
- <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+ <?php if ($post_ids) {
+ global $wp_query;
+ $wp_query->in_the_loop = true; // Fake being in the loop.
+ // fetch 20 posts at a time rather than loading the entire table into memory
+ while ( $next_posts = array_splice($post_ids, 0, 20) ) {
+ $where = "WHERE ID IN (".join(',', $next_posts).")";
+ $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
+ foreach ($posts as $post) {
+ setup_postdata($post); ?>
<item>
<title><?php the_title_rss() ?></title>
-<link><?php permalink_single_rss() ?></link>
+<link><?php the_permalink_rss() ?></link>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
<dc:creator><?php the_author() ?></dc:creator>
-<?php the_category_rss() ?>
+<?php wxr_post_taxonomy() ?>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<description></description>
@@ -204,7 +249,7 @@ $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post
if ( $comments ) { foreach ( $comments as $c ) { ?>
<wp:comment>
<wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id>
-<wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
+<wp:comment_author><?php echo wxr_cdata($c->comment_author); ?></wp:comment_author>
<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
<wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url>
<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>
@@ -217,7 +262,7 @@ if ( $comments ) { foreach ( $comments as $c ) { ?>
</wp:comment>
<?php } } ?>
</item>
-<?php } } ?>
+<?php } } } ?>
</channel>
</rss>
<?php
diff --git a/wp-admin/images/logo-ghost.png b/wp-admin/images/logo-ghost.png
new file mode 100644
index 0000000..46d26cc
--- /dev/null
+++ b/wp-admin/images/logo-ghost.png
Binary files differ
diff --git a/wp-admin/import.php b/wp-admin/import.php
index 8c46046..9637279 100644
--- a/wp-admin/import.php
+++ b/wp-admin/import.php
@@ -14,9 +14,9 @@ require_once ('admin-header.php');
// Load all importers so that they can register.
$import_loc = 'wp-admin/import';
$import_root = ABSPATH.$import_loc;
-$imports_dir = @ dir($import_root);
+$imports_dir = @ opendir($import_root);
if ($imports_dir) {
- while (($file = $imports_dir->read()) !== false) {
+ while (($file = readdir($imports_dir)) !== false) {
if ($file{0} == '.') {
continue;
} elseif (substr($file, -4) == '.php') {
@@ -24,6 +24,7 @@ if ($imports_dir) {
}
}
}
+@closedir($imports_dir);
$importers = get_importers();
diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php
index 4ad7a97..23e0807 100644
--- a/wp-admin/import/blogger.php
+++ b/wp-admin/import/blogger.php
@@ -84,7 +84,7 @@ class Blogger_Import {
if ( empty($this->blogs) ) {
$headers = array(
"GET /feeds/default/blogs HTTP/1.0",
- "Host: www2.blogger.com",
+ "Host: www.blogger.com",
"Authorization: AuthSub token=\"$this->token\""
);
$request = join( "\r\n", $headers ) . "\r\n\r\n";
@@ -380,7 +380,9 @@ class Blogger_Import {
$entry = "<feed>$entry</feed>";
$AtomParser = new AtomParser();
$AtomParser->parse( $entry );
- $this->import_post($AtomParser->entry);
+ $result = $this->import_post($AtomParser->entry);
+ if ( is_wp_error( $result ) )
+ return $result;
unset($AtomParser);
}
} else break;
@@ -509,15 +511,17 @@ class Blogger_Import {
$post_content = str_replace('<hr>', '<hr />', $post_content);
// Checks for duplicates
- if (
- isset( $this->blogs[$importing_blog]['posts'][$entry->old_permalink] ) ||
- post_exists( $post_title, $post_content, $post_date )
- ) {
+ if ( isset( $this->blogs[$importing_blog]['posts'][$entry->old_permalink] ) ) {
+ ++$this->blogs[$importing_blog]['posts_skipped'];
+ } elseif ( $post_id = post_exists( $post_title, $post_content, $post_date ) ) {
+ $this->blogs[$importing_blog]['posts'][$entry->old_permalink] = $post_id;
++$this->blogs[$importing_blog]['posts_skipped'];
} else {
$post = compact('post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($post);
+ if ( is_wp_error( $post_id ) )
+ return $post_id;
wp_create_categories( array_map( 'addslashes', $entry->categories ), $post_id );
@@ -531,6 +535,7 @@ class Blogger_Import {
++$this->blogs[$importing_blog]['posts_done'];
}
$this->save_vars();
+ return;
}
function import_comment( $entry ) {
@@ -767,7 +772,9 @@ class Blogger_Import {
if ( isset( $_REQUEST['blog'] ) ) {
$blog = is_array($_REQUEST['blog']) ? array_shift( array_keys( $_REQUEST['blog'] ) ) : $_REQUEST['blog'];
$blog = (int) $blog;
- $this->import_blog( $blog );
+ $result = $this->import_blog( $blog );
+ if ( is_wp_error( $result ) )
+ echo $result->get_error_message();
} elseif ( isset($_GET['token']) )
$this->auth();
elseif ( $this->token && $this->token_is_valid() )
@@ -915,11 +922,11 @@ class AtomParser {
if(count($this->in_content) == 2) {
array_push($this->in_content, ">");
}
-
+
array_push($this->in_content, "<". $this->ns_to_prefix($name) ."{$xmlns_str}{$attrs_str}");
} else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
$this->in_content = array();
- $this->is_xhtml = $attrs['type'] == 'xhtml';
+ $this->is_xhtml = $attrs['type'] == 'xhtml';
array_push($this->in_content, array($tag,$this->depth));
} else if($tag == 'link') {
array_push($this->entry->links, $attrs);
@@ -935,7 +942,7 @@ class AtomParser {
$tag = array_pop(split(":", $name));
if(!empty($this->in_content)) {
- if($this->in_content[0][0] == $tag &&
+ if($this->in_content[0][0] == $tag &&
$this->in_content[0][1] == $this->depth) {
array_shift($this->in_content);
if($this->is_xhtml) {
@@ -998,14 +1005,14 @@ class AtomParser {
}
}
}
- }
+ }
return $name;
}
function xml_escape($string)
{
- return str_replace(array('&','"',"'",'<','>'),
- array('&amp;','&quot;','&apos;','&lt;','&gt;'),
+ return str_replace(array('&','"',"'",'<','>'),
+ array('&amp;','&quot;','&apos;','&lt;','&gt;'),
$string );
}
}
diff --git a/wp-admin/import/blogware.php b/wp-admin/import/blogware.php
index c9e281c..0083230 100644
--- a/wp-admin/import/blogware.php
+++ b/wp-admin/import/blogware.php
@@ -91,6 +91,9 @@ class BW_Import {
printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
$postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($postdata);
+ if ( is_wp_error( $post_id ) ) {
+ return $post_id;
+ }
if (!$post_id) {
_e("Couldn't get post ID");
echo '</li>';
@@ -155,7 +158,9 @@ class BW_Import {
}
$this->file = $file['file'];
- $this->import_posts();
+ $result = $this->import_posts();
+ if ( is_wp_error( $result ) )
+ return $result;
wp_import_cleanup($file['id']);
echo '<h3>';
@@ -176,7 +181,9 @@ class BW_Import {
$this->greet();
break;
case 1 :
- $this->import();
+ $result = $this->import();
+ if ( is_wp_error( $result ) )
+ $result->get_error_message();
break;
}
diff --git a/wp-admin/import/btt.php b/wp-admin/import/btt.php
new file mode 100644
index 0000000..76a02c3
--- /dev/null
+++ b/wp-admin/import/btt.php
@@ -0,0 +1,115 @@
+<?php
+
+class BunnyTags_Import {
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Bunny&#8217;s Technorati Tags').'</h2>';
+ echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function greet() {
+ echo '<div class="narrow">';
+ echo '<p>'.__('Howdy! This imports tags from an existing Bunny&#8217;s Technorati Tags installation into this blog using the new WordPress native tagging structure.').'</p>';
+ echo '<p>'.__('This is suitable for Bunny&#8217;s Technorati Tags version 0.6.').'</p>';
+ echo '<p><strong>'.__('All existing Bunny&#8217;s Technorati Tags will be removed after import.').'</strong></p>';
+ echo '<p><strong>'.__('Don&#8217;t be stupid - backup your database before proceeding!').'</strong></p>';
+ echo '<form action="admin.php?import=btt&amp;step=1" method="post">';
+ wp_nonce_field('import-btt');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Tags &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+ function dispatch() {
+ if ( empty($_GET['step']) )
+ $step = 0;
+ else
+ $step = abs(intval($_GET['step']));
+
+ // load the header
+ $this->header();
+
+ switch ( $step ) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ check_admin_referer('import-btt');
+ $this->check_post_keyword( true );
+ break;
+ case 2 :
+ check_admin_referer('import-btt');
+ $this->check_post_keyword( false );
+ break;
+ case 3:
+ $this->done();
+ break;
+ }
+
+ // load the footer
+ $this->footer();
+ }
+
+ function check_post_keyword($precheck = true) {
+ global $wpdb;
+
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Reading Bunny&#8217;s Technorati Tags&#8230;').'</h3></p>';
+
+ // import Bunny's Keywords tags
+ $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'tags'");
+ if ( !is_array($metakeys)) {
+ echo '<p>' . __('No Tags Found!') . '</p>';
+ return false;
+ } else {
+ $count = count($metakeys);
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> posts with tags were read.'), $count ) . '<br /></p>';
+ echo '<ul>';
+ foreach ( $metakeys as $post_meta ) {
+ if ( $post_meta->meta_value != '' ) {
+ $post_keys = explode(' ', $post_meta->meta_value);
+ foreach ( $post_keys as $keyword ) {
+ $keyword = addslashes(trim(str_replace('+',' ',$keyword)));
+ if ( '' != $keyword ) {
+ echo '<li>' . $post_meta->post_id . '&nbsp;-&nbsp;' . $keyword . '</li>';
+ if ( !$precheck )
+ wp_add_post_tags($post_meta->post_id, $keyword);
+ }
+ }
+ }
+ if ( !$precheck )
+ delete_post_meta($post_meta->post_id, 'tags');
+ }
+ echo '</ul>';
+ }
+
+ echo '<form action="admin.php?import=btt&amp;step='.($precheck? 2:3).'" method="post">';
+ wp_nonce_field('import-btt');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+ function done() {
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Import Complete!').'</h3></p>';
+ echo '</div>';
+ }
+
+ function BunnyTags_Import() {
+ }
+
+}
+
+// create the import object
+$btt_import = new BunnyTags_Import();
+
+// add it to the import page!
+register_importer('btt', 'Bunny&#8217;s Technorati Tags', __('Import Bunny&#8217;s Technorati Tags into the new native tagging structure.'), array($btt_import, 'dispatch'));
+
+?>
diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php
index 661e1a0..1bf0486 100644
--- a/wp-admin/import/dotclear.php
+++ b/wp-admin/import/dotclear.php
@@ -7,18 +7,6 @@
/**
Add These Functions to make our lives easier
**/
-if(!function_exists('get_catbynicename'))
-{
- function get_catbynicename($category_nicename)
- {
- global $wpdb;
-
- $cat_id -= 0; // force numeric
- $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
-
- return $name;
- }
-}
if(!function_exists('get_comment_count'))
{
@@ -29,15 +17,6 @@ if(!function_exists('get_comment_count'))
}
}
-if(!function_exists('link_cat_exists'))
-{
- function link_cat_exists($catname)
- {
- global $wpdb;
- return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"');
- }
-}
-
if(!function_exists('link_exists'))
{
function link_exists($linkname)
@@ -130,19 +109,19 @@ function textconv ($s) {
**/
class Dotclear_Import {
- function header()
+ function header()
{
echo '<div class="wrap">';
echo '<h2>'.__('Import DotClear').'</h2>';
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
}
- function footer()
+ function footer()
{
echo '</div>';
}
- function greet()
+ function greet()
{
echo '<div class="narrow"><p>'.__('Howdy! This importer allows you to extract posts from a DotClear database into your blog. Mileage may vary.').'</p>';
echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>';
@@ -385,6 +364,8 @@ class Dotclear_Import {
'ping_status' => $comment_status_map[$post_open_tb],
'comment_count' => $post_nb_comment + $post_nb_trackback)
);
+ if ( is_wp_error( $ret_id ) )
+ return $ret_id;
}
else
{
@@ -403,12 +384,17 @@ class Dotclear_Import {
'ping_status' => $comment_status_map[$post_open_tb],
'comment_count' => $post_nb_comment + $post_nb_trackback)
);
+ if ( is_wp_error( $ret_id ) )
+ return $ret_id;
}
$dcposts2wpposts[$post_id] = $ret_id;
// Make Post-to-Category associations
$cats = array();
- if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; }
+ $category1 = get_category_by_slug($post_cat_name);
+ $category1 = $category1->term_id;
+
+ if($cat1 = $category1) { $cats[1] = $cat1; }
if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
}
@@ -509,12 +495,11 @@ class Dotclear_Import {
extract($link);
if ($title != "") {
- if ($cinfo = link_cat_exists (csc ($title))) {
- $category = $cinfo;
+ if ($cinfo = is_term(csc ($title), 'link_category')) {
+ $category = $cinfo['term_id'];
} else {
- $wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('".
- $wpdb->escape (csc ($title))."')");
- $category = $wpdb->insert_id;
+ $category = wp_insert_term($wpdb->escape (csc ($title)), 'link_category');
+ $category = $category['term_id'];
}
} else {
$linkname = $wpdb->escape(csc ($label));
@@ -581,7 +566,9 @@ class Dotclear_Import {
{
// Post Import
$posts = $this->get_dc_posts();
- $this->posts2wp($posts);
+ $result = $this->posts2wp($posts);
+ if ( is_wp_error( $result ) )
+ return $result;
echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
wp_nonce_field('import-dotclear');
@@ -729,7 +716,9 @@ class Dotclear_Import {
$this->import_users();
break;
case 3 :
- $this->import_posts();
+ $result = $this->import_posts();
+ if ( is_wp_error( $result ) )
+ echo $result->get_error_message();
break;
case 4 :
$this->import_comments();
diff --git a/wp-admin/import/greymatter.php b/wp-admin/import/greymatter.php
index 4305cd1..6e92235 100644
--- a/wp-admin/import/greymatter.php
+++ b/wp-admin/import/greymatter.php
@@ -233,6 +233,8 @@ class GM_Import {
$postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt');
$post_ID = wp_insert_post($postdata);
+ if ( is_wp_error( $post_ID ) )
+ return $post_ID;
}
$c=count($entry);
@@ -287,6 +289,7 @@ class GM_Import {
<p><?php _e('Completed GreyMatter import!') ?></p>
<?php
$this->footer();
+ return;
}
function dispatch() {
@@ -301,7 +304,9 @@ class GM_Import {
break;
case 1:
check_admin_referer('import-greymatter');
- $this->import();
+ $result = $this->import();
+ if ( is_wp_error( $result ) )
+ echo $result->get_error_message();
break;
}
}
diff --git a/wp-admin/import/jkw.php b/wp-admin/import/jkw.php
new file mode 100644
index 0000000..9f7b48e
--- /dev/null
+++ b/wp-admin/import/jkw.php
@@ -0,0 +1,178 @@
+<?php
+
+class JeromesKeyword_Import {
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Jerome&#8217;s Keywords').'</h2>';
+ echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function greet() {
+ echo '<div class="narrow">';
+ echo '<p>'.__('Howdy! This imports tags from an existing Jerome&#8217;s Keywords installation into this blog using the new WordPress native tagging structure.').'</p>';
+ echo '<p>'.__('This is suitable for Jerome&#8217;s Keywords version 1.x and 2.0a.').'</p>';
+ echo '<p><strong>'.__('All existing Jerome&#8217;s Keywords will be removed after import.').'</strong></p>';
+ echo '<p><strong>'.__('Don&#8217;t be stupid - backup your database before proceeding!').'</strong></p>';
+ echo '<form action="admin.php?import=jkw&amp;step=1" method="post">';
+ wp_nonce_field('import-jkw');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Version 1.x &raquo;').'" /></p>';
+ echo '</form>';
+ echo '<form action="admin.php?import=jkw&amp;step=3" method="post">';
+ wp_nonce_field('import-jkw');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Version 2.0a &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+ function dispatch() {
+ if ( empty($_GET['step']) )
+ $step = 0;
+ else
+ $step = abs(intval($_GET['step']));
+
+ // load the header
+ $this->header();
+
+ switch ( $step ) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ check_admin_referer('import-jkw');
+ $this->check_V1_post_keyword( true );
+ break;
+ case 2 :
+ check_admin_referer('import-jkw');
+ $this->check_V1_post_keyword( false );
+ break;
+ case 3 :
+ check_admin_referer('import-jkw');
+ $this->check_V2_post_keyword( true );
+ break;
+ case 4 :
+ check_admin_referer('import-jkw');
+ $this->check_V2_post_keyword( false );
+ break;
+ case 5:
+ check_admin_referer('import-jkw');
+ $this->cleanup_V2_import();
+ break;
+ case 6:
+ $this->done();
+ break;
+ }
+
+ // load the footer
+ $this->footer();
+ }
+
+ function check_V1_post_keyword($precheck = true) {
+ global $wpdb;
+
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Reading Jerome&#8217;s Keywords Tags&#8230;').'</h3></p>';
+
+ // import Jerome's Keywords tags
+ $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_key = 'keywords'");
+ if ( !is_array($metakeys)) {
+ echo '<p>' . __('No Tags Found!') . '</p>';
+ return false;
+ } else {
+ $count = count($metakeys);
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> posts with tags were read.'), $count ) . '<br /></p>';
+ echo '<ul>';
+ foreach ( $metakeys as $post_meta ) {
+ if ( $post_meta->meta_value != '' ) {
+ $post_keys = explode(',', $post_meta->meta_value);
+ foreach ( $post_keys as $keyword ) {
+ $keyword = addslashes(trim($keyword));
+ if ( '' != $keyword ) {
+ echo '<li>' . $post_meta->post_id . '&nbsp;-&nbsp;' . $keyword . '</li>';
+ if ( !$precheck )
+ wp_add_post_tags($post_meta->post_id, $keyword);
+ }
+ }
+ }
+ if ( !$precheck )
+ delete_post_meta($post_meta->post_id, 'keywords');
+ }
+ echo '</ul>';
+ }
+
+ echo '<form action="admin.php?import=jkw&amp;step='.($precheck? 2:6).'" method="post">';
+ wp_nonce_field('import-jkw');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+ function check_V2_post_keyword($precheck = true) {
+ global $wpdb;
+
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Reading Jerome&#8217;s Keywords Tags&#8230;').'</h3></p>';
+
+ // import Jerome's Keywords tags
+ $tablename = $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1);
+ $metakeys = $wpdb->get_results("SELECT post_id, tag_name FROM $tablename");
+ if ( !is_array($metakeys) ) {
+ echo '<p>' . __('No Tags Found!') . '</p>';
+ return false;
+ } else {
+ $count = count($metakeys);
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>';
+ echo '<ul>';
+ foreach ( $metakeys as $post_meta ) {
+ $keyword = addslashes(trim($post_meta->tag_name));
+ if ( $keyword != '' ) {
+ echo '<li>' . $post_meta->post_id . '&nbsp;-&nbsp;' . $keyword . '</li>';
+ if ( !$precheck )
+ wp_add_post_tags($post_meta->post_id, $keyword);
+ }
+ }
+ echo '</ul>';
+ }
+ echo '<form action="admin.php?import=jkw&amp;step='.($precheck? 4:5).'" method="post">';
+ wp_nonce_field('import-jkw');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Next &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+ function cleanup_V2_import() {
+ global $wpdb;
+
+ /* options from V2.0a (jeromes-keywords.php) */
+ $options = array('version', 'keywords_table', 'query_varname', 'template', 'meta_always_include', 'meta_includecats', 'meta_autoheader', 'search_strict', 'use_feed_cats', 'post_linkformat', 'post_tagseparator', 'post_includecats', 'post_notagstext', 'cloud_linkformat', 'cloud_tagseparator', 'cloud_includecats', 'cloud_sortorder', 'cloud_displaymax', 'cloud_displaymin', 'cloud_scalemax', 'cloud_scalemin');
+
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1));
+
+ foreach ( $options as $o )
+ delete_option('jkeywords_' . $o);
+
+ $this->done();
+ }
+
+ function done() {
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Import Complete!').'</h3></p>';
+ echo '</div>';
+ }
+
+ function JeromesKeyword_Import() {
+ }
+
+}
+
+// create the import object
+$jkw_import = new JeromesKeyword_Import();
+
+// add it to the import page!
+register_importer('jkw', 'Jerome&#8217;s Keywords', __('Import Jerome&#8217;s Keywords into the new native tagging structure.'), array($jkw_import, 'dispatch'));
+
+?>
diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php
index ceeafeb..81f0365 100644
--- a/wp-admin/import/livejournal.php
+++ b/wp-admin/import/livejournal.php
@@ -49,7 +49,7 @@ class LJ_Import {
preg_match('|<eventtime>(.*?)</eventtime>|is', $post, $post_date);
$post_date = strtotime($post_date[1]);
- $post_date = gmdate('Y-m-d H:i:s', $post_date);
+ $post_date = date('Y-m-d H:i:s', $post_date);
preg_match('|<event>(.*?)</event>|is', $post, $post_content);
$post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
@@ -71,6 +71,8 @@ class LJ_Import {
printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
$postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
$post_id = wp_insert_post($postdata);
+ if ( is_wp_error( $post_id ) )
+ return $post_id;
if (!$post_id) {
_e("Couldn't get post ID");
echo '</li>';
@@ -132,7 +134,9 @@ class LJ_Import {
}
$this->file = $file['file'];
- $this->import_posts();
+ $result = $this->import_posts();
+ if ( is_wp_error( $result ) )
+ return $result;
wp_import_cleanup($file['id']);
echo '<h3>';
@@ -154,7 +158,9 @@ class LJ_Import {
break;
case 1 :
check_admin_referer('import-upload');
- $this->import();
+ $result = $this->import();
+ if ( is_wp_error( $result ) )
+ echo $result->get_error_message();
break;
}
diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php
index cd60654..44bdd61 100644
--- a/wp-admin/import/mt.php
+++ b/wp-admin/import/mt.php
@@ -22,7 +22,7 @@ class MT_Import {
$this->header();
?>
<div class="narrow">
-<p><?php _e('Howdy! We&#8217;re about to begin importing all of your Movable Type or Typepad entries into WordPress. To begin, choose a file to upload and click Upload file and import.'); ?></p>
+<p><?php _e('Howdy! We&#8217;re about to begin importing all of your Movable Type or Typepad entries into WordPress. To begin, either choose a file to upload and click "Upload file and import," or use FTP to upload your MT export file as <code>mt-export.txt</code> in your <code>/wp-content/</code> directory and then click "Import mt-export.txt"'); ?></p>
<?php wp_import_upload_form( add_query_arg('step', 1) ); ?>
<p><?php _e('The importer is smart enough not to import duplicates, so you can run this multiple times without worry if&#8212;for whatever reason&#8212;it doesn\'t finish. If you get an <strong>out of memory</strong> error try splitting up the import file into pieces.'); ?> </p>
</div>
@@ -58,25 +58,27 @@ class MT_Import {
return $user_id;
}
- function get_entries() {
- set_magic_quotes_runtime(0);
- $importdata = file($this->file); // Read the file into an array
- $importdata = implode('', $importdata); // squish it
- $importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata);
- $importdata = preg_replace("/\n--------\n/", "--MT-ENTRY--\n", $importdata);
- $this->posts = explode("--MT-ENTRY--", $importdata);
- }
-
function get_mt_authors() {
- $temp = array ();
- $i = -1;
- foreach ($this->posts as $post) {
- if ('' != trim($post)) {
- ++ $i;
- preg_match("|AUTHOR:(.*)|", $post, $thematch);
- $thematch = trim($thematch[1]);
- array_push($temp, "$thematch"); //store the extracted author names in a temporary array
- }
+ $temp = array();
+ $authors = array();
+
+ $handle = fopen($this->file, 'r');
+ if ( $handle == null )
+ return false;
+
+ $in_comment = false;
+ while ( $line = fgets($handle) ) {
+ $line = trim($line);
+
+ if ( 'COMMENT:' == $line )
+ $in_comment = true;
+ else if ( '-----' == $line )
+ $in_comment = false;
+
+ if ( $in_comment || 0 !== strpos($line,"AUTHOR:") )
+ continue;
+
+ $temp[] = trim( substr($line, strlen("AUTHOR:")) );
}
//we need to find unique values of author names, while preserving the order, so this function emulates the unique_value(); php function, without the sorting.
@@ -88,6 +90,8 @@ class MT_Import {
array_push($authors, "$next");
}
+ fclose($handle);
+
return $authors;
}
@@ -121,7 +125,7 @@ class MT_Import {
?>
<div class="wrap">
<h2><?php _e('Assign Authors'); ?></h2>
-<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
+<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as admin\'s entries.'); ?></p>
<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <i>italics</i>. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?></p>
<p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p>
<?php
@@ -139,7 +143,7 @@ class MT_Import {
echo '</li>';
}
- echo '<input type="submit" value="'.__('Submit').'">'.'<br/>';
+ echo '<input type="submit" value="'.__('Submit').'">'.'<br />';
echo '</form>';
echo '</ol></div>';
@@ -157,226 +161,221 @@ class MT_Import {
$this->file = $file['file'];
$this->id = (int) $file['id'];
- $this->get_entries();
$this->mt_authors_form();
}
+ function save_post(&$post, &$comments, &$pings) {
+ // Reset the counter
+ set_time_limit(30);
+ $post = get_object_vars($post);
+ $post = add_magic_quotes($post);
+ $post = (object) $post;
+
+ if ( $post_id = post_exists($post->post_title, '', $post->post_date) ) {
+ echo '<li>';
+ printf(__('Post <i>%s</i> already exists.'), stripslashes($post->post_title));
+ } else {
+ echo '<li>';
+ printf(__('Importing post <i>%s</i>...'), stripslashes($post->post_title));
+
+ if ( '' != trim( $post->extended ) )
+ $post->post_content .= "\n<!--more-->\n$post->extended";
+
+ $post->post_author = $this->checkauthor($post->post_author); //just so that if a post already exists, new users are not created by checkauthor
+ $post_id = wp_insert_post($post);
+ if ( is_wp_error( $post_id ) )
+ return $post_id;
+
+ // Add categories.
+ if ( 0 != count($post->categories) ) {
+ wp_create_categories($post->categories, $post_id);
+ }
+ }
+
+ $num_comments = 0;
+ foreach ( $comments as $comment ) {
+ $comment = get_object_vars($comment);
+ $comment = add_magic_quotes($comment);
+
+ if ( !comment_exists($comment['comment_author'], $comment['comment_date'])) {
+ $comment['comment_post_ID'] = $post_id;
+ $comment = wp_filter_comment($comment);
+ wp_insert_comment($comment);
+ $num_comments++;
+ }
+ }
+
+ if ( $num_comments )
+ printf(' '.__('(%s comments)'), $num_comments);
+
+ $num_pings = 0;
+ foreach ( $pings as $ping ) {
+ $ping = get_object_vars($ping);
+ $ping = add_magic_quotes($ping);
+
+ if ( !comment_exists($ping['comment_author'], $ping['comment_date'])) {
+ $ping['comment_content'] = "<strong>{$ping['title']}</strong>\n\n{$ping['comment_content']}";
+ $ping['comment_post_ID'] = $post_id;
+ $ping = wp_filter_comment($ping);
+ wp_insert_comment($ping);
+ $num_pings++;
+ }
+ }
+
+ if ( $num_pings )
+ printf(' '.__('(%s pings)'), $num_pings);
+
+ echo "</li>";
+ //ob_flush();flush();
+ }
+
function process_posts() {
global $wpdb;
- $i = -1;
+
+ $handle = fopen($this->file, 'r');
+ if ( $handle == null )
+ return false;
+
+ $context = '';
+ $post = new StdClass();
+ $comment = new StdClass();
+ $comments = array();
+ $ping = new StdClass();
+ $pings = array();
+
echo "<div class='wrap'><ol>";
- foreach ($this->posts as $post) {
- if ('' != trim($post)) {
- ++ $i;
- unset ($post_categories);
-
- // Take the pings out first
- preg_match("|(-----\n\nPING:.*)|s", $post, $pings);
- $post = preg_replace("|(-----\n\nPING:.*)|s", '', $post);
-
- // Then take the comments out
- preg_match("|(-----\nCOMMENT:.*)|s", $post, $comments);
- $post = preg_replace("|(-----\nCOMMENT:.*)|s", '', $post);
-
- // We ignore the keywords
- $post = preg_replace("|(-----\nKEYWORDS:.*)|s", '', $post);
-
- // We want the excerpt
- preg_match("|-----\nEXCERPT:(.*)|s", $post, $excerpt);
- $post_excerpt = $wpdb->escape(trim($excerpt[1]));
- $post = preg_replace("|(-----\nEXCERPT:.*)|s", '', $post);
-
- // We're going to put extended body into main body with a more tag
- preg_match("|-----\nEXTENDED BODY:(.*)|s", $post, $extended);
- $extended = trim($extended[1]);
- if ('' != $extended)
- $extended = "\n<!--more-->\n$extended";
- $post = preg_replace("|(-----\nEXTENDED BODY:.*)|s", '', $post);
-
- // Now for the main body
- preg_match("|-----\nBODY:(.*)|s", $post, $body);
- $body = trim($body[1]);
- $post_content = $wpdb->escape($body.$extended);
- $post = preg_replace("|(-----\nBODY:.*)|s", '', $post);
-
- // Grab the metadata from what's left
- $metadata = explode("\n", $post);
- foreach ($metadata as $line) {
- preg_match("/^(.*?):(.*)/", $line, $token);
- $key = trim($token[1]);
- $value = trim($token[2]);
- // Now we decide what it is and what to do with it
- switch ($key) {
- case '' :
- break;
- case 'AUTHOR' :
- $post_author = $value;
- break;
- case 'TITLE' :
- $post_title = $wpdb->escape($value);
- break;
- case 'STATUS' :
- // "publish" and "draft" enumeration items match up; no change required
- $post_status = $value;
- if (empty ($post_status))
- $post_status = 'publish';
- break;
- case 'ALLOW COMMENTS' :
- $post_allow_comments = $value;
- if ($post_allow_comments == 1) {
- $comment_status = 'open';
- } else {
- $comment_status = 'closed';
- }
- break;
- case 'CONVERT BREAKS' :
- $post_convert_breaks = $value;
- break;
- case 'ALLOW PINGS' :
- $ping_status = trim($meta[2][0]);
- if ($ping_status == 1) {
- $ping_status = 'open';
- } else {
- $ping_status = 'closed';
- }
- break;
- case 'PRIMARY CATEGORY' :
- if (! empty ($value) )
- $post_categories[] = $wpdb->escape($value);
- break;
- case 'CATEGORY' :
- if (! empty ($value) )
- $post_categories[] = $wpdb->escape($value);
- break;
- case 'DATE' :
- $post_modified = strtotime($value);
- $post_modified = date('Y-m-d H:i:s', $post_modified);
- $post_modified_gmt = get_gmt_from_date("$post_modified");
- $post_date = $post_modified;
- $post_date_gmt = $post_modified_gmt;
- break;
- default :
- // echo "\n$key: $value";
- break;
- } // end switch
- } // End foreach
-
- // Let's check to see if it's in already
- if ($post_id = post_exists($post_title, '', $post_date)) {
- echo '<li>';
- printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
- } else {
- echo '<li>';
- printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
-
- $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor
-
- $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt');
- $post_id = wp_insert_post($postdata);
- // Add categories.
- if (0 != count($post_categories)) {
- wp_create_categories($post_categories, $post_id);
- }
- }
- $comment_post_ID = (int) $post_id;
- $comment_approved = 1;
-
- // Now for comments
- $comments = explode("-----\nCOMMENT:", $comments[0]);
- $num_comments = 0;
- foreach ($comments as $comment) {
- if ('' != trim($comment)) {
- // Author
- preg_match("|AUTHOR:(.*)|", $comment, $comment_author);
- $comment_author = $wpdb->escape(trim($comment_author[1]));
- $comment = preg_replace('|(\n?AUTHOR:.*)|', '', $comment);
- preg_match("|EMAIL:(.*)|", $comment, $comment_author_email);
- $comment_author_email = $wpdb->escape(trim($comment_author_email[1]));
- $comment = preg_replace('|(\n?EMAIL:.*)|', '', $comment);
-
- preg_match("|IP:(.*)|", $comment, $comment_author_IP);
- $comment_author_IP = trim($comment_author_IP[1]);
- $comment = preg_replace('|(\n?IP:.*)|', '', $comment);
-
- preg_match("|URL:(.*)|", $comment, $comment_author_url);
- $comment_author_url = $wpdb->escape(trim($comment_author_url[1]));
- $comment = preg_replace('|(\n?URL:.*)|', '', $comment);
-
- preg_match("|DATE:(.*)|", $comment, $comment_date);
- $comment_date = trim($comment_date[1]);
- $comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
- $comment = preg_replace('|(\n?DATE:.*)|', '', $comment);
-
- $comment_content = $wpdb->escape(trim($comment));
- $comment_content = str_replace('-----', '', $comment_content);
- // Check if it's already there
- if (!comment_exists($comment_author, $comment_date)) {
- $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_approved');
- $commentdata = wp_filter_comment($commentdata);
- wp_insert_comment($commentdata);
- $num_comments++;
- }
- }
+ while ( $line = fgets($handle) ) {
+ $line = trim($line);
+
+ if ( '-----' == $line ) {
+ // Finishing a multi-line field
+ if ( 'comment' == $context ) {
+ $comments[] = $comment;
+ $comment = new StdClass();
+ } else if ( 'ping' == $context ) {
+ $pings[] = $ping;
+ $ping = new StdClass();
}
- if ( $num_comments )
- printf(' '.__('(%s comments)'), $num_comments);
-
- // Finally the pings
- // fix the double newline on the first one
- $pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]);
- $pings = explode("-----\nPING:", $pings[0]);
- $num_pings = 0;
- foreach ($pings as $ping) {
- if ('' != trim($ping)) {
- // 'Author'
- preg_match("|BLOG NAME:(.*)|", $ping, $comment_author);
- $comment_author = $wpdb->escape(trim($comment_author[1]));
- $ping = preg_replace('|(\n?BLOG NAME:.*)|', '', $ping);
-
- preg_match("|IP:(.*)|", $ping, $comment_author_IP);
- $comment_author_IP = trim($comment_author_IP[1]);
- $ping = preg_replace('|(\n?IP:.*)|', '', $ping);
-
- preg_match("|URL:(.*)|", $ping, $comment_author_url);
- $comment_author_url = $wpdb->escape(trim($comment_author_url[1]));
- $ping = preg_replace('|(\n?URL:.*)|', '', $ping);
-
- preg_match("|DATE:(.*)|", $ping, $comment_date);
- $comment_date = trim($comment_date[1]);
- $comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
- $ping = preg_replace('|(\n?DATE:.*)|', '', $ping);
-
- preg_match("|TITLE:(.*)|", $ping, $ping_title);
- $ping_title = $wpdb->escape(trim($ping_title[1]));
- $ping = preg_replace('|(\n?TITLE:.*)|', '', $ping);
-
- $comment_content = $wpdb->escape(trim($ping));
- $comment_content = str_replace('-----', '', $comment_content);
-
- $comment_content = "<strong>$ping_title</strong>\n\n$comment_content";
-
- $comment_type = 'trackback';
-
- // Check if it's already there
- if (!comment_exists($comment_author, $comment_date)) {
- $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_type', 'comment_approved');
- $commentdata = wp_filter_comment($commentdata);
- wp_insert_comment($commentdata);
- $num_pings++;
- }
- }
+ $context = '';
+ } else if ( '--------' == $line ) {
+ // Finishing a post.
+ $context = '';
+ $result = $this->save_post($post, $comments, $pings);
+ if ( is_wp_error( $result ) )
+ return $result;
+ $post = new StdClass;
+ $comment = new StdClass();
+ $ping = new StdClass();
+ $comments = array();
+ $pings = array();
+ } else if ( 'BODY:' == $line ) {
+ $context = 'body';
+ } else if ( 'EXTENDED BODY:' == $line ) {
+ $context = 'extended';
+ } else if ( 'EXCERPT:' == $line ) {
+ $context = 'excerpt';
+ } else if ( 'KEYWORDS:' == $line ) {
+ $context = 'keywords';
+ } else if ( 'COMMENT:' == $line ) {
+ $context = 'comment';
+ } else if ( 'PING:' == $line ) {
+ $context = 'ping';
+ } else if ( 0 === strpos($line, "AUTHOR:") ) {
+ $author = trim( substr($line, strlen("AUTHOR:")) );
+ if ( '' == $context )
+ $post->post_author = $author;
+ else if ( 'comment' == $context )
+ $comment->comment_author = $author;
+ } else if ( 0 === strpos($line, "TITLE:") ) {
+ $title = trim( substr($line, strlen("TITLE:")) );
+ if ( '' == $context )
+ $post->post_title = $title;
+ else if ( 'ping' == $context )
+ $ping->title = $title;
+ } else if ( 0 === strpos($line, "STATUS:") ) {
+ $status = trim( substr($line, strlen("STATUS:")) );
+ if ( empty($status) )
+ $status = 'publish';
+ $post->post_status = $status;
+ } else if ( 0 === strpos($line, "ALLOW COMMENTS:") ) {
+ $allow = trim( substr($line, strlen("ALLOW COMMENTS:")) );
+ if ( $allow == 1 )
+ $post->comment_status = 'open';
+ else
+ $post->comment_status = 'closed';
+ } else if ( 0 === strpos($line, "ALLOW PINGS:") ) {
+ $allow = trim( substr($line, strlen("ALLOW PINGS:")) );
+ if ( $allow == 1 )
+ $post->ping_status = 'open';
+ else
+ $post->ping_status = 'closed';
+ } else if ( 0 === strpos($line, "CATEGORY:") ) {
+ $category = trim( substr($line, strlen("CATEGORY:")) );
+ if ( '' != $category )
+ $post->categories[] = $category;
+ } else if ( 0 === strpos($line, "PRIMARY CATEGORY:") ) {
+ $category = trim( substr($line, strlen("PRIMARY CATEGORY:")) );
+ if ( '' != $category )
+ $post->categories[] = $category;
+ } else if ( 0 === strpos($line, "DATE:") ) {
+ $date = trim( substr($line, strlen("DATE:")) );
+ $date = strtotime($date);
+ $date = date('Y-m-d H:i:s', $date);
+ $date_gmt = get_gmt_from_date($date);
+ if ( '' == $context ) {
+ $post->post_modified = $date;
+ $post->post_modified_gmt = $date_gmt;
+ $post->post_date = $date;
+ $post->post_date_gmt = $date_gmt;
+ } else if ( 'comment' == $context ) {
+ $comment->comment_date = $date;
+ } else if ( 'ping' == $context ) {
+ $ping->comment_date = $date;
+ }
+ } else if ( 0 === strpos($line, "EMAIL:") ) {
+ $email = trim( substr($line, strlen("EMAIL:")) );
+ if ( 'comment' == $context )
+ $comment->comment_author_email = $email;
+ else
+ $ping->comment_author_email = '';
+ } else if ( 0 === strpos($line, "IP:") ) {
+ $ip = trim( substr($line, strlen("IP:")) );
+ if ( 'comment' == $context )
+ $comment->comment_author_IP = $ip;
+ else
+ $ping->comment_author_IP = $ip;
+ } else if ( 0 === strpos($line, "URL:") ) {
+ $url = trim( substr($line, strlen("URL:")) );
+ if ( 'comment' == $context )
+ $comment->comment_author_url = $url;
+ else
+ $ping->comment_author_url = $url;
+ } else if ( 0 === strpos($line, "BLOG NAME:") ) {
+ $blog = trim( substr($line, strlen("BLOG NAME:")) );
+ $ping->comment_author = $blog;
+ } else {
+ // Processing multi-line field, check context.
+
+ $line .= "\n";
+ if ( 'body' == $context ) {
+ $post->post_content .= $line;
+ } else if ( 'extended' == $context ) {
+ $post->extended .= $line;
+ } else if ( 'excerpt' == $context ) {
+ $post->post_excerpt .= $line;
+ } else if ( 'comment' == $context ) {
+ $comment->comment_content .= $line;
+ } else if ( 'ping' == $context ) {
+ $ping->comment_content .= $line;
}
- if ( $num_pings )
- printf(' '.__('(%s pings)'), $num_pings);
-
- echo "</li>";
}
}
echo '</ol>';
wp_import_cleanup($this->id);
+ do_action('import_done', 'mt');
echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3></div>';
}
@@ -386,8 +385,9 @@ class MT_Import {
$this->file = get_attached_file($this->id);
$this->get_authors_from_post();
- $this->get_entries();
- $this->process_posts();
+ $result = $this->process_posts();
+ if ( is_wp_error( $result ) )
+ return $result;
}
function dispatch() {
@@ -406,7 +406,9 @@ class MT_Import {
break;
case 2:
check_admin_referer('import-mt');
- $this->import();
+ $result = $this->import();
+ if ( is_wp_error( $result ) )
+ echo $result->get_error_message();
break;
}
}
diff --git a/wp-admin/import/rss.php b/wp-admin/import/rss.php
index f46caa1..11fc770 100644
--- a/wp-admin/import/rss.php
+++ b/wp-admin/import/rss.php
@@ -110,6 +110,8 @@ class RSS_Import {
_e('Post already imported');
} else {
$post_id = wp_insert_post($post);
+ if ( is_wp_error( $post_id ) )
+ return $post_id;
if (!$post_id) {
_e("Couldn't get post ID");
return;
@@ -135,7 +137,9 @@ class RSS_Import {
$this->file = $file['file'];
$this->get_posts();
- $this->import_posts();
+ $result = $this->import_posts();
+ if ( is_wp_error( $result ) )
+ return $result;
wp_import_cleanup($file['id']);
echo '<h3>';
@@ -157,7 +161,9 @@ class RSS_Import {
break;
case 1 :
check_admin_referer('import-upload');
- $this->import();
+ $result = $this->import();
+ if ( is_wp_error( $result ) )
+ echo $result->get_error_message();
break;
}
diff --git a/wp-admin/import/stp.php b/wp-admin/import/stp.php
new file mode 100644
index 0000000..9d5371c
--- /dev/null
+++ b/wp-admin/import/stp.php
@@ -0,0 +1,155 @@
+<?php
+class STP_Import {
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Simple Tagging').'</h2>';
+ echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function greet() {
+ echo '<div class="narrow">';
+ echo '<p>'.__('Howdy! This imports tags from an existing Simple Tagging 1.6.2 installation into this blog using the new WordPress native tagging structure.').'</p>';
+ echo '<p>'.__('This has not been tested on any other versions of Simple Tagging. Mileage may vary.').'</p>';
+ echo '<p>'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 4-step program to help you kick that nasty Simple Tagging habit. Just keep clicking along and we will let you know when you are in the clear!').'</p>';
+ echo '<p><strong>'.__('Don&#8217;t be stupid - backup your database before proceeding!').'</strong></p>';
+ echo '<form action="admin.php?import=stp&amp;step=1" method="post">';
+ wp_nonce_field('import-stp');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+ function dispatch () {
+ if ( empty( $_GET['step'] ) ) {
+ $step = 0;
+ } else {
+ $step = (int) $_GET['step'];
+ }
+ // load the header
+ $this->header();
+ switch ( $step ) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ check_admin_referer('import-stp');
+ $this->import_posts();
+ break;
+ case 2:
+ check_admin_referer('import-stp');
+ $this->import_t2p();
+ break;
+ case 3:
+ check_admin_referer('import-stp');
+ $this->cleanup_import();
+ break;
+ }
+ // load the footer
+ $this->footer();
+ }
+
+
+ function import_posts ( ) {
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Reading STP Post Tags&#8230;').'</h3></p>';
+
+ // read in all the STP tag -> post settings
+ $posts = $this->get_stp_posts();
+
+ // if we didn't get any tags back, that's all there is folks!
+ if ( !is_array($posts) ) {
+ echo '<p>' . __('No posts were found to have tags!') . '</p>';
+ return false;
+ }
+ else {
+ // if there's an existing entry, delete it
+ if ( get_option('stpimp_posts') ) {
+ delete_option('stpimp_posts');
+ }
+
+ add_option('stpimp_posts', $posts);
+ $count = count($posts);
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>';
+ }
+
+ echo '<form action="admin.php?import=stp&amp;step=2" method="post">';
+ wp_nonce_field('import-stp');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+
+ function import_t2p ( ) {
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Adding Tags to Posts&#8230;').'</h3></p>';
+
+ // run that funky magic!
+ $tags_added = $this->tag2post();
+
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags where added!'), $tags_added ) . '<br /></p>';
+ echo '<form action="admin.php?import=stp&amp;step=3" method="post">';
+ wp_nonce_field('import-stp');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+ function get_stp_posts ( ) {
+ global $wpdb;
+ // read in all the posts from the STP post->tag table: should be wp_post2tag
+ $posts_query = "SELECT post_id, tag_name FROM " . $wpdb->prefix . "stp_tags";
+ $posts = $wpdb->get_results($posts_query);
+ return $posts;
+ }
+
+ function tag2post ( ) {
+ global $wpdb;
+
+ // get the tags and posts we imported in the last 2 steps
+ $posts = get_option('stpimp_posts');
+
+ // null out our results
+ $tags_added = 0;
+
+ // loop through each post and add its tags to the db
+ foreach ( $posts as $this_post ) {
+ $the_post = (int) $this_post->post_id;
+ $the_tag = $wpdb->escape($this_post->tag_name);
+ // try to add the tag
+ wp_add_post_tags($the_post, $the_tag);
+ $tags_added++;
+ }
+
+ // that's it, all posts should be linked to their tags properly, pending any errors we just spit out!
+ return $tags_added;
+ }
+
+ function cleanup_import ( ) {
+ delete_option('stpimp_posts');
+ $this->done();
+ }
+
+ function done ( ) {
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Import Complete!').'</h3></p>';
+ echo '<p>' . __('OK, so we lied about this being a 4-step program! You&#8217;re done!') . '</p>';
+ echo '<p>' . __('Now wasn&#8217;t that easy?') . '</p>';
+ echo '</div>';
+ }
+
+ function STP_Import ( ) {
+ // Nothing.
+ }
+}
+
+// create the import object
+$stp_import = new STP_Import();
+
+// add it to the import page!
+register_importer('stp', 'Simple Tagging', __('Import Simple Tagging tags into the new native tagging structure.'), array($stp_import, 'dispatch'));
+?> \ No newline at end of file
diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php
index 2d2b145..1fe54c8 100644
--- a/wp-admin/import/textpattern.php
+++ b/wp-admin/import/textpattern.php
@@ -2,18 +2,6 @@
/**
Add These Functions to make our lives easier
**/
-if(!function_exists('get_catbynicename'))
-{
- function get_catbynicename($category_nicename)
- {
- global $wpdb;
-
- $cat_id -= 0; // force numeric
- $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
-
- return $name;
- }
-}
if(!function_exists('get_comment_count'))
{
@@ -38,14 +26,14 @@ if(!function_exists('link_exists'))
**/
class Textpattern_Import {
- function header()
+ function header()
{
echo '<div class="wrap">';
echo '<h2>'.__('Import Textpattern').'</h2>';
echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
}
- function footer()
+ function footer()
{
echo '</div>';
}
@@ -317,6 +305,8 @@ class Textpattern_Import {
'post_name' => $url_title,
'comment_count' => $comments_count)
);
+ if ( is_wp_error( $ret_id ) )
+ return $ret_id;
}
else
{
@@ -333,13 +323,19 @@ class Textpattern_Import {
'post_name' => $url_title,
'comment_count' => $comments_count)
);
+ if ( is_wp_error( $ret_id ) )
+ return $ret_id;
}
$txpposts2wpposts[$ID] = $ret_id;
// Make Post-to-Category associations
$cats = array();
- if($cat1 = get_catbynicename($Category1)) { $cats[1] = $cat1; }
- if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; }
+ $category1 = get_category_by_slug($Category1);
+ $category1 = $category1->term_id;
+ $category2 = get_category_by_slug($Category2);
+ $category2 = $category1->term_id;
+ if($cat1 = $category1) { $cats[1] = $cat1; }
+ if($cat2 = $category2) { $cats[2] = $cat2; }
if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
}
@@ -506,7 +502,9 @@ class Textpattern_Import {
{
// Post Import
$posts = $this->get_txp_posts();
- $this->posts2wp($posts);
+ $result = $this->posts2wp($posts);
+ if ( is_wp_error( $result ) )
+ return $result;
echo '<form action="admin.php?import=textpattern&amp;step=4" method="post">';
wp_nonce_field('import-textpattern');
@@ -559,11 +557,11 @@ class Textpattern_Import {
{
echo '<p>'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Textpattern, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'</p>';
echo '<h3>'.__('Users').'</h3>';
- echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>';
+ echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn&#8217;t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'</p>';
echo '<h3>'.__('Preserving Authors').'</h3>';
echo '<p>'.__('Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>';
echo '<h3>'.__('Textile').'</h3>';
- echo '<p>'.__('Also, since you\'re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You\'ll want it.').'</p>';
+ echo '<p>'.__('Also, since you&#8217;re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You&#8217;ll want it.').'</p>';
echo '<h3>'.__('WordPress Resources').'</h3>';
echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>';
echo '<ul>';
@@ -571,7 +569,7 @@ class Textpattern_Import {
echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
echo '</ul>';
- echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
+ echo '<p>'.sprintf(__('That&#8217;s it! What are you waiting for? Go <a href="%1$s">login</a>!'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'</p>';
}
function db_form()
@@ -646,7 +644,9 @@ class Textpattern_Import {
$this->import_users();
break;
case 3 :
- $this->import_posts();
+ $result = $this->import_posts();
+ if ( is_wp_error( $result ) )
+ echo $result->get_error_message();
break;
case 4 :
$this->import_comments();
diff --git a/wp-admin/import/utw.php b/wp-admin/import/utw.php
new file mode 100644
index 0000000..b321f25
--- /dev/null
+++ b/wp-admin/import/utw.php
@@ -0,0 +1,276 @@
+<?php
+
+class UTW_Import {
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Ultimate Tag Warrior').'</h2>';
+ echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'<br /><br /></p>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function greet() {
+ echo '<div class="narrow">';
+ echo '<p>'.__('Howdy! This imports tags from an existing Ultimate Tag Warrior 3 installation into this blog using the new WordPress native tagging structure.').'</p>';
+ echo '<p>'.__('This has not been tested on any other versions of Ultimate Tag Warrior. Mileage may vary.').'</p>';
+ echo '<p>'.__('To accommodate larger databases for those tag-crazy authors out there, we have made this into an easy 5-step program to help you kick that nasty UTW habit. Just keep clicking along and we will let you know when you are in the clear!').'</p>';
+ echo '<p><strong>'.__('Don&#8217;t be stupid - backup your database before proceeding!').'</strong></p>';
+ echo '<form action="admin.php?import=utw&amp;step=1" method="post">';
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 1 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+
+ function dispatch () {
+ if ( empty( $_GET['step'] ) ) {
+ $step = 0;
+ } else {
+ $step = (int) $_GET['step'];
+ }
+
+ if ( $step > 1 )
+ check_admin_referer('import-utw');
+
+ // load the header
+ $this->header();
+
+ switch ( $step ) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ $this->import_tags();
+ break;
+ case 2 :
+ $this->import_posts();
+ break;
+ case 3:
+ $this->import_t2p();
+ break;
+ case 4:
+ $this->cleanup_import();
+ break;
+ }
+
+ // load the footer
+ $this->footer();
+ }
+
+
+ function import_tags ( ) {
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Reading UTW Tags&#8230;').'</h3></p>';
+
+ $tags = $this->get_utw_tags();
+
+ // if we didn't get any tags back, that's all there is folks!
+ if ( !is_array($tags) ) {
+ echo '<p>' . __('No Tags Found!') . '</p>';
+ return false;
+ }
+ else {
+
+ // if there's an existing entry, delete it
+ if ( get_option('utwimp_tags') ) {
+ delete_option('utwimp_tags');
+ }
+
+ add_option('utwimp_tags', $tags);
+
+
+ $count = count($tags);
+
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags were read.'), $count ) . '<br /></p>';
+ echo '<p>' . __('The following tags were found:') . '</p>';
+
+ echo '<ul>';
+
+ foreach ( $tags as $tag_id => $tag_name ) {
+
+ echo '<li>' . $tag_name . '</li>';
+
+ }
+
+ echo '</ul>';
+
+ echo '<br />';
+
+ echo '<p>' . __('If you don&#8217;t want to import any of these tags, you should delete them from the UTW tag management page and then re-run this import.') . '</p>';
+
+
+ }
+
+ echo '<form action="admin.php?import=utw&amp;step=2" method="post">';
+ wp_nonce_field('import-utw');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 2 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+ }
+
+
+ function import_posts ( ) {
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Reading UTW Post Tags&#8230;').'</h3></p>';
+
+ // read in all the UTW tag -> post settings
+ $posts = $this->get_utw_posts();
+
+ // if we didn't get any tags back, that's all there is folks!
+ if ( !is_array($posts) ) {
+ echo '<p>' . __('No posts were found to have tags!') . '</p>';
+ return false;
+ }
+ else {
+
+ // if there's an existing entry, delete it
+ if ( get_option('utwimp_posts') ) {
+ delete_option('utwimp_posts');
+ }
+
+ add_option('utwimp_posts', $posts);
+
+
+ $count = count($posts);
+
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> tag to post relationships were read.'), $count ) . '<br /></p>';
+
+ }
+
+ echo '<form action="admin.php?import=utw&amp;step=3" method="post">';
+ wp_nonce_field('import-utw');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 3 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+
+ }
+
+
+ function import_t2p ( ) {
+
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Adding Tags to Posts&#8230;').'</h3></p>';
+
+ // run that funky magic!
+ $tags_added = $this->tag2post();
+
+ echo '<p>' . sprintf( __('Done! <strong>%s</strong> tags where added!'), $tags_added ) . '<br /></p>';
+
+ echo '<form action="admin.php?import=utw&amp;step=4" method="post">';
+ wp_nonce_field('import-utw');
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Step 4 &raquo;').'" /></p>';
+ echo '</form>';
+ echo '</div>';
+
+ }
+
+
+ function get_utw_tags ( ) {
+
+ global $wpdb;
+
+ // read in all the tags from the UTW tags table: should be wp_tags
+ $tags_query = "SELECT tag_id, tag FROM " . $wpdb->prefix . "tags";
+
+ $tags = $wpdb->get_results($tags_query);
+
+ // rearrange these tags into something we can actually use
+ foreach ( $tags as $tag ) {
+
+ $new_tags[$tag->tag_id] = $tag->tag;
+
+ }
+
+ return $new_tags;
+
+ }
+
+ function get_utw_posts ( ) {
+
+ global $wpdb;
+
+ // read in all the posts from the UTW post->tag table: should be wp_post2tag
+ $posts_query = "SELECT tag_id, post_id FROM " . $wpdb->prefix . "post2tag";
+
+ $posts = $wpdb->get_results($posts_query);
+
+ return $posts;
+
+ }
+
+
+ function tag2post ( ) {
+
+ // get the tags and posts we imported in the last 2 steps
+ $tags = get_option('utwimp_tags');
+ $posts = get_option('utwimp_posts');
+
+ // null out our results
+ $tags_added = 0;
+
+ // loop through each post and add its tags to the db
+ foreach ( $posts as $this_post ) {
+
+ $the_post = (int) $this_post->post_id;
+ $the_tag = (int) $this_post->tag_id;
+
+ // what's the tag name for that id?
+ $the_tag = $tags[$the_tag];
+
+ // screw it, just try to add the tag
+ wp_add_post_tags($the_post, $the_tag);
+
+ $tags_added++;
+
+ }
+
+ // that's it, all posts should be linked to their tags properly, pending any errors we just spit out!
+ return $tags_added;
+
+
+ }
+
+
+ function cleanup_import ( ) {
+
+ delete_option('utwimp_tags');
+ delete_option('utwimp_posts');
+
+ $this->done();
+
+ }
+
+
+ function done ( ) {
+
+ echo '<div class="narrow">';
+ echo '<p><h3>'.__('Import Complete!').'</h3></p>';
+
+ echo '<p>' . __('OK, so we lied about this being a 5-step program! You&#8217;re done!') . '</p>';
+
+ echo '<p>' . __('Now wasn&#8217;t that easy?') . '</p>';
+
+ echo '</div>';
+
+ }
+
+
+ function UTW_Import ( ) {
+
+ // Nothing.
+
+ }
+
+}
+
+
+// create the import object
+$utw_import = new UTW_Import();
+
+// add it to the import page!
+register_importer('utw', 'Ultimate Tag Warrior', __('Import Ultimate Tag Warrior tags into the new native tagging structure.'), array($utw_import, 'dispatch'));
+
+?> \ No newline at end of file
diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php
index a56e30a..f39e9bb 100644
--- a/wp-admin/import/wordpress.php
+++ b/wp-admin/import/wordpress.php
@@ -69,39 +69,52 @@ class WP_Import {
function get_entries() {
set_magic_quotes_runtime(0);
- $importdata = array_map('rtrim', file($this->file)); // Read the file into an array
$this->posts = array();
$this->categories = array();
+ $this->tags = array();
$num = 0;
$doing_entry = false;
- foreach ($importdata as $importline) {
- if ( false !== strpos($importline, '<wp:category>') ) {
- preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
- $this->categories[] = $category[1];
- continue;
- }
- if ( false !== strpos($importline, '<item>') ) {
- $this->posts[$num] = '';
- $doing_entry = true;
- continue;
- }
- if ( false !== strpos($importline, '</item>') ) {
- $num++;
- $doing_entry = false;
- continue;
- }
- if ( $doing_entry ) {
- $this->posts[$num] .= $importline . "\n";
+
+ $fp = fopen($this->file, 'r');
+ if ($fp) {
+ while ( !feof($fp) ) {
+ $importline = rtrim(fgets($fp));
+
+ if ( false !== strpos($importline, '<wp:category>') ) {
+ preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
+ $this->categories[] = $category[1];
+ continue;
+ }
+ if ( false !== strpos($importline, '<wp:tag>') ) {
+ preg_match('|<wp:tag>(.*?)</wp:tag>|is', $importline, $tag);
+ $this->tags[] = $tag[1];
+ continue;
+ }
+ if ( false !== strpos($importline, '<item>') ) {
+ $this->posts[$num] = '';
+ $doing_entry = true;
+ continue;
+ }
+ if ( false !== strpos($importline, '</item>') ) {
+ $num++;
+ $doing_entry = false;
+ continue;
+ }
+ if ( $doing_entry ) {
+ $this->posts[$num] .= $importline . "\n";
+ }
}
- }
- foreach ($this->posts as $post) {
- $post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
- if ($post_ID) {
- $this->posts_processed[$post_ID][0] = &$post;
- $this->posts_processed[$post_ID][1] = 0;
+ foreach ($this->posts as $post) {
+ $post_ID = (int) $this->get_tag( $post, 'wp:post_id' );
+ if ($post_ID) {
+ $this->posts_processed[$post_ID][0] = &$post;
+ $this->posts_processed[$post_ID][1] = 0;
+ }
}
+
+ fclose($fp);
}
}
@@ -128,6 +141,32 @@ class WP_Import {
return $authors;
}
+ function get_authors_from_post() {
+ $formnames = array ();
+ $selectnames = array ();
+
+ foreach ($_POST['user'] as $key => $line) {
+ $newname = trim(stripslashes($line));
+ if ($newname == '')
+ $newname = 'left_blank'; //passing author names from step 1 to step 2 is accomplished by using POST. left_blank denotes an empty entry in the form.
+ array_push($formnames, "$newname");
+ } // $formnames is the array with the form entered names
+
+ foreach ($_POST['userselect'] as $user => $key) {
+ $selected = trim(stripslashes($key));
+ array_push($selectnames, "$selected");
+ }
+
+ $count = count($formnames);
+ for ($i = 0; $i < $count; $i ++) {
+ if ($selectnames[$i] != '#NONE#') { //if no name was selected from the select menu, use the name entered in the form
+ array_push($this->newauthornames, "$selectnames[$i]");
+ } else {
+ array_push($this->newauthornames, "$formnames[$i]");
+ }
+ }
+ }
+
function wp_authors_form() {
?>
<h2><?php _e('Assign Authors'); ?></h2>
@@ -147,7 +186,7 @@ class WP_Import {
echo '</li>';
}
- echo '<input type="submit" value="Submit">'.'<br/>';
+ echo '<input type="submit" value="Submit">'.'<br />';
echo '</form>';
echo '</ol>';
@@ -170,7 +209,7 @@ class WP_Import {
function process_categories() {
global $wpdb;
- $cat_names = (array) $wpdb->get_col("SELECT cat_name FROM $wpdb->categories");
+ $cat_names = (array) get_terms('category', 'fields=names');
while ( $c = array_shift($this->categories) ) {
$cat_name = trim($this->get_tag( $c, 'wp:cat_name' ));
@@ -196,12 +235,36 @@ class WP_Import {
}
}
+ function process_tags() {
+ global $wpdb;
+
+ $tag_names = (array) get_terms('post_tag', 'fields=names');
+
+ while ( $c = array_shift($this->tags) ) {
+ $tag_name = trim($this->get_tag( $c, 'wp:tag_name' ));
+
+ // If the category exists we leave it alone
+ if ( in_array($tag_name, $tag_names) )
+ continue;
+
+ $slug = $this->get_tag( $c, 'wp:tag_slug' );
+ $description = $this->get_tag( $c, 'wp:tag_description' );
+
+ $tagarr = compact('slug', 'description');
+
+ $tag_ID = wp_insert_term($tag_name, 'post_tag', $tagarr);
+ }
+ }
+
function process_posts() {
$i = -1;
echo '<ol>';
- foreach ($this->posts as $post)
- $this->process_post($post);
+ foreach ($this->posts as $post) {
+ $result = $this->process_post($post);
+ if ( is_wp_error( $result ) )
+ return $result;
+ }
echo '</ol>';
@@ -236,6 +299,15 @@ class WP_Import {
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr>', '<hr />', $post_content);
+ preg_match_all('|<category domain="tag">(.*?)</category>|is', $post, $tags);
+ $tags = $tags[1];
+
+ $tag_index = 0;
+ foreach ($tags as $tag) {
+ $tags[$tag_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $tag)));
+ $tag_index++;
+ }
+
preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
$categories = $categories[1];
@@ -253,7 +325,11 @@ class WP_Import {
// If it has parent, process parent first.
$post_parent = (int) $post_parent;
if ($parent = $this->posts_processed[$post_parent]) {
- if (!$parent[1]) $this->process_post($parent[0]); // If not yet, process the parent first.
+ if (!$parent[1]) {
+ $result = $this->process_post($parent[0]); // If not yet, process the parent first.
+ if ( is_wp_error( $result ) )
+ return $result;
+ }
$post_parent = $parent[1]; // New ID of the parent;
}
@@ -264,6 +340,8 @@ class WP_Import {
$postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type');
$comment_post_ID = $post_id = wp_insert_post($postdata);
+ if ( is_wp_error( $post_id ) )
+ return $post_id;
// Memorize old and new ID.
if ( $post_id && $post_ID && $this->posts_processed[$post_ID] )
@@ -273,14 +351,38 @@ class WP_Import {
if (count($categories) > 0) {
$post_cats = array();
foreach ($categories as $category) {
- $cat_ID = (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$category'");
+ $slug = sanitize_term_field('slug', $category, 0, 'category', 'db');
+ $cat = get_term_by('slug', $slug, 'category');
+ $cat_ID = 0;
+ if ( ! empty($cat) )
+ $cat_ID = $cat->term_id;
if ($cat_ID == 0) {
+ $category = $wpdb->escape($category);
$cat_ID = wp_insert_category(array('cat_name' => $category));
}
$post_cats[] = $cat_ID;
}
wp_set_post_categories($post_id, $post_cats);
- }
+ }
+
+ // Add tags.
+ if (count($tags) > 0) {
+ $post_tags = array();
+ foreach ($tags as $tag) {
+ $slug = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
+ $tag_obj = get_term_by('slug', $slug, 'post_tag');
+ $tag_id = 0;
+ if ( ! empty($tag_obj) )
+ $tag_id = $tag_obj->term_id;
+ if ( $tag_id == 0 ) {
+ $tag = $wpdb->escape($tag);
+ $tag_id = wp_insert_term($tag, 'post_tag');
+ $tag_id = $tag_id['term_id'];
+ }
+ $post_tags[] = $tag_id;
+ }
+ wp_set_post_tags($post_id, $post_tags);
+ }
}
// Now for comments
@@ -324,9 +426,13 @@ class WP_Import {
$this->id = (int) $_GET['id'];
$this->file = get_attached_file($this->id);
+ $this->get_authors_from_post();
$this->get_entries();
$this->process_categories();
- $this->process_posts();
+ $this->process_tags();
+ $result = $this->process_posts();
+ if ( is_wp_error( $result ) )
+ return $result;
}
function dispatch() {
@@ -346,7 +452,9 @@ class WP_Import {
break;
case 2:
check_admin_referer('import-wordpress');
- $this->import();
+ $result = $this->import();
+ if ( is_wp_error( $result ) )
+ echo $result->get_error_message();
break;
}
$this->footer();
diff --git a/wp-admin/import/wp-cat2tag.php b/wp-admin/import/wp-cat2tag.php
new file mode 100644
index 0000000..ee4104e
--- /dev/null
+++ b/wp-admin/import/wp-cat2tag.php
@@ -0,0 +1,240 @@
+<?php
+
+class WP_Categories_to_Tags {
+ var $categories_to_convert = array();
+ var $all_categories = array();
+
+ function header() {
+ print '<div class="wrap">';
+ print '<h2>' . __('Convert Categories to Tags') . '</h2>';
+ }
+
+ function footer() {
+ print '</div>';
+ }
+
+ function populate_all_categories() {
+ global $wpdb;
+
+ $categories = get_categories('get=all');
+ foreach ( $categories as $category ) {
+ if ( !tag_exists($wpdb->escape($category->name)) )
+ $this->all_categories[] = $category;
+ }
+ }
+
+ function welcome() {
+ $this->populate_all_categories();
+
+ print '<div class="narrow">';
+
+ if (count($this->all_categories) > 0) {
+ print '<p>' . __('Howdy! This converter allows you to selectively convert existing categories to tags. To get started, check the checkboxes of the categories you wish to be converted, then click the Convert button.') . '</p>';
+ print '<p>' . __('Keep in mind that if you convert a category with child categories, those child categories get their parent setting removed, so they\'re in the root.') . '</p>';
+
+ $this->categories_form();
+ } else {
+ print '<p>'.__('You have no categories to convert!').'</p>';
+ }
+
+ print '</div>';
+ }
+
+ function categories_form() {
+ print '<form action="admin.php?import=wp-cat2tag&amp;step=2" method="post">';
+ wp_nonce_field('import-cat2tag');
+ print '<ul style="list-style:none">';
+
+ $hier = _get_term_hierarchy('category');
+
+ foreach ($this->all_categories as $category) {
+ $category = sanitize_term( $category, 'category', 'display' );
+
+ if ((int) $category->parent == 0) {
+ print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($category->term_id) . '" /> ' . $category->name . ' (' . $category->count . ')</label>';
+
+ if (isset($hier[$category->term_id])) {
+ $this->_category_children($category, $hier);
+ }
+
+ print '</li>';
+ }
+ }
+
+ print '</ul>';
+
+ print '<p class="submit"><input type="submit" name="maybe_convert_all_cats" value="' . __('Convert All Categories') . '" /> <input type="submit" name="submit" value="' . __('Convert &raquo;') . '" /></p>';
+ print '</form>';
+ }
+
+ function _category_children($parent, $hier) {
+ print '<ul style="list-style:none">';
+
+ foreach ($hier[$parent->term_id] as $child_id) {
+ $child =& get_category($child_id);
+
+ print '<li><label><input type="checkbox" name="cats_to_convert[]" value="' . intval($child->term_id) . '" /> ' . $child->name . ' (' . $child->count . ')</label>';
+
+ if (isset($hier[$child->term_id])) {
+ $this->_category_children($child, $hier);
+ }
+
+ print '</li>';
+ }
+
+ print '</ul>';
+ }
+
+ function _category_exists($cat_id) {
+ global $wpdb;
+
+ $cat_id = (int) $cat_id;
+
+ $maybe_exists = category_exists($cat_id);
+
+ if ( $maybe_exists ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function convert_them() {
+ global $wpdb;
+
+ if ( (!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) && empty($this->categories_to_convert)) {
+ print '<div class="narrow">';
+ print '<p>' . sprintf(__('Uh, oh. Something didn\'t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag') . '</p>';
+ print '</div>';
+ return;
+ }
+
+
+ if ( empty($this->categories_to_convert) )
+ $this->categories_to_convert = $_POST['cats_to_convert'];
+ $hier = _get_term_hierarchy('category');
+
+ print '<ul>';
+
+ foreach ( (array) $this->categories_to_convert as $cat_id) {
+ $cat_id = (int) $cat_id;
+
+ print '<li>' . sprintf(__('Converting category #%s ... '), $cat_id);
+
+ if (!$this->_category_exists($cat_id)) {
+ _e('Category doesn\'t exist!');
+ } else {
+ $category =& get_category($cat_id);
+
+ if ( tag_exists($wpdb->escape($category->name)) ) {
+ _e('Category is already a tag.');
+ print '</li>';
+ continue;
+ }
+
+ // If the category is the default, leave category in place and create tag.
+ if ( get_option('default_category') == $category->term_id ) {
+ $id = wp_insert_term($category->name, 'post_tag', array('slug' => $category->slug));
+ $id = $id['term_taxonomy_id'];
+ $posts = get_objects_in_term($category->term_id, 'category');
+ foreach ( $posts as $post ) {
+ if ( !$wpdb->get_var("SELECT object_id FROM $wpdb->term_relationships WHERE object_id = '$post' AND term_taxonomy_id = '$id'") )
+ $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$post', '$id')");
+ }
+ } else {
+ // Change the category to a tag.
+ $wpdb->query("UPDATE $wpdb->term_taxonomy SET taxonomy = 'post_tag' WHERE term_id = '{$category->term_id}' AND taxonomy = 'category'");
+
+ // Set all parents to 0 (root-level) if their parent was the converted tag
+ $wpdb->query("UPDATE $wpdb->term_taxonomy SET parent = 0 WHERE parent = '{$category->term_id}' AND taxonomy = 'category'");
+ }
+ // Clean the cache
+ clean_category_cache($category->term_id);
+
+ _e('Converted successfully.');
+ }
+
+ print '</li>';
+ }
+
+ print '</ul>';
+ }
+
+ function convert_all_confirm() {
+ print '<div class="narrow">';
+
+ print '<h3>' . __('Confirm') . '</h3>';
+
+ print '<p>' . __('You are about to convert all categories to tags. Are you sure you want to continue?') . '</p>';
+
+ print '<form action="admin.php?import=wp-cat2tag" method="post">';
+ wp_nonce_field('import-cat2tag');
+ print '<p style="text-align:center" class="submit"><input type="submit" value="' . __('Yes') . '" name="yes_convert_all_cats" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="' . __('No') . '" name="no_dont_do_it" /></p>';
+ print '</form>';
+
+ print '</div>';
+ }
+
+ function convert_all() {
+ global $wpdb;
+
+ $this->populate_all_categories();
+ foreach ( $this->all_categories as $category )
+ $this->categories_to_convert[] = $category->term_id;
+ $this->convert_them();
+ }
+
+ function init() {
+
+ if (isset($_POST['maybe_convert_all_cats'])) {
+ $step = 3;
+ } elseif (isset($_POST['yes_convert_all_cats'])) {
+ $step = 4;
+ } elseif (isset($_POST['no_dont_do_it'])) {
+ die('no_dont_do_it');
+ } else {
+ $step = (isset($_GET['step'])) ? (int) $_GET['step'] : 1;
+ }
+
+ $this->header();
+
+ if (!current_user_can('manage_categories')) {
+ print '<div class="narrow">';
+ print '<p>' . __('Cheatin&#8217; uh?') . '</p>';
+ print '</div>';
+ } else {
+ if ( $step > 1 )
+ check_admin_referer('import-cat2tag');
+
+ switch ($step) {
+ case 1 :
+ $this->welcome();
+ break;
+
+ case 2 :
+ $this->convert_them();
+ break;
+
+ case 3 :
+ $this->convert_all_confirm();
+ break;
+
+ case 4 :
+ $this->convert_all();
+ break;
+ }
+ }
+
+ $this->footer();
+ }
+
+ function WP_Categories_to_Tags() {
+ // Do nothing.
+ }
+}
+
+$wp_cat2tag_importer = new WP_Categories_to_Tags();
+
+register_importer('wp-cat2tag', __('Categories to Tags Converter'), __('Convert existing categories to tags, selectively.'), array(&$wp_cat2tag_importer, 'init'));
+
+?>
diff --git a/wp-admin/includes/admin.php b/wp-admin/includes/admin.php
new file mode 100644
index 0000000..04a4bc1
--- /dev/null
+++ b/wp-admin/includes/admin.php
@@ -0,0 +1,22 @@
+<?php
+
+require_once(ABSPATH . 'wp-admin/includes/bookmark.php');
+require_once(ABSPATH . 'wp-admin/includes/comment.php');
+require_once(ABSPATH . 'wp-admin/includes/file.php');
+require_once(ABSPATH . 'wp-admin/includes/image.php');
+require_once(ABSPATH . 'wp-admin/includes/import.php');
+require_once(ABSPATH . 'wp-admin/includes/misc.php');
+require_once(ABSPATH . 'wp-admin/includes/plugin.php');
+require_once(ABSPATH . 'wp-admin/includes/post.php');
+require_once(ABSPATH . 'wp-admin/includes/taxonomy.php');
+require_once(ABSPATH . 'wp-admin/includes/template.php');
+require_once(ABSPATH . 'wp-admin/includes/theme.php');
+require_once(ABSPATH . 'wp-admin/includes/user.php');
+require_once(ABSPATH . 'wp-admin/includes/update.php');
+
+// MU specific
+require_once(ABSPATH . 'wp-admin/includes/mu.php');
+
+require_once(ABSPATH . WPINC . '/registration.php');
+
+?>
diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php
new file mode 100644
index 0000000..35cc9c9
--- /dev/null
+++ b/wp-admin/includes/bookmark.php
@@ -0,0 +1,177 @@
+<?php
+
+function add_link() {
+ return edit_link();
+}
+
+function edit_link( $link_id = '' ) {
+ if (!current_user_can( 'manage_links' ))
+ wp_die( __( 'Cheatin&#8217; uh?' ));
+
+ $_POST['link_url'] = wp_specialchars( $_POST['link_url'] );
+ $_POST['link_url'] = clean_url($_POST['link_url']);
+ $_POST['link_name'] = wp_specialchars( $_POST['link_name'] );
+ $_POST['link_image'] = wp_specialchars( $_POST['link_image'] );
+ $_POST['link_rss'] = clean_url($_POST['link_rss']);
+
+ if ( !empty( $link_id ) ) {
+ $_POST['link_id'] = $link_id;
+ return wp_update_link( $_POST);
+ } else {
+ return wp_insert_link( $_POST);
+ }
+}
+
+function get_default_link_to_edit() {
+ if ( isset( $_GET['linkurl'] ) )
+ $link->link_url = clean_url( $_GET['linkurl']);
+ else
+ $link->link_url = '';
+
+ if ( isset( $_GET['name'] ) )
+ $link->link_name = attribute_escape( $_GET['name']);
+ else
+ $link->link_name = '';
+
+ $link->link_visible = 'Y';
+
+ return $link;
+}
+
+function wp_delete_link($link_id) {
+ global $wpdb;
+
+ do_action('delete_link', $link_id);
+
+ wp_delete_object_term_relationships($link_id, 'link_category');
+
+ $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
+
+ do_action('deleted_link', $link_id);
+
+ return true;
+}
+
+function wp_get_link_cats($link_id = 0) {
+
+ $cats = wp_get_object_terms($link_id, 'link_category', 'fields=ids');
+
+ return array_unique($cats);
+}
+
+function get_link_to_edit( $link_id ) {
+ return get_link( $link_id, OBJECT, 'edit' );
+}
+
+function wp_insert_link($linkdata) {
+ global $wpdb, $current_user;
+
+ $defaults = array('link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
+
+ $linkdata = wp_parse_args($linkdata, $defaults);
+ $linkdata = sanitize_bookmark($linkdata, 'db');
+
+ extract($linkdata, EXTR_SKIP);
+
+ $update = false;
+
+ if ( !empty($link_id) )
+ $update = true;
+
+ if ( trim( $link_name ) == '' )
+ return 0;
+
+ if ( trim( $link_url ) == '' )
+ return 0;
+
+ if ( empty($link_rating) )
+ $link_rating = 0;
+
+ if ( empty($link_image) )
+ $link_image = '';
+
+ if ( empty($link_target) )
+ $link_target = '';
+
+ if ( empty($link_visible) )
+ $link_visible = 'Y';
+
+ if ( empty($link_owner) )
+ $link_owner = $current_user->id;
+
+ if ( empty($link_notes) )
+ $link_notes = '';
+
+ if ( empty($link_description) )
+ $link_description = '';
+
+ if ( empty($link_rss) )
+ $link_rss = '';
+
+ if ( empty($link_rel) )
+ $link_rel = '';
+
+ // Make sure we set a valid category
+ if (0 == count($link_category) || !is_array($link_category)) {
+ $link_category = array(get_option('default_link_category'));
+ }
+
+ if ( $update ) {
+ $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url',
+ link_name='$link_name', link_image='$link_image',
+ link_target='$link_target',
+ link_visible='$link_visible', link_description='$link_description',
+ link_rating='$link_rating', link_rel='$link_rel',
+ link_notes='$link_notes', link_rss = '$link_rss'
+ WHERE link_id='$link_id'");
+ } else {
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
+ $link_id = (int) $wpdb->insert_id;
+ }
+
+ wp_set_link_cats($link_id, $link_category);
+
+ if ( $update )
+ do_action('edit_link', $link_id);
+ else
+ do_action('add_link', $link_id);
+
+ return $link_id;
+}
+
+function wp_set_link_cats($link_id = 0, $link_categories = array()) {
+ // If $link_categories isn't already an array, make it one:
+ if (!is_array($link_categories) || 0 == count($link_categories))
+ $link_categories = array(get_option('default_link_category'));
+
+ $link_categories = array_map('intval', $link_categories);
+ $link_categories = array_unique($link_categories);
+
+ wp_set_object_terms($link_id, $link_categories, 'link_category');
+} // wp_set_link_cats()
+
+function wp_update_link($linkdata) {
+ global $wpdb;
+
+ $link_id = (int) $linkdata['link_id'];
+
+ $link = get_link($link_id, ARRAY_A);
+
+ // Escape data pulled from DB.
+ $link = add_magic_quotes($link);
+
+ // Passed link category list overwrites existing category list if not empty.
+ if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
+ && 0 != count($linkdata['link_category']) )
+ $link_cats = $linkdata['link_category'];
+ else
+ $link_cats = $link['link_category'];
+
+ // Merge old and new fields with new fields overwriting old ones.
+ $linkdata = array_merge($link, $linkdata);
+ $linkdata['link_category'] = $link_cats;
+
+ return wp_insert_link($linkdata);
+}
+
+?> \ No newline at end of file
diff --git a/wp-admin/includes/comment.php b/wp-admin/includes/comment.php
new file mode 100644
index 0000000..ae0d1d9
--- /dev/null
+++ b/wp-admin/includes/comment.php
@@ -0,0 +1,68 @@
+<?php
+
+function comment_exists($comment_author, $comment_date) {
+ global $wpdb;
+
+ return $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments
+ WHERE comment_author = '$comment_author' AND comment_date = '$comment_date'");
+}
+
+function edit_comment() {
+ global $user_ID;
+
+ $comment_ID = (int) $_POST['comment_ID'];
+ $comment_post_ID = (int) $_POST['comment_post_ID'];
+
+ if (!current_user_can( 'edit_post', $comment_post_ID ))
+ wp_die( __('You are not allowed to edit comments on this post, so you cannot edit this comment.' ));
+
+ $_POST['comment_author'] = $_POST['newcomment_author'];
+ $_POST['comment_author_email'] = $_POST['newcomment_author_email'];
+ $_POST['comment_author_url'] = $_POST['newcomment_author_url'];
+ $_POST['comment_approved'] = $_POST['comment_status'];
+ $_POST['comment_content'] = $_POST['content'];
+ $_POST['comment_ID'] = (int) $_POST['comment_ID'];
+
+ if (!empty ( $_POST['edit_date'] ) ) {
+ $aa = $_POST['aa'];
+ $mm = $_POST['mm'];
+ $jj = $_POST['jj'];
+ $hh = $_POST['hh'];
+ $mn = $_POST['mn'];
+ $ss = $_POST['ss'];
+ $jj = ($jj > 31 ) ? 31 : $jj;
+ $hh = ($hh > 23 ) ? $hh -24 : $hh;
+ $mn = ($mn > 59 ) ? $mn -60 : $mn;
+ $ss = ($ss > 59 ) ? $ss -60 : $ss;
+ $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
+ }
+
+ wp_update_comment( $_POST);
+}
+
+function get_comment_to_edit( $id ) {
+ if ( !$comment = get_comment($id) )
+ return false;
+
+ $comment->comment_ID = (int) $comment->comment_ID;
+ $comment->comment_post_ID = (int) $comment->comment_post_ID;
+
+ $comment->comment_content = format_to_edit( $comment->comment_content );
+ $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content);
+
+ $comment->comment_author = format_to_edit( $comment->comment_author );
+ $comment->comment_author_email = format_to_edit( $comment->comment_author_email );
+ $comment->comment_author_url = clean_url($comment->comment_author_url);
+ $comment->comment_author_url = format_to_edit( $comment->comment_author_url );
+
+ return $comment;
+}
+
+function get_pending_comments_num( $post_id ) {
+ global $wpdb;
+ $post_id = (int) $post_id;
+ $pending = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '0'" );
+ return $pending;
+}
+
+?> \ No newline at end of file
diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php
new file mode 100644
index 0000000..2d58852
--- /dev/null
+++ b/wp-admin/includes/file.php
@@ -0,0 +1,189 @@
+<?php
+
+$wp_file_descriptions = array ('index.php' => __( 'Main Index Template' ), 'style.css' => __( 'Stylesheet' ), 'comments.php' => __( 'Comments' ), 'comments-popup.php' => __( 'Popup Comments' ), 'footer.php' => __( 'Footer' ), 'header.php' => __( 'Header' ), 'sidebar.php' => __( 'Sidebar' ), 'archive.php' => __( 'Archives' ), 'category.php' => __( 'Category Template' ), 'page.php' => __( 'Page Template' ), 'search.php' => __( 'Search Results' ), 'single.php' => __( 'Single Post' ), '404.php' => __( '404 Template' ), 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), '.htaccess' => __( '.htaccess (for rewrite rules )' ),
+ // Deprecated files
+ 'wp-layout.css' => __( 'Stylesheet' ), 'wp-comments.php' => __( 'Comments Template' ), 'wp-comments-popup.php' => __( 'Popup Comments Template' ));
+function get_file_description( $file ) {
+ global $wp_file_descriptions;
+
+ if ( isset( $wp_file_descriptions[basename( $file )] ) ) {
+ return $wp_file_descriptions[basename( $file )];
+ }
+ elseif ( file_exists( ABSPATH . $file ) && is_file( ABSPATH . $file ) ) {
+ $template_data = implode( '', file( ABSPATH . $file ) );
+ if ( preg_match( "|Template Name:(.*)|i", $template_data, $name ))
+ return $name[1];
+ }
+
+ return basename( $file );
+}
+
+function get_home_path() {
+ $home = get_option( 'home' );
+ if ( $home != '' && $home != get_option( 'siteurl' ) ) {
+ $home_path = parse_url( $home );
+ $home_path = $home_path['path'];
+ $root = str_replace( $_SERVER["PHP_SELF"], '', $_SERVER["SCRIPT_FILENAME"] );
+ $home_path = trailingslashit( $root.$home_path );
+ } else {
+ $home_path = ABSPATH;
+ }
+
+ return $home_path;
+}
+
+function get_real_file_to_edit( $file ) {
+ if ('index.php' == $file || '.htaccess' == $file ) {
+ $real_file = get_home_path().$file;
+ } else {
+ $real_file = ABSPATH.$file;
+ }
+
+ return $real_file;
+}
+
+function validate_file( $file, $allowed_files = '' ) {
+ if ( false !== strpos( $file, './' ))
+ return 1;
+
+ if (':' == substr( $file, 1, 1 ))
+ return 2;
+
+ if (!empty ( $allowed_files ) && (!in_array( $file, $allowed_files ) ) )
+ return 3;
+
+ return 0;
+}
+
+function validate_file_to_edit( $file, $allowed_files = '' ) {
+ $file = stripslashes( $file );
+
+ $code = validate_file( $file, $allowed_files );
+
+ if (!$code )
+ return $file;
+
+ switch ( $code ) {
+ case 1 :
+ wp_die( __('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.' ));
+
+ case 2 :
+ wp_die( __('Sorry, can&#8217;t call files with their real path.' ));
+
+ case 3 :
+ wp_die( __('Sorry, that file cannot be edited.' ));
+ }
+}
+
+// array wp_handle_upload ( array &file [, array overrides] )
+// file: reference to a single element of $_FILES. Call the function once for each uploaded file.
+// overrides: an associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
+// On success, returns an associative array of file attributes.
+// On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
+function wp_handle_upload( &$file, $overrides = false ) {
+ // The default error handler.
+ if (! function_exists( 'wp_handle_upload_error' ) ) {
+ function wp_handle_upload_error( &$file, $message ) {
+ return array( 'error'=>$message );
+ }
+ }
+
+ // You may define your own function and pass the name in $overrides['upload_error_handler']
+ $upload_error_handler = 'wp_handle_upload_error';
+
+ // $_POST['action'] must be set and its value must equal $overrides['action'] or this:
+ $action = 'wp_handle_upload';
+
+ // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
+ $upload_error_strings = array( false,
+ __( "The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>." ),
+ __( "The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form." ),
+ __( "The uploaded file was only partially uploaded." ),
+ __( "No file was uploaded." ),
+ __( "Missing a temporary folder." ),
+ __( "Failed to write file to disk." ));
+
+ // All tests are on by default. Most can be turned off by $override[{test_name}] = false;
+ $test_form = true;
+ $test_size = true;
+
+ // If you override this, you must provide $ext and $type!!!!
+ $test_type = true;
+
+ // Install user overrides. Did we mention that this voids your warranty?
+ if ( is_array( $overrides ) )
+ extract( $overrides, EXTR_OVERWRITE );
+
+ // A correct form post will pass this test.
+ if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) )
+ return $upload_error_handler( $file, __( 'Invalid form submission.' ));
+
+ // A successful upload will pass this test. It makes no sense to override this one.
+ if ( $file['error'] > 0 )
+ return $upload_error_handler( $file, $upload_error_strings[$file['error']] );
+
+ // A non-empty file will pass this test.
+ if ( $test_size && !($file['size'] > 0 ) )
+ return $upload_error_handler( $file, __( 'File is empty. Please upload something more substantial.' ));
+
+ // A properly uploaded file will pass this test. There should be no reason to override this one.
+ if (! @ is_uploaded_file( $file['tmp_name'] ) )
+ return $upload_error_handler( $file, __( 'Specified file failed upload test.' ));
+
+ // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
+ if ( $test_type ) {
+ $wp_filetype = wp_check_filetype( $file['name'], $mimes );
+
+ extract( $wp_filetype );
+
+ if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) )
+ return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' ));
+
+ if ( !$ext )
+ $ext = ltrim(strrchr($file['name'], '.'), '.');
+ }
+
+ // A writable uploads dir will pass this test. Again, there's no point overriding this one.
+ if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
+ return $upload_error_handler( $file, $uploads['error'] );
+
+ // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied.
+ if ( isset( $unique_filename_callback ) && function_exists( $unique_filename_callback ) ) {
+ $filename = $unique_filename_callback( $uploads['path'], $file['name'] );
+ } else {
+ $number = '';
+ $filename = str_replace( '#', '_', $file['name'] );
+ $filename = str_replace( array( '\\', "'" ), '', $filename );
+ if ( empty( $ext) )
+ $ext = '';
+ else
+ $ext = ".$ext";
+ while ( file_exists( $uploads['path'] . "/$filename" ) ) {
+ if ( '' == "$number$ext" )
+ $filename = $filename . ++$number . $ext;
+ else
+ $filename = str_replace( "$number$ext", ++$number . $ext, $filename );
+ }
+ $filename = str_replace( $ext, '', $filename );
+ $filename = sanitize_title_with_dashes( $filename ) . $ext;
+ }
+
+ // Move the file to the uploads dir
+ $new_file = $uploads['path'] . "/$filename";
+ if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
+ wp_die( __('There was a problem uploading your file. Please try again.' ) );
+
+ // Set correct file permissions
+ $stat = stat( dirname( $new_file ));
+ $perms = $stat['mode'] & 0000666;
+ @ chmod( $new_file, $perms );
+
+ // Compute the URL
+ $url = $uploads['url'] . "/$filename";
+
+ $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) );
+
+ return $return;
+}
+
+?>
diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php
new file mode 100644
index 0000000..ec4466e
--- /dev/null
+++ b/wp-admin/includes/image.php
@@ -0,0 +1,192 @@
+<?php
+
+function get_udims( $width, $height) {
+ if ( $height <= 96 && $width <= 128 )
+ return array( $width, $height);
+ elseif ( $width / $height > 4 / 3 )
+ return array( 128, (int) ($height / $width * 128 ));
+ else
+ return array( (int) ($width / $height * 96 ), 96 );
+}
+
+function wp_create_thumbnail( $file, $max_side, $effect = '' ) {
+
+ // 1 = GIF, 2 = JPEG, 3 = PNG
+
+ if ( file_exists( $file ) ) {
+ $type = getimagesize( $file );
+
+ // if the associated function doesn't exist - then it's not
+ // handle. duh. i hope.
+
+ if (!function_exists( 'imagegif' ) && $type[2] == 1 ) {
+ $error = __( 'Filetype not supported. Thumbnail not created.' );
+ }
+ elseif (!function_exists( 'imagejpeg' ) && $type[2] == 2 ) {
+ $error = __( 'Filetype not supported. Thumbnail not created.' );
+ }
+ elseif (!function_exists( 'imagepng' ) && $type[2] == 3 ) {
+ $error = __( 'Filetype not supported. Thumbnail not created.' );
+ } else {
+
+ // create the initial copy from the original file
+ if ( $type[2] == 1 ) {
+ $image = imagecreatefromgif( $file );
+ }
+ elseif ( $type[2] == 2 ) {
+ $image = imagecreatefromjpeg( $file );
+ }
+ elseif ( $type[2] == 3 ) {
+ $image = imagecreatefrompng( $file );
+ }
+
+ if ( function_exists( 'imageantialias' ))
+ imageantialias( $image, TRUE );
+
+ $image_attr = getimagesize( $file );
+
+ // figure out the longest side
+
+ if ( $image_attr[0] > $image_attr[1] ) {
+ $image_width = $image_attr[0];
+ $image_height = $image_attr[1];
+ $image_new_width = $max_side;
+
+ $image_ratio = $image_width / $image_new_width;
+ $image_new_height = $image_height / $image_ratio;
+ //width is > height
+ } else {
+ $image_width = $image_attr[0];
+ $image_height = $image_attr[1];
+ $image_new_height = $max_side;
+
+ $image_ratio = $image_height / $image_new_height;
+ $image_new_width = $image_width / $image_ratio;
+ //height > width
+ }
+
+ $thumbnail = imagecreatetruecolor( $image_new_width, $image_new_height);
+ @ imagecopyresampled( $thumbnail, $image, 0, 0, 0, 0, $image_new_width, $image_new_height, $image_attr[0], $image_attr[1] );
+
+ // If no filters change the filename, we'll do a default transformation.
+ if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) )
+ $thumb = preg_replace( '!(\.[^.]+)?$!', '.thumbnail' . '$1', basename( $file ), 1 );
+
+ $thumbpath = str_replace( basename( $file ), $thumb, $file );
+
+ // move the thumbnail to its final destination
+ if ( $type[2] == 1 ) {
+ if (!imagegif( $thumbnail, $thumbpath ) ) {
+ $error = __( "Thumbnail path invalid" );
+ }
+ }
+ elseif ( $type[2] == 2 ) {
+ if (!imagejpeg( $thumbnail, $thumbpath ) ) {
+ $error = __( "Thumbnail path invalid" );
+ }
+ }
+ elseif ( $type[2] == 3 ) {
+ if (!imagepng( $thumbnail, $thumbpath ) ) {
+ $error = __( "Thumbnail path invalid" );
+ }
+ }
+
+ }
+ } else {
+ $error = __( 'File not found' );
+ }
+
+ if (!empty ( $error ) ) {
+ return $error;
+ } else {
+ return apply_filters( 'wp_create_thumbnail', $thumbpath );
+ }
+}
+
+function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
+ if ( ctype_digit( $src_file ) ) // Handle int as attachment ID
+ $src_file = get_attached_file( $src_file );
+
+ $src = wp_load_image( $src_file );
+
+ if ( !is_resource( $src ))
+ return $src;
+
+ $dst = imagecreatetruecolor( $dst_w, $dst_h );
+
+ if ( $src_abs ) {
+ $src_w -= $src_x;
+ $src_h -= $src_y;
+ }
+
+ if (function_exists('imageantialias'))
+ imageantialias( $dst, true );
+
+ imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );
+
+ if ( !$dst_file )
+ $dst_file = str_replace( basename( $src_file ), 'cropped-'.basename( $src_file ), $src_file );
+
+ $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file );
+
+ if ( imagejpeg( $dst, $dst_file ) )
+ return $dst_file;
+ else
+ return false;
+}
+
+function wp_generate_attachment_metadata( $attachment_id, $file ) {
+ $attachment = get_post( $attachment_id );
+
+ $metadata = array();
+ if ( preg_match('!^image/!', get_post_mime_type( $attachment )) ) {
+ $imagesize = getimagesize($file);
+ $metadata['width'] = $imagesize['0'];
+ $metadata['height'] = $imagesize['1'];
+ list($uwidth, $uheight) = get_udims($metadata['width'], $metadata['height']);
+ $metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
+ $metadata['file'] = $file;
+
+ $max = apply_filters( 'wp_thumbnail_creation_size_limit', 3 * 1024 * 1024, $attachment_id, $file );
+
+ if ( $max < 0 || $metadata['width'] * $metadata['height'] < $max ) {
+ $max_side = apply_filters( 'wp_thumbnail_max_side_length', 128, $attachment_id, $file );
+ $thumb = wp_create_thumbnail( $file, $max_side );
+
+ if ( @file_exists($thumb) )
+ $metadata['thumb'] = basename($thumb);
+ }
+ }
+ return apply_filters( 'wp_generate_attachment_metadata', $metadata );
+}
+
+function wp_load_image( $file ) {
+ if ( ctype_digit( $file ) )
+ $file = get_attached_file( $file );
+
+ if ( !file_exists( $file ) )
+ return sprintf(__("File '%s' doesn't exist?"), $file);
+
+ if ( ! function_exists('imagecreatefromstring') )
+ return __('The GD image library is not installed.');
+
+ $contents = file_get_contents( $file );
+
+ $image = imagecreatefromstring( $contents );
+
+ if ( !is_resource( $image ) )
+ return sprintf(__("File '%s' is not an image."), $file);
+
+ return $image;
+}
+
+function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
+ if ( $height <= $hmax && $width <= $wmax )
+ return array( $width, $height);
+ elseif ( $width / $height > $wmax / $hmax )
+ return array( $wmax, (int) ($height / $width * $wmax ));
+ else
+ return array( (int) ($width / $height * $hmax ), $hmax );
+}
+
+?>
diff --git a/wp-admin/includes/import.php b/wp-admin/includes/import.php
new file mode 100644
index 0000000..9835bb1
--- /dev/null
+++ b/wp-admin/includes/import.php
@@ -0,0 +1,45 @@
+<?php
+
+function get_importers() {
+ global $wp_importers;
+ uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
+ return $wp_importers;
+}
+
+function register_importer( $id, $name, $description, $callback ) {
+ global $wp_importers;
+ if ( is_wp_error( $callback ) )
+ return $callback;
+ $wp_importers[$id] = array ( $name, $description, $callback );
+}
+
+function wp_import_cleanup( $id ) {
+ wp_delete_attachment( $id );
+}
+
+function wp_import_handle_upload() {
+ $overrides = array( 'test_form' => false, 'test_type' => false );
+ $file = wp_handle_upload( $_FILES['import'], $overrides );
+
+ if ( isset( $file['error'] ) )
+ return $file;
+
+ $url = $file['url'];
+ $type = $file['type'];
+ $file = addslashes( $file['file'] );
+ $filename = basename( $file );
+
+ // Construct the object array
+ $object = array( 'post_title' => $filename,
+ 'post_content' => $url,
+ 'post_mime_type' => $type,
+ 'guid' => $url
+ );
+
+ // Save the data
+ $id = wp_insert_attachment( $object, $file );
+
+ return array( 'file' => $file, 'id' => $id );
+}
+
+?>
diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php
new file mode 100644
index 0000000..db28014
--- /dev/null
+++ b/wp-admin/includes/misc.php
@@ -0,0 +1,178 @@
+<?php
+
+function got_mod_rewrite() {
+ global $is_apache;
+
+ // take 3 educated guesses as to whether or not mod_rewrite is available
+ if ( !$is_apache )
+ return false;
+
+ if ( function_exists( 'apache_get_modules' ) ) {
+ if ( !in_array( 'mod_rewrite', apache_get_modules() ) )
+ return false;
+ }
+
+ return true;
+}
+
+// Returns an array of strings from a file (.htaccess ) from between BEGIN
+// and END markers.
+function extract_from_markers( $filename, $marker ) {
+ $result = array ();
+
+ if (!file_exists( $filename ) ) {
+ return $result;
+ }
+
+ if ( $markerdata = explode( "\n", implode( '', file( $filename ) ) ));
+ {
+ $state = false;
+ foreach ( $markerdata as $markerline ) {
+ if (strpos($markerline, '# END ' . $marker) !== false)
+ $state = false;
+ if ( $state )
+ $result[] = $markerline;
+ if (strpos($markerline, '# BEGIN ' . $marker) !== false)
+ $state = true;
+ }
+ }
+
+ return $result;
+}
+
+// Inserts an array of strings into a file (.htaccess ), placing it between
+// BEGIN and END markers. Replaces existing marked info. Retains surrounding
+// data. Creates file if none exists.
+// Returns true on write success, false on failure.
+function insert_with_markers( $filename, $marker, $insertion ) {
+ return;
+ if (!file_exists( $filename ) || is_writeable( $filename ) ) {
+ if (!file_exists( $filename ) ) {
+ $markerdata = '';
+ } else {
+ $markerdata = explode( "\n", implode( '', file( $filename ) ) );
+ }
+
+ $f = fopen( $filename, 'w' );
+ $foundit = false;
+ if ( $markerdata ) {
+ $state = true;
+ foreach ( $markerdata as $n => $markerline ) {
+ if (strpos($markerline, '# BEGIN ' . $marker) !== false)
+ $state = false;
+ if ( $state ) {
+ if ( $n + 1 < count( $markerdata ) )
+ fwrite( $f, "{$markerline}\n" );
+ else
+ fwrite( $f, "{$markerline}" );
+ }
+ if (strpos($markerline, '# END ' . $marker) !== false) {
+ fwrite( $f, "# BEGIN {$marker}\n" );
+ if ( is_array( $insertion ))
+ foreach ( $insertion as $insertline )
+ fwrite( $f, "{$insertline}\n" );
+ fwrite( $f, "# END {$marker}\n" );
+ $state = true;
+ $foundit = true;
+ }
+ }
+ }
+ if (!$foundit) {
+ fwrite( $f, "# BEGIN {$marker}\n" );
+ foreach ( $insertion as $insertline )
+ fwrite( $f, "{$insertline}\n" );
+ fwrite( $f, "# END {$marker}\n" );
+ }
+ fclose( $f );
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/**
+ * Updates the htaccess file with the current rules if it is writable.
+ *
+ * Always writes to the file if it exists and is writable to ensure that we blank out old rules.
+ */
+
+function save_mod_rewrite_rules() {
+ global $wp_rewrite;
+
+ $home_path = get_home_path();
+ $htaccess_file = $home_path.'.htaccess';
+
+ // If the file doesn't already exists check for write access to the directory and whether of not we have some rules.
+ // else check for write access to the file.
+ if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
+ if ( got_mod_rewrite() ) {
+ $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
+ return insert_with_markers( $htaccess_file, 'WordPress', $rules );
+ }
+ }
+
+ return false;
+}
+
+function update_recently_edited( $file ) {
+ $oldfiles = (array ) get_option( 'recently_edited' );
+ if ( $oldfiles ) {
+ $oldfiles = array_reverse( $oldfiles );
+ $oldfiles[] = $file;
+ $oldfiles = array_reverse( $oldfiles );
+ $oldfiles = array_unique( $oldfiles );
+ if ( 5 < count( $oldfiles ))
+ array_pop( $oldfiles );
+ } else {
+ $oldfiles[] = $file;
+ }
+ update_option( 'recently_edited', $oldfiles );
+}
+
+// If siteurl or home changed, reset cookies and flush rewrite rules.
+function update_home_siteurl( $old_value, $value ) {
+ global $wp_rewrite, $user_login, $user_pass_md5;
+
+ if ( defined( "WP_INSTALLING" ) )
+ return;
+
+ // If home changed, write rewrite rules to new location.
+ $wp_rewrite->flush_rules();
+ // Clear cookies for old paths.
+ wp_clearcookie();
+ // Set cookies for new paths.
+ wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' ));
+}
+
+add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
+add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
+
+function url_shorten( $url ) {
+ $short_url = str_replace( 'http://', '', stripslashes( $url ));
+ $short_url = str_replace( 'www.', '', $short_url );
+ if ('/' == substr( $short_url, -1 ))
+ $short_url = substr( $short_url, 0, -1 );
+ if ( strlen( $short_url ) > 35 )
+ $short_url = substr( $short_url, 0, 32 ).'...';
+ return $short_url;
+}
+
+function wp_reset_vars( $vars ) {
+ for ( $i=0; $i<count( $vars ); $i += 1 ) {
+ $var = $vars[$i];
+ global $$var;
+
+ if (!isset( $$var ) ) {
+ if ( empty( $_POST["$var"] ) ) {
+ if ( empty( $_GET["$var"] ) )
+ $$var = '';
+ else
+ $$var = $_GET["$var"];
+ } else {
+ $$var = $_POST["$var"];
+ }
+ }
+ }
+}
+
+?>
diff --git a/wp-admin/includes/mu.php b/wp-admin/includes/mu.php
new file mode 100644
index 0000000..8599860
--- /dev/null
+++ b/wp-admin/includes/mu.php
@@ -0,0 +1,202 @@
+<?php
+
+function wpmu_delete_blog($blog_id, $drop = false) {
+ global $wpdb, $wpmuBaseTablePrefix;
+
+ if ( $blog_id != $wpdb->blogid ) {
+ $switch = true;
+ switch_to_blog($blog_id);
+ }
+
+ do_action('delete_blog', $blog_id, $drop);
+
+ $users = get_users_of_blog($blog_id);
+
+ // Remove users from this blog.
+ if ( !empty($users) ) foreach ($users as $user) {
+ remove_user_from_blog($user->user_id, $blog_id);
+ }
+
+ update_blog_status( $wpdb->blogid, 'deleted', 1 );
+
+ if ( $drop ) {
+ $drop_tables = array( $wpmuBaseTablePrefix . $blog_id . "_categories",
+ $wpmuBaseTablePrefix . $blog_id . "_comments",
+ $wpmuBaseTablePrefix . $blog_id . "_linkcategories",
+ $wpmuBaseTablePrefix . $blog_id . "_links",
+ $wpmuBaseTablePrefix . $blog_id . "_link2cat",
+ $wpmuBaseTablePrefix . $blog_id . "_options",
+ $wpmuBaseTablePrefix . $blog_id . "_post2cat",
+ $wpmuBaseTablePrefix . $blog_id . "_postmeta",
+ $wpmuBaseTablePrefix . $blog_id . "_posts",
+ $wpmuBaseTablePrefix . $blog_id . "_referer_visitLog",
+ $wpmuBaseTablePrefix . $blog_id . "_referer_blacklist" );
+ reset( $drop_tables );
+
+ foreach ($drop_tables as $drop_table)
+ $wpdb->query( "DROP TABLE IF EXISTS $drop_table" );
+
+ $wpdb->query( "DELETE FROM $wpdb->blogs WHERE blog_id = '$blog_id'" );
+ $dir = constant( "ABSPATH" ) . "wp-content/blogs.dir/" . $blog_id ."/files/";
+ $dir = rtrim($dir, DIRECTORY_SEPARATOR);
+ $top_dir = $dir;
+ $stack = array($dir);
+ $index = 0;
+
+ while ($index < count($stack)) {
+ # Get indexed directory from stack
+ $dir = $stack[$index];
+
+ $dh = @ opendir($dir);
+ if ($dh) {
+ while (($file = @ readdir($dh)) !== false) {
+ if ($file == '.' or $file == '..')
+ continue;
+
+ if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
+ $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
+ else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file))
+ @ unlink($dir . DIRECTORY_SEPARATOR . $file);
+ }
+ }
+ $index++;
+ }
+
+ $stack = array_reverse($stack); // Last added dirs are deepest
+ foreach($stack as $dir) {
+ if ( $dir != $top_dir)
+ @ rmdir($dir);
+ }
+ }
+ $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key='wp_{$blog_id}_autosave_draft_ids'");
+
+ if ( $switch )
+ restore_current_blog();
+}
+
+function update_blog_public($old_value, $value) {
+ global $wpdb;
+ $value = (int) $value;
+ do_action('update_blog_public');
+ update_blog_status( $wpdb->blogid, 'public', $value );
+}
+
+add_action('update_option_blog_public', 'update_blog_public', 10, 2);
+
+function wpmu_delete_user($id) {
+ global $wpdb;
+
+ $id = (int) $id;
+ $user = get_userdata($id);
+
+ do_action('wpmu_delete_user', $id);
+
+ $blogs = get_blogs_of_user($id);
+
+ if ( ! empty($blogs) ) foreach ($blogs as $blog) {
+ switch_to_blog($blog->userblog_id);
+ remove_user_from_blog($id, $blog->userblog_id);
+
+ $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
+
+ if ($post_ids) {
+ foreach ($post_ids as $post_id)
+ wp_delete_post($post_id);
+ }
+
+ // Clean links
+ $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
+
+ restore_current_blog();
+ }
+
+ $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id");
+ $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$id'");
+
+ wp_cache_delete($id, 'users');
+ wp_cache_delete($user->user_login, 'userlogins');
+
+ return true;
+}
+
+function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
+ $themes = get_themes();
+ if( $blog_id == 0 )
+ $blog_allowed_themes = get_option( "allowedthemes" );
+ else
+ $blog_allowed_themes = get_blog_option( $blog_id, "allowedthemes" );
+ if( !is_array( $blog_allowed_themes ) || empty( $blog_allowed_themes ) ) { // convert old allowed_themes to new allowedthemes
+ if( $blog_id == 0 )
+ $blog_allowed_themes = get_option( "allowed_themes" );
+ else
+ $blog_allowed_themes = get_blog_option( $blog_id, "allowed_themes" );
+ if( is_array( $blog_allowed_themes ) ) {
+ foreach( $themes as $key => $theme ) {
+ $theme_key = wp_specialchars( $theme[ 'Stylesheet' ] );
+ if( isset( $blog_allowed_themes[ $key ] ) == true ) {
+ $blog_allowedthemes[ $theme_key ] = 1;
+ }
+ }
+ $blog_allowed_themes = $blog_allowedthemes;
+ if( $blog_id == 0 ) {
+ add_option( "allowedthemes", $blog_allowed_themes );
+ delete_option( "allowed_themes" );
+ } else {
+ add_blog_option( $blog_id, "allowedthemes", $blog_allowed_themes );
+ delete_blog_option( $blog_id, "allowed_themes" );
+ }
+ }
+ }
+ return $blog_allowed_themes;
+}
+
+function update_option_new_admin_email($old_value, $value) {
+ if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
+ return;
+
+ $hash = md5( $value.time().mt_rand() );
+ $newadminemail = array(
+ "hash" => $hash,
+ "newemail" => $value
+ );
+ update_option( 'adminhash', $newadminemail );
+
+ $content = __("Dear user,\n\n
+You recently requested to have the administration email address on
+your blog changed.\n
+If this is correct, please click on the following link to change it:\n
+###ADMIN_URL###\n\n
+You can safely ignore and delete this email if you do not want to take this action.\n\n
+This email has been sent to ###EMAIL###\n\n
+Regards,\n
+The Webmaster");
+
+ $content = str_replace('###ADMIN_URL###', get_option( "siteurl" ).'/wp-admin/options.php?adminhash='.$hash, $content);
+ $content = str_replace('###EMAIL###', $value, $content);
+
+ wp_mail( $value, sprintf(__('[%s] New Admin Email Address'), get_option('blogname')), $content );
+}
+
+add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2);
+
+function get_site_allowed_themes() {
+ $themes = get_themes();
+ $allowed_themes = get_site_option( 'allowedthemes' );
+ if( !is_array( $allowed_themes ) || empty( $allowed_themes ) ) {
+ $allowed_themes = get_site_option( "allowed_themes" ); // convert old allowed_themes format
+ if( !is_array( $allowed_themes ) ) {
+ $allowed_themes = array();
+ } else {
+ foreach( $themes as $key => $theme ) {
+ $theme_key = wp_specialchars( $theme[ 'Stylesheet' ] );
+ if( isset( $allowed_themes[ $key ] ) == true ) {
+ $allowedthemes[ $theme_key ] = 1;
+ }
+ }
+ $allowed_themes = $allowedthemes;
+ }
+ }
+
+ return $allowed_themes;
+}
+?>
diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php
new file mode 100644
index 0000000..e5911bd
--- /dev/null
+++ b/wp-admin/includes/plugin.php
@@ -0,0 +1,382 @@
+<?php
+
+function get_plugin_data( $plugin_file ) {
+ $plugin_data = implode( '', file( $plugin_file ));
+ preg_match( '|Plugin Name:(.*)$|mi', $plugin_data, $plugin_name );
+ preg_match( '|Plugin URI:(.*)$|mi', $plugin_data, $plugin_uri );
+ preg_match( '|Description:(.*)$|mi', $plugin_data, $description );
+ preg_match( '|Author:(.*)$|mi', $plugin_data, $author_name );
+ preg_match( '|Author URI:(.*)$|mi', $plugin_data, $author_uri );
+
+ if ( preg_match( "|Version:(.*)|i", $plugin_data, $version ))
+ $version = trim( $version[1] );
+ else
+ $version = '';
+
+ $description = wptexturize( trim( $description[1] ));
+
+ $name = $plugin_name[1];
+ $name = trim( $name );
+ $plugin = $name;
+ if ('' != trim($plugin_uri[1]) && '' != $name ) {
+ $plugin = '<a href="' . trim( $plugin_uri[1] ) . '" title="'.__( 'Visit plugin homepage' ).'">'.$plugin.'</a>';
+ }
+
+ if ('' == $author_uri[1] ) {
+ $author = trim( $author_name[1] );
+ } else {
+ $author = '<a href="' . trim( $author_uri[1] ) . '" title="'.__( 'Visit author homepage' ).'">' . trim( $author_name[1] ) . '</a>';
+ }
+
+ return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version);
+}
+
+function get_plugins() {
+ global $wp_plugins;
+
+ if ( isset( $wp_plugins ) ) {
+ return $wp_plugins;
+ }
+
+ $wp_plugins = array ();
+ $plugin_root = ABSPATH . PLUGINDIR;
+
+ // Files in wp-content/plugins directory
+ $plugins_dir = @ opendir( $plugin_root);
+ if ( $plugins_dir ) {
+ while (($file = readdir( $plugins_dir ) ) !== false ) {
+ if ( substr($file, 0, 1) == '.' )
+ continue;
+ if ( is_dir( $plugin_root.'/'.$file ) ) {
+ $plugins_subdir = @ opendir( $plugin_root.'/'.$file );
+ if ( $plugins_subdir ) {
+ while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
+ if ( substr($subfile, 0, 1) == '.' )
+ continue;
+ if ( substr($subfile, -4) == '.php' )
+ $plugin_files[] = "$file/$subfile";
+ }
+ }
+ } else {
+ if ( substr($file, -4) == '.php' )
+ $plugin_files[] = $file;
+ }
+ }
+ }
+ @closedir( $plugins_dir );
+ @closedir( $plugins_subdir );
+
+ if ( !$plugins_dir || !$plugin_files )
+ return $wp_plugins;
+
+ foreach ( $plugin_files as $plugin_file ) {
+ if ( !is_readable( "$plugin_root/$plugin_file" ) )
+ continue;
+
+ $plugin_data = get_plugin_data( "$plugin_root/$plugin_file" );
+
+ if ( empty ( $plugin_data['Name'] ) )
+ continue;
+
+ $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data;
+ }
+
+ uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));
+
+ return $wp_plugins;
+}
+
+//
+// Menu
+//
+
+function add_menu_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ global $menu, $admin_page_hooks;
+
+ $file = plugin_basename( $file );
+
+ $menu[] = array ( $menu_title, $access_level, $file, $page_title );
+
+ $admin_page_hooks[$file] = sanitize_title( $menu_title );
+
+ $hookname = get_plugin_page_hookname( $file, '' );
+ if (!empty ( $function ) && !empty ( $hookname ))
+ add_action( $hookname, $function );
+
+ return $hookname;
+}
+
+function add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ global $submenu;
+ global $menu;
+ global $_wp_real_parent_file;
+ global $_wp_submenu_nopriv;
+ global $_wp_menu_nopriv;
+
+ $file = plugin_basename( $file );
+
+ $parent = plugin_basename( $parent);
+ if ( isset( $_wp_real_parent_file[$parent] ) )
+ $parent = $_wp_real_parent_file[$parent];
+
+ if ( !current_user_can( $access_level ) ) {
+ $_wp_submenu_nopriv[$parent][$file] = true;
+ return false;
+ }
+
+ // If the parent doesn't already have a submenu, add a link to the parent
+ // as the first item in the submenu. If the submenu file is the same as the
+ // parent file someone is trying to link back to the parent manually. In
+ // this case, don't automatically add a link back to avoid duplication.
+ if (!isset( $submenu[$parent] ) && $file != $parent ) {
+ foreach ( $menu as $parent_menu ) {
+ if ( $parent_menu[2] == $parent && current_user_can( $parent_menu[1] ) )
+ $submenu[$parent][] = $parent_menu;
+ }
+ }
+
+ $submenu[$parent][] = array ( $menu_title, $access_level, $file, $page_title );
+
+ $hookname = get_plugin_page_hookname( $file, $parent);
+ if (!empty ( $function ) && !empty ( $hookname ))
+ add_action( $hookname, $function );
+
+ return $hookname;
+}
+
+function add_management_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'edit.php', $page_title, $menu_title, $access_level, $file, $function );
+}
+
+function add_options_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'options-general.php', $page_title, $menu_title, $access_level, $file, $function );
+}
+
+function add_theme_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ return add_submenu_page( 'themes.php', $page_title, $menu_title, $access_level, $file, $function );
+}
+
+function add_users_page( $page_title, $menu_title, $access_level, $file, $function = '' ) {
+ if ( current_user_can('edit_users') )
+ $parent = 'users.php';
+ else
+ $parent = 'profile.php';
+ return add_submenu_page( $parent, $page_title, $menu_title, $access_level, $file, $function );
+}
+
+//
+// Pluggable Menu Support -- Private
+//
+
+function get_admin_page_parent() {
+ global $parent_file;
+ global $menu;
+ global $submenu;
+ global $pagenow;
+ global $plugin_page;
+ global $_wp_real_parent_file;
+ global $_wp_menu_nopriv;
+ global $_wp_submenu_nopriv;
+
+ if ( !empty ( $parent_file ) ) {
+ if ( isset( $_wp_real_parent_file[$parent_file] ) )
+ $parent_file = $_wp_real_parent_file[$parent_file];
+
+ return $parent_file;
+ }
+
+ if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
+ foreach ( $menu as $parent_menu ) {
+ if ( $parent_menu[2] == $plugin_page ) {
+ $parent_file = $plugin_page;
+ if ( isset( $_wp_real_parent_file[$parent_file] ) )
+ $parent_file = $_wp_real_parent_file[$parent_file];
+ return $parent_file;
+ }
+ }
+ if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) {
+ $parent_file = $plugin_page;
+ if ( isset( $_wp_real_parent_file[$parent_file] ) )
+ $parent_file = $_wp_real_parent_file[$parent_file];
+ return $parent_file;
+ }
+ }
+
+ if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) {
+ $parent_file = $pagenow;
+ if ( isset( $_wp_real_parent_file[$parent_file] ) )
+ $parent_file = $_wp_real_parent_file[$parent_file];
+ return $parent_file;
+ }
+
+ foreach (array_keys( $submenu ) as $parent) {
+ foreach ( $submenu[$parent] as $submenu_array ) {
+ if ( isset( $_wp_real_parent_file[$parent] ) )
+ $parent = $_wp_real_parent_file[$parent];
+ if ( $submenu_array[2] == $pagenow ) {
+ $parent_file = $parent;
+ return $parent;
+ } else
+ if ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {
+ $parent_file = $parent;
+ return $parent;
+ }
+ }
+ }
+
+ $parent_file = '';
+ return '';
+}
+
+function get_admin_page_title() {
+ global $title;
+ global $menu;
+ global $submenu;
+ global $pagenow;
+ global $plugin_page;
+
+ if ( isset( $title ) && !empty ( $title ) ) {
+ return $title;
+ }
+
+ $hook = get_plugin_page_hook( $plugin_page, $pagenow );
+
+ $parent = $parent1 = get_admin_page_parent();
+ if ( empty ( $parent) ) {
+ foreach ( $menu as $menu_array ) {
+ if ( isset( $menu_array[3] ) ) {
+ if ( $menu_array[2] == $pagenow ) {
+ $title = $menu_array[3];
+ return $menu_array[3];
+ } else
+ if ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) {
+ $title = $menu_array[3];
+ return $menu_array[3];
+ }
+ } else {
+ $title = $menu_array[0];
+ return $title;
+ }
+ }
+ } else {
+ foreach (array_keys( $submenu ) as $parent) {
+ foreach ( $submenu[$parent] as $submenu_array ) {
+ if ( isset( $plugin_page ) &&
+ ($plugin_page == $submenu_array[2] ) &&
+ (($parent == $pagenow ) || ($parent == $plugin_page ) || ($plugin_page == $hook ) || (($pagenow == 'admin.php' ) && ($parent1 != $submenu_array[2] ) ) )
+ ) {
+ $title = $submenu_array[3];
+ return $submenu_array[3];
+ }
+
+ if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page
+ continue;
+
+ if ( isset( $submenu_array[3] ) ) {
+ $title = $submenu_array[3];
+ return $submenu_array[3];
+ } else {
+ $title = $submenu_array[0];
+ return $title;
+ }
+ }
+ }
+ }
+
+ return $title;
+}
+
+function get_plugin_page_hook( $plugin_page, $parent_page ) {
+ global $wp_filter;
+
+ $hook = get_plugin_page_hookname( $plugin_page, $parent_page );
+ if ( isset( $wp_filter[$hook] ))
+ return $hook;
+ else
+ return null;
+}
+
+function get_plugin_page_hookname( $plugin_page, $parent_page ) {
+ global $admin_page_hooks;
+
+ $parent = get_admin_page_parent();
+
+ if ( empty ( $parent_page ) || 'admin.php' == $parent_page ) {
+ if ( isset( $admin_page_hooks[$plugin_page] ))
+ $page_type = 'toplevel';
+ else
+ if ( isset( $admin_page_hooks[$parent] ))
+ $page_type = $admin_page_hooks[$parent];
+ } else
+ if ( isset( $admin_page_hooks[$parent_page] ) ) {
+ $page_type = $admin_page_hooks[$parent_page];
+ } else {
+ $page_type = 'admin';
+ }
+
+ $plugin_name = preg_replace( '!\.php!', '', $plugin_page );
+
+ return $page_type.'_page_'.$plugin_name;
+}
+
+function user_can_access_admin_page() {
+ global $pagenow;
+ global $menu;
+ global $submenu;
+ global $_wp_menu_nopriv;
+ global $_wp_submenu_nopriv;
+ global $plugin_page;
+
+ $parent = get_admin_page_parent();
+
+ if ( isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
+ return false;
+
+ if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
+ return false;
+
+ if ( empty( $parent) ) {
+ if ( isset( $_wp_menu_nopriv[$pagenow] ) )
+ return false;
+ if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) )
+ return false;
+ if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) )
+ return false;
+ foreach (array_keys( $_wp_submenu_nopriv ) as $key ) {
+ if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )
+ return false;
+ if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
+ return false;
+ }
+ return true;
+ }
+
+ if ( isset( $submenu[$parent] ) ) {
+ foreach ( $submenu[$parent] as $submenu_array ) {
+ if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) {
+ if ( current_user_can( $submenu_array[1] ))
+ return true;
+ else
+ return false;
+ } else if ( $submenu_array[2] == $pagenow ) {
+ if ( current_user_can( $submenu_array[1] ))
+ return true;
+ else
+ return false;
+ }
+ }
+ }
+
+ foreach ( $menu as $menu_array ) {
+ if ( $menu_array[2] == $parent) {
+ if ( current_user_can( $menu_array[1] ))
+ return true;
+ else
+ return false;
+ }
+ }
+
+ return true;
+}
+
+?>
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
new file mode 100644
index 0000000..e27482c
--- /dev/null
+++ b/wp-admin/includes/post.php
@@ -0,0 +1,471 @@
+<?php
+
+// Update an existing post with values provided in $_POST.
+function edit_post() {
+ global $user_ID;
+
+ $post_ID = (int) $_POST['post_ID'];
+
+ if ( 'page' == $_POST['post_type'] ) {
+ if ( !current_user_can( 'edit_page', $post_ID ) )
+ wp_die( __('You are not allowed to edit this page.' ));
+ } else {
+ if ( !current_user_can( 'edit_post', $post_ID ) )
+ wp_die( __('You are not allowed to edit this post.' ));
+ }
+
+ // Autosave shouldn't save too soon after a real save
+ if ( 'autosave' == $_POST['action'] ) {
+ $post =& get_post( $post_ID );
+ $now = time();
+ $then = strtotime($post->post_date_gmt . ' +0000');
+ // Keep autosave_interval in sync with autosave-js.php.
+ $delta = apply_filters( 'autosave_interval', 120 ) / 2;
+ if ( ($now - $then) < $delta )
+ return $post_ID;
+ }
+
+ // Rename.
+ $_POST['ID'] = (int) $_POST['post_ID'];
+ $_POST['post_content'] = $_POST['content'];
+ $_POST['post_excerpt'] = $_POST['excerpt'];
+ $_POST['post_parent'] = $_POST['parent_id'];
+ $_POST['to_ping'] = $_POST['trackback_url'];
+
+ if (!empty ( $_POST['post_author_override'] ) ) {
+ $_POST['post_author'] = (int) $_POST['post_author_override'];
+ } else
+ if (!empty ( $_POST['post_author'] ) ) {
+ $_POST['post_author'] = (int) $_POST['post_author'];
+ } else {
+ $_POST['post_author'] = (int) $_POST['user_ID'];
+ }
+
+ if ( $_POST['post_author'] != $_POST['user_ID'] ) {
+ if ( 'page' == $_POST['post_type'] ) {
+ if ( !current_user_can( 'edit_others_pages' ) )
+ wp_die( __('You are not allowed to edit pages as this user.' ));
+ } else {
+ if ( !current_user_can( 'edit_others_posts' ) )
+ wp_die( __('You are not allowed to edit posts as this user.' ));
+
+ }
+ }
+
+ // What to do based on which button they pressed
+ if ('' != $_POST['saveasdraft'] )
+ $_POST['post_status'] = 'draft';
+ if ('' != $_POST['saveasprivate'] )
+ $_POST['post_status'] = 'private';
+ if ('' != $_POST['publish'] )
+ $_POST['post_status'] = 'publish';
+ if ('' != $_POST['advanced'] )
+ $_POST['post_status'] = 'draft';
+
+ if ( 'page' == $_POST['post_type'] ) {
+ if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' ))
+ $_POST['post_status'] = 'pending';
+ } else {
+ if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' ))
+ $_POST['post_status'] = 'pending';
+ }
+
+ if (!isset( $_POST['comment_status'] ))
+ $_POST['comment_status'] = 'closed';
+
+ if (!isset( $_POST['ping_status'] ))
+ $_POST['ping_status'] = 'closed';
+
+ if (!empty ( $_POST['edit_date'] ) ) {
+ $aa = $_POST['aa'];
+ $mm = $_POST['mm'];
+ $jj = $_POST['jj'];
+ $hh = $_POST['hh'];
+ $mn = $_POST['mn'];
+ $ss = $_POST['ss'];
+ $jj = ($jj > 31 ) ? 31 : $jj;
+ $hh = ($hh > 23 ) ? $hh -24 : $hh;
+ $mn = ($mn > 59 ) ? $mn -60 : $mn;
+ $ss = ($ss > 59 ) ? $ss -60 : $ss;
+ $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
+ $_POST['post_date_gmt'] = get_gmt_from_date( "$aa-$mm-$jj $hh:$mn:$ss" );
+ }
+
+ // Meta Stuff
+ if ( $_POST['meta'] ) {
+ foreach ( $_POST['meta'] as $key => $value )
+ update_meta( $key, $value['key'], $value['value'] );
+ }
+
+ if ( $_POST['deletemeta'] ) {
+ foreach ( $_POST['deletemeta'] as $key => $value )
+ delete_meta( $key );
+ }
+
+ add_meta( $post_ID );
+
+ wp_update_post( $_POST );
+
+ // Reunite any orphaned attachments with their parent
+ if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
+ $draft_ids = array();
+ if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
+ _relocate_children( $draft_temp_id, $post_ID );
+
+ // Now that we have an ID we can fix any attachment anchor hrefs
+ _fix_attachment_links( $post_ID );
+
+ return $post_ID;
+}
+
+// Default post information to use when populating the "Write Post" form.
+function get_default_post_to_edit() {
+ if ( !empty( $_REQUEST['post_title'] ) )
+ $post_title = wp_specialchars( stripslashes( $_REQUEST['post_title'] ));
+ else if ( !empty( $_REQUEST['popuptitle'] ) ) {
+ $post_title = wp_specialchars( stripslashes( $_REQUEST['popuptitle'] ));
+ $post_title = funky_javascript_fix( $post_title );
+ } else {
+ $post_title = '';
+ }
+
+ if ( !empty( $_REQUEST['content'] ) )
+ $post_content = wp_specialchars( stripslashes( $_REQUEST['content'] ));
+ else if ( !empty( $post_title ) ) {
+ $text = wp_specialchars( stripslashes( urldecode( $_REQUEST['text'] ) ) );
+ $text = funky_javascript_fix( $text);
+ $popupurl = clean_url($_REQUEST['popupurl']);
+ $post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\n$text";
+ }
+
+ if ( !empty( $_REQUEST['excerpt'] ) )
+ $post_excerpt = wp_specialchars( stripslashes( $_REQUEST['excerpt'] ));
+ else
+ $post_excerpt = '';
+
+ $post->post_status = 'draft';
+ $post->comment_status = get_option( 'default_comment_status' );
+ $post->ping_status = get_option( 'default_ping_status' );
+ $post->post_pingback = get_option( 'default_pingback_flag' );
+ $post->post_category = get_option( 'default_category' );
+ $post->post_content = apply_filters( 'default_content', $post_content);
+ $post->post_title = apply_filters( 'default_title', $post_title );
+ $post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt);
+ $post->page_template = 'default';
+ $post->post_parent = 0;
+ $post->menu_order = 0;
+
+ return $post;
+}
+
+// Get an existing post and format it for editing.
+function get_post_to_edit( $id ) {
+
+ $post = get_post( $id, OBJECT, 'edit' );
+
+ if ( $post->post_type == 'page' )
+ $post->page_template = get_post_meta( $id, '_wp_page_template', true );
+
+ return $post;
+}
+
+function post_exists($title, $content = '', $post_date = '') {
+ global $wpdb;
+
+ if (!empty ($post_date))
+ $post_date = "AND post_date = '$post_date'";
+
+ if (!empty ($title))
+ return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' $post_date");
+ else
+ if (!empty ($content))
+ return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' $post_date");
+
+ return 0;
+}
+
+// Creates a new post from the "Write Post" form using $_POST information.
+function wp_write_post() {
+ global $user_ID;
+
+ if ( 'page' == $_POST['post_type'] ) {
+ if ( !current_user_can( 'edit_pages' ) )
+ return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this blog.' ) );
+ } else {
+ if ( !current_user_can( 'edit_posts' ) )
+ return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) );
+ }
+
+
+ // Check for autosave collisions
+ $temp_id = false;
+ if ( isset($_POST['temp_ID']) ) {
+ $temp_id = (int) $_POST['temp_ID'];
+ if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
+ $draft_ids = array();
+ foreach ( $draft_ids as $temp => $real )
+ if ( time() + $temp > 86400 ) // 1 day: $temp is equal to -1 * time( then )
+ unset($draft_ids[$temp]);
+
+ if ( isset($draft_ids[$temp_id]) ) { // Edit, don't write
+ $_POST['post_ID'] = $draft_ids[$temp_id];
+ unset($_POST['temp_ID']);
+ update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
+ return edit_post();
+ }
+ }
+
+ // Rename.
+ $_POST['post_content'] = $_POST['content'];
+ $_POST['post_excerpt'] = $_POST['excerpt'];
+ $_POST['post_parent'] = $_POST['parent_id'];
+ $_POST['to_ping'] = $_POST['trackback_url'];
+
+ if (!empty ( $_POST['post_author_override'] ) ) {
+ $_POST['post_author'] = (int) $_POST['post_author_override'];
+ } else {
+ if (!empty ( $_POST['post_author'] ) ) {
+ $_POST['post_author'] = (int) $_POST['post_author'];
+ } else {
+ $_POST['post_author'] = (int) $_POST['user_ID'];
+ }
+
+ }
+
+ if ( $_POST['post_author'] != $_POST['user_ID'] ) {
+ if ( 'page' == $_POST['post_type'] ) {
+ if ( !current_user_can( 'edit_others_pages' ) )
+ return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
+ } else {
+ if ( !current_user_can( 'edit_others_posts' ) )
+ return new WP_Error( 'edit_others_posts', __( 'You are not allowed to post as this user.' ) );
+
+ }
+ }
+
+ // What to do based on which button they pressed
+ if ('' != $_POST['saveasdraft'] )
+ $_POST['post_status'] = 'draft';
+ if ('' != $_POST['saveasprivate'] )
+ $_POST['post_status'] = 'private';
+ if ('' != $_POST['publish'] )
+ $_POST['post_status'] = 'publish';
+ if ('' != $_POST['advanced'] )
+ $_POST['post_status'] = 'draft';
+
+ if ( 'page' == $_POST['post_type'] ) {
+ if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) )
+ $_POST['post_status'] = 'pending';
+ } else {
+ if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) )
+ $_POST['post_status'] = 'pending';
+ }
+
+ if (!isset( $_POST['comment_status'] ))
+ $_POST['comment_status'] = 'closed';
+
+ if (!isset( $_POST['ping_status'] ))
+ $_POST['ping_status'] = 'closed';
+
+ if (!empty ( $_POST['edit_date'] ) ) {
+ $aa = $_POST['aa'];
+ $mm = $_POST['mm'];
+ $jj = $_POST['jj'];
+ $hh = $_POST['hh'];
+ $mn = $_POST['mn'];
+ $ss = $_POST['ss'];
+ $jj = ($jj > 31 ) ? 31 : $jj;
+ $hh = ($hh > 23 ) ? $hh -24 : $hh;
+ $mn = ($mn > 59 ) ? $mn -60 : $mn;
+ $ss = ($ss > 59 ) ? $ss -60 : $ss;
+ $_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
+ $_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date'] );
+ }
+
+ // Create the post.
+ $post_ID = wp_insert_post( $_POST );
+ if ( is_wp_error( $post_ID ) )
+ return $post_ID;
+
+ if ( empty($post_ID) )
+ return 0;
+
+ add_meta( $post_ID );
+
+ // Reunite any orphaned attachments with their parent
+ if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
+ $draft_ids = array();
+ if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
+ _relocate_children( $draft_temp_id, $post_ID );
+ if ( $temp_id && $temp_id != $draft_temp_id )
+ _relocate_children( $temp_id, $post_ID );
+
+ // Update autosave collision detection
+ if ( $temp_id ) {
+ $draft_ids[$temp_id] = $post_ID;
+ update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
+ }
+
+ // Now that we have an ID we can fix any attachment anchor hrefs
+ _fix_attachment_links( $post_ID );
+
+ return $post_ID;
+}
+
+function write_post() {
+ $result = wp_write_post();
+ if( is_wp_error( $result ) )
+ wp_die( $result->get_error_message() );
+ else
+ return $result;
+}
+
+//
+// Post Meta
+//
+
+function add_meta( $post_ID ) {
+ global $wpdb;
+ $post_ID = (int) $post_ID;
+
+ $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
+
+ $metakeyselect = $wpdb->escape( stripslashes( trim( $_POST['metakeyselect'] ) ) );
+ $metakeyinput = $wpdb->escape( stripslashes( trim( $_POST['metakeyinput'] ) ) );
+ $metavalue = maybe_serialize( stripslashes( (trim( $_POST['metavalue'] ) ) ));
+ $metavalue = $wpdb->escape( $metavalue );
+
+ if ( ('0' === $metavalue || !empty ( $metavalue ) ) && ((('#NONE#' != $metakeyselect) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput) ) ) {
+ // We have a key/value pair. If both the select and the
+ // input for the key have data, the input takes precedence:
+
+ if ('#NONE#' != $metakeyselect)
+ $metakey = $metakeyselect;
+
+ if ( $metakeyinput)
+ $metakey = $metakeyinput; // default
+
+ if ( in_array($metakey, $protected) )
+ return false;
+
+ $result = $wpdb->query( "
+ INSERT INTO $wpdb->postmeta
+ (post_id,meta_key,meta_value )
+ VALUES ('$post_ID','$metakey','$metavalue' )
+ " );
+ return $wpdb->insert_id;
+ }
+ return false;
+} // add_meta
+
+function delete_meta( $mid ) {
+ global $wpdb;
+ $mid = (int) $mid;
+
+ return $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'" );
+}
+
+// Get a list of previously defined keys
+function get_meta_keys() {
+ global $wpdb;
+
+ $keys = $wpdb->get_col( "
+ SELECT meta_key
+ FROM $wpdb->postmeta
+ GROUP BY meta_key
+ ORDER BY meta_key" );
+
+ return $keys;
+}
+
+function get_post_meta_by_id( $mid ) {
+ global $wpdb;
+ $mid = (int) $mid;
+
+ $meta = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'" );
+ if ( is_serialized_string( $meta->meta_value ) )
+ $meta->meta_value = maybe_unserialize( $meta->meta_value );
+ return $meta;
+}
+
+// Some postmeta stuff
+function has_meta( $postid ) {
+ global $wpdb;
+
+ return $wpdb->get_results( "
+ SELECT meta_key, meta_value, meta_id, post_id
+ FROM $wpdb->postmeta
+ WHERE post_id = '$postid'
+ ORDER BY meta_key,meta_id", ARRAY_A );
+
+}
+
+function update_meta( $mid, $mkey, $mvalue ) {
+ global $wpdb;
+
+ $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
+
+ if ( in_array($mkey, $protected) )
+ return false;
+
+ $mvalue = maybe_serialize( stripslashes( $mvalue ));
+ $mvalue = $wpdb->escape( $mvalue );
+ $mid = (int) $mid;
+ return $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'" );
+}
+
+//
+// Private
+//
+
+// Replace hrefs of attachment anchors with up-to-date permalinks.
+function _fix_attachment_links( $post_ID ) {
+ global $wp_rewrite;
+
+ $post = & get_post( $post_ID, ARRAY_A );
+
+ $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
+
+ // See if we have any rel="attachment" links
+ if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) )
+ return;
+
+ $i = 0;
+ $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i";
+ foreach ( $anchor_matches[0] as $anchor ) {
+ if ( 0 == preg_match( $search, $anchor, $id_matches ) )
+ continue;
+
+ $id = (int) $id_matches[3];
+
+ // While we have the attachment ID, let's adopt any orphans.
+ $attachment = & get_post( $id, ARRAY_A );
+ if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) {
+ $attachment['post_parent'] = $post_ID;
+ // Escape data pulled from DB.
+ $attachment = add_magic_quotes( $attachment);
+ wp_update_post( $attachment);
+ }
+
+ $post_search[$i] = $anchor;
+ $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor );
+ ++$i;
+ }
+
+ $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] );
+
+ // Escape data pulled from DB.
+ $post = add_magic_quotes( $post);
+
+ return wp_update_post( $post);
+}
+
+// Move child posts to a new parent
+function _relocate_children( $old_ID, $new_ID ) {
+ global $wpdb;
+ $old_ID = (int) $old_ID;
+ $new_ID = (int) $new_ID;
+ return $wpdb->query( "UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID" );
+}
+
+?> \ No newline at end of file
diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php
new file mode 100644
index 0000000..678f127
--- /dev/null
+++ b/wp-admin/includes/schema.php
@@ -0,0 +1,474 @@
+<?php
+// Here we keep the DB structure and option values
+
+global $wp_queries;
+$charset_collate = '';
+
+if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {
+ if ( ! empty($wpdb->charset) )
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
+ if ( ! empty($wpdb->collate) )
+ $charset_collate .= " COLLATE $wpdb->collate";
+}
+
+$wp_queries="CREATE TABLE $wpdb->terms (
+ term_id bigint(20) NOT NULL auto_increment,
+ name varchar(55) NOT NULL default '',
+ slug varchar(200) NOT NULL default '',
+ term_group bigint(10) NOT NULL default 0,
+ PRIMARY KEY (term_id),
+ UNIQUE KEY slug (slug)
+) $charset_collate;
+CREATE TABLE $wpdb->term_taxonomy (
+ term_taxonomy_id bigint(20) NOT NULL auto_increment,
+ term_id bigint(20) NOT NULL default 0,
+ taxonomy varchar(32) NOT NULL default '',
+ description longtext NOT NULL,
+ parent bigint(20) NOT NULL default 0,
+ count bigint(20) NOT NULL default 0,
+ PRIMARY KEY (term_taxonomy_id),
+ UNIQUE KEY term_id_taxonomy (term_id,taxonomy)
+) $charset_collate;
+CREATE TABLE $wpdb->term_relationships (
+ object_id bigint(20) NOT NULL default 0,
+ term_taxonomy_id bigint(20) NOT NULL default 0,
+ PRIMARY KEY (object_id,term_taxonomy_id),
+ KEY term_taxonomy_id (term_taxonomy_id)
+) $charset_collate;
+CREATE TABLE $wpdb->comments (
+ comment_ID bigint(20) unsigned NOT NULL auto_increment,
+ comment_post_ID int(11) NOT NULL default '0',
+ comment_author tinytext NOT NULL,
+ comment_author_email varchar(100) NOT NULL default '',
+ comment_author_url varchar(200) NOT NULL default '',
+ comment_author_IP varchar(100) NOT NULL default '',
+ comment_date datetime NOT NULL default '0000-00-00 00:00:00',
+ comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+ comment_content text NOT NULL,
+ comment_karma int(11) NOT NULL default '0',
+ comment_approved enum('0','1','spam') NOT NULL default '1',
+ comment_agent varchar(255) NOT NULL default '',
+ comment_type varchar(20) NOT NULL default '',
+ comment_parent bigint(20) NOT NULL default '0',
+ user_id bigint(20) NOT NULL default '0',
+ PRIMARY KEY (comment_ID),
+ KEY comment_approved (comment_approved),
+ KEY comment_post_ID (comment_post_ID)
+) $charset_collate;
+CREATE TABLE $wpdb->links (
+ link_id bigint(20) NOT NULL auto_increment,
+ link_url varchar(255) NOT NULL default '',
+ link_name varchar(255) NOT NULL default '',
+ link_image varchar(255) NOT NULL default '',
+ link_target varchar(25) NOT NULL default '',
+ link_category bigint(20) NOT NULL default '0',
+ link_description varchar(255) NOT NULL default '',
+ link_visible enum('Y','N') NOT NULL default 'Y',
+ link_owner int(11) NOT NULL default '1',
+ link_rating int(11) NOT NULL default '0',
+ link_updated datetime NOT NULL default '0000-00-00 00:00:00',
+ link_rel varchar(255) NOT NULL default '',
+ link_notes mediumtext NOT NULL,
+ link_rss varchar(255) NOT NULL default '',
+ PRIMARY KEY (link_id),
+ KEY link_category (link_category),
+ KEY link_visible (link_visible)
+) $charset_collate;
+CREATE TABLE $wpdb->options (
+ option_id bigint(20) NOT NULL auto_increment,
+ blog_id int(11) NOT NULL default '0',
+ option_name varchar(64) NOT NULL default '',
+ option_value longtext NOT NULL,
+ autoload enum('yes','no') NOT NULL default 'yes',
+ PRIMARY KEY (option_id,blog_id,option_name),
+ KEY option_name (option_name)
+) $charset_collate;
+CREATE TABLE $wpdb->postmeta (
+ meta_id bigint(20) NOT NULL auto_increment,
+ post_id bigint(20) NOT NULL default '0',
+ meta_key varchar(255) default NULL,
+ meta_value longtext,
+ PRIMARY KEY (meta_id),
+ KEY post_id (post_id),
+ KEY meta_key (meta_key)
+) $charset_collate;
+CREATE TABLE $wpdb->posts (
+ ID bigint(20) unsigned NOT NULL auto_increment,
+ post_author bigint(20) NOT NULL default '0',
+ post_date datetime NOT NULL default '0000-00-00 00:00:00',
+ post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+ post_content longtext NOT NULL,
+ post_title text NOT NULL,
+ post_category int(4) NOT NULL default '0',
+ post_excerpt text NOT NULL,
+ post_status enum('publish','draft','private','static','object','attachment','inherit','future', 'pending') NOT NULL default 'publish',
+ comment_status enum('open','closed','registered_only') NOT NULL default 'open',
+ ping_status enum('open','closed') NOT NULL default 'open',
+ post_password varchar(20) NOT NULL default '',
+ post_name varchar(200) NOT NULL default '',
+ to_ping text NOT NULL,
+ pinged text NOT NULL,
+ post_modified datetime NOT NULL default '0000-00-00 00:00:00',
+ post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
+ post_content_filtered text NOT NULL,
+ post_parent bigint(20) NOT NULL default '0',
+ guid varchar(255) NOT NULL default '',
+ menu_order int(11) NOT NULL default '0',
+ post_type varchar(20) NOT NULL default 'post',
+ post_mime_type varchar(100) NOT NULL default '',
+ comment_count bigint(20) NOT NULL default '0',
+ PRIMARY KEY (ID),
+ KEY post_name (post_name),
+ KEY type_status_date (post_type,post_status,post_date,ID)
+) $charset_collate;
+CREATE TABLE IF NOT EXISTS $wpdb->users (
+ ID bigint(20) unsigned NOT NULL auto_increment,
+ user_login varchar(60) NOT NULL default '',
+ user_pass varchar(64) NOT NULL default '',
+ user_nicename varchar(50) NOT NULL default '',
+ user_email varchar(100) NOT NULL default '',
+ user_url varchar(100) NOT NULL default '',
+ user_registered datetime NOT NULL default '0000-00-00 00:00:00',
+ user_activation_key varchar(60) NOT NULL default '',
+ user_status int(11) NOT NULL default '0',
+ display_name varchar(250) NOT NULL default '',
+ spam tinyint(2) NOT NULL default '0',
+ deleted tinyint(2) NOT NULL default '0',
+ PRIMARY KEY (ID),
+ KEY user_login_key (user_login),
+ KEY user_nicename (user_nicename)
+) $charset_collate;
+CREATE TABLE IF NOT EXISTS $wpdb->usermeta (
+ umeta_id bigint(20) NOT NULL auto_increment,
+ user_id bigint(20) NOT NULL default '0',
+ meta_key varchar(255) default NULL,
+ meta_value longtext,
+ PRIMARY KEY (umeta_id),
+ KEY user_id (user_id),
+ KEY meta_key (meta_key)
+) $charset_collate;
+CREATE TABLE IF NOT EXISTS $wpdb->blogs (
+ blog_id bigint(20) NOT NULL auto_increment,
+ site_id bigint(20) NOT NULL default '0',
+ domain varchar(200) NOT NULL default '',
+ path varchar(100) NOT NULL default '',
+ registered datetime NOT NULL default '0000-00-00 00:00:00',
+ last_updated datetime NOT NULL default '0000-00-00 00:00:00',
+ public tinyint(2) NOT NULL default '1',
+ archived enum('0','1') NOT NULL default '0',
+ mature tinyint(2) NOT NULL default '0',
+ spam tinyint(2) NOT NULL default '0',
+ deleted tinyint(2) NOT NULL default '0',
+ lang_id int(11) NOT NULL default '0',
+ PRIMARY KEY (blog_id),
+ KEY domain (domain(50),path(5)),
+ KEY lang_id (lang_id)
+);
+CREATE TABLE IF NOT EXISTS $wpdb->blog_versions (
+ blog_id bigint(20) NOT NULL default '0',
+ db_version varchar(20) NOT NULL default '',
+ last_updated datetime NOT NULL default '0000-00-00 00:00:00',
+ PRIMARY KEY (blog_id),
+ KEY db_version (db_version)
+);
+CREATE TABLE IF NOT EXISTS $wpdb->registration_log (
+ ID bigint(20) NOT NULL auto_increment,
+ email varchar(255) NOT NULL default '',
+ IP varchar(30) NOT NULL default '',
+ blog_id bigint(20) NOT NULL default '0',
+ date_registered datetime NOT NULL default '0000-00-00 00:00:00',
+ PRIMARY KEY (ID),
+ KEY IP (IP)
+);
+CREATE TABLE $wpdb->site (
+ id bigint(20) NOT NULL auto_increment,
+ domain varchar(200) NOT NULL default '',
+ path varchar(100) NOT NULL default '',
+ PRIMARY KEY (id),
+ KEY domain (domain,path)
+);
+CREATE TABLE IF NOT EXISTS $wpdb->sitemeta (
+ meta_id bigint(20) NOT NULL auto_increment,
+ site_id bigint(20) NOT NULL default '0',
+ meta_key varchar(255) default NULL,
+ meta_value longtext,
+ PRIMARY KEY (meta_id),
+ KEY meta_key (meta_key),
+ KEY site_id (site_id)
+);
+CREATE TABLE IF NOT EXISTS $wpdb->sitecategories (
+ cat_ID bigint(20) NOT NULL auto_increment,
+ cat_name varchar(55) NOT NULL default '',
+ category_nicename varchar(200) NOT NULL default '',
+ last_updated timestamp NOT NULL,
+ PRIMARY KEY (cat_ID),
+ KEY category_nicename (category_nicename),
+ KEY last_updated (last_updated)
+);
+CREATE TABLE IF NOT EXISTS $wpdb->signups (
+ domain varchar(200) NOT NULL default '',
+ path varchar(100) NOT NULL default '',
+ title longtext NOT NULL,
+ user_login varchar(60) NOT NULL default '',
+ user_email varchar(100) NOT NULL default '',
+ registered datetime NOT NULL default '0000-00-00 00:00:00',
+ activated datetime NOT NULL default '0000-00-00 00:00:00',
+ active tinyint(1) NOT NULL default '0',
+ activation_key varchar(50) NOT NULL default '',
+ meta longtext,
+ KEY activation_key (activation_key),
+ KEY domain (domain)
+);
+";
+
+function populate_options() {
+ global $wpdb, $wp_db_version, $wpblog, $current_site;
+
+ $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
+ $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+ add_option('siteurl', $guessurl);
+ add_option('blogname', __('My Blog'));
+ add_option('blogdescription', __('Just another ' . $current_site->site_name . ' weblog'), __('Short tagline'));
+ add_option('new_users_can_blog', 0);
+ add_option('users_can_register', 0);
+ add_option('admin_email', 'you@example.com');
+ add_option('start_of_week', 1);
+ add_option('use_balanceTags', 0);
+ add_option('use_smilies', 1);
+ add_option('require_name_email', 1);
+ add_option('comments_notify', 1);
+ add_option('posts_per_rss', 10);
+ add_option('rss_excerpt_length', 50);
+ add_option('rss_use_excerpt', 0);
+ add_option('mailserver_url', 'mail.example.com');
+ add_option('mailserver_login', 'login@example.com');
+ add_option('mailserver_pass', 'password');
+ add_option('mailserver_port', 110);
+ add_option('default_category', 1);
+ add_option('default_comment_status', 'open');
+ add_option('default_ping_status', 'open');
+ add_option('default_pingback_flag', 1);
+ add_option('default_post_edit_rows', 10);
+ add_option('posts_per_page', 10);
+ add_option('what_to_show', 'posts');
+ add_option('date_format', __('F j, Y'));
+ add_option('time_format', __('g:i a'));
+ add_option('links_updated_date_format', __('F j, Y g:i a'));
+ add_option('links_recently_updated_prepend', '<em>');
+ add_option('links_recently_updated_append', '</em>');
+ add_option('links_recently_updated_time', 120);
+ add_option('comment_moderation', 0);
+ add_option('moderation_notify', 1);
+ add_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
+ add_option('gzipcompression', 0);
+ add_option('hack_file', 0);
+ add_option('blog_charset', 'UTF-8');
+ add_option('moderation_keys');
+ add_option('active_plugins');
+ add_option('home', $guessurl);
+ // in case it is set, but blank, update "home"
+ if ( !__get_option('home') ) update_option('home', $guessurl);
+ add_option('category_base');
+ add_option('ping_sites', 'http://rpc.pingomatic.com/');
+ add_option('advanced_edit', 0);
+ add_option('comment_max_links', 2);
+ add_option('gmt_offset', date('Z') / 3600);
+ // 1.5
+ add_option('default_email_category', 1);
+ add_option('recently_edited');
+ add_option('use_linksupdate', 0);
+ add_option('template', 'default');
+ add_option('stylesheet', 'default');
+ add_option('comment_whitelist', 1);
+ add_option('page_uris');
+ add_option('blacklist_keys');
+ add_option('comment_registration', 0);
+ add_option('rss_language', 'en');
+ add_option('html_type', 'text/html');
+ // 1.5.1
+ add_option('use_trackback', 0);
+ // 2.0
+ add_option('default_role', 'subscriber');
+ add_option('db_version', $wp_db_version);
+ // 2.0.1
+ if ( ini_get('safe_mode') ) {
+ // Safe mode screws up mkdir(), so we must use a flat structure.
+ add_option('uploads_use_yearmonth_folders', 0);
+ add_option('upload_path', 'wp-content');
+ } else {
+ add_option('uploads_use_yearmonth_folders', 1);
+ add_option('upload_path', 'wp-content/uploads');
+ }
+
+ // 2.0.3
+ add_option('secret', md5(uniqid(microtime())));
+
+ // 2.1
+ add_option('blog_public', '1');
+ add_option('default_link_category', 2);
+ add_option('show_on_front', 'posts');
+
+ // 2.2
+ add_option('tag_base');
+
+ // Delete unused options
+ $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', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing');
+ foreach ($unusedoptions as $option) :
+ delete_option($option);
+ endforeach;
+
+ // Set up a few options not to load by default
+ $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
+ foreach ($fatoptions as $fatoption) :
+ $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
+ endforeach;
+}
+
+function populate_roles() {
+ populate_roles_160();
+ populate_roles_210();
+ populate_roles_230();
+}
+
+function populate_roles_160() {
+ global $wp_roles;
+
+ // Add roles
+ add_role('administrator', __('Administrator'));
+ add_role('editor', __('Editor'));
+ add_role('author', __('Author'));
+ add_role('contributor', __('Contributor'));
+ add_role('subscriber', __('Subscriber'));
+
+ // Add caps for Administrator role
+ $role = get_role('administrator');
+ $role->add_cap('switch_themes');
+ $role->add_cap('edit_themes');
+ $role->add_cap('activate_plugins');
+ $role->add_cap('edit_plugins');
+ $role->add_cap('edit_users');
+ $role->add_cap('edit_files');
+ $role->add_cap('manage_options');
+ $role->add_cap('moderate_comments');
+ $role->add_cap('manage_categories');
+ $role->add_cap('manage_links');
+ $role->add_cap('upload_files');
+ $role->add_cap('import');
+ $role->add_cap('unfiltered_html');
+ $role->add_cap('edit_posts');
+ $role->add_cap('edit_others_posts');
+ $role->add_cap('edit_published_posts');
+ $role->add_cap('publish_posts');
+ $role->add_cap('edit_pages');
+ $role->add_cap('read');
+ $role->add_cap('level_10');
+ $role->add_cap('level_9');
+ $role->add_cap('level_8');
+ $role->add_cap('level_7');
+ $role->add_cap('level_6');
+ $role->add_cap('level_5');
+ $role->add_cap('level_4');
+ $role->add_cap('level_3');
+ $role->add_cap('level_2');
+ $role->add_cap('level_1');
+ $role->add_cap('level_0');
+
+ // Add caps for Editor role
+ $role = get_role('editor');
+ $role->add_cap('moderate_comments');
+ $role->add_cap('manage_categories');
+ $role->add_cap('manage_links');
+ $role->add_cap('upload_files');
+ $role->add_cap('unfiltered_html');
+ $role->add_cap('edit_posts');
+ $role->add_cap('edit_others_posts');
+ $role->add_cap('edit_published_posts');
+ $role->add_cap('publish_posts');
+ $role->add_cap('edit_pages');
+ $role->add_cap('read');
+ $role->add_cap('level_7');
+ $role->add_cap('level_6');
+ $role->add_cap('level_5');
+ $role->add_cap('level_4');
+ $role->add_cap('level_3');
+ $role->add_cap('level_2');
+ $role->add_cap('level_1');
+ $role->add_cap('level_0');
+
+ // Add caps for Author role
+ $role = get_role('author');
+ $role->add_cap('upload_files');
+ $role->add_cap('edit_posts');
+ $role->add_cap('edit_published_posts');
+ $role->add_cap('publish_posts');
+ $role->add_cap('read');
+ $role->add_cap('level_2');
+ $role->add_cap('level_1');
+ $role->add_cap('level_0');
+
+ // Add caps for Contributor role
+ $role = get_role('contributor');
+ $role->add_cap('edit_posts');
+ $role->add_cap('read');
+ $role->add_cap('level_1');
+ $role->add_cap('level_0');
+
+ // Add caps for Subscriber role
+ $role = get_role('subscriber');
+ $role->add_cap('read');
+ $role->add_cap('level_0');
+}
+
+function populate_roles_210() {
+ $roles = array('administrator', 'editor');
+ foreach ($roles as $role) {
+ $role = get_role($role);
+ if ( empty($role) )
+ continue;
+
+ $role->add_cap('edit_others_pages');
+ $role->add_cap('edit_published_pages');
+ $role->add_cap('publish_pages');
+ $role->add_cap('delete_pages');
+ $role->add_cap('delete_others_pages');
+ $role->add_cap('delete_published_pages');
+ $role->add_cap('delete_posts');
+ $role->add_cap('delete_others_posts');
+ $role->add_cap('delete_published_posts');
+ $role->add_cap('delete_private_posts');
+ $role->add_cap('edit_private_posts');
+ $role->add_cap('read_private_posts');
+ $role->add_cap('delete_private_pages');
+ $role->add_cap('edit_private_pages');
+ $role->add_cap('read_private_pages');
+ }
+
+ $role = get_role('administrator');
+ if ( ! empty($role) ) {
+ $role->add_cap('delete_users');
+ $role->add_cap('create_users');
+ }
+
+ $role = get_role('author');
+ if ( ! empty($role) ) {
+ $role->add_cap('delete_posts');
+ $role->add_cap('delete_published_posts');
+ }
+
+ $role = get_role('contributor');
+ if ( ! empty($role) ) {
+ $role->add_cap('delete_posts');
+ }
+}
+
+function populate_roles_230() {
+ /*
+ $role = get_role( 'administrator' );
+
+ if ( !empty( $role ) ) {
+ $role->add_cap( 'unfiltered_upload' );
+ }
+ */
+}
+
+?>
diff --git a/wp-admin/includes/taxonomy.php b/wp-admin/includes/taxonomy.php
new file mode 100644
index 0000000..3f70f45
--- /dev/null
+++ b/wp-admin/includes/taxonomy.php
@@ -0,0 +1,148 @@
+<?php
+
+//
+// Category
+//
+
+function category_exists($cat_name) {
+ $id = is_term($cat_name, 'category');
+ if ( is_array($id) )
+ $id = $id['term_id'];
+ return $id;
+}
+
+function get_category_to_edit( $id ) {
+ $category = get_category( $id, OBJECT, 'edit' );
+ return $category;
+}
+
+function wp_create_category($cat_name) {
+ if ( $id = category_exists($cat_name) )
+ return $id;
+
+ return wp_insert_category( array('cat_name' => $cat_name) );
+}
+
+function wp_create_categories($categories, $post_id = '') {
+ $cat_ids = array ();
+ foreach ($categories as $category) {
+ if ($id = category_exists($category))
+ $cat_ids[] = $id;
+ else
+ if ($id = wp_create_category($category))
+ $cat_ids[] = $id;
+ }
+
+ if ($post_id)
+ wp_set_post_categories($post_id, $cat_ids);
+
+ return $cat_ids;
+}
+
+function wp_delete_category($cat_ID) {
+ global $wpdb;
+
+ $cat_ID = (int) $cat_ID;
+ $default = get_option('default_category');
+
+ // Don't delete the default cat
+ if ( $cat_ID == $default )
+ return 0;
+
+ return wp_delete_term($cat_ID, 'category', "default=$default");
+}
+
+function wp_insert_category($catarr) {
+ global $wpdb;
+
+ extract($catarr, EXTR_SKIP);
+
+ if ( trim( $cat_name ) == '' )
+ return 0;
+
+ $cat_ID = (int) $cat_ID;
+
+ // Are we updating or creating?
+ if ( !empty ($cat_ID) )
+ $update = true;
+ else
+ $update = false;
+
+ $name = $cat_name;
+ $description = $category_description;
+ $slug = $category_nicename;
+ $parent = $category_parent;
+
+ $parent = (int) $parent;
+ if ( empty($parent) || !category_exists( $parent ) || ($cat_ID && cat_is_ancestor_of($cat_ID, $parent) ) )
+ $parent = 0;
+
+ $args = compact('name', 'slug', 'parent', 'description');
+
+ if ( $update )
+ $cat_ID = wp_update_term($cat_ID, 'category', $args);
+ else
+ $cat_ID = wp_insert_term($cat_name, 'category', $args);
+
+ if ( is_wp_error($cat_ID) )
+ return 0;
+
+ return $cat_ID['term_id'];
+}
+
+function wp_update_category($catarr) {
+ global $wpdb;
+
+ $cat_ID = (int) $catarr['cat_ID'];
+
+ if ( $cat_ID == $catarr['category_parent'] )
+ return false;
+
+ // First, get all of the original fields
+ $category = get_category($cat_ID, ARRAY_A);
+
+ // Escape data pulled from DB.
+ $category = add_magic_quotes($category);
+
+ // Merge old and new fields with new fields overwriting old ones.
+ $catarr = array_merge($category, $catarr);
+
+ return wp_insert_category($catarr);
+}
+
+//
+// Tags
+//
+
+function get_tags_to_edit( $post_id ) {
+ global $wpdb;
+
+ $post_id = (int) $post_id;
+ if ( !$post_id )
+ return false;
+
+ $tags = wp_get_post_tags($post_id);
+
+ if ( !$tags )
+ return false;
+
+ foreach ( $tags as $tag )
+ $tag_names[] = $tag->name;
+ $tags_to_edit = join( ', ', $tag_names );
+ $tags_to_edit = attribute_escape( $tags_to_edit );
+ $tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit );
+ return $tags_to_edit;
+}
+
+function tag_exists($tag_name) {
+ return is_term($tag_name, 'post_tag');
+}
+
+function wp_create_tag($tag_name) {
+ if ( $id = tag_exists($tag_name) )
+ return $id;
+
+ return wp_insert_term($tag_name, 'post_tag');
+}
+
+?> \ No newline at end of file
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
new file mode 100644
index 0000000..1cf9284
--- /dev/null
+++ b/wp-admin/includes/template.php
@@ -0,0 +1,626 @@
+<?php
+
+//
+// Big Mess
+//
+
+// Dandy new recursive multiple category stuff.
+function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
+ if ( !$categories )
+ $categories = get_categories( 'hide_empty=0' );
+
+ $children = _get_term_hierarchy('category');
+
+ if ( $categories ) {
+ ob_start();
+ foreach ( $categories as $category ) {
+ if ( $category->term_id == 0 ) {
+ $wpdb->query("DELETE FROM $wpdb->terms WHERE term_id = 0");
+ continue;
+ }
+ if ( $category->parent == $parent) {
+ echo "\t" . _cat_row( $category, $level );
+ if ( isset($children[$category->term_id]) )
+ cat_rows( $category->term_id, $level +1, $categories );
+ }
+ }
+ $output = ob_get_contents();
+ ob_end_clean();
+
+ $output = apply_filters('cat_rows', $output);
+
+ echo $output;
+ } else {
+ return false;
+ }
+}
+
+function _cat_row( $category, $level, $name_override = false ) {
+ global $class;
+
+ $pad = str_repeat( '&#8212; ', $level );
+ if ( current_user_can( 'manage_categories' ) ) {
+ $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->term_id' class='edit'>".__( 'Edit' )."</a></td>";
+ $default_cat_id = (int) get_option( 'default_category' );
+
+ if ( $category->term_id != $default_cat_id )
+ $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&amp;cat_ID=$category->term_id", 'delete-category_' . $category->term_id ) . "' onclick=\"return deleteSomething( 'cat', $category->term_id, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>";
+ else
+ $edit .= "<td style='text-align:center'>".__( "Default" );
+ } else
+ $edit = '';
+
+ $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
+
+ $category->count = number_format_i18n( $category->count );
+ $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
+ $output = "<tr id='cat-$category->term_id'$class>
+ <th scope='row' style='text-align: center'>$category->term_id</th>
+ <td>" . ( $name_override ? $name_override : $pad . ' ' . $category->name ) . "</td>
+ <td>$category->description</td>
+ <td align='center'>$posts_count</td>
+ <td>$edit</td>\n\t</tr>\n";
+
+ return apply_filters('cat_row', $output);
+}
+
+function checked( $checked, $current) {
+ if ( $checked == $current)
+ echo ' checked="checked"';
+}
+
+// TODO: Remove?
+function documentation_link( $for ) {
+ return;
+}
+
+function selected( $selected, $current) {
+ if ( $selected == $current)
+ echo ' selected="selected"';
+}
+
+//
+// Nasty Category Stuff
+//
+
+function sort_cats( $cat1, $cat2 ) {
+ if ( $cat1['checked'] || $cat2['checked'] )
+ return ( $cat1['checked'] && !$cat2['checked'] ) ? -1 : 1;
+ else
+ return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] );
+}
+
+function get_nested_categories( $default = 0, $parent = 0 ) {
+ global $post_ID, $mode, $wpdb, $checked_categories;
+
+ if ( empty($checked_categories) ) {
+ if ( $post_ID ) {
+ $checked_categories = wp_get_post_categories($post_ID);
+
+ if ( count( $checked_categories ) == 0 ) {
+ // No selected categories, strange
+ $checked_categories[] = $default;
+ }
+ } else {
+ $checked_categories[] = $default;
+ }
+ }
+
+ $cats = get_categories("parent=$parent&hide_empty=0&fields=ids");
+
+ $result = array ();
+ if ( is_array( $cats ) ) {
+ foreach ( $cats as $cat) {
+ if ( $cat == 0 ) {
+ $wpdb->query("DELETE FROM $wpdb->terms WHERE term_id = 0");
+ continue;
+ }
+ $result[$cat]['children'] = get_nested_categories( $default, $cat);
+ $result[$cat]['cat_ID'] = $cat;
+ $result[$cat]['checked'] = in_array( $cat, $checked_categories );
+ $result[$cat]['cat_name'] = get_the_category_by_ID( $cat);
+ }
+ }
+
+ $result = apply_filters('get_nested_categories', $result);
+ usort( $result, 'sort_cats' );
+
+ return $result;
+}
+
+function write_nested_categories( $categories ) {
+ foreach ( $categories as $category ) {
+ echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( apply_filters('the_category', $category['cat_name'] )), "</label></li>";
+
+ if ( $category['children'] ) {
+ echo "<ul>\n";
+ write_nested_categories( $category['children'] );
+ echo "</ul>\n";
+ }
+ }
+}
+
+function dropdown_categories( $default = 0 ) {
+ write_nested_categories( get_nested_categories( $default) );
+}
+
+function dropdown_link_categories( $default = 0 ) {
+ global $link_id;
+
+ if ( $link_id ) {
+ $checked_categories = wp_get_link_cats($link_id);
+
+ if ( count( $checked_categories ) == 0 ) {
+ // No selected categories, strange
+ $checked_categories[] = $default;
+ }
+ } else {
+ $checked_categories[] = $default;
+ }
+
+ $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
+
+ if ( empty($categories) )
+ return;
+
+ foreach ( $categories as $category ) {
+ $cat_id = $category->term_id;
+ $name = wp_specialchars( apply_filters('the_category', $category->name));
+ $checked = in_array( $cat_id, $checked_categories );
+ echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
+ }
+}
+
+function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) {
+ global $wpdb, $class, $post;
+
+ if (!$pages )
+ $pages = get_pages( 'sort_column=menu_order' );
+
+ if (! $pages )
+ return false;
+
+ foreach ( $pages as $post) {
+ setup_postdata( $post);
+ if ( $hierarchy && ($post->post_parent != $parent) )
+ continue;
+
+ $post->post_title = wp_specialchars( $post->post_title );
+ $pad = str_repeat( '&#8212; ', $level );
+ $id = (int) $post->ID;
+ $class = ('alternate' == $class ) ? '' : 'alternate';
+?>
+ <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
+ <th scope="row" style="text-align: center"><?php echo $post->ID; ?></th>
+ <td>
+ <?php echo $pad; ?><?php the_title() ?>
+ </td>
+ <td><?php the_author() ?></td>
+ <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $post->post_modified ); ?></td>
+ <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e( 'View' ); ?></a></td>
+ <td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td>
+ <td><?php if ( current_user_can( 'delete_page', $id ) ) { echo "<a href='" . wp_nonce_url( "page.php?action=delete&amp;post=$id", 'delete-page_' . $id ) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . js_escape(sprintf( __("You are about to delete the '%s' page.\n'OK' to delete, 'Cancel' to stop." ), get_the_title() ) ) . "' );\">" . __( 'Delete' ) . "</a>"; } ?></td>
+ </tr>
+
+<?php
+ if ( $hierarchy ) page_rows( $id, $level + 1, $pages );
+ }
+}
+
+function user_row( $user_object, $style = '' ) {
+ global $current_user;
+
+ if ( !(is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
+ $user_object = new WP_User( (int) $user_object );
+ $email = $user_object->user_email;
+ $url = $user_object->user_url;
+ $short_url = str_replace( 'http://', '', $url );
+ $short_url = str_replace( 'www.', '', $short_url );
+ if ('/' == substr( $short_url, -1 ))
+ $short_url = substr( $short_url, 0, -1 );
+ if ( strlen( $short_url ) > 35 )
+ $short_url = substr( $short_url, 0, 32 ).'...';
+ $numposts = get_usernumposts( $user_object->ID );
+ $r = "<tr id='user-$user_object->ID'$style>
+ <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
+ <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
+ <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
+ <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>
+ <td><a href='$url' title='website: $url'>$short_url</a></td>";
+ $r .= "\n\t\t<td align='center'>";
+ if ( $numposts > 0 ) {
+ $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
+ $r .= sprintf(__ngettext( 'View %s post', 'View %s posts', $numposts ), $numposts);
+ $r .= '</a>';
+ }
+ $r .= "</td>\n\t\t<td>";
+ if ( ( is_site_admin() || $current_user->ID == $user_object->ID ) && current_user_can( 'edit_user', $user_object->ID ) ) {
+ $edit_link = add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" );
+ $r .= "<a href='$edit_link' class='edit'>".__( 'Edit' )."</a>";
+ }
+ $r .= "</td>\n\t</tr>";
+ return $r;
+}
+
+function _wp_get_comment_list( $s = false, $start, $num ) {
+ global $wpdb;
+
+ $start = abs( (int) $start );
+ $num = (int) $num;
+
+ if ( $s ) {
+ $s = $wpdb->escape($s);
+ $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
+ (comment_author LIKE '%$s%' OR
+ comment_author_email LIKE '%$s%' OR
+ comment_author_url LIKE ('%$s%') OR
+ comment_author_IP LIKE ('%$s%') OR
+ comment_content LIKE ('%$s%') ) AND
+ comment_approved != 'spam'
+ ORDER BY comment_date DESC LIMIT $start, $num");
+ } else {
+ $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" );
+ }
+
+ update_comment_cache($comments);
+
+ $total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
+
+ return array($comments, $total);
+}
+
+function _wp_comment_list_item( $id, $alt = 0 ) {
+ global $authordata, $comment, $wpdb;
+ $id = (int) $id;
+ $comment =& get_comment( $id );
+ $class = '';
+ $post = get_post($comment->comment_post_ID);
+ $authordata = get_userdata($post->post_author);
+ $comment_status = wp_get_comment_status($comment->comment_ID);
+ if ( 'unapproved' == $comment_status )
+ $class .= ' unapproved';
+ if ( $alt % 2 )
+ $class .= ' alternate';
+ echo "<li id='comment-$comment->comment_ID' class='$class'>";
+?>
+<p><strong><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
+
+<?php comment_text() ?>
+
+<p><?php comment_date(__('M j, g:i A')); ?> &#8212; [
+<?php
+if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
+ echo " <a href='comment.php?action=editcomment&amp;c=".$comment->comment_ID."'>" . __('Edit') . '</a>';
+ echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
+ if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
+ echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
+ echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
+ }
+ echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;dt=spam&amp;p=" . $comment->comment_post_ID . "&amp;c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> ";
+}
+$post = get_post($comment->comment_post_ID, OBJECT, 'display');
+$post_title = wp_specialchars( $post->post_title, 'double' );
+$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
+?>
+ ] &#8212; <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p>
+ </li>
+<?php
+}
+
+function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
+ global $wpdb;
+ if (!$categories )
+ $categories = get_categories( 'hide_empty=0' );
+
+ if ( $categories ) {
+ foreach ( $categories as $category ) {
+ if ( $currentcat != $category->term_id && $parent == $category->parent) {
+ $pad = str_repeat( '&#8211; ', $level );
+ $category->name = wp_specialchars( $category->name );
+ echo "\n\t<option value='$category->term_id'";
+ if ( $currentparent == $category->term_id )
+ echo " selected='selected'";
+ echo ">$pad$category->name</option>";
+ wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
+ }
+ }
+ } else {
+ return false;
+ }
+}
+
+function list_meta( $meta ) {
+ global $post_ID;
+ // Exit if no meta
+ if (!$meta ) {
+ echo '<tbody id="the-list"><tr style="display: none;"><td>&nbsp;</td></tr></tbody>'; //TBODY needed for list-manipulation JS
+ return;
+ }
+ $count = 0;
+?>
+ <thead>
+ <tr>
+ <th><?php _e( 'Key' ) ?></th>
+ <th><?php _e( 'Value' ) ?></th>
+ <th colspan='2'><?php _e( 'Action' ) ?></th>
+ </tr>
+ </thead>
+<?php
+ $r ="\n\t<tbody id='the-list'>";
+ foreach ( $meta as $entry ) {
+ ++ $count;
+ if ( $count % 2 )
+ $style = 'alternate';
+ else
+ $style = '';
+ if ('_' == $entry['meta_key'] { 0 } )
+ $style .= ' hidden';
+
+ if ( is_serialized( $entry['meta_value'] ) ) {
+ if ( is_serialized_string( $entry['meta_value'] ) ) {
+ // this is a serialized string, so we should display it
+ $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
+ } else {
+ // this is a serialized array/object so we should NOT display it
+ --$count;
+ continue;
+ }
+ }
+
+ $key_js = js_escape( $entry['meta_key'] );
+ $entry['meta_key'] = attribute_escape($entry['meta_key']);
+ $entry['meta_value'] = attribute_escape($entry['meta_value']);
+ $entry['meta_id'] = (int) $entry['meta_id'];
+ $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
+ $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>";
+ $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>";
+ $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".attribute_escape(__( 'Update' ))."' /><br />";
+ $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '";
+ $r .= js_escape(sprintf( __("You are about to delete the '%s' custom field on this post.\n'OK' to delete, 'Cancel' to stop." ), $key_js ) );
+ $r .= "' );\" class='deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' /></td>";
+ $r .= "\n\t</tr>";
+ }
+ echo $r;
+ echo "\n\t</tbody>";
+}
+
+function meta_form() {
+ global $wpdb;
+ $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
+ $keys = $wpdb->get_col( "
+ SELECT meta_key
+ FROM $wpdb->postmeta
+ WHERE meta_key NOT LIKE '\_%'
+ GROUP BY meta_key
+ ORDER BY meta_id DESC
+ LIMIT $limit" );
+ if ( $keys )
+ natcasesort($keys);
+?>
+<h3><?php _e( 'Add a new custom field:' ) ?></h3>
+<table id="newmeta" cellspacing="3" cellpadding="3">
+ <tr>
+<th colspan="2"><?php _e( 'Key' ) ?></th>
+<th><?php _e( 'Value' ) ?></th>
+</tr>
+ <tr valign="top">
+ <td align="right" width="18%">
+<?php if ( $keys ) : ?>
+<select id="metakeyselect" name="metakeyselect" tabindex="7">
+<option value="#NONE#"><?php _e( '- Select -' ); ?></option>
+<?php
+
+ foreach ( $keys as $key ) {
+ $key = attribute_escape( $key );
+ echo "\n\t<option value='$key'>$key</option>";
+ }
+?>
+</select> <?php _e( 'or' ); ?>
+<?php endif; ?>
+</td>
+<td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td>
+ <td><textarea id="metavalue" name="metavalue" rows="3" cols="25" tabindex="8"></textarea></td>
+ </tr>
+
+</table>
+<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e( 'Add Custom Field &raquo;' ) ?>" /></p>
+<?php
+
+}
+
+function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) {
+ global $wp_locale, $post, $comment;
+
+ if ( $for_post )
+ $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
+
+ $tab_index_attribute = '';
+ if ( (int) $tab_index > 0 )
+ $tab_index_attribute = " tabindex=\"$tab_index\"";
+
+ echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>';
+
+ $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
+ $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
+ $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
+ $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
+ $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
+ $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
+ $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
+ $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
+
+ echo "<select name=\"mm\" onchange=\"edit_date.checked=true\"$tab_index_attribute>\n";
+ for ( $i = 1; $i < 13; $i = $i +1 ) {
+ echo "\t\t\t<option value=\"$i\"";
+ if ( $i == $mm )
+ echo ' selected="selected"';
+ echo '>' . $wp_locale->get_month( $i ) . "</option>\n";
+ }
+?>
+</select>
+<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> />
+<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> /> @
+<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> /> :
+<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> />
+<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
+<?php
+ if ( $edit ) {
+ printf( _c( 'Existing timestamp: %1$s %2$s, %3$s @ %4$s:%5$s|1: month, 2: month string, 3: full year, 4: hours, 5: minutes' ), $wp_locale->get_month( $mm ), $jj, $aa, $hh, $mn );
+ }
+?>
+</fieldset>
+ <?php
+
+}
+
+function page_template_dropdown( $default = '' ) {
+ $templates = get_page_templates();
+ ksort( $templates );
+ foreach (array_keys( $templates ) as $template )
+ : if ( $default == $templates[$template] )
+ $selected = " selected='selected'";
+ else
+ $selected = '';
+ echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
+ endforeach;
+}
+
+function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
+ global $wpdb, $post_ID;
+ $items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order" );
+
+ if ( $items ) {
+ foreach ( $items as $item ) {
+ // A page cannot be its own parent.
+ if (!empty ( $post_ID ) ) {
+ if ( $item->ID == $post_ID ) {
+ continue;
+ }
+ }
+ $pad = str_repeat( '&nbsp;', $level * 3 );
+ if ( $item->ID == $default)
+ $current = ' selected="selected"';
+ else
+ $current = '';
+
+ echo "\n\t<option value='$item->ID'$current>$pad " . wp_specialchars($item->post_title) . "</option>";
+ parent_dropdown( $default, $item->ID, $level +1 );
+ }
+ } else {
+ return false;
+ }
+}
+
+function browse_happy() {
+ $getit = __( 'WordPress recommends a better browser' );
+ echo '
+ <p id="bh" style="text-align: center;"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></p>
+ ';
+}
+
+if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
+ add_action( 'admin_footer', 'browse_happy' );
+
+function the_attachment_links( $id = false ) {
+ $id = (int) $id;
+ $post = & get_post( $id );
+
+ if ( $post->post_type != 'attachment' )
+ return false;
+
+ $icon = get_attachment_icon( $post->ID );
+ $attachment_data = wp_get_attachment_metadata( $id );
+ $thumb = isset( $attachment_data['thumb'] );
+?>
+<form id="the-attachment-links">
+<table>
+ <col />
+ <col class="widefat" />
+ <tr>
+ <th scope="row"><?php _e( 'URL' ) ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
+ </tr>
+<?php if ( $icon ) : ?>
+ <tr>
+ <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
+ </tr>
+<?php else : ?>
+ <tr>
+ <th scope="row"><?php _e( 'Link to file' ) ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e( 'Link to page' ) ?></th>
+ <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
+ </tr>
+<?php endif; ?>
+</table>
+</form>
+<?php
+}
+
+function wp_dropdown_roles( $default = false ) {
+ global $wp_roles;
+ $r = '';
+ foreach( array_reverse($wp_roles->role_names) as $role => $name )
+ if ( $default == $role ) // Make default first in list
+ $p = "\n\t<option selected='selected' value='$role'>$name</option>";
+ else
+ $r .= "\n\t<option value='$role'>$name</option>";
+ echo $p . $r;
+}
+
+function wp_convert_hr_to_bytes( $size ) {
+ $size = strtolower($size);
+ $bytes = (int) $size;
+ if ( strpos($size, 'k') !== false )
+ $bytes = intval($size) * 1024;
+ elseif ( strpos($size, 'm') !== false )
+ $bytes = intval($size) * 1024 * 1024;
+ elseif ( strpos($size, 'g') !== false )
+ $bytes = intval($size) * 1024 * 1024 * 1024;
+ return $bytes;
+}
+
+function wp_convert_bytes_to_hr( $bytes ) {
+ $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
+ $log = log( $bytes, 1024 );
+ $power = (int) $log;
+ $size = pow(1024, $log - $power);
+ return $size . $units[$power];
+}
+
+function wp_import_upload_form( $action ) {
+ $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
+ $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
+ $bytes = apply_filters( 'import_upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
+ $size = wp_convert_bytes_to_hr( $bytes );
+?>
+<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>">
+<p>
+<?php wp_nonce_field('import-upload'); ?>
+<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
+<input type="file" id="upload" name="import" size="25" />
+<input type="hidden" name="action" value="save" />
+<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
+</p>
+<p class="submit">
+<input type="submit" value="<?php _e( 'Upload file and import &raquo;' ); ?>" />
+</p>
+</form>
+<?php
+}
+
+function wp_remember_old_slug() {
+ global $post;
+ $name = attribute_escape($post->post_name); // just in case
+ if ( strlen($name) )
+ echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
+}
+
+?>
diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php
new file mode 100644
index 0000000..bd39dea
--- /dev/null
+++ b/wp-admin/includes/theme.php
@@ -0,0 +1,52 @@
+<?php
+
+function current_theme_info() {
+ $themes = get_themes();
+ $current_theme = get_current_theme();
+ $ct->name = $current_theme;
+ $ct->title = $themes[$current_theme]['Title'];
+ $ct->version = $themes[$current_theme]['Version'];
+ $ct->parent_theme = $themes[$current_theme]['Parent Theme'];
+ $ct->template_dir = $themes[$current_theme]['Template Dir'];
+ $ct->stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
+ $ct->template = $themes[$current_theme]['Template'];
+ $ct->stylesheet = $themes[$current_theme]['Stylesheet'];
+ $ct->screenshot = $themes[$current_theme]['Screenshot'];
+ $ct->description = $themes[$current_theme]['Description'];
+ $ct->author = $themes[$current_theme]['Author'];
+ return $ct;
+}
+
+function get_broken_themes() {
+ global $wp_broken_themes;
+
+ get_themes();
+ return $wp_broken_themes;
+}
+
+function get_page_templates() {
+ $themes = get_themes();
+ $theme = get_current_theme();
+ $templates = $themes[$theme]['Template Files'];
+ $page_templates = array ();
+
+ if ( is_array( $templates ) ) {
+ foreach ( $templates as $template ) {
+ $template_data = implode( '', file( ABSPATH.$template ));
+
+ preg_match( '|Template Name:(.*)$|mi', $template_data, $name );
+ preg_match( '|Description:(.*)$|mi', $template_data, $description );
+
+ $name = $name[1];
+ $description = $description[1];
+
+ if ( !empty( $name ) ) {
+ $page_templates[trim( $name )] = basename( $template );
+ }
+ }
+ }
+
+ return $page_templates;
+}
+
+?>
diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php
new file mode 100644
index 0000000..cbd0d4a
--- /dev/null
+++ b/wp-admin/includes/update.php
@@ -0,0 +1,122 @@
+<?php
+/*
+// The admin side of our 1.0 update system
+
+function core_update_footer( $msg ) {
+ if ( !current_user_can('manage_options') )
+ return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] );
+
+ $cur = get_option( 'update_core' );
+
+ switch ( $cur->response ) {
+ case 'development' :
+ return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please <a href="%s">stay updated</a>.' ), $GLOBALS['wp_version'], 'http://wordpress.org/download/svn/' );
+ break;
+
+ case 'upgrade' :
+ return sprintf( '| <strong>'.__( 'Your WordPress %s is out of date. <a href="%s">Please update</a>.' ).'</strong>', $GLOBALS['wp_version'], $cur->url );
+ break;
+
+ case 'latest' :
+ default :
+ return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] );
+ break;
+ }
+}
+add_filter( 'update_footer', 'core_update_footer' );
+
+function update_nag() {
+ $cur = get_option( 'update_core' );
+
+ if ( ! isset( $cur->response ) || $cur->response != 'upgrade' )
+ return false;
+
+ if ( current_user_can('manage_options') )
+ $msg = sprintf( __('A new version of WordPress is available! <a href="%s">Please update now</a>.'), $cur->url );
+ else
+ $msg = __('A new version of WordPress is available! Please notify the site administrator.');
+
+ echo "<div id='update-nag'>$msg</div>";
+}
+add_action( 'admin_notices', 'update_nag', 3 );
+
+function wp_update_plugins() {
+ global $wp_version;
+
+ if ( !function_exists('fsockopen') )
+ return false;
+
+ $plugins = get_plugins();
+ $active = get_option( 'active_plugins' );
+ $current = get_option( 'update_plugins' );
+
+ $new_option = '';
+ $new_option->last_checked = time();
+
+ $plugin_changed = false;
+ foreach ( $plugins as $file => $p ) {
+ $new_option->checked[ $file ] = $p['Version'];
+
+ if ( !isset( $current->checked[ $file ] ) ) {
+ $plugin_changed = true;
+ continue;
+ }
+
+ if ( $current->checked[ $file ] != $p['Version'] )
+ $plugin_changed = true;
+ }
+
+ if (
+ isset( $current->last_checked ) &&
+ 43200 > ( time() - $current->last_checked ) &&
+ !$plugin_changed
+ )
+ return false;
+
+ $to_send->plugins = $plugins;
+ $to_send->active = $active;
+ $send = serialize( $to_send );
+
+ $request = 'plugins=' . urlencode( $send );
+ $http_request = "POST /plugins/update-check/1.0/ HTTP/1.0\r\n";
+ $http_request .= "Host: api.wordpress.org\r\n";
+ $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n";
+ $http_request .= "Content-Length: " . strlen($request) . "\r\n";
+ $http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n";
+ $http_request .= "\r\n";
+ $http_request .= $request;
+
+ $response = '';
+ if( false != ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3) ) && is_resource($fs) ) {
+ fwrite($fs, $http_request);
+
+ while ( !feof($fs) )
+ $response .= fgets($fs, 1160); // One TCP-IP packet
+ fclose($fs);
+ $response = explode("\r\n\r\n", $response, 2);
+ }
+
+ $response = unserialize( $response[1] );
+
+ if ( $response )
+ $new_option->response = $response;
+
+ update_option( 'update_plugins', $new_option );
+}
+add_action( 'load-plugins.php', 'wp_update_plugins' );
+
+function wp_plugin_update_row( $file ) {
+ global $plugin_data;
+ $current = get_option( 'update_plugins' );
+ if ( !isset( $current->response[ $file ] ) )
+ return false;
+
+ $r = $current->response[ $file ];
+
+ echo "<tr><td colspan='5' class='plugin-update'>";
+ printf( __('There is a new version of %s available. <a href="%s">Download version %s here</a>.'), $plugin_data['Name'], $r->url, $r->new_version );
+ echo "</td></tr>";
+}
+add_action( 'after_plugin_row', 'wp_plugin_update_row' );
+*/
+?>
diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php
new file mode 100644
index 0000000..71e6399
--- /dev/null
+++ b/wp-admin/includes/upgrade.php
@@ -0,0 +1,1271 @@
+<?php
+
+if ( file_exists(ABSPATH . 'wp-content/install.php') )
+ require (ABSPATH . 'wp-content/install.php');
+require_once(ABSPATH . 'wp-admin/includes/admin.php');
+require_once(ABSPATH . 'wp-admin/includes/schema.php');
+
+if ( !function_exists('wp_install') ) :
+function wp_install($blog_title, $user_name, $user_email, $public, $meta='') {
+ global $wp_rewrite;
+
+ wp_check_mysql_version();
+ wp_cache_flush();
+ make_db_current_silent();
+ populate_options();
+ populate_roles();
+
+ update_option('blogname', $blog_title);
+ update_option('admin_email', $user_email);
+ update_option('blog_public', $public);
+ $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
+
+ if ( defined('WP_SITEURL') && '' != WP_SITEURL )
+ $guessurl = WP_SITEURL;
+ else
+ $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+
+ update_option('siteurl', $guessurl);
+
+ // If not a public blog, don't ping.
+ if ( ! $public )
+ update_option('default_pingback_flag', 0);
+
+ // Create default user. If the user already exists, the user tables are
+ // being shared among blogs. Just set the role in that case.
+ $user_id = username_exists($user_name);
+ if ( !$user_id ) {
+ $random_password = substr(md5(uniqid(microtime())), 0, 6);
+ $user_id = wp_create_user($user_name, $random_password, $user_email);
+ } else {
+ $random_password = __('User already exists. Password inherited.');
+ }
+
+ $user = new WP_User($user_id);
+ $user->set_role('administrator');
+
+ wp_install_defaults($user_id);
+
+ $wp_rewrite->flush_rules();
+
+ wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
+
+ wp_cache_flush();
+
+ return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
+}
+endif;
+
+if ( !function_exists('wp_install_defaults') ) :
+function wp_install_defaults($user_id) {
+ global $wpdb;
+
+ // Default category
+ $cat_name = $wpdb->escape(__('Uncategorized'));
+ $cat_slug = sanitize_title(__('Uncategorized'));
+ $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')");
+ $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('1', 'category', '', '0', '1')");
+
+ // Default link category
+ $cat_name = $wpdb->escape(__('Blogroll'));
+ $cat_slug = sanitize_title(__('Blogroll'));
+ $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$cat_name', '$cat_slug', '0')");
+ $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('2', 'link_category', '', '0', '7')");
+
+ // Now drop in some default links
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://codex.wordpress.org/', 'Documentation', 0, '', '');");
+ $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (1, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/development/', 'Development Blog', 0, 'http://wordpress.org/development/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (2, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/extend/ideas/', 'Suggest Ideas', 0, '', '');");
+ $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (3, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/support/', 'Support Forum', 0, '', '');");
+ $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (4, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/extend/plugins/', 'Plugins', 0, '', '');");
+ $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (5, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://wordpress.org/extend/themes/', 'Themes', 0, '', '');");
+ $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (6, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://planet.wordpress.org/', 'WordPress Planet', 0, '', '');");
+ $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (7, 2)" );
+
+ // First post
+ $now = date('Y-m-d H:i:s');
+ $now_gmt = gmdate('Y-m-d H:i:s');
+ $first_post_guid = get_option('home') . '/?p=1';
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '$first_post_guid', '1', '', '', '')");
+ $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (1, 1)" );
+
+ // Default comment
+ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.'))."')");
+
+ // First Page
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'publish', 'page', '', '', '')");
+}
+endif;
+
+if ( !function_exists('wp_new_blog_notification') ) :
+function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
+ $user = new WP_User($user_id);
+ $email = $user->user_email;
+ $name = $user->user_login;
+ $message_headers = 'From: "' . $blog_title . '" <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
+ $message = sprintf(__("Your new WordPress blog has been successfully set up at:
+
+%1\$s
+
+You can log in to the administrator account with the following information:
+
+Username: %2\$s
+Password: %3\$s
+
+We hope you enjoy your new blog. Thanks!
+
+--The WordPress Team
+http://wordpress.org/
+"), $blog_url, $name, $password);
+
+ @wp_mail($email, __('New WordPress Blog'), $message, $message_headers);
+}
+endif;
+
+if ( !function_exists('wp_upgrade') ) :
+function wp_upgrade() {
+ global $wp_current_db_version, $wp_db_version;
+
+ $wp_current_db_version = __get_option('db_version');
+
+ // We are up-to-date. Nothing to do.
+ if ( $wp_db_version == $wp_current_db_version )
+ return;
+
+ wp_check_mysql_version();
+ wp_cache_flush();
+ make_db_current_silent();
+ upgrade_all();
+ wp_cache_flush();
+}
+endif;
+
+// Functions to be called in install and upgrade scripts
+function upgrade_all() {
+ global $wp_current_db_version, $wp_db_version, $wp_rewrite;
+ $wp_current_db_version = __get_option('db_version');
+
+ // We are up-to-date. Nothing to do.
+ if ( $wp_db_version == $wp_current_db_version )
+ return;
+
+ // If the version is not set in the DB, try to guess the version.
+ if ( empty($wp_current_db_version) ) {
+ $wp_current_db_version = 0;
+
+ // If the template option exists, we have 1.5.
+ $template = __get_option('template');
+ if ( !empty($template) )
+ $wp_current_db_version = 2541;
+ }
+
+ if ( $wp_current_db_version < 6039 )
+ upgrade_230_options_table();
+
+ populate_options();
+
+ if ( $wp_current_db_version < 2541 ) {
+ upgrade_100();
+ upgrade_101();
+ upgrade_110();
+ upgrade_130();
+ }
+
+ if ( $wp_current_db_version < 3308 )
+ upgrade_160();
+
+ if ( $wp_current_db_version < 4772 )
+ upgrade_210();
+
+ if ( $wp_current_db_version < 4351 )
+ upgrade_old_slugs();
+
+ if ( $wp_current_db_version < 5539 )
+ upgrade_230();
+
+ if ( $wp_current_db_version < 6124 )
+ upgrade_230_old_tables();
+
+ maybe_disable_automattic_widgets();
+
+ $wp_rewrite->flush_rules();
+
+ update_option('db_version', $wp_db_version);
+}
+
+function upgrade_100() {
+ global $wpdb;
+
+ // 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 $wpdb->posts WHERE post_name = ''");
+ if ($posts) {
+ foreach($posts as $post) {
+ if ('' == $post->post_name) {
+ $newtitle = sanitize_title($post->post_title);
+ $wpdb->query("UPDATE $wpdb->posts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
+ }
+ }
+ }
+
+ $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
+ foreach ($categories as $category) {
+ if ('' == $category->category_nicename) {
+ $newtitle = sanitize_title($category->cat_name);
+ $wpdb->query("UPDATE $wpdb->categories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'");
+ }
+ }
+
+
+ $wpdb->query("UPDATE $wpdb->options SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
+ WHERE option_name LIKE 'links_rating_image%'
+ AND option_value LIKE 'wp-links/links-images/%'");
+
+ $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
+ if ($done_ids) :
+ foreach ($done_ids as $done_id) :
+ $done_posts[] = $done_id->post_id;
+ endforeach;
+ $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
+ else:
+ $catwhere = '';
+ endif;
+
+ $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
+ if ($allposts) :
+ foreach ($allposts as $post) {
+ // Check to see if it's already been imported
+ $cat = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
+ if (!$cat && 0 != $post->post_category) { // If there's no result
+ $wpdb->query("
+ INSERT INTO $wpdb->post2cat
+ (post_id, category_id)
+ VALUES
+ ('$post->ID', '$post->post_category')
+ ");
+ }
+ }
+ endif;
+}
+
+function upgrade_101() {
+ global $wpdb;
+
+ // Clean up indices, add a few
+ add_clean_index($wpdb->posts, 'post_name');
+ add_clean_index($wpdb->posts, 'post_status');
+ add_clean_index($wpdb->categories, 'category_nicename');
+ add_clean_index($wpdb->comments, 'comment_approved');
+ add_clean_index($wpdb->comments, 'comment_post_ID');
+ add_clean_index($wpdb->links , 'link_category');
+ add_clean_index($wpdb->links , 'link_visible');
+}
+
+
+function upgrade_110() {
+ global $wpdb;
+
+ // Set user_nicename.
+ $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
+ foreach ($users as $user) {
+ if ('' == $user->user_nicename) {
+ $newname = sanitize_title($user->user_nickname);
+ $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
+ }
+ }
+
+ $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
+ foreach ($users as $row) {
+ if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
+ $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
+ }
+ }
+
+
+ // Get the GMT offset, we'll use that later on
+ $all_options = get_alloptions_110();
+
+ $time_difference = $all_options->time_difference;
+
+ $server_time = time()+date('Z');
+ $weblogger_time = $server_time + $time_difference*3600;
+ $gmt_time = time();
+
+ $diff_gmt_server = ($gmt_time - $server_time) / 3600;
+ $diff_weblogger_server = ($weblogger_time - $server_time) / 3600;
+ $diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
+ $gmt_offset = -$diff_gmt_weblogger;
+
+ // Add a gmt_offset option, with value $gmt_offset
+ add_option('gmt_offset', $gmt_offset);
+
+ // Check if we already set the GMT fields (if we did, then
+ // MAX(post_date_gmt) can't be '0000-00-00 00:00:00'
+ // <michel_v> I just slapped myself silly for not thinking about it earlier
+ $got_gmt_fields = ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00') ? false : true;
+
+ if (!$got_gmt_fields) {
+
+ // Add or substract time to all dates, to get GMT dates
+ $add_hours = intval($diff_gmt_weblogger);
+ $add_minutes = intval(60 * ($diff_gmt_weblogger - $add_hours));
+ $wpdb->query("UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
+ $wpdb->query("UPDATE $wpdb->posts SET post_modified = post_date");
+ $wpdb->query("UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'");
+ $wpdb->query("UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
+ $wpdb->query("UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
+ }
+
+}
+
+function upgrade_130() {
+ global $wpdb;
+
+ // Remove extraneous backslashes.
+ $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
+ if ($posts) {
+ foreach($posts as $post) {
+ $post_content = addslashes(deslash($post->post_content));
+ $post_title = addslashes(deslash($post->post_title));
+ $post_excerpt = addslashes(deslash($post->post_excerpt));
+ if ( empty($post->guid) )
+ $guid = get_permalink($post->ID);
+ else
+ $guid = $post->guid;
+
+ $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'");
+ }
+ }
+
+ // Remove extraneous backslashes.
+ $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments");
+ if ($comments) {
+ foreach($comments as $comment) {
+ $comment_content = addslashes(deslash($comment->comment_content));
+ $comment_author = addslashes(deslash($comment->comment_author));
+ $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'");
+ }
+ }
+
+ // Remove extraneous backslashes.
+ $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links");
+ if ($links) {
+ foreach($links as $link) {
+ $link_name = addslashes(deslash($link->link_name));
+ $link_description = addslashes(deslash($link->link_description));
+ $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'");
+ }
+ }
+
+ // The "paged" option for what_to_show is no more.
+ if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') {
+ $wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'");
+ }
+
+ $active_plugins = __get_option('active_plugins');
+
+ // If plugins are not stored in an array, they're stored in the old
+ // newline separated format. Convert to new format.
+ if ( !is_array( $active_plugins ) ) {
+ $active_plugins = explode("\n", trim($active_plugins));
+ update_option('active_plugins', $active_plugins);
+ }
+
+ // Obsolete tables
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
+
+ // Update comments table to use comment_type
+ $wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
+ $wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'");
+
+ // Some versions have multiple duplicate option_name rows with the same values
+ $options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
+ foreach ( $options as $option ) {
+ if ( 1 != $option->dupes ) { // Could this be done in the query?
+ $limit = $option->dupes - 1;
+ $dupe_ids = $wpdb->get_col("SELECT option_id FROM $wpdb->options WHERE option_name = '$option->option_name' LIMIT $limit");
+ $dupe_ids = join($dupe_ids, ',');
+ $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
+ }
+ }
+
+ make_site_theme();
+}
+
+function upgrade_160_helper( $users ) {
+ global $wpdb;
+
+ populate_roles_160();
+
+ foreach ( $users as $user_details ) :
+ $user = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE ID = '" . $user_details[ 'user_id' ] . "'");
+ if ( !empty( $user->user_firstname ) )
+ update_usermeta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) );
+ if ( !empty( $user->user_lastname ) )
+ update_usermeta( $user->ID, 'last_name', $wpdb->escape($user->user_lastname) );
+ if ( !empty( $user->user_nickname ) )
+ update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
+ if ( !empty( $user->user_level ) )
+ update_usermeta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
+ if ( !empty( $user->user_icq ) )
+ update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
+ if ( !empty( $user->user_aim ) )
+ update_usermeta( $user->ID, 'aim', $wpdb->escape($user->user_aim) );
+ if ( !empty( $user->user_msn ) )
+ update_usermeta( $user->ID, 'msn', $wpdb->escape($user->user_msn) );
+ if ( !empty( $user->user_yim ) )
+ update_usermeta( $user->ID, 'yim', $wpdb->escape($user->user_icq) );
+ if ( !empty( $user->user_description ) )
+ update_usermeta( $user->ID, 'description', $wpdb->escape($user->user_description) );
+
+ if ( isset( $user->user_idmode ) ):
+ $idmode = $user->user_idmode;
+ if ($idmode == 'nickname') $id = $user->user_nickname;
+ if ($idmode == 'login') $id = $user->user_login;
+ if ($idmode == 'firstname') $id = $user->user_firstname;
+ if ($idmode == 'lastname') $id = $user->user_lastname;
+ if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
+ if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
+ if (!$idmode) $id = $user->user_nickname;
+ $id = $wpdb->escape( $id );
+ $wpdb->query("UPDATE $wpdb->users SET display_name = '$id' WHERE ID = '$user->ID'");
+ endif;
+
+ // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
+ $caps = get_usermeta( $user->ID, $wpdb->prefix . 'capabilities');
+ if ( empty($caps) || defined('RESET_CAPS') ) {
+ $level = get_usermeta($user->ID, $wpdb->prefix . 'user_level');
+ $role = translate_level_to_role($level);
+ update_usermeta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
+ }
+
+ endforeach;
+}
+
+function upgrade_160() {
+ global $wpdb, $table_prefix, $wp_current_db_version;
+ $users = $wpdb->get_results("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '{$table_prefix}capabilities'", ARRAY_A);
+ upgrade_160_helper( $users );
+ $users = $wpdb->get_results("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '{$table_prefix}user_level'", ARRAY_A);
+ upgrade_160_helper( $users );
+ $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
+ $wpdb->hide_errors();
+ foreach ( $old_user_fields as $old )
+ $wpdb->query("ALTER TABLE $wpdb->users DROP $old");
+ $wpdb->show_errors();
+
+ // populate comment_count field of posts table
+ $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
+ if( is_array( $comments ) ) {
+ foreach ($comments as $comment) {
+ $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" );
+ }
+ }
+
+ // Some alpha versions used a post status of object instead of attachment and put
+ // the mime type in post_type instead of post_mime_type.
+ if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
+ $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
+ foreach ($objects as $object) {
+ $wpdb->query("UPDATE $wpdb->posts SET post_status = 'attachment',
+ post_mime_type = '$object->post_type',
+ post_type = ''
+ WHERE ID = $object->ID");
+
+ $meta = get_post_meta($object->ID, 'imagedata', true);
+ if ( ! empty($meta['file']) )
+ update_attached_file( $object->ID, $meta['file'] );
+ }
+ }
+}
+
+function upgrade_210() {
+ global $wpdb, $wp_current_db_version;
+
+ if ( $wp_current_db_version < 3506 ) {
+ // Update status and type.
+ $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
+
+ if ( ! empty($posts) ) foreach ($posts as $post) {
+ $status = $post->post_status;
+ $type = 'post';
+
+ if ( 'static' == $status ) {
+ $status = 'publish';
+ $type = 'page';
+ } else if ( 'attachment' == $status ) {
+ $status = 'inherit';
+ $type = 'attachment';
+ }
+
+ $wpdb->query("UPDATE $wpdb->posts SET post_status = '$status', post_type = '$type' WHERE ID = '$post->ID'");
+ }
+ }
+
+ if ( $wp_current_db_version < 3845 ) {
+ populate_roles_210();
+ }
+
+ if ( $wp_current_db_version < 3531 ) {
+ // Give future posts a post_status of future.
+ $now = gmdate('Y-m-d H:i:59');
+ $wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
+
+ $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
+ if ( !empty($posts) )
+ foreach ( $posts as $post )
+ wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', array($post->ID));
+ }
+}
+
+function upgrade_230() {
+ global $wp_current_db_version, $wpdb;
+
+ if ( $wp_current_db_version < 5200 ) {
+ populate_roles_230();
+ }
+
+ // Convert categories to terms.
+ $tt_ids = array();
+ $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_ID");
+ foreach ($categories as $category) {
+ $term_id = (int) $category->cat_ID;
+ $name = $wpdb->escape($category->cat_name);
+ $description = $wpdb->escape($category->category_description);
+ $slug = $wpdb->escape($category->category_nicename);
+ $parent = $wpdb->escape($category->category_parent);
+ $term_group = 0;
+
+ // Associate terms with the same slug in a term group and make slugs unique.
+ if ( $exists = $wpdb->get_results("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = '$slug'") ) {
+ $term_group = $exists[0]->term_group;
+ $id = $exists[0]->term_id;
+ $num = 2;
+ do {
+ $alt_slug = $slug . "-$num";
+ $num++;
+ $slug_check = $wpdb->get_var("SELECT slug FROM $wpdb->terms WHERE slug = '$alt_slug'");
+ } while ( $slug_check );
+
+ $slug = $alt_slug;
+
+ if ( empty( $term_group ) ) {
+ $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1;
+ $wpdb->query("UPDATE $wpdb->terms SET term_group = '$term_group' WHERE term_id = '$id'");
+ }
+ }
+
+ $wpdb->query("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES ('$term_id', '$name', '$slug', '$term_group')");
+
+ $count = 0;
+ if ( !empty($category->category_count) ) {
+ $count = (int) $category->category_count;
+ $taxonomy = 'category';
+ $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('$term_id', '$taxonomy', '$description', '$parent', '$count')");
+ $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
+ }
+
+ if ( !empty($category->link_count) ) {
+ $count = (int) $category->link_count;
+ $taxonomy = 'link_category';
+ $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('$term_id', '$taxonomy', '$description', '$parent', '$count')");
+ $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
+ }
+
+ if ( !empty($category->tag_count) ) {
+ $count = (int) $category->tag_count;
+ $taxonomy = 'post_tag';
+ $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('$term_id', '$taxonomy', '$description', '$parent', '$count')");
+ $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
+ }
+
+ if ( empty($count) ) {
+ $count = 0;
+ $taxonomy = 'category';
+ $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('$term_id', '$taxonomy', '$description', '$parent', '$count')");
+ $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
+ }
+ }
+
+ $posts = $wpdb->get_results("SELECT * FROM $wpdb->post2cat");
+ foreach ( $posts as $post ) {
+ $post_id = (int) $post->post_id;
+ $term_id = (int) $post->category_id;
+ $taxonomy = 'category';
+ if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
+ $taxonomy = 'tag';
+ $tt_id = $tt_ids[$term_id][$taxonomy];
+ if ( empty($tt_id) )
+ continue;
+
+ $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$post_id', '$tt_id')");
+ }
+
+ // < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
+ if ( $wp_current_db_version < 3570 ) {
+ // Create link_category terms for link categories. Create a map of link cat IDs
+ // to link_category terms.
+ $link_cat_id_map = array();
+ $default_link_cat = 0;
+ $tt_ids = array();
+ $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
+ foreach ( $link_cats as $category) {
+ $cat_id = (int) $category->cat_id;
+ $term_id = 0;
+ $name = $wpdb->escape($category->cat_name);
+ $slug = sanitize_title($name);
+ $term_group = 0;
+
+ // Associate terms with the same slug in a term group and make slugs unique.
+ if ( $exists = $wpdb->get_results("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = '$slug'") ) {
+ $term_group = $exists[0]->term_group;
+ $term_id = $exists[0]->term_id;
+ }
+
+ if ( empty($term_id) ) {
+ $wpdb->query("INSERT INTO $wpdb->terms (name, slug, term_group) VALUES ('$name', '$slug', '$term_group')");
+ $term_id = (int) $wpdb->insert_id;
+ }
+
+ $link_cat_id_map[$cat_id] = $term_id;
+ $default_link_cat = $term_id;
+
+ $wpdb->query("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ('$term_id', 'link_category', '', '0', '0')");
+ $tt_ids[$term_id] = (int) $wpdb->insert_id;
+ }
+
+ // Associate links to cats.
+ $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
+ if ( !empty($links) ) foreach ( $links as $link ) {
+ if ( 0 == $link->link_category )
+ continue;
+ if ( ! isset($link_cat_id_map[$link->link_category]) )
+ continue;
+ $term_id = $link_cat_id_map[$link->link_category];
+ $tt_id = $tt_ids[$term_id];
+ if ( empty($tt_id) )
+ continue;
+
+ $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$link->link_id', '$tt_id')");
+ }
+
+ // Set default to the last category we grabbed during the upgrade loop.
+ update_option('default_link_category', $default_link_cat);
+ } else {
+ $links = $wpdb->get_results("SELECT * FROM $wpdb->link2cat");
+ foreach ( $links as $link ) {
+ $link_id = (int) $link->link_id;
+ $term_id = (int) $link->category_id;
+ $taxonomy = 'link_category';
+ $tt_id = $tt_ids[$term_id][$taxonomy];
+ if ( empty($tt_id) )
+ continue;
+
+ $wpdb->query("INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id) VALUES ('$link_id', '$tt_id')");
+ }
+ }
+
+ if ( $wp_current_db_version < 4772 ) {
+ // Obsolete linkcategories table
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
+ }
+
+ // Recalculate all counts
+ $terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy");
+ foreach ( (array) $terms as $term ) {
+ if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) )
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = '$term->term_taxonomy_id'");
+ else
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = '$term->term_taxonomy_id'");
+ $wpdb->query("UPDATE $wpdb->term_taxonomy SET count = '$count' WHERE term_taxonomy_id = '$term->term_taxonomy_id'");
+ }
+}
+
+function upgrade_230_options_table() {
+ global $wpdb;
+ $old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
+ $wpdb->hide_errors();
+ foreach ( $old_options_fields as $old )
+ $wpdb->query("ALTER TABLE $wpdb->options DROP $old");
+ $wpdb->show_errors();
+}
+
+function upgrade_230_old_tables() {
+ global $wpdb;
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat');
+}
+
+function upgrade_old_slugs() {
+ // upgrade people who were using the Redirect Old Slugs plugin
+ global $wpdb;
+ $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'");
+}
+
+
+// The functions we use to actually do stuff
+
+// General
+function maybe_create_table($table_name, $create_ddl) {
+ global $wpdb;
+ foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+ if ($table == $table_name) {
+ return true;
+ }
+ }
+ //didn't find it try to create it.
+ $q = $wpdb->query($create_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
+ if ($table == $table_name) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function drop_index($table, $index) {
+ global $wpdb;
+ $wpdb->hide_errors();
+ $wpdb->query("ALTER TABLE `$table` DROP INDEX `$index`");
+ // Now we need to take out all the extra ones we may have created
+ for ($i = 0; $i < 25; $i++) {
+ $wpdb->query("ALTER TABLE `$table` DROP INDEX `{$index}_$i`");
+ }
+ $wpdb->show_errors();
+ return true;
+}
+
+function add_clean_index($table, $index) {
+ global $wpdb;
+ drop_index($table, $index);
+ $wpdb->query("ALTER TABLE `$table` ADD INDEX ( `$index` )");
+ return true;
+}
+
+/**
+ ** maybe_add_column()
+ ** Add column to db table if it doesn't exist.
+ ** Returns: true if already exists or on successful completion
+ ** false on error
+ */
+function maybe_add_column($table_name, $column_name, $create_ddl) {
+ global $wpdb, $debug;
+ foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
+ if ($debug) echo("checking $column == $column_name<br />");
+ if ($column == $column_name) {
+ return true;
+ }
+ }
+ //didn't find it try to create it.
+ $q = $wpdb->query($create_ddl);
+ // we cannot directly tell that whether this succeeded!
+ foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
+ if ($column == $column_name) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+// get_alloptions as it was for 1.2.
+function get_alloptions_110() {
+ global $wpdb;
+ if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
+ foreach ($options as $option) {
+ // "When trying to design a foolproof system,
+ // never underestimate the ingenuity of the fools :)" -- Dougal
+ if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
+ $all_options->{$option->option_name} = stripslashes($option->option_value);
+ }
+ }
+ return $all_options;
+}
+
+// Version of get_option that is private to install/upgrade.
+function __get_option($setting) {
+ global $wpdb;
+
+ if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
+ return preg_replace( '|/+$|', '', constant( 'WP_HOME' ) );
+ }
+
+ if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
+ return preg_replace( '|/+$|', '', constant( 'WP_SITEURL' ) );
+ }
+
+ $option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
+
+ if ( 'home' == $setting && '' == $option )
+ return __get_option('siteurl');
+
+ if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting )
+ $option = preg_replace('|/+$|', '', $option);
+
+ @ $kellogs = unserialize($option);
+ if ($kellogs !== FALSE)
+ return $kellogs;
+ else
+ return $option;
+}
+
+function deslash($content) {
+ // Note: \\\ inside a regex denotes a single backslash.
+
+ // Replace one or more backslashes followed by a single quote with
+ // a single quote.
+ $content = preg_replace("/\\\+'/", "'", $content);
+
+ // Replace one or more backslashes followed by a double quote with
+ // a double quote.
+ $content = preg_replace('/\\\+"/', '"', $content);
+
+ // Replace one or more backslashes with one backslash.
+ $content = preg_replace("/\\\+/", "\\", $content);
+
+ return $content;
+}
+
+function dbDelta($queries, $execute = true) {
+ global $wpdb;
+
+ // Seperate individual queries into an array
+ if( !is_array($queries) ) {
+ $queries = explode( ';', $queries );
+ if('' == $queries[count($queries) - 1]) array_pop($queries);
+ }
+
+ $cqueries = array(); // Creation Queries
+ $iqueries = array(); // Insertion Queries
+ $for_update = array();
+
+ // Create a tablename index for an array ($cqueries) of queries
+ foreach($queries as $qry) {
+ if(preg_match("|CREATE TABLE (?:IF NOT EXISTS )?([^ ]*)|", $qry, $matches)) {
+ $cqueries[strtolower($matches[1])] = $qry;
+ $for_update[$matches[1]] = 'Created table '.$matches[1];
+ }
+ else if(preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
+ array_unshift($cqueries, $qry);
+ }
+ else if(preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
+ $iqueries[] = $qry;
+ }
+ else if(preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
+ $iqueries[] = $qry;
+ }
+ else {
+ // Unrecognized query type
+ }
+ }
+
+ // Check to see which tables and fields exist
+ if($tables = $wpdb->get_col('SHOW TABLES;')) {
+ // For every table in the database
+ foreach($tables as $table) {
+ // If a table query exists for the database table...
+ if( array_key_exists(strtolower($table), $cqueries) ) {
+ // Clear the field and index arrays
+ unset($cfields);
+ unset($indices);
+ // Get all of the field names in the query from between the parens
+ preg_match("|\((.*)\)|ms", $cqueries[strtolower($table)], $match2);
+ $qryline = trim($match2[1]);
+
+ // Separate field lines into an array
+ $flds = explode("\n", $qryline);
+
+ //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
+
+ // For every field line specified in the query
+ foreach($flds as $fld) {
+ // Extract the field name
+ preg_match("|^([^ ]*)|", trim($fld), $fvals);
+ $fieldname = $fvals[1];
+
+ // Verify the found field name
+ $validfield = true;
+ switch(strtolower($fieldname))
+ {
+ case '':
+ case 'primary':
+ case 'index':
+ case 'fulltext':
+ case 'unique':
+ case 'key':
+ $validfield = false;
+ $indices[] = trim(trim($fld), ", \n");
+ break;
+ }
+ $fld = trim($fld);
+
+ // If it's a valid field, add it to the field array
+ if($validfield) {
+ $cfields[strtolower($fieldname)] = trim($fld, ", \n");
+ }
+ }
+
+ // Fetch the table column structure from the database
+ $tablefields = $wpdb->get_results("DESCRIBE {$table};");
+
+ // For every field in the table
+ foreach($tablefields as $tablefield) {
+ // If the table field exists in the field array...
+ if(array_key_exists(strtolower($tablefield->Field), $cfields)) {
+ // Get the field type from the query
+ preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
+ $fieldtype = $matches[1];
+
+ // Is actual field type different from the field type in query?
+ if($tablefield->Type != $fieldtype) {
+ // Add a query to change the column type
+ $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
+ $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
+ }
+
+ // Get the default value from the array
+ //echo "{$cfields[strtolower($tablefield->Field)]}<br>";
+ if(preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
+ $default_value = $matches[1];
+ if($tablefield->Default != $default_value)
+ {
+ // Add a query to change the column's default value
+ $cqueries[] = "ALTER TABLE {$table} ALTER COLUMN {$tablefield->Field} SET DEFAULT '{$default_value}'";
+ $for_update[$table.'.'.$tablefield->Field] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}";
+ }
+ }
+
+ // Remove the field from the array (so it's not added)
+ unset($cfields[strtolower($tablefield->Field)]);
+ }
+ else {
+ // This field exists in the table, but not in the creation queries?
+ }
+ }
+
+ // For every remaining field specified for the table
+ foreach($cfields as $fieldname => $fielddef) {
+ // Push a query line into $cqueries that adds the field to that table
+ $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
+ $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
+ }
+
+ // Index stuff goes here
+ // Fetch the table index structure from the database
+ $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
+
+ if($tableindices) {
+ // Clear the index array
+ unset($index_ary);
+
+ // For every index in the table
+ foreach($tableindices as $tableindex) {
+ // Add the index to the index data array
+ $keyname = $tableindex->Key_name;
+ $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
+ $index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
+ }
+
+ // For each actual index in the index array
+ foreach($index_ary as $index_name => $index_data) {
+ // Build a create string to compare to the query
+ $index_string = '';
+ if($index_name == 'PRIMARY') {
+ $index_string .= 'PRIMARY ';
+ }
+ else if($index_data['unique']) {
+ $index_string .= 'UNIQUE ';
+ }
+ $index_string .= 'KEY ';
+ if($index_name != 'PRIMARY') {
+ $index_string .= $index_name;
+ }
+ $index_columns = '';
+ // For each column in the index
+ foreach($index_data['columns'] as $column_data) {
+ if($index_columns != '') $index_columns .= ',';
+ // Add the field to the column list string
+ $index_columns .= $column_data['fieldname'];
+ if($column_data['subpart'] != '') {
+ $index_columns .= '('.$column_data['subpart'].')';
+ }
+ }
+ // Add the column list to the index create string
+ $index_string .= ' ('.$index_columns.')';
+ error_log("Index string: $index_string", 0);
+ if(!(($aindex = array_search($index_string, $indices)) === false)) {
+ unset($indices[$aindex]);
+ //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
+ }
+ //else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br /><b>Did not find index:</b>".$index_string."<br />".print_r($indices, true)."</pre>\n";
+ }
+ }
+
+ // For every remaining index specified for the table
+ foreach ( (array) $indices as $index ) {
+ // Push a query line into $cqueries that adds the index to that table
+ $cqueries[] = "ALTER TABLE {$table} ADD $index";
+ $for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index;
+ }
+
+ // Remove the original table creation query from processing
+ unset($cqueries[strtolower($table)]);
+ unset($for_update[strtolower($table)]);
+ } else {
+ // This table exists in the database, but not in the creation queries?
+ }
+ }
+ }
+
+ $allqueries = array_merge($cqueries, $iqueries);
+ if($execute) {
+ foreach($allqueries as $query) {
+ //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
+ $wpdb->query($query);
+ }
+ }
+
+ return $for_update;
+}
+
+function make_db_current() {
+ global $wp_queries;
+
+ $alterations = dbDelta($wp_queries);
+ echo "<ol>\n";
+ foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
+ echo "</ol>\n";
+}
+
+function make_db_current_silent() {
+ global $wp_queries;
+
+ $alterations = dbDelta($wp_queries);
+}
+
+function make_site_theme_from_oldschool($theme_name, $template) {
+ $home_path = get_home_path();
+ $site_dir = ABSPATH . "wp-content/themes/$template";
+
+ if (! file_exists("$home_path/index.php"))
+ return false;
+
+ // Copy files from the old locations to the site theme.
+ // TODO: This does not copy arbitarary include dependencies. Only the
+ // standard WP files are copied.
+ $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
+
+ foreach ($files as $oldfile => $newfile) {
+ if ($oldfile == 'index.php')
+ $oldpath = $home_path;
+ else
+ $oldpath = ABSPATH;
+
+ if ($oldfile == 'index.php') { // Check to make sure it's not a new index
+ $index = implode('', file("$oldpath/$oldfile"));
+ if (strpos($index, 'WP_USE_THEMES') !== false) {
+ if (! @copy(ABSPATH . 'wp-content/themes/default/index.php', "$site_dir/$newfile"))
+ return false;
+ continue; // Don't copy anything
+ }
+ }
+
+ if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
+ return false;
+
+ chmod("$site_dir/$newfile", 0777);
+
+ // Update the blog header include in each file.
+ $lines = explode("\n", implode('', file("$site_dir/$newfile")));
+ if ($lines) {
+ $f = fopen("$site_dir/$newfile", 'w');
+
+ foreach ($lines as $line) {
+ if (preg_match('/require.*wp-blog-header/', $line))
+ $line = '//' . $line;
+
+ // Update stylesheet references.
+ $line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
+
+ // Update comments template inclusion.
+ $line = str_replace("<?php include(ABSPATH . 'wp-comments.php'); ?>", "<?php comments_template(); ?>", $line);
+
+ fwrite($f, "{$line}\n");
+ }
+ fclose($f);
+ }
+ }
+
+ // Add a theme header.
+ $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the upgrade.\nVersion: 1.0\nAuthor: Moi\n*/\n";
+
+ $stylelines = file_get_contents("$site_dir/style.css");
+ if ($stylelines) {
+ $f = fopen("$site_dir/style.css", 'w');
+
+ fwrite($f, $header);
+ fwrite($f, $stylelines);
+ fclose($f);
+ }
+
+ return true;
+}
+
+function make_site_theme_from_default($theme_name, $template) {
+ $site_dir = ABSPATH . "wp-content/themes/$template";
+ $default_dir = ABSPATH . 'wp-content/themes/default';
+
+ // Copy files from the default theme to the site theme.
+ //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
+
+ $theme_dir = @ opendir("$default_dir");
+ if ($theme_dir) {
+ while(($theme_file = readdir( $theme_dir )) !== false) {
+ if (is_dir("$default_dir/$theme_file"))
+ continue;
+ if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
+ return;
+ chmod("$site_dir/$theme_file", 0777);
+ }
+ }
+ @closedir($theme_dir);
+
+ // Rewrite the theme header.
+ $stylelines = explode("\n", implode('', file("$site_dir/style.css")));
+ if ($stylelines) {
+ $f = fopen("$site_dir/style.css", 'w');
+
+ foreach ($stylelines as $line) {
+ if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
+ elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
+ elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
+ elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
+ elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
+ fwrite($f, $line . "\n");
+ }
+ fclose($f);
+ }
+
+ // Copy the images.
+ umask(0);
+ if (! mkdir("$site_dir/images", 0777)) {
+ return false;
+ }
+
+ $images_dir = @ opendir("$default_dir/images");
+ if ($images_dir) {
+ while(($image = readdir($images_dir)) !== false) {
+ if (is_dir("$default_dir/images/$image"))
+ continue;
+ if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
+ return;
+ chmod("$site_dir/images/$image", 0777);
+ }
+ }
+ @closedir($images_dir);
+}
+
+// Create a site theme from the default theme.
+function make_site_theme() {
+ return true;
+ // Name the theme after the blog.
+ $theme_name = __get_option('blogname');
+ $template = sanitize_title($theme_name);
+ $site_dir = ABSPATH . "wp-content/themes/$template";
+
+ // If the theme already exists, nothing to do.
+ if ( is_dir($site_dir)) {
+ return false;
+ }
+
+ // We must be able to write to the themes dir.
+ if (! is_writable(ABSPATH . "wp-content/themes")) {
+ return false;
+ }
+
+ umask(0);
+ if (! mkdir($site_dir, 0777)) {
+ return false;
+ }
+
+ if (file_exists(ABSPATH . 'wp-layout.css')) {
+ if (! make_site_theme_from_oldschool($theme_name, $template)) {
+ // TODO: rm -rf the site theme directory.
+ return false;
+ }
+ } else {
+ if (! make_site_theme_from_default($theme_name, $template))
+ // TODO: rm -rf the site theme directory.
+ return false;
+ }
+
+ // Make the new site theme active.
+ $current_template = __get_option('template');
+ if ($current_template == 'default') {
+ update_option('template', $template);
+ update_option('stylesheet', $template);
+ }
+ return $template;
+}
+
+function translate_level_to_role($level) {
+ switch ($level) {
+ case 10:
+ case 9:
+ case 8:
+ return 'administrator';
+ case 7:
+ case 6:
+ case 5:
+ return 'editor';
+ case 4:
+ case 3:
+ case 2:
+ return 'author';
+ case 1:
+ return 'contributor';
+ case 0:
+ return 'subscriber';
+ }
+}
+
+function wp_check_mysql_version() {
+ global $wp_version;
+
+ // Make sure the server has MySQL 4.0
+ $mysql_version = preg_replace('|[^0-9\.]|', '', @mysql_get_server_info());
+ if ( version_compare($mysql_version, '4.0.0', '<') )
+ die(sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version));
+}
+
+function maybe_disable_automattic_widgets() {
+ $plugins = __get_option( 'active_plugins' );
+
+ foreach ( (array) $plugins as $plugin ) {
+ if ( basename( $plugin ) == 'widgets.php' ) {
+ array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
+ update_option( 'active_plugins', $plugins );
+ break;
+ }
+ }
+}
+
+?>
diff --git a/wp-admin/includes/upload.php b/wp-admin/includes/upload.php
new file mode 100644
index 0000000..61b042b
--- /dev/null
+++ b/wp-admin/includes/upload.php
@@ -0,0 +1,381 @@
+<?php
+
+function wp_upload_display( $dims = false, $href = '' ) {
+ global $post;
+ $id = get_the_ID();
+ $attachment_data = wp_get_attachment_metadata( $id );
+ $is_image = (int) wp_attachment_is_image();
+ $filesystem_path = get_attached_file( $id );
+ if ( !isset($attachment_data['width']) && $is_image ) {
+ if ( $image_data = getimagesize( $filesystem_path ) ) {
+ $attachment_data['width'] = $image_data[0];
+ $attachment_data['height'] = $image_data[1];
+ wp_update_attachment_metadata( $id, $attachment_data );
+ }
+ }
+ if ( isset($attachment_data['width']) )
+ list($width,$height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128);
+
+ $post_title = attribute_escape( the_title( '', '', false ) );
+ $post_content = attribute_escape(apply_filters( 'content_edit_pre', $post->post_content ));
+
+ $class = 'text';
+ $innerHTML = get_attachment_innerHTML( $id, false, $dims );
+ if ( $image_src = get_attachment_icon_src() ) {
+ $image_rel = wp_make_link_relative($image_src);
+ $innerHTML = '&nbsp;' . str_replace($image_src, $image_rel, $innerHTML);
+ $class = 'image';
+ }
+
+ $src_base = wp_get_attachment_url();
+ $src = wp_make_link_relative( $src_base );
+ $src_base = str_replace($src, '', $src_base);
+
+ $r = '';
+
+ if ( $href )
+ $r .= "<a id='file-link-$id' href='$href' title='$post_title' class='file-link $class'>\n";
+ if ( $href || $image_src )
+ $r .= "\t\t\t$innerHTML";
+ if ( $href )
+ $r .= "</a>\n";
+ $r .= "\t\t\t\t<span class='upload-file-size'>".size_format(filesize($filesystem_path))."</span>\n";
+ $r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
+ $r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='$src' />\n";
+ $r .= "\t\t\t\t<input type='hidden' name='attachment-url-base-$id' id='attachment-url-base-$id' value='$src_base' />\n";
+
+ if ( !$thumb_base = wp_get_attachment_thumb_url() )
+ $thumb_base = wp_mime_type_icon();
+ if ( $thumb_base ) {
+ $thumb_rel = wp_make_link_relative( $thumb_base );
+ $thumb_base = str_replace( $thumb_rel, '', $thumb_base );
+ $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$thumb_rel' />\n";
+ $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-$id' id='attachment-thumb-url-base-$id' value='$thumb_base' />\n";
+ }
+
+ $r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-$id' id='attachment-is-image-$id' value='$is_image' />\n";
+
+ if ( isset($width) ) {
+ $r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
+ $r .= "\t\t\t\t<input type='hidden' name='attachment-height-$id' id='attachment-height-$id' value='$height' />\n";
+ }
+ $r .= "\t\t\t\t<input type='hidden' name='attachment-page-url-$id' id='attachment-page-url-$id' value='" . get_attachment_link( $id ) . "' />\n";
+ $r .= "\t\t\t\t<input type='hidden' name='attachment-title-$id' id='attachment-title-$id' value='$post_title' />\n";
+ $r .= "\t\t\t\t<input type='hidden' name='attachment-description-$id' id='attachment-description-$id' value='$post_content' />\n";
+ $r .= "\t\t\t</p>\n\t\t</div>\n";
+ return $r;
+}
+
+function wp_upload_view() {
+ global $style, $post_id, $style;
+ $id = get_the_ID();
+ $attachment_data = wp_get_attachment_metadata( $id );
+?>
+ <div id="upload-file">
+ <div id="file-title">
+ <h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
+ echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
+ the_title();
+ if ( !isset($attachment_data['width']) && 'inline' != $style )
+ echo '</a>';
+ ?></h2>
+ <span><?php
+ echo '[&nbsp;';
+ echo '<a href="' . get_permalink() . '">' . __('view') . '</a>';
+ echo '&nbsp;|&nbsp;';
+ echo '<a href="' . clean_url(add_query_arg('action', 'edit')) . '" title="' . __('Edit this file') . '">' . __('edit') . '</a>';
+ echo '&nbsp;|&nbsp;';
+ echo '<a href="' . clean_url(remove_query_arg(array('action', 'ID'))) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
+ echo '&nbsp;]'; ?></span>
+ </div>
+
+ <div id="upload-file-view" class="alignleft">
+<?php if ( isset($attachment_data['width']) && 'inline' != $style )
+ echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
+ echo wp_upload_display( array(171, 128) );
+ if ( isset($attachment_data['width']) && 'inline' != $style )
+ echo '</a>'; ?>
+ </div>
+ <?php the_attachment_links( $id ); ?>
+ </div>
+<?php echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' ) . "' /></form>\n";
+}
+
+function wp_upload_form() {
+ $id = get_the_ID();
+ global $post_id, $tab, $style;
+ $enctype = $id ? '' : ' enctype="multipart/form-data"';
+ $post_id = (int) $post_id;
+?>
+ <form<?php echo $enctype; ?> id="upload-file" method="post" action="<?php echo get_option('siteurl') . '/wp-admin/upload.php?style=' . attribute_escape($style . '&amp;tab=upload&amp;post_id=' . $post_id); ?>">
+<?php
+ if ( $id ) :
+ $attachment = get_post_to_edit( $id );
+ $attachment_data = wp_get_attachment_metadata( $id );
+?>
+ <div id="file-title">
+ <h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
+ echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
+ the_title();
+ if ( !isset($attachment_data['width']) && 'inline' != $style )
+ echo '</a>';
+ ?></h2>
+ <span><?php
+ echo '[&nbsp;';
+ echo '<a href="' . get_permalink() . '">' . __('view') . '</a>';
+ echo '&nbsp;|&nbsp;';
+ echo '<a href="' . clean_url(add_query_arg('action', 'view')) . '">' . __('links') . '</a>';
+ echo '&nbsp;|&nbsp;';
+ echo '<a href="' . clean_url(remove_query_arg(array('action','ID'))) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
+ echo '&nbsp;]'; ?></span>
+ </div>
+
+ <div id="upload-file-view" class="alignleft">
+<?php if ( isset($attachment_data['width']) && 'inline' != $style )
+ echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
+ echo wp_upload_display( array(171, 128) );
+ if ( isset($attachment_data['width']) && 'inline' != $style )
+ echo '</a>'; ?>
+ </div>
+<?php endif; ?>
+ <table><col /><col class="widefat" />
+<?php if ( $id ): ?>
+ <tr>
+ <th scope="row"><label for="url"><?php _e('URL'); ?></label></th>
+ <td><input type="text" id="url" class="readonly" value="<?php echo wp_get_attachment_url(); ?>" readonly="readonly" /></td>
+ </tr>
+<?php else : ?>
+ <tr>
+ <th scope="row"><label for="upload"><?php _e('File'); ?></label></th>
+ <td><input type="file" id="upload" name="image" /></td>
+ </tr>
+<?php endif; ?>
+ <tr>
+ <th scope="row"><label for="post_title"><?php _e('Title'); ?></label></th>
+ <td><input type="text" id="post_title" name="post_title" value="<?php echo $attachment->post_title; ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><label for="post_content"><?php _e('Description'); ?></label></th>
+ <td><textarea name="post_content" id="post_content"><?php echo $attachment->post_content; ?></textarea></td>
+ </tr>
+ <tr id="buttons" class="submit">
+ <td colspan='2'>
+<?php if ( $id ) : ?>
+ <input type="submit" name="delete" id="delete" class="delete alignleft" value="<?php _e('Delete File'); ?>" />
+<?php else : ?>
+ <p class="alignleft" style="margin:.25em 0; padding: 4px 0;"><?php display_space_usage(); ?></p>
+<?php endif; ?>
+ <input type="hidden" name="from_tab" value="<?php echo $tab; ?>" />
+ <input type="hidden" name="action" value="<?php echo $id ? 'save' : 'upload'; ?>" />
+<?php if ( $post_id ) : ?>
+ <input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
+<?php endif; if ( $id ) : ?>
+ <input type="hidden" name="ID" value="<?php echo $id; ?>" />
+<?php endif; ?>
+ <?php wp_nonce_field( 'inlineuploading' ); ?>
+ <div class="submit">
+ <input type="submit" value="<?php $id ? _e('Save &raquo;') : _e('Upload &raquo;'); ?>" />
+ </div>
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php
+}
+
+function display_space_usage() {
+ $space = get_space_allowed();
+ $percentused = ( intval( get_dirsize( constant( "ABSPATH" ) . constant( "UPLOADS" ) )/1024/1024 ) / $space ) * 100;
+ $buymore = '';
+ if( $space < 10000 )
+ $buymore = '<a target="_blank" title="opens in new window" href="/wp-admin/paid-upgrades.php">Buy more</a>'; // open in new window in case they have a post open
+
+ /*
+ if( $space < 10000 ) {
+ $buymore = '<a target="_blank" title="opens in new window" href="/wp-admin/paid-upgrades.php">Buy more space</a>'; // open in new window in case they have a post open
+ if( get_option( 'use_upgraded_upload_filetypes' ) != '1' ) { $buymore .= __( " and you can upload " ) . str_replace( " ", ", ", get_site_option( "upgraded_upload_filetypes" ) ) . __(" files");}
+ }
+ */
+ if( $space > 1000 ) {
+ $space = number_format( $space / 1024 );
+ $space .= "GB";
+ } else {
+ $space .= "MB";
+ }
+ ?>
+ <strong>Used: <?php echo number_format( $percentused ) ?>% of <?php echo $space . ". $buymore" ?></strong>
+ <?php
+}
+
+function wp_upload_tab_upload() {
+ wp_upload_form();
+}
+
+function wp_upload_tab_upload_action() {
+ global $action;
+ if ( isset($_POST['delete']) )
+ $action = 'delete';
+
+ switch ( $action ) :
+ case 'upload' :
+ global $from_tab, $post_id, $style;
+ if ( !$from_tab )
+ $from_tab = 'upload';
+
+ check_admin_referer( 'inlineuploading' );
+
+ global $post_id, $post_title, $post_content;
+
+ if ( !current_user_can( 'upload_files' ) )
+ wp_die( __('You are not allowed to upload files.')
+ . " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=" . attribute_escape($style . "&amp;tab=browse-all&amp;post_id=$post_id") . "'>"
+ . __('Browse Files') . '</a>'
+ );
+
+ $overrides = array('action'=>'upload');
+
+ $file = wp_handle_upload($_FILES['image'], $overrides);
+
+ if ( isset($file['error']) )
+ wp_die($file['error'] . "<br /><a href='" . get_option('siteurl')
+ . "/wp-admin/upload.php?style=" . attribute_escape($style . "&amp;tab=$from_tab&amp;post_id=$post_id") . "'>" . __('Back to Image Uploading') . '</a>'
+ );
+
+ $url = $file['url'];
+ $type = $file['type'];
+ $file = $file['file'];
+ $filename = basename($file);
+
+ // Construct the attachment array
+ $attachment = array(
+ 'post_title' => $post_title,
+ 'post_content' => $post_content,
+ 'post_type' => 'attachment',
+ 'post_parent' => $post_id,
+ 'post_mime_type' => $type,
+ 'guid' => $url
+ );
+
+ // Save the data
+ $id = wp_insert_attachment($attachment, $file, $post_id);
+
+ wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
+
+ wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id");
+ die;
+ break;
+
+ case 'save' :
+ global $from_tab, $post_id, $style;
+ if ( !$from_tab )
+ $from_tab = 'upload';
+ check_admin_referer( 'inlineuploading' );
+
+ wp_update_post($_POST);
+ wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id");
+ die;
+ break;
+
+ case 'delete' :
+ global $ID, $post_id, $from_tab, $style;
+ if ( !$from_tab )
+ $from_tab = 'upload';
+
+ check_admin_referer( 'inlineuploading' );
+
+ if ( !current_user_can('edit_post', (int) $ID) )
+ wp_die( __('You are not allowed to delete this attachment.')
+ . " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=" . attribute_escape($style . "&amp;tab=$from_tab&amp;post_id=$post_id") . "'>"
+ . __('Go back') . '</a>'
+ );
+
+ wp_delete_attachment($ID);
+
+ wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id" );
+ die;
+ break;
+
+ endswitch;
+}
+
+add_action( 'upload_files_upload', 'wp_upload_tab_upload_action' );
+
+function wp_upload_grab_attachments( $obj ) {
+ $obj->is_attachment = true;
+}
+
+function wp_upload_posts_where( $where ) {
+ global $post_id;
+ return $where . " AND post_parent = '" . (int) $post_id . "'";
+}
+
+function wp_upload_tab_browse() {
+ global $action, $paged;
+ $old_vars = compact( 'paged' );
+
+ switch ( $action ) :
+ case 'edit' :
+ case 'view' :
+ global $ID;
+ $attachments = query_posts("attachment_id=$ID");
+ if ( have_posts() ) : while ( have_posts() ) : the_post();
+ 'edit' == $action ? wp_upload_form() : wp_upload_view();
+ endwhile; endif;
+ break;
+ default :
+ global $tab, $post_id, $style;
+ add_action( 'pre_get_posts', 'wp_upload_grab_attachments' );
+ if ( 'browse' == $tab && $post_id )
+ add_filter( 'posts_where', 'wp_upload_posts_where' );
+ $attachments = query_posts("what_to_show=posts&post_status=any&posts_per_page=10&paged=$paged");
+
+ echo "<ul id='upload-files'>\n";
+ if ( have_posts() ) : while ( have_posts() ) : the_post();
+ $href = wp_specialchars( add_query_arg( array(
+ 'action' => 'inline' == $style ? 'view' : 'edit',
+ 'ID' => get_the_ID())
+ ), 1 );
+
+ echo "\t<li id='file-";
+ the_ID();
+ echo "' class='alignleft'>\n";
+ echo wp_upload_display( array(128,128), $href );
+ echo "\t</li>\n";
+ endwhile;
+ else :
+ echo "\t<li>" . __('There are no attachments to show.') . "</li>\n";
+ endif;
+ echo "</ul>\n\n";
+
+ echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' ) . "' /></form>\n";
+ break;
+ endswitch;
+
+ extract($old_vars);
+
+ echo "<div class='clear'></div>";
+}
+
+
+function wp_upload_tab_browse_action() {
+ global $style;
+ if ( 'inline' == $style )
+ wp_enqueue_script('upload');
+}
+
+add_action( 'upload_files_browse', 'wp_upload_tab_browse_action' );
+add_action( 'upload_files_browse-all', 'wp_upload_tab_browse_action' );
+
+function wp_upload_admin_head() {
+ wp_admin_css( 'css/upload' );
+ if ( 'inline' == @$_GET['style'] ) {
+ echo "<style type='text/css' media='screen'>\n";
+ echo "\t#upload-menu { position: absolute; z-index: 2; }\n";
+ echo "\tbody > #upload-menu { position: fixed; }\n";
+ echo "\t#upload-content { top: 2em; }\n";
+ echo "\t#upload-file { position: absolute; top: 15px; }\n";
+ echo "</style>";
+ }
+}
+
+?>
diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php
new file mode 100644
index 0000000..ca15057
--- /dev/null
+++ b/wp-admin/includes/user.php
@@ -0,0 +1,284 @@
+<?php
+
+// Creates a new user from the "Users" form using $_POST information.
+function add_user() {
+ if ( func_num_args() ) { // The hackiest hack that ever did hack
+ global $current_user, $wp_roles;
+ $user_id = (int) func_get_arg( 0 );
+
+ if ( isset( $_POST['role'] ) ) {
+ if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap( 'edit_users' ) ) {
+ $user = new WP_User( $user_id );
+ $user->set_role( $_POST['role'] );
+ }
+ }
+ } else {
+ add_action( 'user_register', 'add_user' ); // See above
+ return edit_user();
+ }
+}
+
+function edit_user( $user_id = 0 ) {
+ global $current_user, $wp_roles, $wpdb;
+ if ( $user_id != 0 ) {
+ $update = true;
+ $user->ID = (int) $user_id;
+ $userdata = get_userdata( $user_id );
+ $user->user_login = $wpdb->escape( $userdata->user_login );
+ } else {
+ $update = false;
+ $user = '';
+ }
+
+ if ( isset( $_POST['user_login'] ))
+ $user->user_login = wp_specialchars( trim( $_POST['user_login'] ));
+
+ $pass1 = $pass2 = '';
+ if ( isset( $_POST['pass1'] ))
+ $pass1 = $_POST['pass1'];
+ if ( isset( $_POST['pass2'] ))
+ $pass2 = $_POST['pass2'];
+
+ if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) {
+ if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap( 'edit_users' ))
+ $user->role = $_POST['role'];
+ }
+
+ if ( isset( $_POST['email'] ))
+ $user->user_email = wp_specialchars( trim( $_POST['email'] ));
+ if ( isset( $_POST['url'] ) ) {
+ $user->user_url = clean_url( trim( $_POST['url'] ));
+ $user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
+ }
+ if ( isset( $_POST['first_name'] ))
+ $user->first_name = wp_specialchars( trim( $_POST['first_name'] ));
+ if ( isset( $_POST['last_name'] ))
+ $user->last_name = wp_specialchars( trim( $_POST['last_name'] ));
+ if ( isset( $_POST['nickname'] ))
+ $user->nickname = wp_specialchars( trim( $_POST['nickname'] ));
+ if ( isset( $_POST['display_name'] ))
+ $user->display_name = wp_specialchars( trim( $_POST['display_name'] ));
+ if ( isset( $_POST['description'] ))
+ $user->description = trim( $_POST['description'] );
+ if ( isset( $_POST['jabber'] ))
+ $user->jabber = wp_specialchars( trim( $_POST['jabber'] ));
+ if ( isset( $_POST['aim'] ))
+ $user->aim = wp_specialchars( trim( $_POST['aim'] ));
+ if ( isset( $_POST['yim'] ))
+ $user->yim = wp_specialchars( trim( $_POST['yim'] ));
+ if ( !$update )
+ $user->rich_editing = 'true'; // Default to true for new users.
+ else if ( isset( $_POST['rich_editing'] ) )
+ $user->rich_editing = $_POST['rich_editing'];
+ else
+ $user->rich_editing = 'false';
+
+ $errors = new WP_Error();
+
+ /* checking that username has been typed */
+ if ( $user->user_login == '' )
+ $errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ));
+
+ /* checking the password has been typed twice */
+ do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 ));
+
+ if (!$update ) {
+ if ( $pass1 == '' || $pass2 == '' )
+ $errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' ));
+ } else {
+ if ((empty ( $pass1 ) && !empty ( $pass2 ) ) || (empty ( $pass2 ) && !empty ( $pass1 ) ) )
+ $errors->add( 'pass', __( "<strong>ERROR</strong>: you typed your new password only once." ));
+ }
+
+ /* Check for "\" in password */
+ if( strpos( " ".$pass1, "\\" ) )
+ $errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ));
+
+ /* checking the password has been typed twice the same */
+ if ( $pass1 != $pass2 )
+ $errors->add( 'pass', __( '<strong>ERROR</strong>: Please type the same password in the two password fields.' ));
+
+ if (!empty ( $pass1 ))
+ $user->user_pass = $pass1;
+
+ if ( !$update && !validate_username( $user->user_login ) )
+ $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid. Please enter a valid username.' ));
+
+ if (!$update && username_exists( $user->user_login ))
+ $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered, please choose another one.' ));
+
+ /* checking e-mail address */
+ if ( empty ( $user->user_email ) ) {
+ $errors->add( 'user_email', __( "<strong>ERROR</strong>: please type an e-mail address" ));
+ } else
+ if (!is_email( $user->user_email ) ) {
+ $errors->add( 'user_email', __( "<strong>ERROR</strong>: the email address isn't correct" ));
+ }
+
+ if ( $errors->get_error_codes() )
+ return $errors;
+
+ if ( $update ) {
+ $user_id = wp_update_user( get_object_vars( $user ));
+ } else {
+ $user_id = wp_insert_user( get_object_vars( $user ));
+ wp_new_user_notification( $user_id );
+ }
+ return $user_id;
+}
+
+function get_author_user_ids() {
+ global $wpdb;
+ // wpmu site admins don't have user_levels
+ $level_key = $wpdb->prefix . 'capabilities';
+
+ $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value != '0'";
+
+ return $wpdb->get_col( $query );
+}
+
+function get_editable_authors( $user_id ) {
+ global $wpdb;
+
+ $editable = get_editable_user_ids( $user_id );
+
+ if( !$editable ) {
+ return false;
+ } else {
+ $editable = join(',', $editable);
+ $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
+ }
+
+ return apply_filters('get_editable_authors', $authors);
+}
+
+function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
+ global $wpdb;
+
+ $user = new WP_User( $user_id );
+
+ if ( ! $user->has_cap('edit_others_posts') ) {
+ if ( $user->has_cap('edit_posts') || $exclude_zeros == false )
+ return array($user->id);
+ else
+ return false;
+ }
+
+ // wpmu site admins don't have user_levels
+ $level_key = $wpdb->prefix . 'capabilities';
+
+ $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'";
+ if ( $exclude_zeros )
+ $query .= " AND meta_value != 'a:1:{s:10:\"subscriber\";b:1;}'";
+
+ return $wpdb->get_col( $query );
+}
+
+function get_nonauthor_user_ids() {
+ global $wpdb;
+ // wpmu site admins don't have user_levels
+ $level_key = $wpdb->prefix . 'capabilities';
+
+ $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key' AND meta_value = '0'";
+
+ return $wpdb->get_col( $query );
+}
+
+function get_others_unpublished_posts($user_id, $type='any') {
+ global $wpdb;
+ $user = get_userdata( $user_id );
+ $level_key = $wpdb->prefix . 'user_level';
+
+ $editable = get_editable_user_ids( $user_id );
+
+ if ( in_array($type, array('draft', 'pending')) )
+ $type_sql = " post_status = '$type' ";
+ else
+ $type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
+
+ $dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
+
+ if( !$editable ) {
+ $other_unpubs = '';
+ } else {
+ $editable = join(',', $editable);
+ $other_unpubs = $wpdb->get_results("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != '$user_id' ORDER BY post_modified $dir");
+ }
+
+ return apply_filters('get_others_drafts', $other_unpubs);
+}
+
+function get_others_drafts($user_id) {
+ return get_others_unpublished_posts($user_id, 'draft');
+}
+
+function get_others_pending($user_id) {
+ return get_others_unpublished_posts($user_id, 'pending');
+}
+
+function get_user_to_edit( $user_id ) {
+ $user = new WP_User( $user_id );
+ $user->user_login = attribute_escape($user->user_login);
+ $user->user_email = attribute_escape($user->user_email);
+ $user->user_url = clean_url($user->user_url);
+ $user->first_name = attribute_escape($user->first_name);
+ $user->last_name = attribute_escape($user->last_name);
+ $user->display_name = attribute_escape($user->display_name);
+ $user->nickname = attribute_escape($user->nickname);
+ $user->aim = attribute_escape($user->aim);
+ $user->yim = attribute_escape($user->yim);
+ $user->jabber = attribute_escape($user->jabber);
+ $user->description = wp_specialchars($user->description);
+
+ return $user;
+}
+
+function get_users_drafts( $user_id ) {
+ global $wpdb;
+ $user_id = (int) $user_id;
+ $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = $user_id ORDER BY post_modified DESC";
+ $query = apply_filters('get_users_drafts', $query);
+ return $wpdb->get_results( $query );
+}
+
+function wp_delete_user($id, $reassign = 'novalue') {
+ global $wpdb;
+
+ $id = (int) $id;
+ $user = get_userdata($id);
+
+ if ($reassign == 'novalue') {
+ $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
+
+ if ($post_ids) {
+ foreach ($post_ids as $post_id)
+ wp_delete_post($post_id);
+ }
+
+ // Clean links
+ $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
+ } else {
+ $reassign = (int) $reassign;
+ $wpdb->query("UPDATE $wpdb->posts SET post_author = {$reassign} WHERE post_author = {$id}");
+ $wpdb->query("UPDATE $wpdb->links SET link_owner = {$reassign} WHERE link_owner = {$id}");
+ }
+
+ // FINALLY, delete user
+ do_action('delete_user', $id);
+
+ $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$wpdb->prefix}capabilities'");
+
+ wp_cache_delete($id, 'users');
+ wp_cache_delete($user->user_login, 'userlogins');
+
+ return true;
+}
+
+function wp_revoke_user($id) {
+ $id = (int) $id;
+
+ $user = new WP_User($id);
+ $user->remove_all_caps();
+}
+
+?>
diff --git a/wp-admin/index-extra.php b/wp-admin/index-extra.php
index b3d38e9..a516f8b 100644
--- a/wp-admin/index-extra.php
+++ b/wp-admin/index-extra.php
@@ -2,15 +2,19 @@
require_once('admin.php');
require_once (ABSPATH . WPINC . '/rss.php');
-@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
switch ( $_GET['jax'] ) {
case 'incominglinks' :
-$rss = @fetch_rss(apply_filters( 'dashboard_incoming_links_feed', 'http://feeds.technorati.com/cosmos/rss/?url='. trailingslashit(get_option('home')) .'&partner=wordpress' ));
+
+$rss_feed = apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?hl=en&scoring=d&ie=utf-8&num=10&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) );
+$more_link = apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?hl=en&scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) );
+
+$rss = @fetch_rss( $rss_feed );
if ( isset($rss->items) && 1 < count($rss->items) ) { // Technorati returns a 1-item feed when it has no results
?>
-<h3><?php _e('Incoming Links'); ?> <cite><a href="<?php echo apply_filters( 'dashboard_incoming_links_link', 'http://www.technorati.com/search/'. trailingslashit(get_option('home')) .'?partner=wordpress' ); ?>"><?php _e('More &raquo;'); ?></a></cite></h3>
+<h3><?php _e('Incoming Links'); ?> <cite><a href="<?php echo htmlspecialchars( $more_link ); ?>"><?php _e('More &raquo;'); ?></a></cite></h3>
<ul>
<?php
$rss->items = array_slice($rss->items, 0, 10);
@@ -60,7 +64,7 @@ $post = preg_replace( '|.+?:(.+)|s', '$1', $item['title'] );
}
?>
</ul>
-<p class="readmore"><a href="<?php echo apply_filters( 'dashboard_secondary_link', 'http://planet.wordpress.org/' ); ?>"><?php _e('Read more'); ?> &raquo;</a></p>
+<p class="readmore"><a href="<?php echo apply_filters( 'dashboard_secondary_link', 'http://planet.wordpress.org/' ); ?>"><?php _e('Read more &raquo;'); ?></a></p>
<?php
}
break;
diff --git a/wp-admin/index.php b/wp-admin/index.php
index 7e70aec..2447e2f 100644
--- a/wp-admin/index.php
+++ b/wp-admin/index.php
@@ -1,23 +1,22 @@
<?php
-require_once('admin.php');
+require_once('admin.php');
function index_js() {
?>
<script type="text/javascript">
-Event.observe( window, 'load', dashboard_init, false );
-function dashboard_init() {
- var update1 = new Ajax.Updater( 'incominglinks', 'index-extra.php?jax=incominglinks' );
- var update2 = new Ajax.Updater( 'devnews', 'index-extra.php?jax=devnews' );
- var update3 = new Ajax.Updater( 'planetnews', 'index-extra.php?jax=planetnews' );
-}
+ jQuery(function() {
+ jQuery('#incominglinks').load('index-extra.php?jax=incominglinks');
+ jQuery('#devnews').load('index-extra.php?jax=devnews');
+ jQuery('#planetnews').load('index-extra.php?jax=planetnews');
+ });
</script>
<?php
}
add_action( 'admin_head', 'index_js' );
-wp_enqueue_script('prototype');
-wp_enqueue_script('interface');
-$title = __('Dashboard');
+wp_enqueue_script( 'jquery' );
+
+$title = __('Dashboard');
$parent_file = 'index.php';
require_once('admin-header.php');
@@ -40,17 +39,17 @@ $numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE commen
if ( $comments || $numcomments ) :
?>
<div>
-<h3><?php _e('Comments'); ?> <a href="edit-comments.php" title="<?php _e('More comments...'); ?>">&raquo;</a></h3>
+<h3><?php printf( __( 'Comments <a href="%s" title="More comments&#8230;">&raquo;</a>' ), 'edit-comments.php' ); ?></h3>
<?php if ( $numcomments ) : ?>
-<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format($numcomments) ); ?> &raquo;</a></strong></p>
+<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s) &raquo;'), number_format_i18n($numcomments) ); ?></a></strong></p>
<?php endif; ?>
<ul>
<?php
if ( $comments ) {
foreach ($comments as $comment) {
- echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . apply_filters('the_title', get_the_title($comment->comment_post_ID)) . '</a>');
+ echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');
edit_comment_link(__("Edit"), ' <small>(', ')</small>');
echo '</li>';
}
@@ -64,7 +63,7 @@ foreach ($comments as $comment) {
if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :
?>
<div>
-<h3><?php _e('Posts'); ?> <a href="edit.php" title="<?php _e('More posts...'); ?>">&raquo;</a></h3>
+<h3><?php printf( __( 'Posts <a href="%s" title="More posts&#8230;">&raquo;</a>' ), 'edit.php' ); ?></h3>
<ul>
<?php
foreach ($recentposts as $post) {
@@ -101,14 +100,16 @@ foreach ($scheduled as $post) {
<?php
$numposts = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");
$numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
-$numcats = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories");
+$numcats = wp_count_terms('category');
+$numtags = wp_count_terms('post_tag');
-$post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format($numposts), 'edit.php');
-$comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format($numcomms), 'edit-comments.php');
-$cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format($numcats), 'categories.php');
+$post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format_i18n($numposts), 'edit.php');
+$comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format_i18n($numcomms), 'edit-comments.php');
+$cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format_i18n($numcats), 'categories.php');
+$tag_str = sprintf(__ngettext('%1$s tag', '%1$s tags', $numtags), number_format_i18n($numtags));
?>
-<p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s.'), $post_str, $comm_str, $cat_str); ?></p>
+<p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s and %4$s.'), $post_str, $comm_str, $cat_str, $tag_str); ?></p>
</div>
<?php do_action('activity_box_end'); ?>
diff --git a/wp-admin/cat.js b/wp-admin/js/cat.js
index e93adfc..e697e9b 100644
--- a/wp-admin/cat.js
+++ b/wp-admin/js/cat.js
@@ -4,7 +4,8 @@ function newCatAddIn() {
var jaxcat = $('jaxcat');
if ( !jaxcat )
return false;
- Element.update(jaxcat,'<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="' + catL10n.add + '"/><input type="hidden"/><span id="howto">' + catL10n.how + '</span></span>');
+ // These multiple blank hidden inputs are needed: https://bugzilla.mozilla.org/show_bug.cgi?id=377815 , #3895 , #4664
+ Element.update(jaxcat,'<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="' + catL10n.add + '"/><input type="hidden"/><input type="hidden"/><span id="howto">' + catL10n.how + '</span></span>');
$('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); };
$('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); };
}
diff --git a/wp-admin/categories.js b/wp-admin/js/categories.js
index 515d530..3cee6c6 100644
--- a/wp-admin/categories.js
+++ b/wp-admin/js/categories.js
@@ -1,16 +1,16 @@
-addLoadEvent(function() {
- if (!theList.theList) return false;
- document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); };
- theList.addComplete = function(what, where, update, transport) {
- var name = getNodeValue(transport.responseXML, 'name').unescapeHTML();
- var id = transport.responseXML.getElementsByTagName(what)[0].getAttribute('id');
- var options = document.forms['addcat'].category_parent.options;
- options[options.length] = new Option(name, id);
- };
- theList.delComplete = function(what, id) {
- var options = document.forms['addcat'].category_parent.options;
- for ( var o = 0; o < options.length; o++ )
- if ( id == options[o].value )
- options[o] = null;
- };
-});
+addLoadEvent(function() {
+ if (!theList.theList) return false;
+ document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); };
+ theList.addComplete = function(what, where, update, transport) {
+ var name = getNodeValue(transport.responseXML, 'name').unescapeHTML();
+ var id = transport.responseXML.getElementsByTagName(what)[0].getAttribute('id');
+ var options = document.forms['addcat'].category_parent.options;
+ options[options.length] = new Option(name, id);
+ };
+ theList.delComplete = function(what, id) {
+ var options = document.forms['addcat'].category_parent.options;
+ for ( var o = 0; o < options.length; o++ )
+ if ( id == options[o].value )
+ options[o] = null;
+ };
+});
diff --git a/wp-admin/custom-fields.js b/wp-admin/js/custom-fields.js
index ad7a2db..ad7a2db 100644
--- a/wp-admin/custom-fields.js
+++ b/wp-admin/js/custom-fields.js
diff --git a/wp-admin/dbx-admin-key.js b/wp-admin/js/dbx-admin-key.js
index 3b3f7af..3b3f7af 100644
--- a/wp-admin/dbx-admin-key.js
+++ b/wp-admin/js/dbx-admin-key.js
diff --git a/wp-admin/edit-comments.js b/wp-admin/js/edit-comments.js
index e1fc68f..e1fc68f 100644
--- a/wp-admin/edit-comments.js
+++ b/wp-admin/js/edit-comments.js
diff --git a/wp-admin/js/link-cat.js b/wp-admin/js/link-cat.js
new file mode 100644
index 0000000..a0775ce
--- /dev/null
+++ b/wp-admin/js/link-cat.js
@@ -0,0 +1,10 @@
+addLoadEvent(function(){linkcatList=new listMan('linkcategorychecklist');linkcatList.ajaxRespEl='jaxcat';linkcatList.topAdder=1;linkcatList.alt=0;linkcatList.showLink=0;});
+addLoadEvent(newLinkCatAddIn);
+function newLinkCatAddIn() {
+ var jaxcat = $('jaxcat');
+ if ( !jaxcat )
+ return false;
+ Element.update(jaxcat,'<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="' + linkcatL10n.add + '"/><input type="hidden"/><span id="howto">' + linkcatL10n.how + '</span></span>');
+ $('newcat').onkeypress = function(e) { return killSubmit("linkcatList.ajaxAdder('link-category','jaxcat');", e); };
+ $('catadd').onclick = function() { linkcatList.ajaxAdder('link-category', 'jaxcat'); };
+}
diff --git a/wp-admin/upload.js b/wp-admin/js/upload.js
index a77e9d1..d38cdcb 100644
--- a/wp-admin/upload.js
+++ b/wp-admin/js/upload.js
@@ -5,18 +5,38 @@ addLoadEvent( function() {
tab: '',
postID: 0,
+ toQueryParams: function(qryStrOrig) {
+ var params = new Object();
+ var qryStr = qryStrOrig;
+ var i = 0;
+ do {
+ params[qryStr.split("=")[0].replace(/&/, "")] = ( qryStr.split("=")[1] ) ? qryStr.split("=")[1].split(/&|$/)[0] : '';
+ qryStr = ( qryStr.split("=")[1] ) ? qryStr.split(qryStr.split("=")[1].split(/&|$/)[0])[1] : '';
+ i++;
+ }
+ while(i < (qryStrOrig.split("=").length - 1));
+ return params;
+ },
+
+ toQueryString: function(params) {
+ var qryStr = '';
+ for ( var key in params )
+ qryStr += key + '=' + params[key] + '&';
+ return qryStr;
+ },
+
initializeVars: function() {
this.urlData = document.location.href.split('?');
- this.params = this.urlData[1].toQueryParams();
+ this.params = this.toQueryParams(this.urlData[1]);
this.postID = this.params['post_id'];
this.tab = this.params['tab'];
this.style = this.params['style'];
this.ID = this.params['ID'];
if ( !this.style )
this.style = 'default';
- var nonceEl = $('nonce-value');
+ var nonceEl = jQuery('#nonce-value');
if ( nonceEl )
- this.nonce = nonceEl.value;
+ this.nonce = jQuery(nonceEl).val();
if ( this.ID ) {
this.grabImageData( this.ID );
this.imageView( this.ID );
@@ -26,36 +46,38 @@ addLoadEvent( function() {
initializeLinks: function() {
if ( this.ID )
return;
- $$('a.file-link').each( function(i) {
- var id = i.id.split('-').pop();
- i.onclick = function(e) { theFileList[ 'inline' == theFileList.style ? 'imageView' : 'editView' ](id, e); }
- } );
+ jQuery('a.file-link').each(function() {
+ var id = jQuery(this).attr('id').split('-').pop();
+ jQuery(this).attr('href','javascript:void(0)').click(function(e) {
+ theFileList[ 'inline' == theFileList.style ? 'imageView' : 'editView' ](id, e);
+ });
+ });
},
grabImageData: function(id) {
if ( id == this.currentImage.ID )
return;
- var thumbEl = $('attachment-thumb-url-' + id);
+ var thumbEl = jQuery('#attachment-thumb-url-' + id);
if ( thumbEl ) {
- this.currentImage.thumb = ( 0 == id ? '' : thumbEl.value );
- this.currentImage.thumbBase = ( 0 == id ? '' : $('attachment-thumb-url-base-' + id).value );
+ this.currentImage.thumb = ( 0 == id ? '' : jQuery(thumbEl).val() );
+ this.currentImage.thumbBase = ( 0 == id ? '' : jQuery('#attachment-thumb-url-base-' + id).val() );
} else {
this.currentImage.thumb = false;
}
- this.currentImage.src = ( 0 == id ? '' : $('attachment-url-' + id).value );
- this.currentImage.srcBase = ( 0 == id ? '' : $('attachment-url-base-' + id).value );
- this.currentImage.page = ( 0 == id ? '' : $('attachment-page-url-' + id).value );
- this.currentImage.title = ( 0 == id ? '' : $('attachment-title-' + id).value );
- this.currentImage.description = ( 0 == id ? '' : $('attachment-description-' + id).value );
- var widthEl = $('attachment-width-' + id);
+ this.currentImage.src = ( 0 == id ? '' : jQuery('#attachment-url-' + id).val() );
+ this.currentImage.srcBase = ( 0 == id ? '' : jQuery('#attachment-url-base-' + id).val() );
+ this.currentImage.page = ( 0 == id ? '' : jQuery('#attachment-page-url-' + id).val() );
+ this.currentImage.title = ( 0 == id ? '' : jQuery('#attachment-title-' + id).val() );
+ this.currentImage.description = ( 0 == id ? '' : jQuery('#attachment-description-' + id).val() );
+ var widthEl = jQuery('#attachment-width-' + id);
if ( widthEl ) {
- this.currentImage.width = ( 0 == id ? '' : widthEl.value );
- this.currentImage.height = ( 0 == id ? '' : $('attachment-height-' + id).value );
+ this.currentImage.width = ( 0 == id ? '' : jQuery(widthEl).val() );
+ this.currentImage.height = ( 0 == id ? '' : jQuery('#attachment-height-' + id).val() );
} else {
this.currentImage.width = false;
this.currentImage.height = false;
}
- this.currentImage.isImage = ( 0 == id ? 0 : $('attachment-is-image-' + id).value );
+ this.currentImage.isImage = ( 0 == id ? 0 : jQuery('#attachment-is-image-' + id).val() );
this.currentImage.ID = id;
},
@@ -65,10 +87,10 @@ addLoadEvent( function() {
h += "<div id='upload-file'>"
if ( this.ID ) {
- var params = $H(this.params);
+ var params = this.params;
params.ID = '';
params.action = '';
- h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "'";
+ h += "<a href='" + this.urlData[0] + '?' + this.toQueryString(params) + "'";
} else {
h += "<a href='#' onclick='return theFileList.cancelView();'";
}
@@ -108,7 +130,7 @@ addLoadEvent( function() {
if ( display.length ) {
display.push("<br /><label for='display-title'><input type='radio' name='display' id='display-title' value='title' /> " + this.title + "</label>");
h += "<tr><th style='padding-bottom:.5em'>" + this.show + "</th><td style='padding-bottom:.5em'>";
- $A(display).each( function(i) { h += i; } );
+ jQuery(display).each( function() { h += this; } );
h += "</td></tr>";
}
@@ -125,12 +147,9 @@ addLoadEvent( function() {
h += "</div>";
- new Insertion.Top('upload-content', h);
- var displayEl = $(checked);
- if ( displayEl )
- displayEl.checked = true;
-
- if (e) Event.stop(e);
+ jQuery(h).prependTo('#upload-content');
+ jQuery('#' + checked).attr('checked','checked');
+ if (e) return e.stopPropagation();
return false;
},
@@ -144,10 +163,10 @@ addLoadEvent( function() {
h += "<form id='upload-file' method='post' action='" + action + "'>";
if ( this.ID ) {
- var params = $H(this.params);
+ var params = this.params;
params.ID = '';
params.action = '';
- h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "'";
+ h += "<a href='" + this.urlData[0] + '?' + this.toQueryString(params) + "'";
} else {
h += "<a href='#' onclick='return theFileList.cancelView();'";
}
@@ -182,23 +201,24 @@ addLoadEvent( function() {
h += "<td><textarea name='post_content' id='post_content'>" + this.currentImage.description + "</textarea></td>";
h += "</tr><tr id='buttons' class='submit'><td colspan='2'><input type='button' id='delete' name='delete' class='delete alignleft' value='" + this.deleteText + "' onclick='theFileList.deleteFile(" + id + ");' />";
h += "<input type='hidden' name='from_tab' value='" + this.tab + "' />";
+ h += "<input type='hidden' name='post_parent' value='" + parseInt(this.postID,10) + "' />";
h += "<input type='hidden' name='action' id='action-value' value='save' />";
h += "<input type='hidden' name='ID' value='" + id + "' />";
h += "<input type='hidden' name='_wpnonce' value='" + this.nonce + "' />";
h += "<div class='submit'><input type='submit' value='" + this.saveText + "' /></div>";
h += "</td></tr></table></form>";
- new Insertion.Top('upload-content', h);
- if (e) Event.stop(e);
+ jQuery(h).prependTo('#upload-content');
+ if (e) e.stopPropagation();
return false;
},
prepView: function(id) {
this.cancelView( true );
- var filesEl = $('upload-files');
+ var filesEl = jQuery('#upload-files');
if ( filesEl )
filesEl.hide();
- var navEl = $('current-tab-nav');
+ var navEl = jQuery('#current-tab-nav');
if ( navEl )
navEl.hide();
this.grabImageData(id);
@@ -206,18 +226,18 @@ addLoadEvent( function() {
cancelView: function( prep ) {
if ( !prep ) {
- var filesEl = $('upload-files');
+ var filesEl = jQuery('#upload-files');
if ( filesEl )
- Element.show(filesEl);
- var navEl = $('current-tab-nav');
+ jQuery(filesEl).show();
+ var navEl = jQuery('#current-tab-nav');
if ( navEl )
- Element.show(navEl);
+ jQuery(navEl).show();
}
if ( !this.ID )
this.grabImageData(0);
- var div = $('upload-file');
+ var div = jQuery('#upload-file');
if ( div )
- Element.remove(div);
+ jQuery(div).remove();
return false;
},
@@ -227,10 +247,10 @@ addLoadEvent( function() {
var display = '';
var h = '';
- link = $A(document.forms.uploadoptions.elements.link).detect( function(i) { return i.checked; } ).value;
- displayEl = $A(document.forms.uploadoptions.elements.display).detect( function(i) { return i.checked; } )
+ link = jQuery('input[@type=radio][@name="link"][@checked]','#uploadoptions').val();
+ displayEl = jQuery('input[@type=radio][@name="display"][@checked]','#uploadoptions');
if ( displayEl )
- display = displayEl.value;
+ display = jQuery(displayEl).val();
else if ( 1 == this.currentImage.isImage )
display = 'full';
@@ -259,15 +279,17 @@ addLoadEvent( function() {
deleteFile: function(id) {
if ( confirm( this.confirmText.replace(/%title%/g, this.currentImage.title) ) ) {
- $('action-value').value = 'delete';
- $('upload-file').submit();
+ jQuery('#action-value').attr('value','delete');
+ jQuery('#upload-file').submit();
return true;
}
return false;
}
};
- Object.extend( theFileList, uploadL10n );
+
+ for ( var property in uploadL10n )
+ theFileList[property] = uploadL10n[property];
theFileList.initializeVars();
theFileList.initializeLinks();
} );
diff --git a/wp-admin/users.js b/wp-admin/js/users.js
index f249f65..f249f65 100644
--- a/wp-admin/users.js
+++ b/wp-admin/js/users.js
diff --git a/wp-admin/xfn.js b/wp-admin/js/xfn.js
index 9bcde19..2fe41eb 100644
--- a/wp-admin/xfn.js
+++ b/wp-admin/js/xfn.js
@@ -43,4 +43,4 @@ function blurry() {
}
}
-addLoadEvent(blurry);
+addLoadEvent(blurry); \ No newline at end of file
diff --git a/wp-admin/link-add.php b/wp-admin/link-add.php
index 1e48fe8..2b06d8e 100644
--- a/wp-admin/link-add.php
+++ b/wp-admin/link-add.php
@@ -13,7 +13,7 @@ wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',
wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
if ( current_user_can( 'manage_categories' ) )
- wp_enqueue_script( 'ajaxcat' );
+ wp_enqueue_script( 'ajaxlinkcat' );
require('admin-header.php');
?>
diff --git a/wp-admin/link-category.php b/wp-admin/link-category.php
new file mode 100644
index 0000000..4205892
--- /dev/null
+++ b/wp-admin/link-category.php
@@ -0,0 +1,71 @@
+<?php
+require_once('admin.php');
+
+wp_reset_vars(array('action', 'cat'));
+
+switch($action) {
+
+case 'addcat':
+
+ check_admin_referer('add-link-category');
+
+ if ( !current_user_can('manage_categories') )
+ wp_die(__('Cheatin&#8217; uh?'));
+
+ if ( wp_insert_term($_POST['name'], 'link_category', $_POST ) ) {
+ wp_redirect('edit-link-categories.php?message=1#addcat');
+ } else {
+ wp_redirect('edit-link-categories.php?message=4#addcat');
+ }
+ exit;
+break;
+
+case 'delete':
+ $cat_ID = (int) $_GET['cat_ID'];
+ check_admin_referer('delete-link-category_' . $cat_ID);
+
+ if ( !current_user_can('manage_categories') )
+ wp_die(__('Cheatin&#8217; uh?'));
+
+ $cat_name = get_term_field('name', $cat_ID, 'link_category');
+
+ // Don't delete the default cats.
+ if ( $cat_ID == get_option('default_link_category') )
+ wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
+
+ wp_delete_term($cat_ID, 'link_category');
+
+ wp_redirect('edit-link-categories.php?message=2');
+ exit;
+
+break;
+
+case 'edit':
+ $title = __('Categories');
+ $parent_file = 'link-manager.php';
+ $submenu_file = 'edit-link-categories.php';
+ require_once ('admin-header.php');
+ $cat_ID = (int) $_GET['cat_ID'];
+ $category = get_term_to_edit($cat_ID, 'link_category');
+ include('edit-link-category-form.php');
+ include('admin-footer.php');
+ exit;
+break;
+
+case 'editedcat':
+ $cat_ID = (int) $_POST['cat_ID'];
+ check_admin_referer('update-link-category_' . $cat_ID);
+
+ if ( !current_user_can('manage_categories') )
+ wp_die(__('Cheatin&#8217; uh?'));
+
+ if ( wp_update_term($cat_ID, 'link_category', $_POST) )
+ wp_redirect('edit-link-categories.php?message=3');
+ else
+ wp_redirect('edit-link-categories.php?message=5');
+
+ exit;
+break;
+}
+
+?>
diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php
index f602097..ade3143 100644
--- a/wp-admin/link-manager.php
+++ b/wp-admin/link-manager.php
@@ -76,11 +76,11 @@ if ( isset($_GET['deleted']) ) {
<p><?php _e('Here you <a href="link-add.php">add links</a> to sites that you visit often and share them on your blog. When you have a list of links in your sidebar to other blogs, it&#8217;s called a &#8220;blogroll.&#8221;'); ?></p>
<form id="cats" method="get" action="">
<p><?php
-$categories = get_categories("hide_empty=1&type=link");
+$categories = get_terms('link_category', "hide_empty=1");
$select_cat = "<select name=\"cat_id\">\n";
$select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('All') . "</option>\n";
foreach ((array) $categories as $cat)
- $select_cat .= '<option value="' . $cat->cat_ID . '"' . (($cat->cat_ID == $cat_id) ? " selected='selected'" : '') . '>' . wp_specialchars(apply_filters('link_category', $cat->cat_name)) . "</option>\n";
+ $select_cat .= '<option value="' . $cat->term_id . '"' . (($cat->term_id == $cat_id) ? " selected='selected'" : '') . '>' . sanitize_term_field('name', $cat->name, $cat->term_id, 'link_category', 'display') . "</option>\n";
$select_cat .= "</select>\n";
$select_order = "<select name=\"order_by\">\n";
@@ -131,9 +131,8 @@ if ( $links ) {
<tbody id="the-list">
<?php
foreach ($links as $link) {
- $link->link_name = attribute_escape(apply_filters('link_title', $link->link_name));
- $link->link_description = wp_specialchars(apply_filters('link_description', $link->link_description));
- $link->link_url = clean_url($link->link_url);
+ $link = sanitize_bookmark($link);
+ $link->link_name = attribute_escape($link->link_name);
$link->link_category = wp_get_link_cats($link->link_id);
$short_url = str_replace('http://', '', $link->link_url);
$short_url = str_replace('www.', '', $short_url);
@@ -159,8 +158,10 @@ if ( $links ) {
?><td><?php
$cat_names = array();
foreach ($link->link_category as $category) {
- $cat_name = get_the_category_by_ID($category);
- $cat_name = wp_specialchars(apply_filters('link_category', $cat_name));
+ $cat = get_term($category, 'link_category', OBJECT, 'display');
+ if ( is_wp_error( $cat ) )
+ echo $cat->get_error_message();
+ $cat_name = $cat->name;
if ( $cat_id != $category )
$cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
$cat_names[] = $cat_name;
@@ -195,7 +196,7 @@ if ( $links ) {
<div id="ajax-response"></div>
-<p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Links') ?> &raquo;" onclick="return confirm('<?php echo js_escape(__("You are about to delete these links permanently.\n'Cancel' to stop, 'OK' to delete.")); ?>')" /></p>
+<p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Links &raquo;') ?>" onclick="return confirm('<?php echo js_escape(__("You are about to delete these links permanently.\n'Cancel' to stop, 'OK' to delete.")); ?>')" /></p>
</form>
<?php } ?>
diff --git a/wp-admin/link.php b/wp-admin/link.php
index 425e912..464943a 100644
--- a/wp-admin/link.php
+++ b/wp-admin/link.php
@@ -93,7 +93,7 @@ switch ($action) {
case 'edit' :
wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
if ( current_user_can( 'manage_categories' ) )
- wp_enqueue_script( 'ajaxcat' );
+ wp_enqueue_script( 'ajaxlinkcat' );
$parent_file = 'link-manager.php';
$submenu_file = 'link-manager.php';
$title = __('Edit Link');
diff --git a/wp-admin/menu.php b/wp-admin/menu.php
index affd314..f03138e 100644
--- a/wp-admin/menu.php
+++ b/wp-admin/menu.php
@@ -50,6 +50,7 @@ $submenu['edit.php'][40] = array(__('Export'), 'import', 'export.php');
$submenu['link-manager.php'][5] = array(__('Manage Blogroll'), 'manage_links', 'link-manager.php');
$submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php');
$submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php');
+$submenu['link-manager.php'][30] = array(__('Categories'), 'manage_links', 'edit-link-categories.php');
if ( current_user_can('edit_users') ) {
$_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
@@ -109,7 +110,7 @@ foreach ($submenu as $parent => $sub) {
// Menus for which the original parent is not acessible due to lack of privs will have the next
// submenu in line be assigned as the new menu parent.
foreach ( $menu as $id => $data ) {
- if ( empty($submenu[$data[2]]) )
+ if ( empty($submenu[$data[2]]) )
continue;
$subs = $submenu[$data[2]];
$first_sub = array_shift($subs);
diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php
index e24a9a1..2048a6e 100644
--- a/wp-admin/moderation.php
+++ b/wp-admin/moderation.php
@@ -1,206 +1,226 @@
<?php
-require_once('admin.php');
-$title = __('Moderate comments');
+require_once './admin.php';
+
+$title = __( 'Moderate Comments' );
$parent_file = 'edit-comments.php';
+
wp_enqueue_script( 'admin-comments' );
-wp_reset_vars(array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky'));
+wp_reset_vars( array( 'action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky' ) );
$comment = array();
-if (isset($_POST["comment"])) {
- foreach ($_POST["comment"] as $k => $v) {
- $comment[intval($k)] = $v;
+
+if ( isset( $_POST['comment'] ) && is_array( $_POST['comment'] ) ) {
+ foreach ( $_POST['comment'] as $k => $v ) {
+ $comment[intval( $k )] = $v;
}
}
-switch($action) {
-
-case 'update':
+if ( $action == 'update' ) {
+ check_admin_referer( 'moderate-comments' );
- check_admin_referer('moderate-comments');
-
- if ( !current_user_can('moderate_comments') )
- wp_die(__('Your level is not high enough to moderate comments.'));
+ if ( !current_user_can( 'moderate_comments' ) ) {
+ wp_die( __( 'Your level is not high enough to moderate comments.' ) );
+ }
$item_ignored = 0;
$item_deleted = 0;
$item_approved = 0;
$item_spam = 0;
- foreach($comment as $key => $value) {
- if ($feelinglucky && 'later' == $value)
- $value = 'delete';
- switch($value) {
- case 'later':
- // do nothing with that comment
- // wp_set_comment_status($key, "hold");
- ++$item_ignored;
- break;
- case 'delete':
- wp_set_comment_status($key, 'delete');
- ++$item_deleted;
- break;
- case 'spam':
- wp_set_comment_status($key, 'spam');
- ++$item_spam;
- break;
- case 'approve':
- wp_set_comment_status($key, 'approve');
- if ( get_option('comments_notify') == true ) {
- wp_notify_postauthor($key);
- }
- ++$item_approved;
- break;
+ foreach ( $comment as $k => $v ) {
+ if ( $feelinglucky && $v == 'later' ) {
+ $v = 'delete';
}
- }
- $file = basename(__FILE__);
- wp_redirect("$file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam");
- exit();
+ switch ( $v ) {
+ case 'later' :
+ $item_ignored++;
+ break;
-break;
+ case 'delete' :
+ wp_set_comment_status( $k, 'delete' );
+ $item_deleted++;
+ break;
-default:
+ case 'spam' :
+ wp_set_comment_status( $k, 'spam' );
+ $item_spam++;
+ break;
-require_once('admin-header.php');
+ case 'approve' :
+ wp_set_comment_status( $k, 'approve' );
-if ( isset($_GET['deleted']) || isset($_GET['approved']) || isset($_GET['ignored']) ) {
- echo "<div id='moderated' class='updated fade'>\n<p>";
- $approved = (int) $_GET['approved'];
- $deleted = (int) $_GET['deleted'];
- $ignored = (int) $_GET['ignored'];
- $spam = (int) $_GET['spam'];
- if ($approved) {
- printf(__ngettext('%s comment approved', '%s comments approved', $approved), $approved);
- echo "<br/>\n";
- }
- if ($deleted) {
- printf(__ngettext('%s comment deleted', '%s comments deleted', $deleted), $deleted);
- echo "<br/>\n";
- }
- if ($spam) {
- printf(__ngettext('%s comment marked as spam', '%s comments marked as spam', $spam), $spam);
- echo "<br/>\n";
- }
- if ($ignored) {
- printf(__ngettext('%s comment unchanged', '%s comments unchanged', $ignored), $ignored);
- echo "<br/>\n";
+ if ( get_option( 'comments_notify' ) == true ) {
+ wp_notify_postauthor( $k );
+ }
+
+ $item_approved++;
+ break;
+ }
}
- echo "</p></div>\n";
+
+ wp_redirect( basename( __FILE__ ) . '?ignored=' . $item_ignored . '&deleted=' . $item_deleted . '&approved=' . $item_approved . '&spam=' . $item_spam );
+ exit;
}
-?>
+require_once './admin-header.php';
-<div class="wrap">
+if ( !current_user_can( 'moderate_comments' ) ) {
+ echo '<div class="wrap"><p>' . __( 'Your level is not high enough to moderate comments.' ) . '</p></div>';
+ include_once './admin-footer.php';
+ exit;
+}
-<?php
-if ( current_user_can('moderate_comments') )
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'");
-else
- $comments = '';
-
-if ($comments) {
- // list all comments that are waiting for approval
- $file = basename(__FILE__);
-?>
- <h2><?php _e('Moderation Queue') ?></h2>
- <form name="approval" action="moderation.php" method="post">
- <?php wp_nonce_field('moderate-comments') ?>
- <input type="hidden" name="action" value="update" />
- <ol id="the-comment-list" class="commentlist">
-<?php
-$i = 0;
- foreach($comments as $comment) {
- ++$i;
- $comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date);
- $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'");
- if ($i % 2) $class = 'js-unapproved alternate';
- else $class = 'js-unapproved';
- echo "\n\t<li id='comment-$comment->comment_ID' class='$class'>";
- ?>
- <p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
-<?php comment_text() ?>
-<p><?php comment_date(__('M j, g:i A')); ?> &#8212; [ <?php
-echo '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'">' . __('Edit') . '</a> | ';
-echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author )) . "', theCommentList );\">" . __('Delete') . "</a> | "; ?>
-<?php
-$post = get_post($comment->comment_post_ID);
-$post_title = wp_specialchars( $post->post_title, 'double' );
-$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
-?>
-<a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] &#8212;
- <?php _e('Bulk action:') ?>
- <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-approve" value="approve" /> <label for="comment-<?php echo $comment->comment_ID; ?>-approve"><?php _e('Approve') ?></label> &nbsp;
- <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-spam" value="spam" /> <label for="comment-<?php echo $comment->comment_ID; ?>-spam"><?php _e('Spam') ?></label> &nbsp;
- <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-delete" value="delete" /> <label for="comment-<?php echo $comment->comment_ID; ?>-delete"><?php _e('Delete') ?></label> &nbsp;
- <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-nothing" value="later" checked="checked" /> <label for="comment-<?php echo $comment->comment_ID; ?>-nothing"><?php _e('Defer until later') ?></label>
- </p>
-
- </li>
-<?php
- }
-?>
- </ol>
+if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) {
+ $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
+ $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
+ $spam = isset( $_GET['ignored'] ) ? (int) $_GET['spam'] : 0;
-<div id="ajax-response"></div>
+ if ( $approved > 0 || $deleted > 0 || $spam > 0 ) {
+ echo '<div id="moderated" class="updated fade"><p>';
-<p class="submit"><input type="submit" name="submit" value="<?php _e('Bulk Moderate Comments &raquo;') ?>" /></p>
-<script type="text/javascript">
-// <![CDATA[
-function markAllForDelete() {
- for (var i=0; i< document.approval.length; i++) {
- if (document.approval[i].value == "delete") {
- document.approval[i].checked = true;
- }
- }
-}
-function markAllForApprove() {
- for (var i=0; i< document.approval.length; i++) {
- if (document.approval[i].value == "approve") {
- document.approval[i].checked = true;
+ if ( $approved > 0 ) {
+ printf( __ngettext( '%s comment approved.', '%s comments approved.', $approved ), $approved );
+ echo '<br />';
}
- }
-}
-function markAllForDefer() {
- for (var i=0; i< document.approval.length; i++) {
- if (document.approval[i].value == "later") {
- document.approval[i].checked = true;
+
+ if ( $deleted > 0 ) {
+ printf( __ngettext( '%s comment deleted', '%s comments deleted.', $deleted ), $deleted );
+ echo '<br />';
}
- }
-}
-function markAllAsSpam() {
- for (var i=0; i< document.approval.length; i++) {
- if (document.approval[i].value == "spam") {
- document.approval[i].checked = true;
+
+ if ( $spam > 0 ) {
+ printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
+ echo '<br />';
}
+
+ echo '</p></div>';
}
}
-document.write('<ul><li><a href="javascript:markAllForApprove()"><?php _e('Mark all for approval'); ?></a></li><li><a href="javascript:markAllAsSpam()"><?php _e('Mark all as spam'); ?></a></li><li><a href="javascript:markAllForDelete()"><?php _e('Mark all for deletion'); ?></a></li><li><a href="javascript:markAllForDefer()"><?php _e('Mark all for later'); ?></a></li></ul>');
-// ]]>
-</script>
-
-<noscript>
- <p>
- <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked "defer." <strong>Warning: This can&#8217;t be undone.</strong>'); ?></label>
- </p>
-</noscript>
-</form>
-<?php
-} else {
- // nothing to approve
- echo '<p>'.__("Currently there are no comments for you to moderate.") . "</p>\n";
-}
+
?>
+<div class="wrap">
+<?php
-</div>
+$comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'" );
-<?php
+if ( !$comments ) {
+ echo '<p>' . __( 'Currently there are no comments for you to moderate.' ) . '</p></div>';
+ include_once './admin-footer.php';
+ exit;
+}
-break;
+$total = count( $comments );
+$per = 100;
+
+if ( isset( $_GET['paged'] ) ) {
+ $page = (int) $_GET['paged'];
+} else {
+ $page = 1;
}
+$start = ( $page * $per ) - $per;
+$stop = $start + $per;
-include('admin-footer.php');
+$page_links = paginate_links( array(
+ 'base' => add_query_arg( 'paged', '%#%' ),
+ 'format' => '',
+ 'total' => ceil( $total / $per ),
+ 'current' => $page,
+ 'prev_text' => '&laquo;',
+ 'next_text' => '&raquo;'
+) );
+
+$comments = array_slice( $comments, $start, $stop );
?>
+ <h2><?php _e( 'Moderation Queue' ); ?></h2>
+
+ <?php
+ if ( $page_links ) {
+ echo '<p class="pagenav">' . $page_links . '</p>';
+ }
+ ?>
+
+ <form name="approval" id="approval" action="<?php echo basename( __FILE__ ); ?>" method="post">
+ <?php wp_nonce_field( 'moderate-comments' ); ?>
+ <input type="hidden" name="action" value="update" />
+ <ol id="the-comments-list" class="commentlist">
+ <?php
+ $i = 0;
+
+ foreach ( $comments as $comment ) {
+ $class = 'js-unapproved';
+
+ if ( $i++ % 2 ) {
+ $class .= ' alternate';
+ }
+ ?>
+ <li id="comment-<?php comment_ID(); ?>" class="<?php echo $class; ?>">
+ <p>
+ <strong><?php comment_author(); ?></strong>
+ <?php if ( !empty( $comment->comment_author_email ) ) { ?>| <?php comment_author_email_link(); ?> <?php } ?>
+ <?php if ( !empty( $comment->comment_author_url ) && $comment->comment_author_url != 'http://' ) { ?>| <?php comment_author_url_link(); ?> <?php } ?>
+ | <?php _e( 'IP:' ); ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP(); ?>"><?php comment_author_IP(); ?></a>
+ </p>
+
+ <p>
+ <?php comment_text(); ?>
+ </p>
+
+ <p><small>
+ <?php comment_date( __( 'M j, g:i A' ) ); ?> &#8212;
+ [ <a href="comment.php?action=editcomment&amp;c=<?php comment_ID(); ?>" title="<?php _e( 'Edit this comment' ); ?>"><?php _e( 'Edit' ); ?></a> |
+ <a href="post.php?action=deletecomment&amp;p=<?php echo $comment->comment_post_ID; ?>" title="<?php _e( 'Delete this comment' ); ?>" onclick="return deleteSomething( 'comment', <?php comment_ID(); ?>, '<?php echo js_escape( sprintf( __( "You are about to delete this comment by '%s'.\n'OK' to delete, 'Cancel' to stop." ), get_comment_author() ) ); ?>', theCommentList );"><?php _e( 'Delete' ); ?></a> ] &#8212;
+ <a href="<?php echo get_permalink( $comment->comment_post_ID ); ?>" title="<?php _e( 'View the post' ); ?>"><?php printf( __( 'View post &#8220;%s&#8221;' ), get_the_title( $comment->comment_post_ID ) ); ?></a>
+ </small></p>
+
+ <p><small>
+ <?php _e( 'Bulk action:' ); ?>
+ <label for="comment-<?php comment_ID(); ?>-approve"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-approve" value="approve" /> <?php _e( 'Approve' ); ?></label> &nbsp;
+ <label for="comment-<?php comment_ID(); ?>-spam"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-spam" value="spam" /> <?php _e( 'Spam' ); ?></label> &nbsp;
+ <label for="comment-<?php comment_ID(); ?>-delete"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-delete" value="delete" /> <?php _e( 'Delete' ); ?></label> &nbsp;
+ <label for="comment-<?php comment_ID(); ?>-nothing"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-nothing" value="later" checked="checked" /> <?php _e( 'No action' ); ?></label>
+ </small></p>
+ </li>
+ <?php
+ }
+ ?>
+ </ol>
+
+ <?php
+ if ( $page_links ) {
+ echo '<p class="pagenav">' . $page_links . '</p>';
+ }
+ ?>
+
+ <div id="ajax-response"></div>
+
+ <noscript>
+ <p class="submit">
+ <label for="feelinglucky"><input name="feelinglucky" id="feelinglucky" type="checkbox" value="true" /> <?php _e( 'Delete every comment marked &#8220;defer.&#8221; <strong>Warning: This can&#8217;t be undone.</strong>' ); ?></label>
+ </p>
+ </noscript>
+
+ <p class="submit">
+ <input type="submit" id="submit" name="submit" value="<?php _e( 'Bulk Moderate Comments &raquo;' ); ?>" />
+ </p>
+
+ <script type="text/javascript">
+ // <![CDATA[
+ function mark_all_as( what ) {
+ for ( var i = 0; i < document.approval.length; i++ ) {
+ if ( document.approval[i].value == what ) {
+ document.approval[i].checked = true;
+ }
+ }
+ }
+
+ document.write( '<p><strong><?php _e( 'Mark all:' ); ?></strong> <a href="javascript:mark_all_as(\'approve\')"><?php _e( 'Approved' ); ?></a> &ndash; <a href="javascript:mark_all_as(\'spam\')"><?php _e( 'Spam' ); ?></a> &ndash; <a href="javascript:mark_all_as(\'delete\')"><?php _e( 'Deleted' ); ?></a> &ndash; <a href="javascript:mark_all_as(\'later\')"><?php _e( 'Later' ); ?></a></p>' );
+ // ]]>
+ </script>
+ </form>
+</div>
+<?php include_once './admin-footer.php'; ?>
diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php
index 5791bc0..78deefd 100644
--- a/wp-admin/options-discussion.php
+++ b/wp-admin/options-discussion.php
@@ -7,78 +7,78 @@ $parent_file = 'options-general.php';
include('admin-header.php');
?>
-<div class="wrap">
-<h2><?php _e('Discussion Options') ?></h2>
-<form method="post" action="options.php">
+<div class="wrap">
+<h2><?php _e('Discussion Options') ?></h2>
+<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /></p>
<fieldset class="options">
-<legend><?php echo __('Usual settings for an article:').'<br /><small><em>('.__('These settings may be overridden for individual articles.').')</em></small>'; ?></legend>
-<ul>
-<li>
-<label for="default_pingback_flag">
-<input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_option('default_pingback_flag')); ?> />
-<?php _e('Attempt to notify any Weblogs linked to from the article (slows down posting.)') ?></label>
-</li>
-<li>
-<label for="default_ping_status">
-<input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_option('default_ping_status')); ?> />
-<?php _e('Allow link notifications from other Weblogs (pingbacks and trackbacks.)') ?></label>
-</li>
-<li>
-<label for="default_comment_status">
-<input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
-<?php _e('Allow people to post comments on the article') ?></label>
-</li>
-</ul>
+<legend><?php echo __('Usual settings for an article:').'<br /><small><em>('.__('These settings may be overridden for individual articles.').')</em></small>'; ?></legend>
+<ul>
+<li>
+<label for="default_pingback_flag">
+<input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_option('default_pingback_flag')); ?> />
+<?php _e('Attempt to notify any blogs linked to from the article (slows down posting.)') ?></label>
+</li>
+<li>
+<label for="default_ping_status">
+<input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_option('default_ping_status')); ?> />
+<?php _e('Allow link notifications from other blogs (pingbacks and trackbacks.)') ?></label>
+</li>
+<li>
+<label for="default_comment_status">
+<input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
+<?php _e('Allow people to post comments on the article') ?></label>
+</li>
+</ul>
</fieldset>
<fieldset class="options">
-<legend><?php _e('E-mail me whenever:') ?></legend>
-<ul>
-<li>
-<label for="comments_notify">
-<input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> />
-<?php _e('Anyone posts a comment') ?> </label>
-</li>
-<li>
-<label for="moderation_notify">
-<input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_option('moderation_notify')); ?> />
-<?php _e('A comment is held for moderation') ?> </label>
-</li>
-</ul>
+<legend><?php _e('E-mail me whenever:') ?></legend>
+<ul>
+<li>
+<label for="comments_notify">
+<input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> />
+<?php _e('Anyone posts a comment') ?> </label>
+</li>
+<li>
+<label for="moderation_notify">
+<input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_option('moderation_notify')); ?> />
+<?php _e('A comment is held for moderation') ?> </label>
+</li>
+</ul>
</fieldset>
<fieldset class="options">
-<legend><?php _e('Before a comment appears:') ?></legend>
+<legend><?php _e('Before a comment appears:') ?></legend>
<ul>
<li>
-<label for="comment_moderation">
-<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_option('comment_moderation')); ?> />
-<?php _e('An administrator must always approve the comment') ?> </label>
-</li>
-<li><label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label></li>
-<li><label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_option('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label></li>
-</ul>
+<label for="comment_moderation">
+<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_option('comment_moderation')); ?> />
+<?php _e('An administrator must always approve the comment') ?> </label>
+</li>
+<li><label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label></li>
+<li><label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_option('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label></li>
+</ul>
</fieldset>
<fieldset class="options">
<legend><?php _e('Comment Moderation') ?></legend>
<p><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" size="3" value="' . get_option('comment_max_links'). '" />' ) ?></p>
<p><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="moderation.php">moderation queue</a>. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></p>
-<p>
-<textarea name="moderation_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('moderation_keys'); ?></textarea>
-</p>
+<p>
+<textarea name="moderation_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('moderation_keys'); ?></textarea>
+</p>
</fieldset>
<fieldset class="options">
<legend><?php _e('Comment Blacklist') ?></legend>
<p><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></p>
-<p>
-<textarea name="blacklist_keys" cols="60" rows="4" id="blacklist_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('blacklist_keys'); ?></textarea>
+<p>
+<textarea name="blacklist_keys" cols="60" rows="4" id="blacklist_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('blacklist_keys'); ?></textarea>
</p>
</fieldset>
<p class="submit">
-<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="default_pingback_flag,default_ping_status,default_comment_status,comments_notify,moderation_notify,comment_moderation,require_name_email,comment_whitelist,comment_max_links,moderation_keys,blacklist_keys" />
-<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
+<input type="hidden" name="action" value="update" />
+<input type="hidden" name="page_options" value="default_pingback_flag,default_ping_status,default_comment_status,comments_notify,moderation_notify,comment_moderation,require_name_email,comment_whitelist,comment_max_links,moderation_keys,blacklist_keys" />
+<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
</p>
</form>
</div>
diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php
index 6a1f691..c768611 100644
--- a/wp-admin/options-general.php
+++ b/wp-admin/options-general.php
@@ -6,22 +6,22 @@ $parent_file = 'options-general.php';
include('./admin-header.php');
?>
-
+
<div class="wrap">
<h2><?php _e('General Options') ?></h2>
-<form method="post" action="options.php">
+<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /></p>
-<table class="optiontable">
-<tr valign="top">
-<th scope="row"><?php _e('Weblog title:') ?></th>
-<td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" size="40" /></td>
-</tr>
-<tr valign="top">
-<th scope="row"><?php _e('Tagline:') ?></th>
+<table class="optiontable">
+<tr valign="top">
+<th scope="row"><?php _e('Blog title:') ?></th>
+<td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" size="40" /></td>
+</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Tagline:') ?></th>
<td><input name="blogdescription" type="text" id="blogdescription" style="width: 95%" value="<?php form_option('blogdescription'); ?>" size="45" />
<br />
-<?php _e('In a few words, explain what this weblog is about.') ?></td>
+<?php _e('In a few words, explain what this blog is about.') ?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Membership:') ?></th>
@@ -71,8 +71,8 @@ if( is_array( $lang_files ) && count($lang_files) >= 1 ) {
<td><code><?php echo gmdate(__('Y-m-d g:i:s a')); ?></code></td>
</tr>
<tr>
-<th scope="row"><?php _e('Times in the weblog should differ by:') ?> </th>
-<td><input name="gmt_offset" type="text" id="gmt_offset" size="2" value="<?php form_option('gmt_offset'); ?>" />
+<th scope="row"><?php _e('Times in the blog should differ by:') ?> </th>
+<td><input name="gmt_offset" type="text" id="gmt_offset" size="2" value="<?php form_option('gmt_offset'); ?>" />
<?php _e('hours') ?> (<?php _e('Your timezone offset, for example <code>-6</code> for Central Time.'); ?>)</td>
</tr>
<tr>
@@ -84,7 +84,7 @@ if( is_array( $lang_files ) && count($lang_files) >= 1 ) {
<th scope="row"><?php _e('Default time format:') ?></th>
<td><input name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br />
<?php _e('Output:') ?> <strong><?php echo gmdate(get_option('time_format'), current_time('timestamp')); ?></strong></td>
-</tr>
+</tr>
<tr>
<th scope="row">&nbsp;</th>
<td><?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Update options" to update sample output.') ?> </td>
@@ -101,14 +101,14 @@ endfor;
</select></td>
</tr>
</table>
-</fieldset>
+</fieldset>
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
-<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="blogname,blogdescription,new_admin_email,users_can_register,gmt_offset,date_format,time_format,start_of_week,comment_registration,WPLANG,language" />
+<input type="hidden" name="action" value="update" />
+<input type="hidden" name="page_options" value="blogname,blogdescription,new_admin_email,users_can_register,gmt_offset,date_format,time_format,start_of_week,comment_registration,WPLANG,language" />
</p>
</form>
-</div>
+</div>
<?php include('./admin-footer.php') ?>
diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php
index 75792db..e4361b1 100644
--- a/wp-admin/options-permalink.php
+++ b/wp-admin/options-permalink.php
@@ -79,10 +79,21 @@ if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
}
$wp_rewrite->set_category_base($category_base);
}
+
+ if ( isset($_POST['tag_base']) ) {
+ $tag_base = $_POST['tag_base'];
+ if (! empty($tag_base) )
+ $tag_base = preg_replace('#/+#', '/', '/' . $_POST['tag_base']);
+ if( $tag_base != '' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) {
+ $tag_base = '/blog' . $tag_base;
+ }
+ $wp_rewrite->set_tag_base($tag_base);
+ }
}
$permalink_structure = get_option('permalink_structure');
$category_base = get_option('category_base');
+$tag_base = get_option( 'tag_base' );
if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
$writable = true;
@@ -99,16 +110,16 @@ $wp_rewrite->flush_rules();
<?php if (isset($_POST['submit'])) : ?>
<div id="message" class="updated fade"><p><?php
-if ($writable)
- _e('Permalink structure updated.');
+if ( $permalink_structure && !$usingpi && !$writable )
+ _e('You should update your .htaccess now.');
else
- _e('You should update your .htaccess now.');
+ _e('Permalink structure updated.');
?></p></div>
<?php endif; ?>
-<div class="wrap">
- <h2><?php _e('Customize Permalink Structure') ?></h2>
-<form name="form" action="options-permalink.php" method="post">
+<div class="wrap">
+ <h2><?php _e('Customize Permalink Structure') ?></h2>
+<form name="form" action="options-permalink.php" method="post">
<?php wp_nonce_field('update-permalink') ?>
<p class="submit"><input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>" /></p>
<p><?php _e('By default WordPress uses web <abbr title="Universal Resource Locator">URL</abbr>s which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
@@ -153,17 +164,20 @@ checked="checked"
<h3><?php _e('Optional'); ?></h3>
<?php if ($is_apache) : ?>
- <p><?php _e('If you like, you may enter a custom prefix for your category <abbr title="Universal Resource Locator">URL</abbr>s here. For example, <code>/taxonomy/tags</code> would make your category links like <code>http://example.org/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
+ <p><?php _e('If you like, you may enter custom bases for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>/topics/</code> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
<?php else : ?>
- <p><?php _e('If you like, you may enter a custom prefix for your category <abbr title="Universal Resource Locator">URL</abbr>s here. For example, <code>/index.php/taxonomy/tags</code> would make your category links like <code>http://example.org/index.php/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
+ <p><?php _e('If you like, you may enter custom bases for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>/topics/</code> as your category base would make your category links like <code>http://example.org/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p>
<?php endif; ?>
- <p>
- <?php _e('Category base'); ?>: <?php if( $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $category_base = str_replace( "/blog", "", $category_base ); }?><input name="category_base" type="text" class="code" value="<?php echo attribute_escape( $category_base ); ?>" size="30" />
- </p>
- <p class="submit">
- <input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>" />
- </p>
- </form>
+ <p>
+ <?php _e('Category base'); ?>: <?php if( $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $category_base = str_replace( "/blog", "", $category_base ); }?><input name="category_base" type="text" class="code" value="<?php echo attribute_escape( $category_base ); ?>" size="30" />
+ </p>
+ <p>
+ <?php _e('Tag base'); ?>: <?php if( $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $tag_base = str_replace( "/blog", "", $tag_base ); }?> <input name="tag_base" id="tag_base" type="text" class="code" value="<?php echo attribute_escape($tag_base); ?>" size="30" />
+ </p>
+ <p class="submit">
+ <input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>" />
+ </p>
+ </form>
<?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
<p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Make_a_Directory_Writable">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
<form action="options-permalink.php" method="post">
diff --git a/wp-admin/options-reading.php b/wp-admin/options-reading.php
index 9e0e8df..fbc08bc 100644
--- a/wp-admin/options-reading.php
+++ b/wp-admin/options-reading.php
@@ -7,25 +7,25 @@ $parent_file = 'options-general.php';
include('admin-header.php');
?>
-<div class="wrap">
-<h2><?php _e('Reading Options') ?></h2>
+<div class="wrap">
+<h2><?php _e('Reading Options') ?></h2>
<form name="form1" method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /></p>
<?php if ( get_pages() ): ?>
-<fieldset class="options">
-<legend><?php _e('Front Page') ?></legend>
-<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
-<tr valign="top">
-<th width="33%" scope="row"><?php _e('Front page displays:')?></th>
+<fieldset class="options">
+<legend><?php _e('Front Page') ?></legend>
+<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
+<tr valign="top">
+<th width="33%" scope="row"><?php _e('Front page displays:')?></th>
<td>
<p><label>
- <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked('posts', get_option('show_on_front')); ?> />
+ <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked('posts', get_option('show_on_front')); ?> />
<?php _e('Your latest posts'); ?>
</label>
</p>
<p><label>
- <input name="show_on_front" type="radio" value="page" class="tog" <?php checked('page', get_option('show_on_front')); ?> />
+ <input name="show_on_front" type="radio" value="page" class="tog" <?php checked('page', get_option('show_on_front')); ?> />
<?php printf(__('A <a href="%s">static page</a> (select below)'), 'edit-pages.php'); ?>
</label>
</p>
@@ -40,30 +40,30 @@ include('admin-header.php');
</p>
</div>
<?php endif; ?>
-</td>
-</tr>
-</table>
+</td>
+</tr>
+</table>
</fieldset>
<?php endif; ?>
-<fieldset class="options">
-<legend><?php _e('Blog Pages') ?></legend>
-<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
-<tr valign="top">
-<th width="33%" scope="row"><?php _e('Show at most:') ?></th>
+<fieldset class="options">
+<legend><?php _e('Blog Pages') ?></legend>
+<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
+<tr valign="top">
+<th width="33%" scope="row"><?php _e('Show at most:') ?></th>
<td>
<input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" /> <?php _e('posts') ?>
-</td>
-</tr>
-</table>
-</fieldset>
+</td>
+</tr>
+</table>
+</fieldset>
-<fieldset class="options">
-<legend><?php _e('Syndication Feeds') ?></legend>
-<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
-<tr valign="top">
-<th width="33%" scope="row"><?php _e('Show the most recent:') ?></th>
-<td><input name="posts_per_rss" type="text" id="posts_per_rss" value="<?php form_option('posts_per_rss'); ?>" size="3" /> <?php _e('posts') ?></td>
+<fieldset class="options">
+<legend><?php _e('Syndication Feeds') ?></legend>
+<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
+<tr valign="top">
+<th width="33%" scope="row"><?php _e('Show the most recent:') ?></th>
+<td><input name="posts_per_rss" type="text" id="posts_per_rss" value="<?php form_option('posts_per_rss'); ?>" size="3" /> <?php _e('posts') ?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('For each article, show:') ?> </th>
@@ -72,21 +72,21 @@ include('admin-header.php');
<label><input name="rss_use_excerpt" type="radio" value="1" <?php checked(1, get_option('rss_use_excerpt')); ?> /> <?php _e('Summary') ?></label></p>
<p><?php _e('Note: If you use the <code>&lt;!--more--&gt;</code> feature, it will cut off posts in RSS feeds.'); ?></p>
</td>
-</tr>
-</table>
-</fieldset>
-<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
-<tr valign="top">
-<th width="33%" scope="row"><?php _e('Encoding for pages and feeds:') ?></th>
+</tr>
+</table>
+</fieldset>
+<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
+<tr valign="top">
+<th width="33%" scope="row"><?php _e('Encoding for pages and feeds:') ?></th>
<td><input name="blog_charset" type="text" id="blog_charset" value="<?php form_option('blog_charset'); ?>" size="20" class="code" /><br />
-<?php _e('The character encoding you write your blog in (UTF-8 is <a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html">recommended</a>)') ?></td>
+<?php _e('The character encoding you write your blog in (UTF-8 is <a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html">recommended</a>)') ?></td>
</tr>
-</table>
-<p class="submit">
-<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="posts_per_page,posts_per_rss,rss_use_excerpt,blog_charset,show_on_front,page_on_front,page_for_posts" />
-<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
-</p>
-</form>
-</div>
+</table>
+<p class="submit">
+<input type="hidden" name="action" value="update" />
+<input type="hidden" name="page_options" value="posts_per_page,posts_per_rss,rss_use_excerpt,blog_charset,show_on_front,page_on_front,page_for_posts" />
+<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
+</p>
+</form>
+</div>
<?php include('./admin-footer.php'); ?>
diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php
index 1f70b74..6c0db1e 100644
--- a/wp-admin/options-writing.php
+++ b/wp-admin/options-writing.php
@@ -7,17 +7,17 @@ $parent_file = 'options-general.php';
include('admin-header.php');
?>
-<div class="wrap">
-<h2><?php _e('Writing Options') ?></h2>
-<form method="post" action="options.php">
+<div class="wrap">
+<h2><?php _e('Writing Options') ?></h2>
+<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /></p>
-<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
-<tr valign="top">
-<th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th>
-<td><input name="default_post_edit_rows" type="text" id="default_post_edit_rows" value="<?php form_option('default_post_edit_rows'); ?>" size="2" style="width: 1.5em; " />
-<?php _e('lines') ?></td>
-</tr>
+<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
+<tr valign="top">
+<th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th>
+<td><input name="default_post_edit_rows" type="text" id="default_post_edit_rows" value="<?php form_option('default_post_edit_rows'); ?>" size="2" style="width: 1.5em; " />
+<?php _e('lines') ?></td>
+</tr>
<tr valign="top">
<th scope="row"><?php _e('Formatting:') ?></th>
<td>
@@ -31,11 +31,12 @@ include('admin-header.php');
<th scope="row"><?php _e('Default post category:') ?></th>
<td><select name="default_category" id="default_category">
<?php
-$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
+$categories = get_categories('get=all');
foreach ($categories as $category) :
-if ($category->cat_ID == get_option('default_category')) $selected = " selected='selected'";
+$category = sanitize_category($category);
+if ($category->term_id == get_option('default_category')) $selected = " selected='selected'";
else $selected = '';
-echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
+echo "\n\t<option value='$category->term_id' $selected>$category->name</option>";
endforeach;
?>
</select></td>
@@ -44,18 +45,17 @@ endforeach;
<th scope="row"><?php _e('Default link category:') ?></th>
<td><select name="default_link_category" id="default_link_category">
<?php
-foreach ($categories as $category) :
-if ($category->cat_ID == get_option('default_link_category')) $selected = " selected='selected'";
+$link_categories = get_terms('link_category', 'get=all');
+foreach ($link_categories as $category) :
+$category = sanitize_term($category, 'link_category');
+if ($category->term_id == get_option('default_link_category')) $selected = " selected='selected'";
else $selected = '';
-echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
+echo "\n\t<option value='$category->term_id' $selected>$category->name</option>";
endforeach;
?>
</select></td>
</tr>
</table>
-
-
-
<p class="submit">
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,default_category,default_email_category,use_balanceTags,default_link_category" />
diff --git a/wp-admin/options.php b/wp-admin/options.php
index baccbe3..cb5763e 100644
--- a/wp-admin/options.php
+++ b/wp-admin/options.php
@@ -42,15 +42,14 @@ case 'update':
if ($options) {
foreach ($options as $option) {
$option = trim($option);
- $value = trim($_POST[$option]);
- $value = sanitize_option($option, $value); // This does stripslashes on those that need it
+ $value = $_POST[$option];
+ if(!is_array($value)) $value = trim($value);
+ $value = stripslashes_deep($value);
update_option($option, $value);
}
}
-
- $referred = remove_query_arg('updated' , wp_get_referer());
+
$goback = add_query_arg('updated', 'true', wp_get_referer());
- $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
wp_redirect($goback);
break;
@@ -98,7 +97,6 @@ foreach ( (array) $options as $option) :
else echo "<input class='$class' type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . attribute_escape($value) . "'$disabled />";
echo "</td>
- <td>$option->option_description</td>
</tr>";
endforeach;
?>
diff --git a/wp-admin/page-new.php b/wp-admin/page-new.php
index 7ed2cfa..ff86155 100644
--- a/wp-admin/page-new.php
+++ b/wp-admin/page-new.php
@@ -10,7 +10,7 @@ require_once('admin-header.php');
?>
<?php if ( (isset($_GET['posted']) && $_GET['posted']) || isset($_GET['saved']) ) : ?>
-<div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?></strong> <a href="edit-pages.php"><?php _e('Manage pages'); ?></a> | <a href="<?php echo get_page_link( isset($_GET['posted']) ? $_GET['posted'] : $_GET['saved'] ); ?>"><?php _e('View page') ; ?> &raquo;</a></p></div>
+<div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?></strong> <a href="edit-pages.php"><?php _e('Manage pages'); ?></a> | <a href="<?php echo get_page_link( isset($_GET['posted']) ? $_GET['posted'] : $_GET['saved'] ); ?>"><?php _e('View page &raquo;') ; ?></a></p></div>
<?php endif; ?>
<?php
@@ -23,4 +23,4 @@ if ( current_user_can('edit_pages') ) {
}
?>
-<?php include('admin-footer.php'); ?>
+<?php include('admin-footer.php'); ?>
diff --git a/wp-admin/page.php b/wp-admin/page.php
index 2825184..7a373e9 100644
--- a/wp-admin/page.php
+++ b/wp-admin/page.php
@@ -46,6 +46,8 @@ case 'edit':
$page_ID = $post_ID = $p = (int) $_GET['post'];
$post = get_post_to_edit($page_ID);
+ if ( empty($post->ID) ) wp_die( __("You attempted to edit a page that doesn't exist. Perhaps it was deleted?") );
+
if ( 'post' == $post->post_type ) {
wp_redirect("post.php?action=edit&post=$post_ID");
exit();
@@ -138,7 +140,7 @@ case 'delete':
if ( ! wp_delete_attachment($page_id) )
wp_die( __('Error in deleting...') );
} else {
- if ( !wp_delete_post($page_id) )
+ if ( !wp_delete_post($page_id) )
wp_die( __('Error in deleting...') );
}
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php
index 885994b..d2c7d48 100644
--- a/wp-admin/plugins.php
+++ b/wp-admin/plugins.php
@@ -18,7 +18,7 @@ if ( isset($_GET['action']) ) {
if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
wp_die(__('Plugin file does not exist.'));
if (!in_array($plugin, $current)) {
- wp_redirect('plugins.php?error=true'); // we'll override this later if the plugin can be included without fatal error
+ wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), 'plugins.php?error=true&plugin=' . $plugin)); // we'll override this later if the plugin can be included without fatal error
ob_start();
@include(ABSPATH . PLUGINDIR . '/' . $plugin);
$current[] = $plugin;
@@ -28,7 +28,15 @@ if ( isset($_GET['action']) ) {
ob_end_clean();
}
wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above
- } else if ('deactivate' == $_GET['action']) {
+ } elseif ('error_scrape' == $_GET['action']) {
+ $plugin = trim($_GET['plugin']);
+ check_admin_referer('plugin-activation-error_' . $plugin);
+ if ( validate_file($plugin) )
+ wp_die(__('Invalid plugin.'));
+ if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) )
+ wp_die(__('Plugin file does not exist.'));
+ include(ABSPATH . PLUGINDIR . '/' . $plugin);
+ } elseif ('deactivate' == $_GET['action']) {
check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
$current = get_option('active_plugins');
array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
@@ -38,12 +46,12 @@ if ( isset($_GET['action']) ) {
} elseif ($_GET['action'] == 'deactivate-all') {
check_admin_referer('deactivate-all');
$current = get_option('active_plugins');
-
+
foreach ($current as $plugin) {
array_splice($current, array_search($plugin, $current), 1);
do_action('deactivate_' . $plugin);
}
-
+
update_option('active_plugins', array());
wp_redirect('plugins.php?deactivate-all=true');
}
@@ -80,7 +88,15 @@ foreach ($check_plugins as $check_plugin) {
?>
<?php if ( isset($_GET['error']) ) : ?>
- <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p></div>
+ <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p>
+ <?php
+ $plugin = trim($_GET['plugin']);
+ if ( wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) && 1 == strtolower(ini_get('display_errors'))) { ?>
+ <iframe style="border:0" width="100%" height="70px" src="<?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&amp;plugin=<?php echo attribute_escape($plugin); ?>&amp;_wpnonce=<?php echo attribute_escape($_GET['_error_nonce']); ?>"></iframe>
+ <?php
+ }
+ ?>
+ </div>
<?php elseif ( isset($_GET['activate']) ) : ?>
<div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
<?php elseif ( isset($_GET['deactivate']) ) : ?>
@@ -142,7 +158,7 @@ if (empty($plugins)) {
<tr $style>
<td class='name'>{$plugin_data['Title']}</td>
<td class='vers'>{$plugin_data['Version']}</td>
- <td class='desc'><p>{$plugin_data['Description']} <cite>".sprintf(__('By %s'), $plugin_data['Author']).".</cite></p></td>
+ <td class='desc'><p>{$plugin_data['Description']}$author</p></td>
<td class='togl'>$toggle</td>";
echo"
</tr>";
diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php
index fd8a046..c6b709b 100644
--- a/wp-admin/post-new.php
+++ b/wp-admin/post-new.php
@@ -10,7 +10,7 @@ require_once ('./admin-header.php');
if ( ! current_user_can('edit_posts') ) { ?>
<div class="wrap">
-<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />
+<p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to add the <code>edit_posts</code> capability to your user, in order to be authorized to post.<br />
You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
When you&#8217;re promoted, just reload this page and you&#8217;ll be able to blog. :)'), get_option('admin_email')); ?>
</p>
@@ -21,34 +21,65 @@ When you&#8217;re promoted, just reload this page and you&#8217;ll be able to bl
}
if ( isset($_GET['posted']) && $_GET['posted'] ) : ?>
-<div id="message" class="updated fade"><p><strong><?php _e('Post saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?> &raquo;</a></p></div>
+<div id="message" class="updated fade"><p><strong><?php _e('Post saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post &raquo;'); ?></a></p></div>
<?php
endif;
+?>
-if ( $drafts = get_users_drafts( $user_ID ) ) { ?>
-<div class="wrap">
-<p><strong><?php _e('Your Drafts:') ?></strong>
-<?php
-// Show drafts.
- $num_drafts = count($drafts);
- if ( $num_drafts > 15 ) $num_drafts = 15;
- for ( $i = 0; $i < $num_drafts; $i++ ) {
- $draft = $drafts[$i];
- if ( 0 != $i )
- echo ', ';
- if ( empty($draft->post_title) )
- $draft->post_title = sprintf(__('Post # %s'), $draft->ID);
- echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
- }
- if ( 15 < count($drafts) ) { ?>
- , <a href="edit.php"><?php echo sprintf(__('and %s more'), (count($drafts) - 15) ); ?> &raquo;</a>
- <?php } ?>
-.</p>
-</div>
<?php
+$my_drafts = get_users_drafts($user_ID);
+$pending = get_others_pending($user_ID);
+$others_drafts = get_others_drafts($user_ID);
+
+$nag_posts_limit = (int) apply_filters('nag_posts_limit', 3);
+
+$nag_posts = array(
+ array(
+ 'my_drafts',
+ __('Your Drafts:'),
+ 'edit.php?post_status=draft&amp;author=' . $user_ID,
+ count($my_drafts)),
+ array(
+ 'pending',
+ __('Pending Review:'),
+ 'edit.php?post_status=pending',
+ count($pending)),
+ array(
+ 'others_drafts',
+ __('Others&#8217; Drafts:'),
+ 'edit.php?post_status=draft&author=-' . $user_ID,
+ count($others_drafts))
+ );
+
+if ( !empty($my_drafts) || !empty($pending) || !empty($others_drafts) ) {
+ echo '<div class="wrap" id="draft-nag">';
+
+ foreach ( $nag_posts as $nag ) {
+ if ( ${$nag[0]} ) {
+ echo '<p><strong>' . wp_specialchars($nag[1]) . '</strong> ';
+ $i = 0;
+ foreach ( ${$nag[0]} as $post ) {
+ $i++;
+ if ( $i > $nag_posts_limit )
+ break;
+ echo '<a href="post.php?action=edit&amp;post=' . $post->ID . '">';
+ ( '' == the_title('', '', FALSE) ) ? printf( __('Post #%s'), $post->ID ) : the_title();
+ echo '</a>';
+ if ( $i < min($nag[3], $nag_posts_limit) )
+ echo ', ';
+ }
+ if ( $nag[3] > $nag_posts_limit )
+ printf(__(', and <a href="%s">%d more</a>'), $nag[2], $nag[3] - $nag_posts_limit);
+ echo '.</p>';
+ }
+ }
+ echo "</div>\n";
}
+?>
+
+<?php
// Show post form.
$post = get_default_post_to_edit();
include('edit-form-advanced.php');
@@ -57,17 +88,17 @@ include('edit-form-advanced.php');
<?php if ( $is_NS4 || $is_gecko || $is_winIE ) { ?>
<div id="wp-bookmarklet" class="wrap">
<h3><?php _e('WordPress Bookmarklet'); ?></h3>
-<p><?php _e('Right click on the following link and choose "Add to favorites" to create a posting shortcut.'); ?></p>
+<p><?php _e('Right click on the following link and choose &#0147;Bookmark This Link...&#0148; or &#0147;Add to Favorites...&#0148; to create a posting shortcut.'); ?></p>
<p>
<?php
if ($is_NS4 || $is_gecko) {
?>
-<a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press It - %s'), wp_specialchars(get_option('blogname'))); ?></a>
+<a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press It - %s'), get_bloginfo('name', 'display')); ?></a>
<?php
} else if ($is_winIE) {
?>
-<a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
+<a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;location.href='<?php echo get_option('siteurl') ?>/wp-admin/post-new.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press it - %s'), get_bloginfo('name', 'display')); ?></a>
<script type="text/javascript">
<!--
function oneclickbookmarklet(blah) {
@@ -78,15 +109,15 @@ window.open ("profile.php?action=IErightclick", "oneclickbookmarklet", "width=50
<br />
<br />
<?php _e('One-click bookmarklet:') ?><br />
-<a href="javascript:oneclickbookmarklet(0);"><?php _e('click here') ?></a>
+<a href="javascript:oneclickbookmarklet(0);"><?php _e('click here') ?></a>
<?php
} else if ($is_opera) {
?>
-<a href="javascript:location.href='<?php echo get_option('siteurl'); ?>/wp-admin/post-new.php?popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
+<a href="javascript:location.href='<?php echo get_option('siteurl'); ?>/wp-admin/post-new.php?popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
<?php
} else if ($is_macIE) {
?>
-<a href="javascript:Q='';location.href='<?php echo get_option('siteurl'); ?>/wp-admin/bookmarklet.php?text='+escape(document.getSelection())+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
+<a href="javascript:Q='';location.href='<?php echo get_option('siteurl'); ?>/wp-admin/bookmarklet.php?text='+escape(document.getSelection())+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_option('blogname')); ?></a>
<?php
}
?>
diff --git a/wp-admin/post.php b/wp-admin/post.php
index 3006773..680f8ab 100644
--- a/wp-admin/post.php
+++ b/wp-admin/post.php
@@ -38,6 +38,9 @@ case 'post':
if ( isset($_POST['save']) )
$location = "post.php?action=edit&post=$post_ID";
+ if ( empty($post_ID) )
+ $location = 'post-new.php';
+
wp_redirect($location);
exit();
break;
@@ -48,6 +51,8 @@ case 'edit':
$post_ID = $p = (int) $_GET['post'];
$post = get_post($post_ID);
+ if ( empty($post->ID) ) wp_die( __("You attempted to edit a post that doesn't exist. Perhaps it was deleted?") );
+
if ( 'page' == $post->post_type ) {
wp_redirect("page.php?action=edit&post=$post_ID");
exit();
@@ -149,7 +154,7 @@ case 'delete':
if ( ! wp_delete_attachment($post_id) )
wp_die( __('Error in deleting...') );
} else {
- if ( !wp_delete_post($post_id) )
+ if ( !wp_delete_post($post_id) )
wp_die( __('Error in deleting...') );
}
diff --git a/wp-admin/profile.php b/wp-admin/profile.php
index 7654868..53d82b6 100644
--- a/wp-admin/profile.php
+++ b/wp-admin/profile.php
@@ -39,7 +39,7 @@ $bookmarklet_height= 440;
<p class="submit"><input type="submit" value="<?php _e('Update Profile &raquo;') ?>" name="submit" /></p>
-<fieldset>
+<fieldset id="information">
<legend><?php _e('Name'); ?></legend>
<p><label><?php _e('Username: (no editing)'); ?><br />
<input type="text" name="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
@@ -72,7 +72,7 @@ $bookmarklet_height= 440;
</select></label></p>
</fieldset>
-<fieldset>
+<fieldset id="contact-info">
<legend><?php _e('Contact Info'); ?></legend>
<p><label><?php _e('E-mail: (required)') ?><br />
@@ -95,7 +95,7 @@ $bookmarklet_height= 440;
</p>
</fieldset>
<br clear="all" />
-<fieldset>
+<fieldset id="about-yourself">
<legend><?php _e('About Yourself'); ?></legend>
<p class="desc"><?php _e('Share a little biographical information. '); ?></p>
<p><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p>
@@ -105,7 +105,7 @@ $bookmarklet_height= 440;
$show_password_fields = apply_filters('show_password_fields', true);
if ( $show_password_fields ) :
?>
-<fieldset>
+<fieldset id="update-password">
<legend><?php _e('Update Your Password'); ?></legend>
<p class="desc"><?php _e('If you would like to change your password type a new one twice below. Otherwise leave this blank.'); ?></p>
<p><label><?php _e('New Password:'); ?><br />
diff --git a/wp-admin/rtl.css b/wp-admin/rtl.css
index ebb6206..0dd46f6 100644
--- a/wp-admin/rtl.css
+++ b/wp-admin/rtl.css
@@ -1,247 +1,133 @@
-#viewarc, #viewcat, #namediv, #emaildiv, #uridiv, #planetnews li, #login ul li, #your-profile fieldset, #footer .logo, .alignleft .available-theme {
- float: right;
- }
-
-#templateside, .alignright {
- float: left;
+html,
+.dbx-handle,
+#post_name,
+input[name=link_url],
+input[name=link_image],
+input[name=opml_url],
+input[name=file],
+input#rss_uri,
+#template #newcontent,
+#devnews,
+#planetnews,
+#content,
+body.login #login a,
+#newcomment_author_url,
+#email {
+ direction: ltr;
}
-
-#login #send, .readmore, .widefat th {
- text-align: right;
+#adminmenu,
+#submenu,
+#minisub,
+.wrap,
+.updated,
+.confirm,
+#devnews h3,
+#planetnews h3,
+#wphead,
+#user_info,
+body.login,
+#login_error {
+ direction: rtl;
}
-
-#postcustomsubmit, form#upload th, .submit, .editform th {
+p.submit,
+.dbx-handle {
text-align: left;
}
-
-#devnews h4, #wphead h1, #your-profile legend, fieldset.options legend, #planetnews li .post {
- font-family: Tahoma, Georgia, "Times New Roman", Times, serif;
+html *,
+select,
+input,
+table * {
+ font-family: tahoma, Tahoma, "Times New Roman", Times, serif;
}
-
#wphead {
padding: .8em 2em .8em 19em;
}
-
-#wphead h1 {
- font-size: 2.4em;
- }
-
-#postdiv, #titlediv, #guiddiv, #tagdiv {
- margin: 0 0 0 8px;
- }
-
-#ed_toolbar input {
- margin: 3px 0 2px 2px;
- }
-
-#edButtons input, #edButtons input:active {
- margin: 0px 0 -1px 2px;
- }
-
-body, td {
- font: 13px Tahoma, "Lucida Grande", "Lucida Sans Unicode", Verdana;
- }
-
-h1, h2, h3, h4, h5 {
- font-family: "Times New Roman", Times, serif;
- }
-h3.dbx-handle {
- font-family: tahoma, Verdana, Arial, Helvetica, sans-serif;
- }
-
-textarea, input, select {
- font: 13px Tahoma, Verdana, Arial, Helvetica, sans-serif;
- }
-
-.quicktags, .search {
- font: 12px Tahoma, Georgia, "Times New Roman", Times, serif;
- }
-
-.updated, .confirm {
- padding: 0 3em 0 1em;
- }
-
-.submit input, .submit input:focus, .button, .button:focus {
- border-left-color: #999;
- border-right-color: #ccc;
- }
-
-.submit input:active, .button:active {
- border-left-color: #ccc;
- border-right-color: #999;
+#user_info {
+ right: auto;
+ left: 1em;
}
-
#adminmenu {
padding: .2em 2em .3em .2em;
height: 28px;
}
-
+* html #adminmenu {
+ padding-bottom: 0;
+ }
#adminmenu a {
margin: 0 0 0 10px;
display: block;
float: right;
font: 700 16px/130% "Times New Roman", Times, serif;
}
-
#adminmenu a.current {
border-right: 0;
border-left: 2px solid #4f96c8;
}
-
#submenu, #minisub {
padding: 1px 3em 0 2em;
}
-
#submenu {
height: 28px;
}
-
#submenu a {
margin: 0 0 0 10px;
display: block;
float: right;
line-height: 155%;
}
-
#submenu .current {
border-right: 0;
border-left: 2px solid #045290;
}
-
-#currenttheme img {
- float: right;
- margin-right: auto;
- margin-left: 1em;
- }
-
-#postdiv #quicktags {
- padding-right: 0;
- padding-left: 6px;
- }
-
-.readmore {
- margin-right: auto;
- margin-left: 5em;
+.dbx-content input, .dbx-content select {
+ margin-right: 8px;
}
-
-#postexcerpt div, #attachmentlinks div {
- margin-right: auto;
- margin-left: 8px;
+#newcat {
+ width: 100px;
}
-
-* html #postexcerpt .dbx-toggle-open {
- padding-right: 0;
- padding-left: 8px;
- }
-
-#searchform {
- float: right;
- margin-right: auto;
- margin-left: 1em;
+.updated, .confirm {
+ background-position: 98.5%;
+ padding: 0 3em 0 1em;
}
-
-#poststuff {
+.page-numbers {
margin-right: auto;
- margin-left: 16em;
+ margin-left: 3px;
}
-
-#template div {
- margin-right: auto;
- margin-left: 190px;
+.wrap ul {
+ margin-right: 45%;
+ margin-left: 0;
}
-
-* html #template div {
- margin-right: auto;
- margin-left: 0px;
+* html .wrap ul {
+ margin-right: 50%;
}
-
-#user_info {
- right: auto;
- left: 1em;
+.wrap h2 {
+ font-family: "Times New Roman", Times, serif;
}
-
#zeitgeist {
- float: left;
- margin-left: auto;
margin-right: 1em;
}
-
#zeitgeist ul {
margin: 0 .6em .3em 0;
padding: 0 .6em 0 0;
}
-
-.wrap ul {
- margin-left: 500px;
- }
-
#categorydiv ul {
margin-left: auto;
margin-right: 10px;
}
-
-#moremeta {
- margin-right: 0;
- margin-left: 15px;
- right: auto;
+a.view-link {
left: 6%;
- }
-
-#moremeta .dbx-content {
- background: url(images/box-butt.gif) no-repeat bottom left;
- padding-right: 10px;
- padding-left: 0;
- text-align: right;
- }
-
-#moremeta .dbx-handle {
- background: #2685af url(images/box-head.gif) no-repeat left;
- margin-top: -2px;
- }
-
-#moremeta .dbx-box {
- background: url(images/box-bg.gif) repeat-y left;
- padding-bottom: 0;
- }
-
-a.dbx-toggle, a.dbx-toggle:visited {
right: auto;
- left: 2px;
- }
-
-
-#categorychecklist {
margin-right: auto;
- margin-left: 6px;
- }
-
-#ajax-response.alignleft {
- margin-left: auto;
- margin-right: 2em;
- }
-
-#postdivrich #edButtons {
- padding-left: 0;
- padding-right: 3px;
- }
-
-.page-numbers {
- margin-right: auto;
- margin-left: 3px;
}
-
-a.view-link {
- right:auto;
- left:5%;
- margin-right:0;
- margin-left:220px;
- }
-#advancedstuff {
- direction: ltr;
+#postdiv #quicktags {
+ padding-right: 0;
+ padding-left: 6px;
+ margin-right: 0;
}
-#advancedstuff .dbx-handle {
- text-align: right;
+.options ul {
+ margin-right: 0;
}
-#advancedstuff .dbx-content * {
- direction: rtl;
+*form#template > div > textarea#newcontent {
+ margin-right: -300px;
+ width: 107%;
}
diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php
index 41e9787..139ccd3 100644
--- a/wp-admin/setup-config.php
+++ b/wp-admin/setup-config.php
@@ -2,19 +2,28 @@
die();
define('WP_INSTALLING', true);
+require_once('../wp-includes/compat.php');
+require_once('../wp-includes/functions.php');
+
if (!file_exists('../wp-config-sample.php'))
- die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
+ wp_die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
$configFile = file('../wp-config-sample.php');
-if (!is_writable('../')) die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually.");
+if ( !is_writable('../'))
+ wp_die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually.");
+// Check if wp-config.php has been created
+if (file_exists('../wp-config.php'))
+ wp_die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p>");
if (isset($_GET['step']))
$step = $_GET['step'];
else
$step = 0;
-header( 'Content-Type: text/html; charset=utf-8' );
+
+function display_header(){
+ header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -77,12 +86,11 @@ header( 'Content-Type: text/html; charset=utf-8' );
<body>
<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
<?php
-// Check if wp-config.php has been created
-if (file_exists('../wp-config.php'))
- die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p></body></html>");
+}//end function display_header();
switch($step) {
case 0:
+ display_header();
?>
<p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
@@ -99,6 +107,7 @@ switch($step) {
break;
case 1:
+ display_header();
?>
</p>
<form method="post" action="setup-config.php?step=2">
@@ -178,6 +187,8 @@ switch($step) {
}
fclose($handle);
chmod('../wp-config.php', 0666);
+
+ display_header();
?>
<p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to <a href="install.php">run the install!</a></p>
<?php
diff --git a/wp-admin/sidebar.php b/wp-admin/sidebar.php
index a2ea264..830a7e2 100644
--- a/wp-admin/sidebar.php
+++ b/wp-admin/sidebar.php
@@ -13,7 +13,7 @@ if ('b' == $_GET['a']) {
<head>
<title>WordPress &#8250; Posted</title>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=UTF-8" />
-<link rel="stylesheet" href="wp-admin.css" type="text/css" />
+<?php wp_admin_css(); ?>
</head>
<body>
<p>Posted !</p>
@@ -28,7 +28,7 @@ if ('b' == $_GET['a']) {
<head>
<title>WordPress &#8250; Sidebar</title>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('blog_charset'); ?>" />
-<link rel="stylesheet" href="wp-admin.css" type="text/css" />
+<?php wp_admin_css(); ?>
<style type="text/css" media="screen">
form {
padding: 3px;
diff --git a/wp-admin/templates.php b/wp-admin/templates.php
deleted file mode 100644
index 7f9063f..0000000
--- a/wp-admin/templates.php
+++ /dev/null
@@ -1,161 +0,0 @@
-<?php
-require_once('admin.php');
-wp_die( 'The template editor is disabled.' );
-$title = __('Template &amp; File Editing');
-$parent_file = 'edit.php';
-
-wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
-
-$recents = get_option('recently_edited');
-
-if (empty($file)) {
- if ($recents) {
- $file = $recents[0];
- } else {
- $file = 'index.php';
- }
-}
-
-$file = validate_file_to_edit($file);
-$real_file = get_real_file_to_edit($file);
-
-switch($action) {
-
-case 'update':
-
- check_admin_referer('edit-file_' . $file);
-
- if ( ! current_user_can('edit_files') )
- wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
-
- $newcontent = stripslashes($_POST['newcontent']);
- if (is_writeable($real_file)) {
- $f = @ fopen($real_file, 'w+');
- if ( $f ) {
- fwrite($f, $newcontent);
- fclose($f);
- wp_redirect("templates.php?file=$file&a=te");
- } else {
- wp_redirect("templates.php?file=$file&a=err");
- }
- } else {
- wp_redirect("templates.php?file=$file&a=err");
- }
-
- exit();
-
-break;
-
-default:
-
- require_once('./admin-header.php');
-
- if ( ! current_user_can('edit_files') )
- wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
-
- if (strpos($file, 'wp-config.php') !== false)
- wp_die('<p>'.__('The config file cannot be edited or viewed through the web interface. Sorry!').'</p>');
-
- update_recently_edited($file);
-
- if (!is_file($real_file))
- $error = true;
-
- if (!$error) {
- $f = @ fopen($real_file, 'r');
- if ( $f ) {
- if ( filesize($real_file ) > 0 ) {
- $content = fread($f, filesize($real_file));
- $content = htmlspecialchars($content);
- } else {
- $content = '';
- }
- } else {
- $error = true;
- }
- }
-
- ?>
-<?php if (isset($_GET['a'])) : ?>
- <?php if ( 'err' == $_GET['a'] ) : ?>
- <div id="message" class="error"><p><?php _e('Could not save file.') ?></p></div>
- <?php else: ?>
- <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
- <?php endif; ?>
-<?php endif; ?>
- <div class="wrap">
-<?php
-if (is_writeable($real_file)) {
- echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), wp_specialchars($file) ) . '</h2>';
-} else {
- echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), wp_specialchars($file) ) . '</h2>';
-}
-?>
-<div id="templateside">
-<?php
-if ( $recents ) :
-?>
-<h3><?php _e('Recent'); ?></h3>
-<?php
-echo '<ol>';
-foreach ($recents as $recent) :
- echo "<li><a href='templates.php?file=" . attribute_escape($recent) . "'>" . wp_specialchars(get_file_description(basename($recent))) . "</a></li>";
-endforeach;
-echo '</ol>';
-endif;
-?>
-<h3><?php _e('Common'); ?></h3>
- <?php $common_files = array('index.php', '.htaccess', 'my-hacks.php');
- $old_files = array('wp-layout.css', 'wp-comments.php', 'wp-comments-popup.php');
- foreach ($old_files as $old_file) {
- if (file_exists(ABSPATH . $old_file))
- $common_files[] = $old_file;
- } ?>
-<ul>
- <?php foreach ($common_files as $common_file) : ?>
- <li><a href="templates.php?file=<?php echo $common_file?>"><?php echo get_file_description($common_file); ?></a></li>
- <?php endforeach; ?>
-</ul>
-</div>
-<?php if (!$error) { ?>
- <form name="template" id="template" action="templates.php" method="post">
- <?php wp_nonce_field('edit-file_' . $file) ?>
- <div><textarea cols="70" rows="25" name="newcontent" id='newcontent' tabindex="1"><?php echo $content ?></textarea>
- <input type="hidden" name="action" value="update" />
- <input type="hidden" name="file" value="<?php echo $file ?>" />
- </div>
-<?php if ( is_writeable($real_file) ) : ?>
- <p class="submit">
-<?php
- echo "<input type='submit' name='submit' value=' " . __('Update File &raquo;') . "' tabindex='2' />";
-?>
-</p>
-<?php else : ?>
-<p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
-<?php endif; ?>
- </form>
- <?php
- } else {
- echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
- }
- ?>
-<div class="clear"> &nbsp; </div>
-</div>
-<div class="wrap">
-<h2><?php _e('Other Files') ?></h2>
-
- <p><?php _e('To edit a file, type its name here. You can edit any file <a href="http://codex.wordpress.org/Changing_File_Permissions" title="Read more about making files writable">writable by the server</a>, e.g. CHMOD 666.') ?></p>
- <form name="file" action="templates.php" method="get">
- <input type="text" name="file" />
- <input type="submit" name="submit" value="<?php _e('Edit file &raquo;') ?>" />
- </form>
-
- <p><?php _e('Note: of course, you can also edit the files/templates in your text editor of choice and upload them. This online editor is only meant to be used when you don&#8217;t have access to a text editor or FTP client.') ?></p>
-</div>
-<?php
-
-break;
-}
-
-include("admin-footer.php");
-?>
diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php
deleted file mode 100644
index cc044ed..0000000
--- a/wp-admin/theme-editor.php
+++ /dev/null
@@ -1,153 +0,0 @@
-<?php
-require_once('admin.php');
-wp_die( "The theme editor is disabled" );
-
-$title = __("Edit Themes");
-$parent_file = 'themes.php';
-
-wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme'));
-
-$themes = get_themes();
-
-if (empty($theme)) {
- $theme = get_current_theme();
-} else {
- $theme = stripslashes($theme);
- }
-
-
-if ( ! isset($themes[$theme]) )
- wp_die(__('The requested theme does not exist.'));
-
-$allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
-
-if (empty($file)) {
- $file = $allowed_files[0];
-}
-
-$file = validate_file_to_edit($file, $allowed_files);
-$real_file = get_real_file_to_edit($file);
-
-$file_show = basename( $file );
-
-switch($action) {
-
-case 'update':
-
- check_admin_referer('edit-theme_' . $file . $theme);
-
- if ( !current_user_can('edit_themes') )
- wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
-
- $newcontent = stripslashes($_POST['newcontent']);
- $theme = urlencode($theme);
- if (is_writeable($real_file)) {
- $f = fopen($real_file, 'w+');
- fwrite($f, $newcontent);
- fclose($f);
- $location = "theme-editor.php?file=$file&theme=$theme&a=te";
- } else {
- $location = "theme-editor.php?file=$file&theme=$theme";
- }
-
- $location = wp_kses_no_null($location);
- $strip = array('%0d', '%0a');
- $location = str_replace($strip, '', $location);
- header("Location: $location");
- exit();
-
-break;
-
-default:
-
- if ( !current_user_can('edit_themes') )
- wp_die('<p>'.__('You do not have sufficient permissions to edit themes for this blog.').'</p>');
-
- require_once('admin-header.php');
-
- update_recently_edited($file);
-
- if (!is_file($real_file))
- $error = 1;
-
- if (!$error && filesize($real_file) > 0) {
- $f = fopen($real_file, 'r');
- $content = fread($f, filesize($real_file));
- $content = htmlspecialchars($content);
- }
-
- ?>
-<?php if (isset($_GET['a'])) : ?>
- <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
-<?php endif; ?>
- <div class="wrap">
- <form name="theme" action="theme-editor.php" method="post">
- <?php _e('Select theme to edit:') ?>
- <select name="theme" id="theme">
- <?php
- foreach ($themes as $a_theme) {
- $theme_name = $a_theme['Name'];
- if ($theme_name == $theme) $selected = " selected='selected'";
- else $selected = '';
- $theme_name = attribute_escape($theme_name);
- echo "\n\t<option value=\"$theme_name\" $selected>$theme_name</option>";
- }
-?>
- </select>
- <input type="submit" name="Submit" value="<?php _e('Select &raquo;') ?>" class="button" />
- </form>
- </div>
-
- <div class="wrap">
- <?php
- if ( is_writeable($real_file) ) {
- echo '<h2>' . sprintf(__('Editing <code>%s</code>'), $file_show) . '</h2>';
- } else {
- echo '<h2>' . sprintf(__('Browsing <code>%s</code>'), $file_show) . '</h2>';
- }
- ?>
- <div id="templateside">
- <h3><?php printf(__("<strong>'%s'</strong> theme files"), $theme) ?></h3>
-
-<?php
-if ($allowed_files) :
-?>
- <ul>
-<?php foreach($allowed_files as $allowed_file) : ?>
- <li><a href="theme-editor.php?file=<?php echo "$allowed_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo get_file_description($allowed_file); ?></a></li>
-<?php endforeach; ?>
- </ul>
-<?php endif; ?>
-</div>
- <?php
- if (!$error) {
- ?>
- <form name="template" id="template" action="theme-editor.php" method="post">
- <?php wp_nonce_field('edit-theme_' . $file . $theme) ?>
- <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
- <input type="hidden" name="action" value="update" />
- <input type="hidden" name="file" value="<?php echo $file ?>" />
- <input type="hidden" name="theme" value="<?php echo $theme ?>" />
- </div>
-<?php if ( is_writeable($real_file) ) : ?>
- <p class="submit">
-<?php
- echo "<input type='submit' name='submit' value=' " . __('Update File &raquo;') . "' tabindex='2' />";
-?>
-</p>
-<?php else : ?>
-<p><em><?php _e('If this file were writable you could edit it.'); ?></em></p>
-<?php endif; ?>
- </form>
- <?php
- } else {
- echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
- }
- ?>
-<div class="clear"> &nbsp; </div>
-</div>
-<?php
-break;
-}
-
-include("admin-footer.php") ?>
diff --git a/wp-admin/themes.php b/wp-admin/themes.php
index 0b7d64f..37f4dd9 100644
--- a/wp-admin/themes.php
+++ b/wp-admin/themes.php
@@ -73,7 +73,7 @@ if( is_site_admin() ) {
<?php if ( $ct->screenshot ) : ?>
<img src="<?php echo get_option('siteurl') . '/' . $ct->stylesheet_dir . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
<?php endif; ?>
-<h3><?php printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h3>
+<h3><?php printf(_c('%1$s %2$s by %3$s|1: theme title, 2: theme version, 3: theme author'), $ct->title, $ct->version, $ct->author) ; ?></h3>
<p><?php echo $ct->description; ?></p>
</div>
@@ -98,7 +98,7 @@ foreach ($theme_names as $theme_name) {
$author = $themes[$theme_name]['Author'];
$screenshot = $themes[$theme_name]['Screenshot'];
$stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
- $activate_link = wp_nonce_url("themes.php?action=activate&amp;template=$template&amp;stylesheet=$stylesheet", 'switch-theme_' . $template);
+ $activate_link = wp_nonce_url("themes.php?action=activate&amp;template=".urlencode($template)."&amp;stylesheet=".urlencode($stylesheet), 'switch-theme_' . $template);
?>
<div class="available-theme">
<h3><a href="<?php echo $activate_link; ?>"><?php echo $title; ?></a></h3>
diff --git a/wp-admin/update-links.php b/wp-admin/update-links.php
index 2482deb..6641279 100644
--- a/wp-admin/update-links.php
+++ b/wp-admin/update-links.php
@@ -1,5 +1,5 @@
<?php
-require_once( dirname( dirname(__FILE__) ) . '/wp-config.php');
+require_once('../wp-config.php');
require_once( ABSPATH . 'wp-includes/class-snoopy.php');
if ( !get_option('use_linksupdate') )
diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php
index 3c2fa61..12dfb11 100644
--- a/wp-admin/upgrade-functions.php
+++ b/wp-admin/upgrade-functions.php
@@ -1,1136 +1,4 @@
<?php
-
-if ( file_exists(ABSPATH . 'wp-content/install.php') )
- require (ABSPATH . 'wp-content/install.php');
-require_once(ABSPATH . '/wp-admin/admin-functions.php');
-require_once(ABSPATH . '/wp-admin/admin-db.php');
-require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
-require_once(ABSPATH . WPINC . '/registration.php');
-
-if ( !function_exists('wp_install') ) :
-function wp_install($blog_title, $user_name, $user_email, $public, $meta='') {
- global $wp_rewrite;
-
- wp_check_mysql_version();
- wp_cache_flush();
- make_db_current_silent();
- populate_options();
- populate_roles();
-
- update_option('blogname', $blog_title);
- update_option('admin_email', $user_email);
- update_option('blog_public', $public);
- $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
-
- if ( defined('WP_SITEURL') && '' != WP_SITEURL )
- $guessurl = WP_SITEURL;
- else
- $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
-
- update_option('siteurl', $guessurl);
-
- // If not a public blog, don't ping.
- if ( ! $public )
- update_option('default_pingback_flag', 0);
-
- // Create default user. If the user already exists, the user tables are
- // being shared among blogs. Just set the role in that case.
- $user_id = username_exists($user_name);
- if ( !$user_id ) {
- $random_password = substr(md5(uniqid(microtime())), 0, 6);
- $user_id = wp_create_user($user_name, $random_password, $user_email);
- } else {
- $random_password = __('User already exists. Password inherited.');
- }
-
- $user = new WP_User($user_id);
- $user->set_role('administrator');
-
- wp_install_defaults($user_id);
-
- $wp_rewrite->flush_rules();
-
- wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
-
- wp_cache_flush();
-
- return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
-}
-endif;
-
-if ( !function_exists('wp_install_defaults') ) :
-function wp_install_defaults($user_id) {
- global $wpdb;
-
- // Default category
- $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
-
- // Default link category
- $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, link_count, category_description) VALUES ('0', '".$wpdb->escape(__('Blogroll'))."', '".sanitize_title(__('Blogroll'))."', '7', '')");
-
- // Now drop in some default links
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://inphotos.org/', 'Donncha', 0, 'http://inphotos.org/feed/', '');");
- $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (1, 2)" );
-
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 0, 'http://zengun.org/weblog/feed/', '');");
- $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (2, 2)" );
-
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 0, 'http://boren.nu/feed/', '');");
- $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (3, 2)" );
-
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 0, 'http://xml.photomatt.net/feed/', '');");
- $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (4, 2)" );
-
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 0, 'http://zed1.com/journalized/feed/', '');");
- $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (5, 2)" );
-
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 0, 'http://www.alexking.org/blog/wp-rss2.php', '');");
- $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (6, 2)" );
-
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 0, 'http://dougal.gunters.org/feed/', '');");
- $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (7, 2)" );
-
- // First post
- $now = date('Y-m-d H:i:s');
- $now_gmt = gmdate('Y-m-d H:i:s');
- $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '1', '', '', '')");
-
- $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
-
- // Default comment
- $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.'))."')");
-
- // First Page
- $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'publish', 'page', '', '', '')");
-}
-endif;
-
-if ( !function_exists('wp_new_blog_notification') ) :
-function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
- $user = new WP_User($user_id);
- $email = $user->user_email;
- $name = $user->user_login;
- $message_headers = 'From: "' . $blog_title . '" <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
- $message = sprintf(__("Your new WordPress blog has been successfully set up at:
-
-%1\$s
-
-You can log in to the administrator account with the following information:
-
-Username: %2\$s
-Password: %3\$s
-
-We hope you enjoy your new weblog. Thanks!
-
---The WordPress Team
-http://wordpress.org/
-"), $blog_url, $name, $password);
-
- @wp_mail($email, __('New WordPress Blog'), $message, $message_headers);
-}
-endif;
-
-if ( !function_exists('wp_upgrade') ) :
-function wp_upgrade() {
- global $wp_current_db_version, $wp_db_version;
-
- $wp_current_db_version = __get_option('db_version');
-
- // We are up-to-date. Nothing to do.
- if ( $wp_db_version == $wp_current_db_version )
- return;
-
- wp_check_mysql_version();
- wp_cache_flush();
- make_db_current_silent();
- upgrade_all();
- wp_cache_flush();
-}
-endif;
-
-// Functions to be called in install and upgrade scripts
-function upgrade_all() {
- global $wp_current_db_version, $wp_db_version, $wp_rewrite;
- $wp_current_db_version = __get_option('db_version');
-
- // We are up-to-date. Nothing to do.
- if ( $wp_db_version == $wp_current_db_version )
- return;
-
- // If the version is not set in the DB, try to guess the version.
- if ( empty($wp_current_db_version) ) {
- $wp_current_db_version = 0;
-
- // If the template option exists, we have 1.5.
- $template = __get_option('template');
- if ( !empty($template) )
- $wp_current_db_version = 2541;
- }
-
- populate_options();
-
- if ( $wp_current_db_version < 2541 ) {
- upgrade_100();
- upgrade_101();
- upgrade_110();
- upgrade_130();
- }
-
- maybe_disable_automattic_widgets();
-
- if ( $wp_current_db_version < 3308 )
- upgrade_160();
-
- if ( $wp_current_db_version < 4772 )
- upgrade_210();
-
- if ( $wp_current_db_version < 4351 )
- upgrade_old_slugs();
-
- $wp_rewrite->flush_rules();
-
- update_option('db_version', $wp_db_version);
-}
-
-function upgrade_100() {
- global $wpdb;
-
- // 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 $wpdb->posts WHERE post_name = ''");
- if ($posts) {
- foreach($posts as $post) {
- if ('' == $post->post_name) {
- $newtitle = sanitize_title($post->post_title);
- $wpdb->query("UPDATE $wpdb->posts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
- }
- }
- }
-
- $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
- foreach ($categories as $category) {
- if ('' == $category->category_nicename) {
- $newtitle = sanitize_title($category->cat_name);
- $wpdb->query("UPDATE $wpdb->categories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'");
- }
- }
-
-
- $wpdb->query("UPDATE $wpdb->options SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
- WHERE option_name LIKE 'links_rating_image%'
- AND option_value LIKE 'wp-links/links-images/%'");
-
- $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
- if ($done_ids) :
- foreach ($done_ids as $done_id) :
- $done_posts[] = $done_id->post_id;
- endforeach;
- $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
- else:
- $catwhere = '';
- endif;
-
- $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
- if ($allposts) :
- foreach ($allposts as $post) {
- // Check to see if it's already been imported
- $cat = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
- if (!$cat && 0 != $post->post_category) { // If there's no result
- $wpdb->query("
- INSERT INTO $wpdb->post2cat
- (post_id, category_id)
- VALUES
- ('$post->ID', '$post->post_category')
- ");
- }
- }
- endif;
-}
-
-function upgrade_101() {
- global $wpdb;
-
- // Clean up indices, add a few
- add_clean_index($wpdb->posts, 'post_name');
- add_clean_index($wpdb->posts, 'post_status');
- add_clean_index($wpdb->categories, 'category_nicename');
- add_clean_index($wpdb->comments, 'comment_approved');
- add_clean_index($wpdb->comments, 'comment_post_ID');
- add_clean_index($wpdb->links , 'link_category');
- add_clean_index($wpdb->links , 'link_visible');
-}
-
-
-function upgrade_110() {
- global $wpdb;
-
- // Set user_nicename.
- $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
- foreach ($users as $user) {
- if ('' == $user->user_nicename) {
- $newname = sanitize_title($user->user_nickname);
- $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
- }
- }
-
- $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
- foreach ($users as $row) {
- if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
- $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
- }
- }
-
-
- // Get the GMT offset, we'll use that later on
- $all_options = get_alloptions_110();
-
- $time_difference = $all_options->time_difference;
-
- $server_time = time()+date('Z');
- $weblogger_time = $server_time + $time_difference*3600;
- $gmt_time = time();
-
- $diff_gmt_server = ($gmt_time - $server_time) / 3600;
- $diff_weblogger_server = ($weblogger_time - $server_time) / 3600;
- $diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
- $gmt_offset = -$diff_gmt_weblogger;
-
- // Add a gmt_offset option, with value $gmt_offset
- add_option('gmt_offset', $gmt_offset);
-
- // Check if we already set the GMT fields (if we did, then
- // MAX(post_date_gmt) can't be '0000-00-00 00:00:00'
- // <michel_v> I just slapped myself silly for not thinking about it earlier
- $got_gmt_fields = ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00') ? false : true;
-
- if (!$got_gmt_fields) {
-
- // Add or substract time to all dates, to get GMT dates
- $add_hours = intval($diff_gmt_weblogger);
- $add_minutes = intval(60 * ($diff_gmt_weblogger - $add_hours));
- $wpdb->query("UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
- $wpdb->query("UPDATE $wpdb->posts SET post_modified = post_date");
- $wpdb->query("UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'");
- $wpdb->query("UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
- $wpdb->query("UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
- }
-
-}
-
-function upgrade_130() {
- global $wpdb;
-
- // Remove extraneous backslashes.
- $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
- if ($posts) {
- foreach($posts as $post) {
- $post_content = addslashes(deslash($post->post_content));
- $post_title = addslashes(deslash($post->post_title));
- $post_excerpt = addslashes(deslash($post->post_excerpt));
- if ( empty($post->guid) )
- $guid = get_permalink($post->ID);
- else
- $guid = $post->guid;
-
- $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'");
- }
- }
-
- // Remove extraneous backslashes.
- $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments");
- if ($comments) {
- foreach($comments as $comment) {
- $comment_content = addslashes(deslash($comment->comment_content));
- $comment_author = addslashes(deslash($comment->comment_author));
- $wpdb->query("UPDATE $wpdb->comments SET comment_content = '$comment_content', comment_author = '$comment_author' WHERE comment_ID = '$comment->comment_ID'");
- }
- }
-
- // Remove extraneous backslashes.
- $links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links");
- if ($links) {
- foreach($links as $link) {
- $link_name = addslashes(deslash($link->link_name));
- $link_description = addslashes(deslash($link->link_description));
- $wpdb->query("UPDATE $wpdb->links SET link_name = '$link_name', link_description = '$link_description' WHERE link_id = '$link->link_id'");
- }
- }
-
- // The "paged" option for what_to_show is no more.
- if ($wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'what_to_show'") == 'paged') {
- $wpdb->query("UPDATE $wpdb->options SET option_value = 'posts' WHERE option_name = 'what_to_show'");
- }
-
- $active_plugins = __get_option('active_plugins');
-
- // If plugins are not stored in an array, they're stored in the old
- // newline separated format. Convert to new format.
- if ( !is_array( $active_plugins ) ) {
- $active_plugins = explode("\n", trim($active_plugins));
- update_option('active_plugins', $active_plugins);
- }
-
- // Obsolete tables
- $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
- $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
- $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
- $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
-
- // Update comments table to use comment_type
- $wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
- $wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'");
-
- // Some versions have multiple duplicate option_name rows with the same values
- $options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
- foreach ( $options as $option ) {
- if ( 1 != $option->dupes ) { // Could this be done in the query?
- $limit = $option->dupes - 1;
- $dupe_ids = $wpdb->get_col("SELECT option_id FROM $wpdb->options WHERE option_name = '$option->option_name' LIMIT $limit");
- $dupe_ids = join($dupe_ids, ',');
- $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
- }
- }
-
- make_site_theme();
-}
-
-function upgrade_160_helper( $users ) {
- global $wpdb;
-
- populate_roles_160();
-
- foreach ( $users as $user_details ) :
- $user = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE ID = '" . $user_details[ 'user_id' ] . "'");
- if ( !empty( $user->user_firstname ) )
- update_usermeta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) );
- if ( !empty( $user->user_lastname ) )
- update_usermeta( $user->ID, 'last_name', $wpdb->escape($user->user_lastname) );
- if ( !empty( $user->user_nickname ) )
- update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
- if ( !empty( $user->user_level ) )
- update_usermeta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
- if ( !empty( $user->user_icq ) )
- update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
- if ( !empty( $user->user_aim ) )
- update_usermeta( $user->ID, 'aim', $wpdb->escape($user->user_aim) );
- if ( !empty( $user->user_msn ) )
- update_usermeta( $user->ID, 'msn', $wpdb->escape($user->user_msn) );
- if ( !empty( $user->user_yim ) )
- update_usermeta( $user->ID, 'yim', $wpdb->escape($user->user_icq) );
- if ( !empty( $user->user_description ) )
- update_usermeta( $user->ID, 'description', $wpdb->escape($user->user_description) );
-
- if ( isset( $user->user_idmode ) ):
- $idmode = $user->user_idmode;
- if ($idmode == 'nickname') $id = $user->user_nickname;
- if ($idmode == 'login') $id = $user->user_login;
- if ($idmode == 'firstname') $id = $user->user_firstname;
- if ($idmode == 'lastname') $id = $user->user_lastname;
- if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
- if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
- if (!$idmode) $id = $user->user_nickname;
- $id = $wpdb->escape( $id );
- $wpdb->query("UPDATE $wpdb->users SET display_name = '$id' WHERE ID = '$user->ID'");
- endif;
-
- // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
- $caps = get_usermeta( $user->ID, $wpdb->prefix . 'capabilities');
- if ( empty($caps) || defined('RESET_CAPS') ) {
- $level = get_usermeta($user->ID, $wpdb->prefix . 'user_level');
- $role = translate_level_to_role($level);
- update_usermeta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
- }
-
- endforeach;
-}
-
-function upgrade_160() {
- global $wpdb, $table_prefix, $wp_current_db_version;
- $users = $wpdb->get_results("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '{$table_prefix}capabilities'", ARRAY_A);
- upgrade_160_helper( $users );
- $users = $wpdb->get_results("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '{$table_prefix}user_level'", ARRAY_A);
- upgrade_160_helper( $users );
- $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
- $wpdb->hide_errors();
- foreach ( $old_user_fields as $old )
- $wpdb->query("ALTER TABLE $wpdb->users DROP $old");
- $wpdb->show_errors();
-
- if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts
- $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
- foreach ( $categories as $cat_id ) {
- $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status='publish' AND category_id = '$cat_id'");
- $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
- }
- }
- add_option( "gmt_offset", 0 );
-
- // populate comment_count field of posts table
- $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
- if( is_array( $comments ) ) {
- foreach ($comments as $comment) {
- $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $comment->c WHERE ID = '$comment->comment_post_ID'" );
- }
- }
-
- // Some alpha versions used a post status of object instead of attachment and put
- // the mime type in post_type instead of post_mime_type.
- if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
- $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
- foreach ($objects as $object) {
- $wpdb->query("UPDATE $wpdb->posts SET post_status = 'attachment',
- post_mime_type = '$object->post_type',
- post_type = ''
- WHERE ID = $object->ID");
-
- $meta = get_post_meta($object->ID, 'imagedata', true);
- if ( ! empty($meta['file']) )
- update_attached_file( $object->ID, $meta['file'] );
- }
- }
-}
-
-function upgrade_210() {
- global $wpdb, $wp_current_db_version;
-
- if ( $wp_current_db_version < 3506 ) {
- // Update status and type.
- $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
-
- if ( ! empty($posts) ) foreach ($posts as $post) {
- $status = $post->post_status;
- $type = 'post';
-
- if ( 'static' == $status ) {
- $status = 'publish';
- $type = 'page';
- } else if ( 'attachment' == $status ) {
- $status = 'inherit';
- $type = 'attachment';
- }
-
- $wpdb->query("UPDATE $wpdb->posts SET post_status = '$status', post_type = '$type' WHERE ID = '$post->ID'");
- }
- }
-
- if ( $wp_current_db_version < 3845 ) {
- populate_roles_210();
- }
-
- if ( $wp_current_db_version < 3531 ) {
- // Give future posts a post_status of future.
- $now = gmdate('Y-m-d H:i:59');
- $wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
-
- $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
- if ( !empty($posts) )
- foreach ( $posts as $post )
- wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', array($post->ID));
- }
-
- if ( $wp_current_db_version < 3570 ) {
- // Create categories for link categories if a category with the same
- // name doesn't exist. Create a map of link cat IDs to cat IDs.
- $link_cat_id_map = array();
- $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
- foreach ( $link_cats as $link_cat) {
- if ( $cat_id = category_exists($link_cat->cat_name) ) {
- $link_cat_id_map[$link_cat->cat_id] = $cat_id;
- $default_link_cat = $cat_id;
- } else {
- $link_cat_id_map[$link_cat->cat_id] = wp_create_category($link_cat->cat_name);
- $default_link_cat = $link_cat_id_map[$link_cat->cat_id];
- }
- }
-
- // Associate links to cats.
- $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
- if ( !empty($links) ) foreach ( $links as $link ) {
- if ( 0 == $link->link_category )
- continue;
- if ( ! isset($link_cat_id_map[$link->link_category]) )
- continue;
- $link_cat = $link_cat_id_map[$link->link_category];
- $cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = '$link->link_id' AND category_id = '$link_cat'");
- if ( !$cat ) {
- $wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id)
- VALUES ('$link->link_id', '$link_cat')");
- }
- }
-
- // Set default to the last category we grabbed during the upgrade loop.
- update_option('default_link_category', $default_link_cat);
-
- // Count links per category.
- if ( 0 == $wpdb->get_var("SELECT SUM(link_count) FROM $wpdb->categories") ) {
- $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
- foreach ( $categories as $cat_id ) {
- $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
- $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
- }
- }
- }
-
- if ( $wp_current_db_version < 4772 ) {
- // Obsolete linkcategories table
- $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
- }
-}
-
-function upgrade_old_slugs() {
- // upgrade people who were using the Redirect Old Slugs plugin
- global $wpdb;
- $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'");
-}
-
-
-// The functions we use to actually do stuff
-
-// General
-function maybe_create_table($table_name, $create_ddl) {
- global $wpdb;
- foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
- if ($table == $table_name) {
- return true;
- }
- }
- //didn't find it try to create it.
- $q = $wpdb->query($create_ddl);
- // we cannot directly tell that whether this succeeded!
- foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
- if ($table == $table_name) {
- return true;
- }
- }
- return false;
-}
-
-function drop_index($table, $index) {
- global $wpdb;
- $wpdb->hide_errors();
- $wpdb->query("ALTER TABLE `$table` DROP INDEX `$index`");
- // Now we need to take out all the extra ones we may have created
- for ($i = 0; $i < 25; $i++) {
- $wpdb->query("ALTER TABLE `$table` DROP INDEX `{$index}_$i`");
- }
- $wpdb->show_errors();
- return true;
-}
-
-function add_clean_index($table, $index) {
- global $wpdb;
- drop_index($table, $index);
- $wpdb->query("ALTER TABLE `$table` ADD INDEX ( `$index` )");
- return true;
-}
-
-/**
- ** maybe_add_column()
- ** Add column to db table if it doesn't exist.
- ** Returns: true if already exists or on successful completion
- ** false on error
- */
-function maybe_add_column($table_name, $column_name, $create_ddl) {
- global $wpdb, $debug;
- foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
- if ($debug) echo("checking $column == $column_name<br />");
- if ($column == $column_name) {
- return true;
- }
- }
- //didn't find it try to create it.
- $q = $wpdb->query($create_ddl);
- // we cannot directly tell that whether this succeeded!
- foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
- if ($column == $column_name) {
- return true;
- }
- }
- return false;
-}
-
-
-// get_alloptions as it was for 1.2.
-function get_alloptions_110() {
- global $wpdb;
- if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
- foreach ($options as $option) {
- // "When trying to design a foolproof system,
- // never underestimate the ingenuity of the fools :)" -- Dougal
- if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
- if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
- if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
- $all_options->{$option->option_name} = stripslashes($option->option_value);
- }
- }
- return $all_options;
-}
-
-// Version of get_option that is private to install/upgrade.
-function __get_option($setting) {
- global $wpdb;
-
- if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
- return preg_replace( '|/+$|', '', constant( 'WP_HOME' ) );
- }
-
- if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) {
- return preg_replace( '|/+$|', '', constant( 'WP_SITEURL' ) );
- }
-
- $option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'");
-
- if ( 'home' == $setting && '' == $option )
- return __get_option('siteurl');
-
- if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting )
- $option = preg_replace('|/+$|', '', $option);
-
- @ $kellogs = unserialize($option);
- if ($kellogs !== FALSE)
- return $kellogs;
- else
- return $option;
-}
-
-function deslash($content) {
- // Note: \\\ inside a regex denotes a single backslash.
-
- // Replace one or more backslashes followed by a single quote with
- // a single quote.
- $content = preg_replace("/\\\+'/", "'", $content);
-
- // Replace one or more backslashes followed by a double quote with
- // a double quote.
- $content = preg_replace('/\\\+"/', '"', $content);
-
- // Replace one or more backslashes with one backslash.
- $content = preg_replace("/\\\+/", "\\", $content);
-
- return $content;
-}
-
-function dbDelta($queries, $execute = true) {
- global $wpdb;
-
- // Seperate individual queries into an array
- if( !is_array($queries) ) {
- $queries = explode( ';', $queries );
- if('' == $queries[count($queries) - 1]) array_pop($queries);
- }
-
- $cqueries = array(); // Creation Queries
- $iqueries = array(); // Insertion Queries
- $for_update = array();
-
- // Create a tablename index for an array ($cqueries) of queries
- foreach($queries as $qry) {
- if(preg_match("|CREATE TABLE (?:IF NOT EXISTS )?([^ ]*)|", $qry, $matches)) {
- $cqueries[strtolower($matches[1])] = $qry;
- $for_update[$matches[1]] = 'Created table '.$matches[1];
- }
- else if(preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
- array_unshift($cqueries, $qry);
- }
- else if(preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
- $iqueries[] = $qry;
- }
- else if(preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
- $iqueries[] = $qry;
- }
- else {
- // Unrecognized query type
- }
- }
-
- // Check to see which tables and fields exist
- if($tables = $wpdb->get_col('SHOW TABLES;')) {
- // For every table in the database
- foreach($tables as $table) {
- // If a table query exists for the database table...
- if( array_key_exists(strtolower($table), $cqueries) ) {
- // Clear the field and index arrays
- unset($cfields);
- unset($indices);
- // Get all of the field names in the query from between the parens
- preg_match("|\((.*)\)|ms", $cqueries[strtolower($table)], $match2);
- $qryline = trim($match2[1]);
-
- // Separate field lines into an array
- $flds = explode("\n", $qryline);
-
- //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
-
- // For every field line specified in the query
- foreach($flds as $fld) {
- // Extract the field name
- preg_match("|^([^ ]*)|", trim($fld), $fvals);
- $fieldname = $fvals[1];
-
- // Verify the found field name
- $validfield = true;
- switch(strtolower($fieldname))
- {
- case '':
- case 'primary':
- case 'index':
- case 'fulltext':
- case 'unique':
- case 'key':
- $validfield = false;
- $indices[] = trim(trim($fld), ", \n");
- break;
- }
- $fld = trim($fld);
-
- // If it's a valid field, add it to the field array
- if($validfield) {
- $cfields[strtolower($fieldname)] = trim($fld, ", \n");
- }
- }
-
- // Fetch the table column structure from the database
- $tablefields = $wpdb->get_results("DESCRIBE {$table};");
-
- // For every field in the table
- foreach($tablefields as $tablefield) {
- // If the table field exists in the field array...
- if(array_key_exists(strtolower($tablefield->Field), $cfields)) {
- // Get the field type from the query
- preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
- $fieldtype = $matches[1];
-
- // Is actual field type different from the field type in query?
- if($tablefield->Type != $fieldtype) {
- // Add a query to change the column type
- $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
- $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
- }
-
- // Get the default value from the array
- //echo "{$cfields[strtolower($tablefield->Field)]}<br>";
- if(preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
- $default_value = $matches[1];
- if($tablefield->Default != $default_value)
- {
- // Add a query to change the column's default value
- $cqueries[] = "ALTER TABLE {$table} ALTER COLUMN {$tablefield->Field} SET DEFAULT '{$default_value}'";
- $for_update[$table.'.'.$tablefield->Field] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}";
- }
- }
-
- // Remove the field from the array (so it's not added)
- unset($cfields[strtolower($tablefield->Field)]);
- }
- else {
- // This field exists in the table, but not in the creation queries?
- }
- }
-
- // For every remaining field specified for the table
- foreach($cfields as $fieldname => $fielddef) {
- // Push a query line into $cqueries that adds the field to that table
- $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
- $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
- }
-
- // Index stuff goes here
- // Fetch the table index structure from the database
- $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
-
- if($tableindices) {
- // Clear the index array
- unset($index_ary);
-
- // For every index in the table
- foreach($tableindices as $tableindex) {
- // Add the index to the index data array
- $keyname = $tableindex->Key_name;
- $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
- $index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
- }
-
- // For each actual index in the index array
- foreach($index_ary as $index_name => $index_data) {
- // Build a create string to compare to the query
- $index_string = '';
- if($index_name == 'PRIMARY') {
- $index_string .= 'PRIMARY ';
- }
- else if($index_data['unique']) {
- $index_string .= 'UNIQUE ';
- }
- $index_string .= 'KEY ';
- if($index_name != 'PRIMARY') {
- $index_string .= $index_name;
- }
- $index_columns = '';
- // For each column in the index
- foreach($index_data['columns'] as $column_data) {
- if($index_columns != '') $index_columns .= ',';
- // Add the field to the column list string
- $index_columns .= $column_data['fieldname'];
- if($column_data['subpart'] != '') {
- $index_columns .= '('.$column_data['subpart'].')';
- }
- }
- // Add the column list to the index create string
- $index_string .= ' ('.$index_columns.')';
-
- if(!(($aindex = array_search($index_string, $indices)) === false)) {
- unset($indices[$aindex]);
- //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br/>Found index:".$index_string."</pre>\n";
- }
- //else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br/><b>Did not find index:</b>".$index_string."<br/>".print_r($indices, true)."</pre>\n";
- }
- }
-
- // For every remaining index specified for the table
- foreach($indices as $index) {
- // Push a query line into $cqueries that adds the index to that table
- $cqueries[] = "ALTER TABLE {$table} ADD $index";
- $for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index;
- }
-
- // Remove the original table creation query from processing
- unset($cqueries[strtolower($table)]);
- unset($for_update[strtolower($table)]);
- } else {
- // This table exists in the database, but not in the creation queries?
- }
- }
- }
-
- $allqueries = array_merge($cqueries, $iqueries);
- if($execute) {
- foreach($allqueries as $query) {
- //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
- $wpdb->query($query);
- }
- }
-
- return $for_update;
-}
-
-function make_db_current() {
- global $wp_queries;
-
- populate_queries();
- $alterations = dbDelta($wp_queries);
- echo "<ol>\n";
- foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
- echo "</ol>\n";
-}
-
-function make_db_current_silent() {
- global $wp_queries;
-
- populate_queries();
- $alterations = dbDelta($wp_queries);
-}
-
-function make_site_theme_from_oldschool($theme_name, $template) {
- $home_path = get_home_path();
- $site_dir = ABSPATH . "wp-content/themes/$template";
-
- if (! file_exists("$home_path/index.php"))
- return false;
-
- // Copy files from the old locations to the site theme.
- // TODO: This does not copy arbitarary include dependencies. Only the
- // standard WP files are copied.
- $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
-
- foreach ($files as $oldfile => $newfile) {
- if ($oldfile == 'index.php')
- $oldpath = $home_path;
- else
- $oldpath = ABSPATH;
-
- if ($oldfile == 'index.php') { // Check to make sure it's not a new index
- $index = implode('', file("$oldpath/$oldfile"));
- if (strpos($index, 'WP_USE_THEMES') !== false) {
- if (! @copy(ABSPATH . 'wp-content/themes/default/index.php', "$site_dir/$newfile"))
- return false;
- continue; // Don't copy anything
- }
- }
-
- if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
- return false;
-
- chmod("$site_dir/$newfile", 0777);
-
- // Update the blog header include in each file.
- $lines = explode("\n", implode('', file("$site_dir/$newfile")));
- if ($lines) {
- $f = fopen("$site_dir/$newfile", 'w');
-
- foreach ($lines as $line) {
- if (preg_match('/require.*wp-blog-header/', $line))
- $line = '//' . $line;
-
- // Update stylesheet references.
- $line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
-
- // Update comments template inclusion.
- $line = str_replace("<?php include(ABSPATH . 'wp-comments.php'); ?>", "<?php comments_template(); ?>", $line);
-
- fwrite($f, "{$line}\n");
- }
- fclose($f);
- }
- }
-
- // Add a theme header.
- $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the upgrade.\nVersion: 1.0\nAuthor: Moi\n*/\n";
-
- $stylelines = file_get_contents("$site_dir/style.css");
- if ($stylelines) {
- $f = fopen("$site_dir/style.css", 'w');
-
- fwrite($f, $header);
- fwrite($f, $stylelines);
- fclose($f);
- }
-
- return true;
-}
-
-function make_site_theme_from_default($theme_name, $template) {
- $site_dir = ABSPATH . "wp-content/themes/$template";
- $default_dir = ABSPATH . 'wp-content/themes/default';
-
- // Copy files from the default theme to the site theme.
- //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
-
- $theme_dir = @ dir("$default_dir");
- if ($theme_dir) {
- while(($theme_file = $theme_dir->read()) !== false) {
- if (is_dir("$default_dir/$theme_file"))
- continue;
- if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
- return;
- chmod("$site_dir/$theme_file", 0777);
- }
- }
-
- // Rewrite the theme header.
- $stylelines = explode("\n", implode('', file("$site_dir/style.css")));
- if ($stylelines) {
- $f = fopen("$site_dir/style.css", 'w');
-
- foreach ($stylelines as $line) {
- if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
- elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
- elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
- elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
- elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
- fwrite($f, $line . "\n");
- }
- fclose($f);
- }
-
- // Copy the images.
- umask(0);
- if (! mkdir("$site_dir/images", 0777)) {
- return false;
- }
-
- $images_dir = @ dir("$default_dir/images");
- if ($images_dir) {
- while(($image = $images_dir->read()) !== false) {
- if (is_dir("$default_dir/images/$image"))
- continue;
- if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
- return;
- chmod("$site_dir/images/$image", 0777);
- }
- }
-}
-
-// Create a site theme from the default theme.
-function make_site_theme() {
- return true;
- // Name the theme after the blog.
- $theme_name = __get_option('blogname');
- $template = sanitize_title($theme_name);
- $site_dir = ABSPATH . "wp-content/themes/$template";
-
- // If the theme already exists, nothing to do.
- if ( is_dir($site_dir)) {
- return false;
- }
-
- // We must be able to write to the themes dir.
- if (! is_writable(ABSPATH . "wp-content/themes")) {
- return false;
- }
-
- umask(0);
- if (! mkdir($site_dir, 0777)) {
- return false;
- }
-
- if (file_exists(ABSPATH . 'wp-layout.css')) {
- if (! make_site_theme_from_oldschool($theme_name, $template)) {
- // TODO: rm -rf the site theme directory.
- return false;
- }
- } else {
- if (! make_site_theme_from_default($theme_name, $template))
- // TODO: rm -rf the site theme directory.
- return false;
- }
-
- // Make the new site theme active.
- $current_template = __get_option('template');
- if ($current_template == 'default') {
- update_option('template', $template);
- update_option('stylesheet', $template);
- }
- return $template;
-}
-
-function translate_level_to_role($level) {
- switch ($level) {
- case 10:
- case 9:
- case 8:
- return 'administrator';
- case 7:
- case 6:
- case 5:
- return 'editor';
- case 4:
- case 3:
- case 2:
- return 'author';
- case 1:
- return 'contributor';
- case 0:
- return 'subscriber';
- }
-}
-
-function wp_check_mysql_version() {
- global $wp_version;
-
- // Make sure the server has MySQL 4.0
- $mysql_version = preg_replace('|[^0-9\.]|', '', @mysql_get_server_info());
- if ( version_compare($mysql_version, '4.0.0', '<') )
- die(sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version));
-}
-
-function maybe_disable_automattic_widgets() {
- $plugins = __get_option( 'active_plugins' );
-
- foreach ( (array) $plugins as $plugin ) {
- if ( basename( $plugin ) == 'widgets.php' ) {
- array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
- update_option( 'active_plugins', $plugins );
- break;
- }
- }
-}
-
+// Deprecated. Use includes/upgrade.php.
+require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
?>
diff --git a/wp-admin/upgrade-schema.php b/wp-admin/upgrade-schema.php
deleted file mode 100644
index 2481340..0000000
--- a/wp-admin/upgrade-schema.php
+++ /dev/null
@@ -1,471 +0,0 @@
-<?php
-// Here we keep the DB structure and option values
-
-$charset_collate = '';
-
-if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {
- if ( ! empty($wpdb->charset) )
- $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
- if ( ! empty($wpdb->collate) )
- $charset_collate .= " COLLATE $wpdb->collate";
-}
-
-populate_queries(); // Added to ensure compatability. Safe to delete?
-
-function populate_queries() {
- global $charset_collate, $wp_queries, $wpdb;
-
- $wp_queries = "CREATE TABLE $wpdb->categories (
- cat_ID bigint(20) NOT NULL auto_increment,
- cat_name varchar(55) NOT NULL default '',
- category_nicename varchar(200) NOT NULL default '',
- category_description longtext NOT NULL,
- category_parent bigint(20) NOT NULL default '0',
- category_count bigint(20) NOT NULL default '0',
- link_count bigint(20) NOT NULL default '0',
- posts_private tinyint(1) NOT NULL default '0',
- links_private tinyint(1) NOT NULL default '0',
- PRIMARY KEY (cat_ID),
- KEY category_nicename (category_nicename)
- ) $charset_collate;
- CREATE TABLE $wpdb->comments (
- comment_ID bigint(20) unsigned NOT NULL auto_increment,
- comment_post_ID int(11) NOT NULL default '0',
- comment_author tinytext NOT NULL,
- comment_author_email varchar(100) NOT NULL default '',
- comment_author_url varchar(200) NOT NULL default '',
- comment_author_IP varchar(100) NOT NULL default '',
- comment_date datetime NOT NULL default '0000-00-00 00:00:00',
- comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
- comment_content text NOT NULL,
- comment_karma int(11) NOT NULL default '0',
- comment_approved enum('0','1','spam') NOT NULL default '1',
- comment_agent varchar(255) NOT NULL default '',
- comment_type varchar(20) NOT NULL default '',
- comment_parent bigint(20) NOT NULL default '0',
- user_id bigint(20) NOT NULL default '0',
- PRIMARY KEY (comment_ID),
- KEY comment_approved (comment_approved),
- KEY comment_post_ID (comment_post_ID)
- ) $charset_collate;
- CREATE TABLE $wpdb->link2cat (
- rel_id bigint(20) NOT NULL auto_increment,
- link_id bigint(20) NOT NULL default '0',
- category_id bigint(20) NOT NULL default '0',
- PRIMARY KEY (rel_id),
- KEY link_id (link_id,category_id)
- ) $charset_collate;
- CREATE TABLE $wpdb->links (
- link_id bigint(20) NOT NULL auto_increment,
- link_url varchar(255) NOT NULL default '',
- link_name varchar(255) NOT NULL default '',
- link_image varchar(255) NOT NULL default '',
- link_target varchar(25) NOT NULL default '',
- link_category bigint(20) NOT NULL default '0',
- link_description varchar(255) NOT NULL default '',
- link_visible enum('Y','N') NOT NULL default 'Y',
- link_owner int(11) NOT NULL default '1',
- link_rating int(11) NOT NULL default '0',
- link_updated datetime NOT NULL default '0000-00-00 00:00:00',
- link_rel varchar(255) NOT NULL default '',
- link_notes mediumtext NOT NULL,
- link_rss varchar(255) NOT NULL default '',
- PRIMARY KEY (link_id),
- KEY link_category (link_category),
- KEY link_visible (link_visible)
- ) $charset_collate;
- CREATE TABLE $wpdb->options (
- option_id bigint(20) NOT NULL auto_increment,
- blog_id int(11) NOT NULL default '0',
- option_name varchar(64) NOT NULL default '',
- option_can_override enum('Y','N') NOT NULL default 'Y',
- option_type int(11) NOT NULL default '1',
- option_value longtext NOT NULL,
- option_width int(11) NOT NULL default '20',
- option_height int(11) NOT NULL default '8',
- option_description tinytext NOT NULL,
- option_admin_level int(11) NOT NULL default '1',
- autoload enum('yes','no') NOT NULL default 'yes',
- PRIMARY KEY (option_id,blog_id,option_name),
- KEY option_name (option_name)
- ) $charset_collate;
- CREATE TABLE $wpdb->post2cat (
- rel_id bigint(20) NOT NULL auto_increment,
- post_id bigint(20) NOT NULL default '0',
- category_id bigint(20) NOT NULL default '0',
- PRIMARY KEY (rel_id),
- KEY post_id (post_id,category_id)
- ) $charset_collate;
- CREATE TABLE $wpdb->postmeta (
- meta_id bigint(20) NOT NULL auto_increment,
- post_id bigint(20) NOT NULL default '0',
- meta_key varchar(255) default NULL,
- meta_value longtext,
- PRIMARY KEY (meta_id),
- KEY post_id (post_id),
- KEY meta_key (meta_key)
- ) $charset_collate;
- CREATE TABLE $wpdb->posts (
- ID bigint(20) unsigned NOT NULL auto_increment,
- post_author bigint(20) NOT NULL default '0',
- post_date datetime NOT NULL default '0000-00-00 00:00:00',
- post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
- post_content longtext NOT NULL,
- post_title text NOT NULL,
- post_category int(4) NOT NULL default '0',
- post_excerpt text NOT NULL,
- post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish',
- comment_status enum('open','closed','registered_only') NOT NULL default 'open',
- ping_status enum('open','closed') NOT NULL default 'open',
- post_password varchar(20) NOT NULL default '',
- post_name varchar(200) NOT NULL default '',
- to_ping text NOT NULL,
- pinged text NOT NULL,
- post_modified datetime NOT NULL default '0000-00-00 00:00:00',
- post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
- post_content_filtered text NOT NULL,
- post_parent bigint(20) NOT NULL default '0',
- guid varchar(255) NOT NULL default '',
- menu_order int(11) NOT NULL default '0',
- post_type varchar(20) NOT NULL default 'post',
- post_mime_type varchar(100) NOT NULL default '',
- comment_count bigint(20) NOT NULL default '0',
- PRIMARY KEY (ID),
- KEY post_name (post_name),
- KEY type_status_date (post_type,post_status,post_date,ID)
- ) $charset_collate;
- CREATE TABLE $wpdb->users (
- ID bigint(20) unsigned NOT NULL auto_increment,
- user_login varchar(60) NOT NULL default '',
- user_pass varchar(64) NOT NULL default '',
- user_nicename varchar(50) NOT NULL default '',
- user_email varchar(100) NOT NULL default '',
- user_url varchar(100) NOT NULL default '',
- user_registered datetime NOT NULL default '0000-00-00 00:00:00',
- user_activation_key varchar(60) NOT NULL default '',
- user_status int(11) NOT NULL default '0',
- display_name varchar(250) NOT NULL default '',
- spam tinyint(2) NOT NULL default '0',
- deleted tinyint(2) NOT NULL default '0',
- PRIMARY KEY (ID),
- KEY user_login_key (user_login)
- ) $charset_collate;
- CREATE TABLE $wpdb->usermeta (
- umeta_id bigint(20) NOT NULL auto_increment,
- user_id bigint(20) NOT NULL default '0',
- meta_key varchar(255) default NULL,
- meta_value longtext,
- PRIMARY KEY (umeta_id),
- KEY user_id (user_id),
- KEY meta_key (meta_key)
- ) $charset_collate;
- CREATE TABLE $wpdb->blogs (
- blog_id bigint(20) NOT NULL auto_increment,
- site_id bigint(20) NOT NULL default '0',
- domain varchar(200) NOT NULL default '',
- path varchar(100) NOT NULL default '',
- registered datetime NOT NULL default '0000-00-00 00:00:00',
- last_updated datetime NOT NULL default '0000-00-00 00:00:00',
- public tinyint(2) NOT NULL default '1',
- archived enum('0','1') NOT NULL default '0',
- mature tinyint(2) NOT NULL default '0',
- spam tinyint(2) NOT NULL default '0',
- deleted tinyint(2) NOT NULL default '0',
- lang_id int(11) NOT NULL default '0',
- PRIMARY KEY (blog_id),
- KEY domain (domain(50),path(5)),
- KEY lang_id (lang_id)
- );
- CREATE TABLE $wpdb->blog_versions (
- blog_id bigint(20) NOT NULL default '0',
- db_version varchar(20) NOT NULL default '',
- last_updated datetime NOT NULL default '0000-00-00 00:00:00',
- PRIMARY KEY (blog_id),
- KEY db_version (db_version)
- );
- CREATE TABLE $wpdb->registration_log (
- ID bigint(20) NOT NULL auto_increment,
- email varchar(255) NOT NULL default '',
- IP varchar(30) NOT NULL default '',
- blog_id bigint(20) NOT NULL default '0',
- date_registered datetime NOT NULL default '0000-00-00 00:00:00',
- PRIMARY KEY (ID),
- KEY IP (IP)
- );
- CREATE TABLE $wpdb->site (
- id bigint(20) NOT NULL auto_increment,
- domain varchar(200) NOT NULL default '',
- path varchar(100) NOT NULL default '',
- PRIMARY KEY (id),
- KEY domain (domain,path)
- );
- CREATE TABLE $wpdb->sitemeta (
- meta_id bigint(20) NOT NULL auto_increment,
- site_id bigint(20) NOT NULL default '0',
- meta_key varchar(255) default NULL,
- meta_value longtext,
- PRIMARY KEY (meta_id),
- KEY meta_key (meta_key),
- KEY site_id (site_id)
- );
- CREATE TABLE $wpdb->sitecategories (
- cat_ID bigint(20) NOT NULL auto_increment,
- cat_name varchar(55) NOT NULL default '',
- category_nicename varchar(200) NOT NULL default '',
- last_updated timestamp NOT NULL,
- PRIMARY KEY (cat_ID),
- KEY category_nicename (category_nicename),
- KEY last_updated (last_updated)
- );
- CREATE TABLE $wpdb->signups (
- domain varchar(200) NOT NULL default '',
- path varchar(100) NOT NULL default '',
- title longtext NOT NULL,
- user_login varchar(60) NOT NULL default '',
- user_email varchar(100) NOT NULL default '',
- registered datetime NOT NULL default '0000-00-00 00:00:00',
- activated datetime NOT NULL default '0000-00-00 00:00:00',
- active tinyint(1) NOT NULL default '0',
- activation_key varchar(50) NOT NULL default '',
- meta longtext,
- KEY activation_key (activation_key),
- KEY domain (domain)
- );
- ";
-}
-
-function populate_options() {
- global $wpdb, $wp_db_version, $wpblog, $current_site;
-
- $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
- $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
- add_option('siteurl', $guessurl, __('WordPress web address'));
- add_option('blogname', __('My Weblog'), __('Blog title'));
- add_option('blogdescription', __('Just another ' . $current_site->site_name . ' weblog'), __('Short tagline'));
- add_option('new_users_can_blog', 0);
- add_option('users_can_register', 0);
- add_option('admin_email', 'you@example.com');
- add_option('start_of_week', 1);
- add_option('use_balanceTags', 0);
- add_option('use_smilies', 1);
- add_option('require_name_email', 1);
- add_option('comments_notify', 1);
- add_option('posts_per_rss', 10);
- add_option('rss_excerpt_length', 50);
- add_option('rss_use_excerpt', 0);
- add_option('mailserver_url', 'mail.example.com');
- add_option('mailserver_login', 'login@example.com');
- add_option('mailserver_pass', 'password');
- add_option('mailserver_port', 110);
- add_option('default_category', 1);
- add_option('default_comment_status', 'open');
- add_option('default_ping_status', 'open');
- add_option('default_pingback_flag', 1);
- add_option('default_post_edit_rows', 10);
- add_option('posts_per_page', 10);
- add_option('what_to_show', 'posts');
- add_option('date_format', __('F j, Y'));
- add_option('time_format', __('g:i a'));
- add_option('links_updated_date_format', __('F j, Y g:i a'));
- add_option('links_recently_updated_prepend', '<em>');
- add_option('links_recently_updated_append', '</em>');
- add_option('links_recently_updated_time', 120);
- add_option('comment_moderation', 0);
- add_option('moderation_notify', 1);
- add_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/');
- add_option('gzipcompression', 0);
- add_option('hack_file', 0);
- add_option('blog_charset', 'UTF-8');
- add_option('moderation_keys');
- add_option('active_plugins');
- add_option('home', $guessurl);
- // in case it is set, but blank, update "home"
- if ( !__get_option('home') ) update_option('home', $guessurl);
- add_option('category_base');
- add_option('ping_sites', 'http://rpc.pingomatic.com/');
- add_option('advanced_edit', 0);
- add_option('comment_max_links', 2);
- add_option('gmt_offset', date('Z') / 3600);
- // 1.5
- add_option('default_email_category', 1, __('Posts by email go to this category'));
- add_option('recently_edited');
- add_option('use_linksupdate', 0);
- add_option('template', 'default');
- add_option('stylesheet', 'default');
- add_option('comment_whitelist', 1);
- add_option('page_uris');
- add_option('blacklist_keys');
- add_option('comment_registration', 0);
- add_option('rss_language', 'en');
- add_option('html_type', 'text/html');
- // 1.5.1
- add_option('use_trackback', 0);
- // 2.0
- add_option('default_role', 'subscriber');
- add_option('db_version', $wp_db_version);
- // 2.0.1
- if ( ini_get('safe_mode') ) {
- // Safe mode screws up mkdir(), so we must use a flat structure.
- add_option('uploads_use_yearmonth_folders', 0);
- add_option('upload_path', 'wp-content');
- } else {
- add_option('uploads_use_yearmonth_folders', 1);
- add_option('upload_path', 'wp-content/uploads');
- }
-
- // 2.0.3
- add_option('secret', md5(uniqid(microtime())));
-
- // 2.1
- add_option('blog_public', '1');
- add_option('default_link_category', 2);
- add_option('show_on_front', 'posts');
-
- // Delete unused options
- $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', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing');
- foreach ($unusedoptions as $option) :
- delete_option($option);
- endforeach;
-
- // Set up a few options not to load by default
- $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
- foreach ($fatoptions as $fatoption) :
- $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
- endforeach;
-}
-
-function populate_roles() {
- populate_roles_160();
- populate_roles_210();
-}
-
-function populate_roles_160() {
- global $wp_roles;
-
- // Add roles
- add_role('administrator', __('Administrator'));
- add_role('editor', __('Editor'));
- add_role('author', __('Author'));
- add_role('contributor', __('Contributor'));
- add_role('subscriber', __('Subscriber'));
-
- // Add caps for Administrator role
- $role = get_role('administrator');
- $role->add_cap('switch_themes');
- $role->add_cap('edit_themes');
- $role->add_cap('activate_plugins');
- $role->add_cap('edit_plugins');
- $role->add_cap('edit_users');
- $role->add_cap('edit_files');
- $role->add_cap('manage_options');
- $role->add_cap('moderate_comments');
- $role->add_cap('manage_categories');
- $role->add_cap('manage_links');
- $role->add_cap('upload_files');
- $role->add_cap('import');
- $role->add_cap('edit_posts');
- $role->add_cap('edit_others_posts');
- $role->add_cap('edit_published_posts');
- $role->add_cap('publish_posts');
- $role->add_cap('edit_pages');
- $role->add_cap('read');
- $role->add_cap('level_10');
- $role->add_cap('level_9');
- $role->add_cap('level_8');
- $role->add_cap('level_7');
- $role->add_cap('level_6');
- $role->add_cap('level_5');
- $role->add_cap('level_4');
- $role->add_cap('level_3');
- $role->add_cap('level_2');
- $role->add_cap('level_1');
- $role->add_cap('level_0');
-
- // Add caps for Editor role
- $role = get_role('editor');
- $role->add_cap('moderate_comments');
- $role->add_cap('manage_categories');
- $role->add_cap('manage_links');
- $role->add_cap('upload_files');
- $role->add_cap('edit_posts');
- $role->add_cap('edit_others_posts');
- $role->add_cap('edit_published_posts');
- $role->add_cap('publish_posts');
- $role->add_cap('edit_pages');
- $role->add_cap('read');
- $role->add_cap('level_7');
- $role->add_cap('level_6');
- $role->add_cap('level_5');
- $role->add_cap('level_4');
- $role->add_cap('level_3');
- $role->add_cap('level_2');
- $role->add_cap('level_1');
- $role->add_cap('level_0');
-
- // Add caps for Author role
- $role = get_role('author');
- $role->add_cap('upload_files');
- $role->add_cap('edit_posts');
- $role->add_cap('edit_published_posts');
- $role->add_cap('publish_posts');
- $role->add_cap('read');
- $role->add_cap('level_2');
- $role->add_cap('level_1');
- $role->add_cap('level_0');
-
- // Add caps for Contributor role
- $role = get_role('contributor');
- $role->add_cap('edit_posts');
- $role->add_cap('read');
- $role->add_cap('level_1');
- $role->add_cap('level_0');
-
- // Add caps for Subscriber role
- $role = get_role('subscriber');
- $role->add_cap('read');
- $role->add_cap('level_0');
-}
-
-function populate_roles_210() {
- $roles = array('administrator', 'editor');
- foreach ($roles as $role) {
- $role = get_role($role);
- if ( empty($role) )
- continue;
-
- $role->add_cap('edit_others_pages');
- $role->add_cap('edit_published_pages');
- $role->add_cap('publish_pages');
- $role->add_cap('delete_pages');
- $role->add_cap('delete_others_pages');
- $role->add_cap('delete_published_pages');
- $role->add_cap('delete_posts');
- $role->add_cap('delete_others_posts');
- $role->add_cap('delete_published_posts');
- $role->add_cap('delete_private_posts');
- $role->add_cap('edit_private_posts');
- $role->add_cap('read_private_posts');
- $role->add_cap('delete_private_pages');
- $role->add_cap('edit_private_pages');
- $role->add_cap('read_private_pages');
- }
-
- $role = get_role('administrator');
- if ( ! empty($role) ) {
- $role->add_cap('delete_users');
- $role->add_cap('create_users');
- }
-
- $role = get_role('author');
- if ( ! empty($role) ) {
- $role->add_cap('delete_posts');
- $role->add_cap('delete_published_posts');
- }
-
- $role = get_role('contributor');
- if ( ! empty($role) ) {
- $role->add_cap('delete_posts');
- }
-}
-
-?>
diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php
index b08ffba..b8069b5 100644
--- a/wp-admin/upgrade.php
+++ b/wp-admin/upgrade.php
@@ -5,23 +5,20 @@ if (!file_exists('../wp-config.php'))
require('../wp-config.php');
timer_start();
-require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
+require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
if (isset($_GET['step']))
$step = (int) $_GET['step'];
else
$step = 0;
-@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php _e('WordPress &rsaquo; Upgrade'); ?></title>
- <link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/install.css?version=<?php bloginfo('version'); ?>" type="text/css" />
- <?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
- <link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/install-rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
- <?php endif; ?>
+ <?php wp_admin_css( 'css/install' ); ?>
</head>
<body>
<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
@@ -39,7 +36,7 @@ switch($step) :
?>
<h2><?php _e('Database Upgrade Required'); ?></h2>
<p><?php _e('Your WordPress database is out-of-date, and must be upgraded before you can continue.'); ?></p>
-<p><?php _e('The upgrade process may take a while, so please be patient.'); ?></p>
+<p><?php _e('The upgrade process may take a while, so please be patient.'); ?></p>
<h2 class="step"><a href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
<?php
break;
diff --git a/wp-admin/upload-rtl.css b/wp-admin/upload-rtl.css
deleted file mode 100644
index cf1a7c2..0000000
--- a/wp-admin/upload-rtl.css
+++ /dev/null
@@ -1,50 +0,0 @@
-#upload-menu li a.upload-tab-link {
- float: right;
- margin: 0 .75em 0 0;
-}
-
-table { float: right; }
-
-#upload-menu li #current-tab-nav {
- float: right;
- padding: 5px 0 0 5px;
- margin-right: -5px;
-}
-
-#upload-file th, #the-attachment-links textarea { text-align: left; }
-
-h2 { margin: 0 0 0 .2em; }
-
-#upload-files li { margin: 0 15px 15px 0; }
-
-#upload-file-view { padding: 0 75px 0 0; }
-
-#upload-menu li {
- display: block;
- float: right;
-}
-
-#upload-menu li.current {
- border-right: 0;
- border-left: 2px solid #448abd;
-}
-
-#upload-file {
- left: auto;
- right: 0;
-}
-
-#file-title {
- margin: 0 75px .2em 0;
- font-family: Tahoma, Georgia, "Times New Roman", Times, serif;
-}
-
-.back {
- left: auto;
- right: 14px;
-}
-
-#uploadoptions td {
- padding-left: 0;
- padding-right: 1em;
-}
diff --git a/wp-admin/upload.php b/wp-admin/upload.php
index 2aa3f66..bfbd9fc 100644
--- a/wp-admin/upload.php
+++ b/wp-admin/upload.php
@@ -1,7 +1,7 @@
<?php
require_once('admin.php');
-@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
if (!current_user_can('upload_files'))
wp_die(__('You do not have permission to upload files.'));
@@ -16,7 +16,7 @@ $post_id = (int) $post_id;
if ( $action == 'edit' && !$ID )
wp_die(__("You are not allowed to be here"));
-require_once('upload-functions.php');
+require_once('includes/upload.php');
if ( !$tab )
$tab = 'browse-all';
@@ -63,10 +63,7 @@ if ( 'inline' == $style ) : ?>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php bloginfo('name') ?> &rsaquo; <?php _e('Uploads'); ?> &#8212; WordPress</title>
-<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
-<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
-<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
-<?php endif; ?>
+<?php wp_admin_css(); ?>
<script type="text/javascript">
//<![CDATA[
function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
diff --git a/wp-admin/users.php b/wp-admin/users.php
index 154a7d7..83c6cb5 100644
--- a/wp-admin/users.php
+++ b/wp-admin/users.php
@@ -489,7 +489,7 @@ default:
<p><a href="users.php"><?php _e('&laquo; Back to All Users'); ?></a></p>
<?php endif; ?>
- <h3><?php
+ <h3><?php
if ( 0 == $wp_user_search->first_user && $wp_user_search->total_users_for_query <= 50 )
printf(__('%3$s shown below'), $wp_user_search->first_user + 1, min($wp_user_search->first_user + $wp_user_search->users_per_page, $wp_user_search->total_users_for_query), $wp_user_search->total_users_for_query);
else
diff --git a/wp-admin/widgets-rtl.css b/wp-admin/widgets-rtl.css
deleted file mode 100644
index a399bae..0000000
--- a/wp-admin/widgets-rtl.css
+++ /dev/null
@@ -1,40 +0,0 @@
-#sbreset, #lastmodule, #palettediv .module, .dropzone, .dropzone ul { float: right; }
-
-* .module, #lastmodule { text-align: right; }
-
-* html #palettediv ul { padding: 0 10px 0 0; }
-
-#palettediv ul { padding: 0 10px 0 0;
- margin-left: 1px!important;}
-
-* .handle, #lastmodule span {
- border-right: 1px solid #f2f2f2;
- border-left: 1px solid #e8e8e8;
-}
-
-#sbadmin p.submit {
- padding-right: 0;
- padding-left: 10px;
- clear: right;
-}
-
-#palettediv .module, #lastmodule, .dropzone {
- margin-right: auto;
- margin-left: 10px;
-}
-
-* .popper {
- right: auto;
- left: 3px;
- background-position: 5px 0;
-}
-
-.controlcloser {
- right: auto;
- left: 8px;
-}
-
-#shadow {
- left: auto;
- right: 0px;
-}
diff --git a/wp-admin/widgets.php b/wp-admin/widgets.php
index b6b330c..a33dc84 100644
--- a/wp-admin/widgets.php
+++ b/wp-admin/widgets.php
@@ -5,38 +5,25 @@ require_once 'admin.php';
if ( ! current_user_can('switch_themes') )
wp_die( __( 'Cheatin&#8217; uh?' ));
-wp_enqueue_script( 'scriptaculous-effects' );
-wp_enqueue_script( 'scriptaculous-dragdrop' );
+wp_enqueue_script('interface');
function wp_widgets_admin_head() {
global $wp_registered_sidebars, $wp_registered_widgets, $wp_registered_widget_controls;
-
- define( 'WP_WIDGETS_WIDTH', 1 + 262 * ( count( $wp_registered_sidebars ) ) );
- define( 'WP_WIDGETS_HEIGHT', 35 * ( count( $wp_registered_widgets ) ) );
?>
- <link rel="stylesheet" href="widgets.css?version=<?php bloginfo('version'); ?>" type="text/css" />
+ <?php wp_admin_css( 'css/widgets' ); ?>
<!--[if IE 7]>
<style type="text/css">
- #palette {float:left;}
+ #palette { float: <?php echo ( get_bloginfo( 'text_direction' ) == 'rtl' ) ? 'right' : 'left'; ?>; }
</style>
<![endif]-->
- <style type="text/css">
- .dropzone ul { height: <?php echo constant( 'WP_WIDGETS_HEIGHT' ); ?>px; }
- #sbadmin #zones { width: <?php echo constant( 'WP_WIDGETS_WIDTH' ); ?>px; }
- </style>
-<?php
- if ( get_bloginfo( 'text_direction' ) == 'rtl' ) {
-?>
- <link rel="stylesheet" href="widgets-rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
<?php
- }
-
+
$cols = array();
foreach ( $wp_registered_sidebars as $index => $sidebar ) {
$cols[] = '\'' . $index . '\'';
}
$cols = implode( ', ', $cols );
-
+
$widgets = array();
foreach ( $wp_registered_widgets as $name => $widget ) {
$widgets[] = '\'' . $widget['id'] . '\'';
@@ -49,127 +36,111 @@ function wp_widgets_admin_head() {
var widgets = [<?php echo $widgets; ?>];
var controldims = new Array;
<?php foreach ( $wp_registered_widget_controls as $name => $widget ) : ?>
- controldims['<?php echo $widget['id']; ?>control'] = new Array;
- controldims['<?php echo $widget['id']; ?>control']['width'] = <?php echo (int) $widget['width']; ?>;
- controldims['<?php echo $widget['id']; ?>control']['height'] = <?php echo (int) $widget['height']; ?>;
+ controldims['#<?php echo $widget['id']; ?>control'] = new Array;
+ controldims['#<?php echo $widget['id']; ?>control']['width'] = <?php echo (int) $widget['width']; ?>;
+ controldims['#<?php echo $widget['id']; ?>control']['height'] = <?php echo (int) $widget['height']; ?>;
<?php endforeach; ?>
function initWidgets() {
<?php foreach ( $wp_registered_widget_controls as $name => $widget ) : ?>
- $('<?php echo $widget['id']; ?>popper').onclick = function() {popControl('<?php echo $widget['id']; ?>control');};
- $('<?php echo $widget['id']; ?>closer').onclick = function() {unpopControl('<?php echo $widget['id']; ?>control');};
- new Draggable('<?php echo $widget['id']; ?>control', {revert:false,handle:'controlhandle',starteffect:function(){},endeffect:function(){},change:function(o){dragChange(o);}});
+ jQuery('#<?php echo $widget['id']; ?>popper').click(function() {popControl('#<?php echo $widget['id']; ?>control');});
+ jQuery('#<?php echo $widget['id']; ?>closer').click(function() {unpopControl('#<?php echo $widget['id']; ?>control');});
+ jQuery('#<?php echo $widget['id']; ?>control').Draggable({handle: '.controlhandle', zIndex: 1000});
if ( true && window.opera )
- $('<?php echo $widget['id']; ?>control').style.border = '1px solid #bbb';
+ jQuery('#<?php echo $widget['id']; ?>control').css('border','1px solid #bbb');
<?php endforeach; ?>
- if ( true && window.opera )
- $('shadow').style.background = 'transparent';
- new Effect.Opacity('shadow', {to:0.0});
- widgets.map(function(o) {o='widgetprefix-'+o; Position.absolutize(o); Position.relativize(o);} );
- $A(Draggables.drags).map(function(o) {o.startDrag(null); o.finishDrag(null);});
- //for ( var n in Draggables.drags ) {
- for ( n=0; n<=Draggables.drags.length; n++ ) {
- if ( parseInt( n ) ) {
- if ( Draggables.drags[n].element.id == 'lastmodule' ) {
- Draggables.drags[n].destroy();
- break;
- }
- }
- }
- resetPaletteHeight();
+ jQuery('#shadow').css('opacity','0');
+ jQuery(widgets).each(function(o) {o='#widgetprefix-'+o; jQuery(o).css('position','relative');} );
}
function resetDroppableHeights() {
var max = 6;
- cols.map(function(o) {var c = $(o).childNodes.length; if ( c > max ) max = c;} );
- var height = 35 * ( max + 1);
- cols.map(function(o) {h = (($(o).childNodes.length + 1) * 35); $(o).style.height = (h > 280 ? h : 280) + 'px';} );
- }
- function resetPaletteHeight() {
- var p = $('palette'), pd = $('palettediv'), last = $('lastmodule');
- p.appendChild(last);
- if ( Draggables.activeDraggable && last.id == Draggables.activeDraggable.element.id )
- last = last.previousSibling;
- var y1 = Position.cumulativeOffset(last)[1] + last.offsetHeight;
- var y2 = Position.cumulativeOffset(pd)[1] + pd.offsetHeight;
- var dy = y1 - y2;
- pd.style.height = (pd.offsetHeight + dy + 9) + "px";
+ jQuery.map(cols, function(o) {
+ var c = jQuery('#' + o + ' li').length;
+ if ( c > max ) max = c;
+ });
+ var maxheight = 35 * ( max + 1);
+ jQuery.map(cols, function(o) {
+ height = 0 == jQuery('#' + o + ' li').length ? maxheight - jQuery('#' + o + 'placemat').height() : maxheight;
+ jQuery('#' + o).height(height);
+ });
}
function maxHeight(elm) {
htmlheight = document.body.parentNode.clientHeight;
bodyheight = document.body.clientHeight;
var height = htmlheight > bodyheight ? htmlheight : bodyheight;
- $(elm).style.height = height + 'px';
+ jQuery(elm).height(height);
+ }
+ function getViewportDims() {
+ var x,y;
+ if (self.innerHeight) { // all except Explorer
+ x = self.innerWidth;
+ y = self.innerHeight;
+ } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
+ x = document.documentElement.clientWidth;
+ y = document.documentElement.clientHeight;
+ } else if (document.body) { // other Explorers
+ x = document.body.clientWidth;
+ y = document.body.clientHeight;
+ }
+ return new Array(x,y);
}
function dragChange(o) {
- el = o.element ? o.element : $(o);
- var p = Position.page(el);
- var right = p[0];
- var top = p[1];
- var left = $('shadow').offsetWidth - (el.offsetWidth + right);
- var bottom = $('shadow').offsetHeight - (el.offsetHeight + top);
- if ( right < 1 ) el.style.left = 0;
- if ( top < 1 ) el.style.top = 0;
- if ( left < 1 ) el.style.left = (left + right) + 'px';
- if ( bottom < 1 ) el.style.top = (top + bottom) + 'px';
+ var p = getViewportDims();
+ var screenWidth = p[0];
+ var screenHeight = p[1];
+ var elWidth = parseInt( jQuery(o).css('width') );
+ var elHeight = parseInt( jQuery(o).css('height') );
+ var elLeft = parseInt( jQuery(o).css('left') );
+ var elTop = parseInt( jQuery(o).css('top') );
+ if ( screenWidth < ( parseInt(elLeft) + parseInt(elWidth) ) )
+ jQuery(o).css('left', ( screenWidth - elWidth ) + 'px' );
+ if ( screenHeight < ( parseInt(elTop) + parseInt(elHeight) ) )
+ jQuery(o).css('top', ( screenHeight - elHeight ) + 'px' );
+ if ( elLeft < 1 )
+ jQuery(o).css('left', '1px');
+ if ( elTop < 1 )
+ jQuery(o).css('top', '1px');
}
function popControl(elm) {
- el = $(elm);
- el.style.width = controldims[elm]['width'] + 'px';
- el.style.height = controldims[elm]['height'] + 'px';
var x = ( document.body.clientWidth - controldims[elm]['width'] ) / 2;
var y = ( document.body.parentNode.clientHeight - controldims[elm]['height'] ) / 2;
- el.style.position = 'absolute';
- el.style.right = '' + x + 'px';
- el.style.top = '' + y + 'px';
- el.style.zIndex = 1000;
- el.className='control';
- $('shadow').onclick = function() {unpopControl(elm);};
- window.onresize = function(){maxHeight('shadow');dragChange(elm);};
+ jQuery(elm).css({display: 'block', width: controldims[elm]['width'] + 'px', height: controldims[elm]['height'] + 'px', position: 'absolute', right: x + 'px', top: y + 'px', zIndex: '1000' });
+ jQuery(elm).attr('class','control');
+ jQuery('#shadow').click(function() {unpopControl(elm);});
+ window.onresize = function(){maxHeight('#shadow');dragChange(elm);};
popShadow();
}
function popShadow() {
- maxHeight('shadow');
- var shadow = $('shadow');
- shadow.style.zIndex = 999;
- shadow.style.display = 'block';
- new Effect.Opacity('shadow', {duration:0.5, from:0.0, to:0.2});
+ maxHeight('#shadow');
+ jQuery('#shadow').css({zIndex: '999', display: 'block'});
+ jQuery('#shadow').fadeTo('fast', 0.2);
}
function unpopShadow() {
- new Effect.Opacity('shadow', {to:0.0});
- $('shadow').style.display = 'none';
+ jQuery('#shadow').fadeOut('fast', function() {jQuery('#shadow').hide()});
}
function unpopControl(el) {
- $(el).className='hidden';
+ jQuery(el).attr('class','hidden');
+ jQuery(el).hide();
unpopShadow();
}
function serializeAll() {
- <?php foreach ( $wp_registered_sidebars as $index => $sidebar ) : ?>
- $('<?php echo $index; ?>order').value = Sortable.serialize('<?php echo $index; ?>');
+ <?php $i = 0; foreach ( $wp_registered_sidebars as $index => $sidebar ) : $i++; ?>
+ var serial<?php echo $i ?> = jQuery.SortSerialize('<?php echo $index ?>');
+ jQuery('#<?php echo $index ?>order').attr('value',serial<?php echo $i ?>.hash.replace(/widgetprefix-/g, ''));
<?php endforeach; ?>
}
function updateAll() {
- resetDroppableHeights();
- resetPaletteHeight();
- cols.map(function(o){
- var pm = $(o+'placematt');
- if ( $(o).childNodes.length == 0 ) {
- pm.style.display = 'block';
- //Position.absolutize(o+'placematt');
- } else {
- pm.style.display = 'none';
- }
+ jQuery.map(cols, function(o) {
+ if ( jQuery('#' + o + ' li').length )
+ jQuery('#'+o+'placemat span.handle').hide();
+ else
+ jQuery('#'+o+'placemat span.handle').show();
});
+ resetDroppableHeights();
}
- function noSelection(event) {
- if ( document.selection ) {
- var range = document.selection.createRange();
- range.collapse(false);
- range.select();
- return false;
- }
- }
- addLoadEvent(updateAll);
- addLoadEvent(initWidgets);
- Event.observe(window, 'resize', resetPaletteHeight);
+ jQuery(document).ready( function() {
+ updateAll();
+ initWidgets();
+ });
// ]]>
</script>
<?php
@@ -179,19 +150,19 @@ do_action( 'sidebar_admin_setup' );
function wp_widget_draggable( $name ) {
global $wp_registered_widgets, $wp_registered_widget_controls;
-
+
if ( !isset( $wp_registered_widgets[$name] ) ) {
return;
}
-
+
$sanitized_name = sanitize_title( $wp_registered_widgets[$name]['id'] );
$link_title = __( 'Configure' );
- $popper = ( isset( $wp_registered_widget_controls[$name] ) )
+ $popper = ( isset( $wp_registered_widget_controls[$name] ) )
? ' <div class="popper" id="' . $sanitized_name . 'popper" title="' . $link_title . '">&#8801;</div>'
: '';
-
+
$output = '<li class="module" id="widgetprefix-%1$s"><span class="handle">%2$s</span></li>';
-
+
printf( $output, $sanitized_name, $wp_registered_widgets[$name]['name'] . $popper );
}
@@ -204,11 +175,11 @@ if ( count( $wp_registered_sidebars ) < 1 ) {
?>
<div class="wrap">
<h2><?php _e( 'No Sidebars Defined' ); ?></h2>
-
+
<p><?php _e( 'You are seeing this message because the theme you are currently using isn&#8217;t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://automattic.com/code/widgets/themes/">follow these instructions</a>.' ); /* TODO: article on codex */; ?></p>
</div>
<?php
-
+
require_once 'admin-footer.php';
exit;
}
@@ -221,23 +192,23 @@ if ( empty( $sidebars_widgets ) ) {
if ( isset( $_POST['action'] ) ) {
check_admin_referer( 'widgets-save-widget-order' );
-
+
switch ( $_POST['action'] ) {
case 'default' :
$sidebars_widgets = wp_get_widget_defaults();
wp_set_sidebars_widgets( $sidebars_widgets );
break;
-
+
case 'save_widget_order' :
$sidebars_widgets = array();
-
+
foreach ( $wp_registered_sidebars as $index => $sidebar ) {
$postindex = $index . 'order';
-
+
parse_str( $_POST[$postindex], $order );
-
+
$new_order = $order[$index];
-
+
if ( is_array( $new_order ) ) {
foreach ( $new_order as $sanitized_name ) {
foreach ( $wp_registered_widgets as $name => $widget ) {
@@ -248,7 +219,7 @@ if ( isset( $_POST['action'] ) ) {
}
}
}
-
+
wp_set_sidebars_widgets( $sidebars_widgets );
break;
}
@@ -260,14 +231,14 @@ $inactive_widgets = array();
foreach ( $wp_registered_widgets as $name => $widget ) {
$is_active = false;
-
+
foreach ( $wp_registered_sidebars as $index => $sidebar ) {
if ( is_array( $sidebars_widgets[$index] ) && in_array( $name, $sidebars_widgets[$index] ) ) {
$is_active = true;
break;
}
}
-
+
if ( !$is_active ) {
$inactive_widgets[] = $name;
}
@@ -297,9 +268,9 @@ if ( isset( $_POST['action'] ) ) {
?>
<div class="wrap">
<h2><?php _e( 'Sidebar Arrangement' ); ?></h2>
-
+
<p><?php _e( 'You can drag and drop widgets onto your sidebar below.' ); ?></p>
-
+
<form id="sbadmin" method="post" onsubmit="serializeAll();">
<p class="submit">
<input type="submit" value="<?php _e( 'Save Changes &raquo;' ); ?>" />
@@ -309,17 +280,17 @@ if ( isset( $_POST['action'] ) ) {
foreach ( $wp_registered_sidebars as $index => $sidebar ) {
?>
<input type="hidden" id="<?php echo $index; ?>order" name="<?php echo $index; ?>order" value="" />
-
+
<div class="dropzone">
<h3><?php echo $sidebar['name']; ?></h3>
-
- <div id="<?php echo $index; ?>placematt" class="module placemat">
+
+ <div id="<?php echo $index; ?>placemat" class="placemat">
<span class="handle">
<h4><?php _e( 'Default Sidebar' ); ?></h4>
<?php _e( 'Your theme will display its usual sidebar when this box is empty. Dragging widgets into this box will replace the usual sidebar with your customized sidebar.' ); ?>
</span>
</div>
-
+
<ul id="<?php echo $index; ?>">
<?php
if ( is_array( $sidebars_widgets[$index] ) ) {
@@ -333,42 +304,39 @@ if ( isset( $_POST['action'] ) ) {
<?php
}
?>
-
- <br class="clear" />
-
+
</div>
-
+
<div id="palettediv">
<h3><?php _e( 'Available Widgets' ); ?></h3>
-
+
<ul id="palette">
<?php
foreach ( $inactive_widgets as $name ) {
wp_widget_draggable( $name );
}
?>
- <li id="lastmodule"><span></span></li>
</ul>
</div>
-
+
<script type="text/javascript">
// <![CDATA[
+ jQuery(document).ready(function(){
<?php foreach ( $containers as $container ) { ?>
- Sortable.create("<?php echo $container; ?>", {
- dropOnEmpty: true, containment: [<?php echo $c_string; ?>],
- handle: 'handle', constraint: false, onUpdate: updateAll,
- format: /^widgetprefix-(.*)$/
- });
+ jQuery('ul#<?php echo $container; ?>').Sortable({
+ accept: 'module', activeclass: 'activeDraggable', opacity: 0.8, revert: true, onStop: updateAll
+ });
<?php } ?>
+ });
// ]]>
</script>
-
+
<p class="submit">
<?php wp_nonce_field( 'widgets-save-widget-order' ); ?>
<input type="hidden" name="action" id="action" value="save_widget_order" />
<input type="submit" value="<?php _e( 'Save Changes &raquo;' ); ?>" />
</p>
-
+
<div id="controls">
<?php foreach ( $wp_registered_widget_controls as $name => $widget ) { ?>
<div class="hidden" id="<?php echo $widget['id']; ?>control">
@@ -381,12 +349,12 @@ if ( isset( $_POST['action'] ) ) {
<?php } ?>
</div>
</form>
-
+
<br class="clear" />
</div>
-
+
<div id="shadow"> </div>
-
+
<?php do_action( 'sidebar_admin_page' ); ?>
<?php require_once 'admin-footer.php'; ?>
diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css
index 5fc8d55..2b06951 100644
--- a/wp-admin/wp-admin.css
+++ b/wp-admin/wp-admin.css
@@ -103,24 +103,23 @@ thead, .thead {
padding: 1em;
}
-a.edit, a.delete, a.edit:hover, a.delete:hover {
+a.view, a.edit, a.delete, a.view:hover, a.edit:hover, a.delete:hover {
border-bottom: none;
display: block;
padding: 5px 0;
text-align: center;
}
-a.edit:hover {
+a.view:hover, a.edit:hover {
background: #ccc;
color: #036;
}
a:visited {
- color: #006;
+ color: #004;
}
a:hover {
-/* border-bottom: 1px solid #3a75ae;*/
color: #069;
}
@@ -132,7 +131,7 @@ body {
}
body, td {
- font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
+ font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
}
fieldset {
@@ -170,13 +169,13 @@ form, label input {
}
h2 {
- border-bottom: .5em solid #e5f3ff;
color: #333;
- font: normal 32px/5px serif;
+ font: normal 32px Georgia, "Times New Roman", Times, serif;
margin: 5px 10px;
+ background: url( images/heading-bg.gif ) repeat-x bottom;
}
-img, #footer a {
+img {
border: 0;
}
@@ -437,7 +436,7 @@ form#upload #post_content {
}
.wrap h2 {
- margin: .4em 0 .5em;
+ margin: 0 0 .5em;
clear: both;
}
@@ -538,7 +537,7 @@ input.disabled, textarea.disabled {
border: none;
}
-#postdiv, #titlediv, #guiddiv {
+#postdiv, #titlediv, #guiddiv, #tagdiv {
margin: 0 8px 0 0;
padding: 0;
}
@@ -558,7 +557,7 @@ input.disabled, textarea.disabled {
line-height: 140%;
}
-#titlediv input, #guiddiv input {
+#titlediv input, #guiddiv input, #tagdiv input {
margin: 0;
width: 100%;
}
@@ -654,24 +653,15 @@ input.delete:hover {
#footer {
clear: both;
- text-align: center;
- width: 500px;
- margin: auto;
- height: 100px;
-}
-
-#footer .docs {
- padding-top: 19px;
- line-height: 160%;
+ height: 35px;
+ padding-left: 40px;
+ margin: 15px 5%;
+ background: url('images/logo-ghost.png') no-repeat top left;
}
-#footer .docs a {
- text-decoration: underline;
-}
-#footer .logo {
- float: left;
+#footer p {
margin: 0;
- padding: 0;
+ padding: 5px 0;
}
#login {
@@ -689,6 +679,9 @@ input.delete:hover {
padding: 0 50px 25px;
_width: 325px;
_margin: 0 auto;
+ min-height: 200px;
+ height: auto !important; /* min-height fast hack */
+ height: 200px;
}
#login #login_error {
@@ -791,22 +784,25 @@ input.delete:hover {
width: 320px;
}
-#searchform {
+#searchform fieldset {
float: left;
- margin-right: 1em;
- width: 18em;
+ margin: 0 1.5ex 1em 0;
+ padding: 0;
}
-#viewarc {
- float: left;
- width: 23em;
- margin-bottom: 1em;
+#searchform fieldset legend {
+ padding: 0 0 .2em 1px;
+}
+
+#searchform #s {
+ padding: 4px 3px;
}
-#viewcat {
+#searchform #post-query-submit {
float: left;
- width: 30em;
- margin-bottom: 1em;
+ margin: 14px 0 1em;
+ position: relative;
+ top: .35em;
}
#postcustom .updatemeta, #postcustom .deletemeta {
@@ -894,7 +890,7 @@ input.delete:hover {
font-family: Georgia, "Times New Roman", Times, serif;
}
-#wphead h1 span {
+#wphead h1 span#viewsite {
font-size: .4em;
letter-spacing: 0;
}
@@ -912,17 +908,13 @@ input.delete:hover {
}
#zeitgeist h2, fieldset legend a {
- border-bottom: none;
+ background: none;
}
* html #zeitgeist h2 {
padding-top: 10px;
}
-#zeitgeist h2 {
- margin-top: .4em;
-}
-
#zeitgeist h3 {
border-bottom: 1px solid #ccc;
font-size: 16px;
@@ -1339,3 +1331,20 @@ a.view-link {
margin-right: 220px;
text-decoration:underline;
}
+
+#update-nag, .plugin-update {
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #ccc;
+ background: #fffeeb;
+ line-height: 29px;
+ font-size: 12px;
+ color: #555;
+ text-align: center;
+}
+
+#update-nag a, .plugin-update a {
+ font-size: 1.1em;
+}
+#update-nag a:link, .plugin-update a:link {
+ color: #036;
+}