X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/3e7fab96d7874067884348df10bbdcdefa4a89ad..88550bc3400cc7c035ff590ecb007c7938041ded:/wp-admin/export.php diff --git a/wp-admin/export.php b/wp-admin/export.php index eab8044d..78ccf13e 100644 --- a/wp-admin/export.php +++ b/wp-admin/export.php @@ -1,272 +1,244 @@ +if ( !current_user_can('export') ) + wp_die(__('You do not have sufficient permissions to export the content of this site.')); -
-

-
-

-

-

-
-

- - - - - - -
- -
-

- -

-
-
-
+/** Load WordPress export API */ +require_once( ABSPATH . 'wp-admin/includes/export.php' ); +$title = __('Export'); +/** + * Display JavaScript on the page. + * + * @since 3.5.0 + */ +function export_add_js() { +?> + 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; +add_action( 'admin_head', 'export_add_js' ); + +get_current_screen()->add_help_tab( array( + 'id' => 'overview', + 'title' => __('Overview'), + 'content' => '

' . __('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.') . '

' . + '

' . __('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.') . '

', +) ); + +get_current_screen()->set_help_sidebar( + '

' . __('For more information:') . '

' . + '

' . __('Documentation on Export') . '

' . + '

' . __('Support Forums') . '

' +); + +// If the 'download' URL parameter is set, a WXR export file is baked and returned. +if ( isset( $_GET['download'] ) ) { + $args = array(); + + if ( ! isset( $_GET['content'] ) || 'all' == $_GET['content'] ) { + $args['content'] = 'all'; + } else if ( 'posts' == $_GET['content'] ) { + $args['content'] = 'post'; + + if ( $_GET['cat'] ) + $args['category'] = (int) $_GET['cat']; + + if ( $_GET['post_author'] ) + $args['author'] = (int) $_GET['post_author']; + + if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) { + $args['start_date'] = $_GET['post_start_date']; + $args['end_date'] = $_GET['post_end_date']; + } + + if ( $_GET['post_status'] ) + $args['status'] = $_GET['post_status']; + } else if ( 'pages' == $_GET['content'] ) { + $args['content'] = 'page'; + + if ( $_GET['page_author'] ) + $args['author'] = (int) $_GET['page_author']; + + if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) { + $args['start_date'] = $_GET['page_start_date']; + $args['end_date'] = $_GET['page_end_date']; + } + + if ( $_GET['page_status'] ) + $args['status'] = $_GET['page_status']; } else { - $categories[] = $cat; + $args['content'] = $_GET['content']; } -} -unset($categories); - -function wxr_cdata($str) { - if ( seems_utf8($str) == false ) - $str = utf8_encode($str); - - // $str = ent2ncr(wp_specialchars($str)); - $str = ""; + /** + * Filter the export args. + * + * @since 3.5.0 + * + * @param array $args The arguments to send to the exporter. + */ + $args = apply_filters( 'export_args', $args ); - 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) . ''; + export_wp( $args ); + die(); } -function wxr_tag_description($t) { - if ( empty($t->description) ) +require_once( ABSPATH . 'wp-admin/admin-header.php' ); + +/** + * Create the date options fields for exporting a given post type. + * + * @global wpdb $wpdb WordPress database abstraction object. + * @global WP_Locale $wp_locale Date and Time Locale object. + * + * @since 3.1.0 + * + * @param string $post_type The post type. Default 'post'. + */ +function export_date_options( $post_type = 'post' ) { + global $wpdb, $wp_locale; + + $months = $wpdb->get_results( $wpdb->prepare( " + SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month + FROM $wpdb->posts + WHERE post_type = %s AND post_status != 'auto-draft' + ORDER BY post_date DESC + ", $post_type ) ); + + $month_count = count( $months ); + if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) 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"; - } + foreach ( $months as $date ) { + if ( 0 == $date->year ) + continue; - 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"; + $month = zeroise( $date->month, 2 ); + echo ''; } - - 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; ?> +

+

+

+ +

+
+ +

+

+ +

+
    +
  • + + __('All') ) ); ?> +
  • +
  • + get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID"); -if ( $postmeta ) { + $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" ); + wp_dropdown_users( array( 'include' => $authors, 'name' => 'post_author', 'multi' => true, 'show_option_all' => __('All') ) ); ?> - - -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; ?> - - - - - - +
  • +
  • + + + +
  • +
  • + + +
  • +
+ +

+
    +
  • + get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" ); + wp_dropdown_users( array( 'include' => $authors, 'name' => 'page_author', 'multi' => true, 'show_option_all' => __('All') ) ); +?> +
  • +
  • + + + +
  • +
  • + + +
  • +
+ + false, 'can_export' => true ), 'objects' ) as $post_type ) : ?> +

+ -include ('admin-footer.php'); + + + +
+
+ +