From b32ab97f22d386ce7e60d692f653609cceb190e5 Mon Sep 17 00:00:00 2001 From: fred Date: Thu, 13 Jun 2024 15:01:13 +0200 Subject: [PATCH 1/5] Include term meta in export file --- src/WP_Export_WXR_Formatter.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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; + } } From d756a660739a07781cb0a3487539cc0950dfc13e Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Wed, 2 Apr 2025 21:04:02 +0545 Subject: [PATCH 2/5] Fix Gherkin lint issues --- features/export.feature | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/features/export.feature b/features/export.feature index 2c6445a2..aa3818f2 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 From d09f0f2bae133ad1f48b76b9c53a560c9d531412 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 7 May 2025 13:34:39 +0200 Subject: [PATCH 3/5] Require PHP 7.2.24+ --- phpcs.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ - + From 59c4b8a6682978f97922e4c032efb68b9981a42d Mon Sep 17 00:00:00 2001 From: fred Date: Thu, 5 Jun 2025 15:26:24 +0200 Subject: [PATCH 4/5] Add a scenario and two tests --- features/export.feature | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/features/export.feature b/features/export.feature index aa3818f2..6e28975f 100644 --- a/features/export.feature +++ b/features/export.feature @@ -1291,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: + """ + + """ From 009d4648c014a29edfd3d1f0712aef2ad278b0a1 Mon Sep 17 00:00:00 2001 From: fred Date: Thu, 5 Jun 2025 15:48:27 +0200 Subject: [PATCH 5/5] wrong indentation of tests --- features/export.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/export.feature b/features/export.feature index 6e28975f..74ce0d44 100644 --- a/features/export.feature +++ b/features/export.feature @@ -1307,11 +1307,11 @@ Feature: Export content. """ """ - And the {EXPORT_FILE} file should contain: + And the {EXPORT_FILE} file should contain: """ """ - And the {EXPORT_FILE} file should contain: + And the {EXPORT_FILE} file should contain: """ """