diff --git a/features/export.feature b/features/export.feature
index 2c6445a2..74ce0d44 100644
--- a/features/export.feature
+++ b/features/export.feature
@@ -59,7 +59,7 @@ Feature: Export content.
"""
When I run `wp export --post_type=page --post_status=draft`
- And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
+ Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
When I run `wp site empty --yes`
Then STDOUT should not be empty
@@ -100,7 +100,7 @@ Feature: Export content.
"""
When I run `wp export --post_type=page,post`
- And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
+ Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
When I run `wp site empty --yes`
Then STDOUT should not be empty
@@ -175,8 +175,7 @@ Feature: Export content.
"""
When I run `wp export --post__in={POST_ID}`
- And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
-
+ Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
And the {EXPORT_FILE} file should not contain:
"""
{ATTACHMENT_ID}
@@ -223,7 +222,7 @@ Feature: Export content.
And save STDOUT as {POST_ID_TWO}
When I run `wp export --post__in="{POST_ID} {POST_ID_TWO}"`
- And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
+ Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
When I run `wp site empty --yes`
Then STDOUT should not be empty
@@ -256,7 +255,7 @@ Feature: Export content.
And save STDOUT as {POST_ID_TWO}
When I run `wp export --post__in="{POST_ID},{POST_ID_TWO}"`
- And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
+ Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
When I run `wp site empty --yes`
Then STDOUT should not be empty
@@ -291,7 +290,7 @@ Feature: Export content.
"""
When I run `wp export --post_type=post --start_date=2013-08-02 --end_date=2013-08-02`
- And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
+ Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
When I run `wp site empty --yes`
Then STDOUT should not be empty
@@ -522,7 +521,7 @@ Feature: Export content.
"""
When I run `wp export --start_id=6`
- And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
+ Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
When I run `wp site empty --yes`
Then STDOUT should not be empty
@@ -557,7 +556,7 @@ Feature: Export content.
"""
When I run `wp export --post_type__not_in=post`
- And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
+ Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
When I run `wp site empty --yes`
Then STDOUT should not be empty
@@ -585,7 +584,7 @@ Feature: Export content.
"""
When I run `wp export --post_type__not_in=post,page`
- And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
+ Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
When I run `wp site empty --yes`
Then STDOUT should not be empty
@@ -662,7 +661,7 @@ Feature: Export content.
"""
When I run `wp export --skip_comments`
- And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
+ Then save STDOUT 'Writing to file %s' as {EXPORT_FILE}
When I run `wp site empty --yes`
Then STDOUT should not be empty
@@ -1292,3 +1291,27 @@ Feature: Export content.
"""
2
"""
+
+ Scenario: Export term meta
+ Given a WP install
+
+ When I run `wp term meta add 1 term_metakey term_metavalue`
+ Then STDOUT should contain:
+ """
+ Success:
+ """
+
+ When I run `wp export`
+ And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
+ Then the {EXPORT_FILE} file should contain:
+ """
+
+ """
+ And the {EXPORT_FILE} file should contain:
+ """
+
+ """
+ And the {EXPORT_FILE} file should contain:
+ """
+
+ """
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 129c35d7..0dbb91a3 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -38,7 +38,7 @@
-
+
diff --git a/src/WP_Export_WXR_Formatter.php b/src/WP_Export_WXR_Formatter.php
index 3910cc8e..811bc2c2 100644
--- a/src/WP_Export_WXR_Formatter.php
+++ b/src/WP_Export_WXR_Formatter.php
@@ -132,6 +132,7 @@ public function categories() {
->tag( 'wp:category_parent', $category->parent_slug )
->optional_cdata( 'wp:cat_name', $category->name )
->optional_cdata( 'wp:category_description', $category->description )
+ ->oxymel( $this->term_meta( $category ) )
->end;
}
return $oxymel->to_string();
@@ -256,6 +257,7 @@ protected function terms( $terms ) {
$oxymel
->optional_cdata( 'wp:term_name', $term->name )
->optional_cdata( 'wp:term_description', $term->description )
+ ->oxymel( $this->term_meta( $term ) )
->end;
}
return $oxymel->to_string();
@@ -276,4 +278,20 @@ protected function comment_meta( $comment ) {
}
return $oxymel;
}
+
+ protected function term_meta( $term ) {
+ global $wpdb;
+ $metas = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->termmeta WHERE term_id = %d", $term->term_id ) );
+ if ( ! $metas ) {
+ return new Oxymel();
+ }
+ $oxymel = new WP_Export_Oxymel();
+ foreach ( $metas as $meta ) {
+ $oxymel->tag( 'wp:termmeta' )->contains
+ ->tag( 'wp:meta_key' )->contains->cdata( $meta->meta_key )->end
+ ->tag( 'wp:meta_value' )->contains->cdata( $meta->meta_value )->end
+ ->end;
+ }
+ return $oxymel;
+ }
}