Changeset 13573 for trunk/wp-admin/includes/export.php
- Timestamp:
- 03/03/2010 04:45:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/export.php
r13055 r13573 24 24 * @param unknown_type $author 25 25 */ 26 function export_wp($author='' ) {26 function export_wp($author='', $category='', $post_type='', $status='', $start_date='', $end_date='') { 27 27 global $wpdb, $post_ids, $post, $wp_taxonomies; 28 28 29 29 do_action('export_wp'); 30 30 31 $filename = 'wordpress.' . date('Y-m-d') . '.xml'; 31 if(strlen($start_date) > 4 && strlen($end_date) > 4) { 32 $filename = 'wordpress.' . $start_date . '.' . $end_date . '.xml'; 33 } else { 34 $filename = 'wordpress.' . date('Y-m-d') . '.xml'; 35 } 32 36 33 37 header('Content-Description: File Transfer'); … … 35 39 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); 36 40 37 $where = ''; 38 if ( $author and $author != 'all' ) { 39 $author_id = (int) $author; 40 $where = $wpdb->prepare(" WHERE post_author = %d ", $author_id); 41 } 41 if ( $post_type and $post_type != 'all' ) { 42 $where = $wpdb->prepare("WHERE post_type = %s ", $post_type); 43 } else { 44 $where = "WHERE post_type != 'revision' "; 45 } 46 if ( $author and $author != 'all' ) { 47 $author_id = (int) $author; 48 $where .= $wpdb->prepare("AND post_author = %d ", $author_id); 49 } 50 if ( $start_date and $start_date != 'all' ) { 51 $where .= $wpdb->prepare("AND post_date >= %s ", $start_date); 52 } 53 if ( $end_date and $end_date != 'all' ) { 54 $where .= $wpdb->prepare("AND post_date < %s ", $end_date); 55 } 56 if ( $category and $category != 'all' ) { 57 $taxomony_id = (int) $category; 58 $where .= $wpdb->prepare("AND ID IN (SELECT object_id FROM {$wpdb->term_relationships} " . "WHERE term_taxonomy_id = %d) ", $taxomony_id); 59 } 60 if ( $status and $status != 'all' ) { 61 $where .= $wpdb->prepare("AND post_status = %s ", $status); 62 } 42 63 43 64 // grab a snapshot of post IDs, just in case it changes during the export … … 301 322 $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); 302 323 foreach ($posts as $post) { 303 // Don't export revisions. They bloat the export.304 if ( 'revision' == $post->post_type )305 continue;306 324 setup_postdata($post); 307 325
Note: See TracChangeset
for help on using the changeset viewer.