diff --git a/wp-admin/export.php b/wp-admin/export.php index 45f1774ce8..976e36fe65 100644 --- a/wp-admin/export.php +++ b/wp-admin/export.php @@ -1,10 +1,13 @@ @@ -44,229 +47,6 @@ foreach ( $authors as $id ) { get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); - -$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->term_id] = $category->parent; - - $parents = array_unique(array_diff($parents, array_keys($parents))); - - if ( $zero = array_search('0', $parents) ) - unset($parents[$zero]); - - return $parents; -} - -while ( $parents = wxr_missing_parents($categories) ) { - $found_parents = get_categories("include=" . join(', ', $parents)); - if ( is_array($found_parents) && count($found_parents) ) - $categories = array_merge($categories, $found_parents); - else - break; -} - -// Put them in order to be inserted with no child going before its parent -$pass = 0; -$passes = 1000 + count($categories); -while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) { - if ( $cat->parent == 0 || isset($cats[$cat->parent]) ) { - $cats[$cat->term_id] = $cat; - } else { - $categories[] = $cat; - } -} -unset($categories); - -function wxr_cdata($str) { - if ( seems_utf8($str) == false ) - $str = utf8_encode($str); - - // $str = ent2ncr(wp_specialchars($str)); - - $str = ""; - - return $str; -} - -function wxr_cat_name($c) { - if ( empty($c->name) ) - return; - - echo '' . wxr_cdata($c->name) . ''; -} - -function wxr_category_description($c) { - if ( empty($c->description) ) - return; - - echo '' . wxr_cdata($c->description) . ''; -} - -function wxr_tag_name($t) { - if ( empty($t->name) ) - return; - - echo '' . wxr_cdata($t->name) . ''; -} - -function wxr_tag_description($t) { - if ( empty($t->description) ) - return; - - echo '' . wxr_cdata($t->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\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\n"; - } - - echo $the_list; -} - -echo '\n"; - -?> - - - - - - - - - - - - - - - - - - - - - <?php bloginfo_rss('name'); ?> - - - - http://wordpress.org/?v= - - - slug; ?>parent ? $cats[$c->parent]->name : ''; ?> - - - slug; ?> - - - 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); ?> - -<?php the_title_rss() ?> - - - - - - - -post_content ?>]]> -ID; ?> -post_date; ?> -post_date_gmt; ?> -comment_status; ?> -ping_status; ?> -post_name; ?> -post_status; ?> -post_parent; ?> -menu_order; ?> -post_type; ?> -get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID"); -if ( $postmeta ) { -?> - - -meta_key; ?> -meta_value; ?> - - - -get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID"); -if ( $comments ) { foreach ( $comments as $c ) { ?> - -comment_ID; ?> -comment_author); ?> -comment_author_email; ?> -comment_author_url; ?> -comment_author_IP; ?> -comment_date; ?> -comment_date_gmt; ?> -comment_content; ?> -comment_approved; ?> -comment_type; ?> -comment_parent; ?> - - - - - - - diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php new file mode 100644 index 0000000000..aa20dc2381 --- /dev/null +++ b/wp-admin/includes/export.php @@ -0,0 +1,226 @@ +get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); + +$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->term_id] = $category->parent; + + $parents = array_unique(array_diff($parents, array_keys($parents))); + + if ( $zero = array_search('0', $parents) ) + unset($parents[$zero]); + + return $parents; +} + +while ( $parents = wxr_missing_parents($categories) ) { + $found_parents = get_categories("include=" . join(', ', $parents)); + if ( is_array($found_parents) && count($found_parents) ) + $categories = array_merge($categories, $found_parents); + else + break; +} + +// Put them in order to be inserted with no child going before its parent +$pass = 0; +$passes = 1000 + count($categories); +while ( ( $cat = array_shift($categories) ) && ++$pass < $passes ) { + if ( $cat->parent == 0 || isset($cats[$cat->parent]) ) { + $cats[$cat->term_id] = $cat; + } else { + $categories[] = $cat; + } +} +unset($categories); + +function wxr_cdata($str) { + if ( seems_utf8($str) == false ) + $str = utf8_encode($str); + + // $str = ent2ncr(wp_specialchars($str)); + + $str = ""; + + return $str; +} + +function wxr_cat_name($c) { + if ( empty($c->name) ) + return; + + echo '' . wxr_cdata($c->name) . ''; +} + +function wxr_category_description($c) { + if ( empty($c->description) ) + return; + + echo '' . wxr_cdata($c->description) . ''; +} + +function wxr_tag_name($t) { + if ( empty($t->name) ) + return; + + echo '' . wxr_cdata($t->name) . ''; +} + +function wxr_tag_description($t) { + if ( empty($t->description) ) + return; + + echo '' . wxr_cdata($t->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\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\n"; + } + + echo $the_list; +} + +echo '\n"; + +?> + + + + + + + + + + + + + + + + + + + + + <?php bloginfo_rss('name'); ?> + + + + http://wordpress.org/?v= + + + slug; ?>parent ? $cats[$c->parent]->name : ''; ?> + + + slug; ?> + + + 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); ?> + +<?php the_title_rss() ?> + + + + + + + +post_content ?>]]> +ID; ?> +post_date; ?> +post_date_gmt; ?> +comment_status; ?> +ping_status; ?> +post_name; ?> +post_status; ?> +post_parent; ?> +menu_order; ?> +post_type; ?> +get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID"); +if ( $postmeta ) { +?> + + +meta_key; ?> +meta_value; ?> + + + +get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID"); +if ( $comments ) { foreach ( $comments as $c ) { ?> + +comment_ID; ?> +comment_author); ?> +comment_author_email; ?> +comment_author_url; ?> +comment_author_IP; ?> +comment_date; ?> +comment_date_gmt; ?> +comment_content; ?> +comment_approved; ?> +comment_type; ?> +comment_parent; ?> + + + + + + + \ No newline at end of file