wp/wp-admin/includes/export.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 21 48c4eec2b7e6
--- a/wp/wp-admin/includes/export.php	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/includes/export.php	Wed Sep 21 18:19:35 2022 +0200
@@ -23,6 +23,7 @@
  * 'auto-draft' status will be skipped.
  *
  * @since 2.1.0
+ * @since 5.7.0 Added the `post_modified` and `post_modified_gmt` fields to the export file.
  *
  * @global wpdb    $wpdb WordPress database abstraction object.
  * @global WP_Post $post Global post object.
@@ -168,7 +169,7 @@
 
 		// Put categories in order with no child going before its parent.
 		while ( $cat = array_shift( $categories ) ) {
-			if ( 0 == $cat->parent || isset( $cats[ $cat->parent ] ) ) {
+			if ( ! $cat->parent || isset( $cats[ $cat->parent ] ) ) {
 				$cats[ $cat->term_id ] = $cat;
 			} else {
 				$categories[] = $cat;
@@ -177,7 +178,7 @@
 
 		// Put terms in order with no child going before its parent.
 		while ( $t = array_shift( $custom_terms ) ) {
-			if ( 0 == $t->parent || isset( $terms[ $t->parent ] ) ) {
+			if ( ! $t->parent || isset( $terms[ $t->parent ] ) ) {
 				$terms[ $t->term_id ] = $t;
 			} else {
 				$custom_terms[] = $t;
@@ -227,7 +228,7 @@
 	 *
 	 * @since 2.1.0
 	 *
-	 * @param object $category Category Object
+	 * @param WP_Term $category Category Object
 	 */
 	function wxr_cat_name( $category ) {
 		if ( empty( $category->name ) ) {
@@ -242,7 +243,7 @@
 	 *
 	 * @since 2.1.0
 	 *
-	 * @param object $category Category Object
+	 * @param WP_Term $category Category Object
 	 */
 	function wxr_category_description( $category ) {
 		if ( empty( $category->description ) ) {
@@ -257,7 +258,7 @@
 	 *
 	 * @since 2.3.0
 	 *
-	 * @param object $tag Tag Object
+	 * @param WP_Term $tag Tag Object
 	 */
 	function wxr_tag_name( $tag ) {
 		if ( empty( $tag->name ) ) {
@@ -272,7 +273,7 @@
 	 *
 	 * @since 2.3.0
 	 *
-	 * @param object $tag Tag Object
+	 * @param WP_Term $tag Tag Object
 	 */
 	function wxr_tag_description( $tag ) {
 		if ( empty( $tag->description ) ) {
@@ -287,7 +288,7 @@
 	 *
 	 * @since 2.9.0
 	 *
-	 * @param object $term Term Object
+	 * @param WP_Term $term Term Object
 	 */
 	function wxr_term_name( $term ) {
 		if ( empty( $term->name ) ) {
@@ -302,7 +303,7 @@
 	 *
 	 * @since 2.9.0
 	 *
-	 * @param object $term Term Object
+	 * @param WP_Term $term Term Object
 	 */
 	function wxr_term_description( $term ) {
 		if ( empty( $term->description ) ) {
@@ -372,7 +373,7 @@
 
 		foreach ( $authors as $author ) {
 			echo "\t<wp:author>";
-			echo '<wp:author_id>' . intval( $author->ID ) . '</wp:author_id>';
+			echo '<wp:author_id>' . (int) $author->ID . '</wp:author_id>';
 			echo '<wp:author_login>' . wxr_cdata( $author->user_login ) . '</wp:author_login>';
 			echo '<wp:author_email>' . wxr_cdata( $author->user_email ) . '</wp:author_email>';
 			echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
@@ -395,7 +396,7 @@
 
 		foreach ( $nav_menus as $menu ) {
 			echo "\t<wp:term>";
-			echo '<wp:term_id>' . intval( $menu->term_id ) . '</wp:term_id>';
+			echo '<wp:term_id>' . (int) $menu->term_id . '</wp:term_id>';
 			echo '<wp:term_taxonomy>nav_menu</wp:term_taxonomy>';
 			echo '<wp:term_slug>' . wxr_cdata( $menu->slug ) . '</wp:term_slug>';
 			wxr_term_name( $menu );
@@ -478,7 +479,7 @@
 
 	<?php foreach ( $cats as $c ) : ?>
 	<wp:category>
-		<wp:term_id><?php echo intval( $c->term_id ); ?></wp:term_id>
+		<wp:term_id><?php echo (int) $c->term_id; ?></wp:term_id>
 		<wp:category_nicename><?php echo wxr_cdata( $c->slug ); ?></wp:category_nicename>
 		<wp:category_parent><?php echo wxr_cdata( $c->parent ? $cats[ $c->parent ]->slug : '' ); ?></wp:category_parent>
 		<?php
@@ -490,7 +491,7 @@
 	<?php endforeach; ?>
 	<?php foreach ( $tags as $t ) : ?>
 	<wp:tag>
-		<wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id>
+		<wp:term_id><?php echo (int) $t->term_id; ?></wp:term_id>
 		<wp:tag_slug><?php echo wxr_cdata( $t->slug ); ?></wp:tag_slug>
 		<?php
 		wxr_tag_name( $t );
@@ -501,7 +502,7 @@
 	<?php endforeach; ?>
 	<?php foreach ( $terms as $t ) : ?>
 	<wp:term>
-		<wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id>
+		<wp:term_id><?php echo (int) $t->term_id; ?></wp:term_id>
 		<wp:term_taxonomy><?php echo wxr_cdata( $t->taxonomy ); ?></wp:term_taxonomy>
 		<wp:term_slug><?php echo wxr_cdata( $t->slug ); ?></wp:term_slug>
 		<wp:term_parent><?php echo wxr_cdata( $t->parent ? $terms[ $t->parent ]->slug : '' ); ?></wp:term_parent>
@@ -534,15 +535,21 @@
 
 		// 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 ) . ')';
+			$where = 'WHERE ID IN (' . implode( ',', $next_posts ) . ')';
 			$posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" );
 
 			// Begin Loop.
 			foreach ( $posts as $post ) {
 				setup_postdata( $post );
 
-				/** This filter is documented in wp-includes/feed.php */
-				$title = apply_filters( 'the_title_rss', $post->post_title );
+				/**
+				 * Filters the post title used for WXR exports.
+				 *
+				 * @since 5.7.0
+				 *
+				 * @param string $post_title Title of the current post.
+				 */
+				$title = wxr_cdata( apply_filters( 'the_title_export', $post->post_title ) );
 
 				/**
 				 * Filters the post content used for WXR exports.
@@ -573,18 +580,20 @@
 		<description></description>
 		<content:encoded><?php echo $content; ?></content:encoded>
 		<excerpt:encoded><?php echo $excerpt; ?></excerpt:encoded>
-		<wp:post_id><?php echo intval( $post->ID ); ?></wp:post_id>
+		<wp:post_id><?php echo (int) $post->ID; ?></wp:post_id>
 		<wp:post_date><?php echo wxr_cdata( $post->post_date ); ?></wp:post_date>
 		<wp:post_date_gmt><?php echo wxr_cdata( $post->post_date_gmt ); ?></wp:post_date_gmt>
+		<wp:post_modified><?php echo wxr_cdata( $post->post_modified ); ?></wp:post_modified>
+		<wp:post_modified_gmt><?php echo wxr_cdata( $post->post_modified_gmt ); ?></wp:post_modified_gmt>
 		<wp:comment_status><?php echo wxr_cdata( $post->comment_status ); ?></wp:comment_status>
 		<wp:ping_status><?php echo wxr_cdata( $post->ping_status ); ?></wp:ping_status>
 		<wp:post_name><?php echo wxr_cdata( $post->post_name ); ?></wp:post_name>
 		<wp:status><?php echo wxr_cdata( $post->post_status ); ?></wp:status>
-		<wp:post_parent><?php echo intval( $post->post_parent ); ?></wp:post_parent>
-		<wp:menu_order><?php echo intval( $post->menu_order ); ?></wp:menu_order>
+		<wp:post_parent><?php echo (int) $post->post_parent; ?></wp:post_parent>
+		<wp:menu_order><?php echo (int) $post->menu_order; ?></wp:menu_order>
 		<wp:post_type><?php echo wxr_cdata( $post->post_type ); ?></wp:post_type>
 		<wp:post_password><?php echo wxr_cdata( $post->post_password ); ?></wp:post_password>
-		<wp:is_sticky><?php echo intval( $is_sticky ); ?></wp:is_sticky>
+		<wp:is_sticky><?php echo (int) $is_sticky; ?></wp:is_sticky>
 				<?php	if ( 'attachment' === $post->post_type ) : ?>
 		<wp:attachment_url><?php echo wxr_cdata( wp_get_attachment_url( $post->ID ) ); ?></wp:attachment_url>
 	<?php endif; ?>
@@ -620,7 +629,7 @@
 				foreach ( $comments as $c ) :
 					?>
 		<wp:comment>
-			<wp:comment_id><?php echo intval( $c->comment_ID ); ?></wp:comment_id>
+			<wp:comment_id><?php echo (int) $c->comment_ID; ?></wp:comment_id>
 			<wp:comment_author><?php echo wxr_cdata( $c->comment_author ); ?></wp:comment_author>
 			<wp:comment_author_email><?php echo wxr_cdata( $c->comment_author_email ); ?></wp:comment_author_email>
 			<wp:comment_author_url><?php echo esc_url_raw( $c->comment_author_url ); ?></wp:comment_author_url>
@@ -630,8 +639,8 @@
 			<wp:comment_content><?php echo wxr_cdata( $c->comment_content ); ?></wp:comment_content>
 			<wp:comment_approved><?php echo wxr_cdata( $c->comment_approved ); ?></wp:comment_approved>
 			<wp:comment_type><?php echo wxr_cdata( $c->comment_type ); ?></wp:comment_type>
-			<wp:comment_parent><?php echo intval( $c->comment_parent ); ?></wp:comment_parent>
-			<wp:comment_user_id><?php echo intval( $c->user_id ); ?></wp:comment_user_id>
+			<wp:comment_parent><?php echo (int) $c->comment_parent; ?></wp:comment_parent>
+			<wp:comment_user_id><?php echo (int) $c->user_id; ?></wp:comment_user_id>
 					<?php
 					$c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
 					foreach ( $c_meta as $meta ) :