File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1291,3 +1291,27 @@ Feature: Export content.
12911291 """
12921292 2
12931293 """
1294+
1295+ Scenario : Export term meta
1296+ Given a WP install
1297+
1298+ When I run `wp term meta add 1 term_metakey term_metavalue`
1299+ Then STDOUT should contain:
1300+ """
1301+ Success:
1302+ """
1303+
1304+ When I run `wp export`
1305+ And save STDOUT 'Writing to file %s' as {EXPORT_FILE}
1306+ Then the {EXPORT_FILE} file should contain:
1307+ """
1308+ <wp:termmeta>
1309+ """
1310+ And the {EXPORT_FILE} file should contain:
1311+ """
1312+ <wp:meta_key>term_metakey</wp:meta_key>
1313+ """
1314+ And the {EXPORT_FILE} file should contain:
1315+ """
1316+ <wp:meta_value><![CDATA[term_metavalue]]></wp:meta_value>
1317+ """
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ public function categories() {
135135 ->tag ( 'wp:category_parent ' , $ category ->parent_slug )
136136 ->optional_cdata ( 'wp:cat_name ' , $ category ->name )
137137 ->optional_cdata ( 'wp:category_description ' , $ category ->description )
138+ ->oxymel ( $ this ->term_meta ( $ category ) )
138139 ->end ;
139140 }
140141 return $ oxymel ->to_string ();
@@ -259,6 +260,7 @@ protected function terms( $terms ) {
259260 $ oxymel
260261 ->optional_cdata ( 'wp:term_name ' , $ term ->name )
261262 ->optional_cdata ( 'wp:term_description ' , $ term ->description )
263+ ->oxymel ( $ this ->term_meta ( $ term ) )
262264 ->end ;
263265 }
264266 return $ oxymel ->to_string ();
@@ -279,4 +281,20 @@ protected function comment_meta( $comment ) {
279281 }
280282 return $ oxymel ;
281283 }
284+
285+ protected function term_meta ( $ term ) {
286+ global $ wpdb ;
287+ $ metas = $ wpdb ->get_results ( $ wpdb ->prepare ( "SELECT * FROM $ wpdb ->termmeta WHERE term_id = %d " , $ term ->term_id ) );
288+ if ( ! $ metas ) {
289+ return new Oxymel ();
290+ }
291+ $ oxymel = new WP_Export_Oxymel ();
292+ foreach ( $ metas as $ meta ) {
293+ $ oxymel ->tag ( 'wp:termmeta ' )->contains
294+ ->tag ( 'wp:meta_key ' , $ meta ->meta_key )
295+ ->tag ( 'wp:meta_value ' )->contains ->cdata ( $ meta ->meta_value )->end
296+ ->end ;
297+ }
298+ return $ oxymel ;
299+ }
282300}
You can’t perform that action at this time.
0 commit comments