Skip to content

Commit b32ab97

Browse files
author
fred
committed
Include term meta in export file
1 parent 31e3d71 commit b32ab97

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎src/WP_Export_WXR_Formatter.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public function categories() {
132132
->tag( 'wp:category_parent', $category->parent_slug )
133133
->optional_cdata( 'wp:cat_name', $category->name )
134134
->optional_cdata( 'wp:category_description', $category->description )
135+
->oxymel( $this->term_meta( $category ) )
135136
->end;
136137
}
137138
return $oxymel->to_string();
@@ -256,6 +257,7 @@ protected function terms( $terms ) {
256257
$oxymel
257258
->optional_cdata( 'wp:term_name', $term->name )
258259
->optional_cdata( 'wp:term_description', $term->description )
260+
->oxymel( $this->term_meta( $term ) )
259261
->end;
260262
}
261263
return $oxymel->to_string();
@@ -276,4 +278,20 @@ protected function comment_meta( $comment ) {
276278
}
277279
return $oxymel;
278280
}
281+
282+
protected function term_meta( $term ) {
283+
global $wpdb;
284+
$metas = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->termmeta WHERE term_id = %d", $term->term_id ) );
285+
if ( ! $metas ) {
286+
return new Oxymel();
287+
}
288+
$oxymel = new WP_Export_Oxymel();
289+
foreach ( $metas as $meta ) {
290+
$oxymel->tag( 'wp:termmeta' )->contains
291+
->tag( 'wp:meta_key' )->contains->cdata( $meta->meta_key )->end
292+
->tag( 'wp:meta_value' )->contains->cdata( $meta->meta_value )->end
293+
->end;
294+
}
295+
return $oxymel;
296+
}
279297
}

0 commit comments

Comments
 (0)