equal
deleted
inserted
replaced
22 * @since unknown |
22 * @since unknown |
23 * |
23 * |
24 * @param unknown_type $author |
24 * @param unknown_type $author |
25 */ |
25 */ |
26 function export_wp($author='') { |
26 function export_wp($author='') { |
27 global $wpdb, $post_ids, $post; |
27 global $wpdb, $post_ids, $post, $wp_taxonomies; |
28 |
28 |
29 do_action('export_wp'); |
29 do_action('export_wp'); |
30 |
30 |
31 $filename = 'wordpress.' . date('Y-m-d') . '.xml'; |
31 $filename = 'wordpress.' . date('Y-m-d') . '.xml'; |
32 |
32 |
43 // grab a snapshot of post IDs, just in case it changes during the export |
43 // grab a snapshot of post IDs, just in case it changes during the export |
44 $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); |
44 $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); |
45 |
45 |
46 $categories = (array) get_categories('get=all'); |
46 $categories = (array) get_categories('get=all'); |
47 $tags = (array) get_tags('get=all'); |
47 $tags = (array) get_tags('get=all'); |
|
48 |
|
49 $custom_taxonomies = $wp_taxonomies; |
|
50 unset($custom_taxonomies['category']); |
|
51 unset($custom_taxonomies['post_tag']); |
|
52 unset($custom_taxonomies['link_category']); |
|
53 $custom_taxonomies = array_keys($custom_taxonomies); |
|
54 $terms = (array) get_terms($custom_taxonomies, 'get=all'); |
48 |
55 |
49 /** |
56 /** |
50 * {@internal Missing Short Description}} |
57 * {@internal Missing Short Description}} |
51 * |
58 * |
52 * @since unknown |
59 * @since unknown |
184 |
191 |
185 /** |
192 /** |
186 * {@internal Missing Short Description}} |
193 * {@internal Missing Short Description}} |
187 * |
194 * |
188 * @since unknown |
195 * @since unknown |
|
196 * |
|
197 * @param object $t Term Object |
|
198 */ |
|
199 function wxr_term_name($t) { |
|
200 if ( empty($t->name) ) |
|
201 return; |
|
202 |
|
203 echo '<wp:term_name>' . wxr_cdata($t->name) . '</wp:term_name>'; |
|
204 } |
|
205 |
|
206 /** |
|
207 * {@internal Missing Short Description}} |
|
208 * |
|
209 * @since unknown |
|
210 * |
|
211 * @param object $t Term Object |
|
212 */ |
|
213 function wxr_term_description($t) { |
|
214 if ( empty($t->description) ) |
|
215 return; |
|
216 |
|
217 echo '<wp:term_description>' . wxr_cdata($t->description) . '</wp:term_description>'; |
|
218 } |
|
219 |
|
220 /** |
|
221 * {@internal Missing Short Description}} |
|
222 * |
|
223 * @since unknown |
189 */ |
224 */ |
190 function wxr_post_taxonomy() { |
225 function wxr_post_taxonomy() { |
191 $categories = get_the_category(); |
226 $categories = get_the_category(); |
192 $tags = get_the_tags(); |
227 $tags = get_the_tags(); |
193 $the_list = ''; |
228 $the_list = ''; |
219 <!-- It contains information about your blog's posts, comments, and categories. --> |
254 <!-- It contains information about your blog's posts, comments, and categories. --> |
220 <!-- You may use this file to transfer that content from one site to another. --> |
255 <!-- You may use this file to transfer that content from one site to another. --> |
221 <!-- This file is not intended to serve as a complete backup of your blog. --> |
256 <!-- This file is not intended to serve as a complete backup of your blog. --> |
222 |
257 |
223 <!-- To import this information into a WordPress blog follow these steps. --> |
258 <!-- To import this information into a WordPress blog follow these steps. --> |
224 <!-- 1. Log into that blog as an administrator. --> |
259 <!-- 1. Log in to that blog as an administrator. --> |
225 <!-- 2. Go to Tools: Import in the blog's admin panels (or Manage: Import in older versions of WordPress). --> |
260 <!-- 2. Go to Tools: Import in the blog's admin panels (or Manage: Import in older versions of WordPress). --> |
226 <!-- 3. Choose "WordPress" from the list. --> |
261 <!-- 3. Choose "WordPress" from the list. --> |
227 <!-- 4. Upload this file using the form provided on that page. --> |
262 <!-- 4. Upload this file using the form provided on that page. --> |
228 <!-- 5. You will first be asked to map the authors in this export file to users --> |
263 <!-- 5. You will first be asked to map the authors in this export file to users --> |
229 <!-- on the blog. For each author, you may choose to map to an --> |
264 <!-- on the blog. For each author, you may choose to map to an --> |
254 <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> |
289 <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> |
255 <?php endforeach; endif; ?> |
290 <?php endforeach; endif; ?> |
256 <?php if ( $tags ) : foreach ( $tags as $t ) : ?> |
291 <?php if ( $tags ) : foreach ( $tags as $t ) : ?> |
257 <wp:tag><wp:tag_slug><?php echo $t->slug; ?></wp:tag_slug><?php wxr_tag_name($t); ?><?php wxr_tag_description($t); ?></wp:tag> |
292 <wp:tag><wp:tag_slug><?php echo $t->slug; ?></wp:tag_slug><?php wxr_tag_name($t); ?><?php wxr_tag_description($t); ?></wp:tag> |
258 <?php endforeach; endif; ?> |
293 <?php endforeach; endif; ?> |
|
294 <?php if ( $terms ) : foreach ( $terms as $t ) : ?> |
|
295 <wp:term><wp:term_taxonomy><?php echo $t->taxonomy; ?></wp:term_taxonomy><wp:term_slug><?php echo $t->slug; ?></wp:term_slug><wp:term_parent><?php echo $t->parent ? $custom_taxonomies[$t->parent]->name : ''; ?></wp:term_parent><?php wxr_term_name($t); ?><?php wxr_term_description($t); ?></wp:term> |
|
296 <?php endforeach; endif; ?> |
259 <?php do_action('rss2_head'); ?> |
297 <?php do_action('rss2_head'); ?> |
260 <?php if ($post_ids) { |
298 <?php if ($post_ids) { |
261 global $wp_query; |
299 global $wp_query; |
262 $wp_query->in_the_loop = true; // Fake being in the loop. |
300 $wp_query->in_the_loop = true; // Fake being in the loop. |
263 // fetch 20 posts at a time rather than loading the entire table into memory |
301 // fetch 20 posts at a time rather than loading the entire table into memory |
266 $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); |
304 $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); |
267 foreach ($posts as $post) { |
305 foreach ($posts as $post) { |
268 // Don't export revisions. They bloat the export. |
306 // Don't export revisions. They bloat the export. |
269 if ( 'revision' == $post->post_type ) |
307 if ( 'revision' == $post->post_type ) |
270 continue; |
308 continue; |
271 setup_postdata($post); ?> |
309 setup_postdata($post); |
|
310 |
|
311 $is_sticky = 0; |
|
312 if ( is_sticky( $post->ID ) ) |
|
313 $is_sticky = 1; |
|
314 |
|
315 ?> |
272 <item> |
316 <item> |
273 <title><?php echo apply_filters('the_title_rss', $post->post_title); ?></title> |
317 <title><?php echo apply_filters('the_title_rss', $post->post_title); ?></title> |
274 <link><?php the_permalink_rss() ?></link> |
318 <link><?php the_permalink_rss() ?></link> |
275 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> |
319 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> |
276 <dc:creator><?php echo wxr_cdata(get_the_author()); ?></dc:creator> |
320 <dc:creator><?php echo wxr_cdata(get_the_author()); ?></dc:creator> |
289 <wp:status><?php echo $post->post_status; ?></wp:status> |
333 <wp:status><?php echo $post->post_status; ?></wp:status> |
290 <wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent> |
334 <wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent> |
291 <wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order> |
335 <wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order> |
292 <wp:post_type><?php echo $post->post_type; ?></wp:post_type> |
336 <wp:post_type><?php echo $post->post_type; ?></wp:post_type> |
293 <wp:post_password><?php echo $post->post_password; ?></wp:post_password> |
337 <wp:post_password><?php echo $post->post_password; ?></wp:post_password> |
|
338 <wp:is_sticky><?php echo $is_sticky; ?></wp:is_sticky> |
294 <?php |
339 <?php |
295 if ($post->post_type == 'attachment') { ?> |
340 if ($post->post_type == 'attachment') { ?> |
296 <wp:attachment_url><?php echo wp_get_attachment_url($post->ID); ?></wp:attachment_url> |
341 <wp:attachment_url><?php echo wp_get_attachment_url($post->ID); ?></wp:attachment_url> |
297 <?php } ?> |
342 <?php } ?> |
298 <?php |
343 <?php |
311 if ( $comments ) { foreach ( $comments as $c ) { ?> |
356 if ( $comments ) { foreach ( $comments as $c ) { ?> |
312 <wp:comment> |
357 <wp:comment> |
313 <wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id> |
358 <wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id> |
314 <wp:comment_author><?php echo wxr_cdata($c->comment_author); ?></wp:comment_author> |
359 <wp:comment_author><?php echo wxr_cdata($c->comment_author); ?></wp:comment_author> |
315 <wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email> |
360 <wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email> |
316 <wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url> |
361 <wp:comment_author_url><?php echo esc_url_raw( $c->comment_author_url ); ?></wp:comment_author_url> |
317 <wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP> |
362 <wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP> |
318 <wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date> |
363 <wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date> |
319 <wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt> |
364 <wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt> |
320 <wp:comment_content><?php echo wxr_cdata($c->comment_content) ?></wp:comment_content> |
365 <wp:comment_content><?php echo wxr_cdata($c->comment_content) ?></wp:comment_content> |
321 <wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved> |
366 <wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved> |