+ * @param WP_Term $term Term object.
+ */
+ function wxr_term_meta( $term ) {
+ global $wpdb;
+
+ $termmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->termmeta WHERE term_id = %d", $term->term_id ) );
+
+ foreach ( $termmeta as $meta ) {
+ /**
+ * Filters whether to selectively skip term meta used for WXR exports.
+ *
+ * Returning a truthy value to the filter will skip the current meta
+ * object from being exported.
+ *
+ * @since 4.6.0
+ *
+ * @param bool $skip Whether to skip the current piece of term meta. Default false.
+ * @param string $meta_key Current meta key.
+ * @param object $meta Current meta object.
+ */
+ if ( ! apply_filters( 'wxr_export_skip_termmeta', false, $meta->meta_key, $meta ) ) {
+ printf( "\t\t<wp:termmeta>\n\t\t\t<wp:meta_key>%s</wp:meta_key>\n\t\t\t<wp:meta_value>%s</wp:meta_value>\n\t\t</wp:termmeta>\n", wxr_cdata( $meta->meta_key ), wxr_cdata( $meta->meta_value ) );
+ }
+ }
+ }
+
+ /**
+ * Output list of authors with posts
+ *
+ * @since 3.1.0
+ *
+ * @global wpdb $wpdb WordPress database abstraction object.
+ *
+ * @param array $post_ids Array of post IDs to filter the query by. Optional.
+ */
+ function wxr_authors_list( array $post_ids = null ) {
+ global $wpdb;
+
+ if ( !empty( $post_ids ) ) {
+ $post_ids = array_map( 'absint', $post_ids );
+ $and = 'AND ID IN ( ' . implode( ', ', $post_ids ) . ')';
+ } else {
+ $and = '';
+ }
+
+ $authors = array();
+ $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and" );
+ foreach ( (array) $results as $result )
+ $authors[] = get_userdata( $result->post_author );
+
+ $authors = array_filter( $authors );
+
+ foreach ( $authors as $author ) {
+ echo "\t<wp:author>";
+ echo '<wp:author_id>' . intval( $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>';
+ echo '<wp:author_first_name>' . wxr_cdata( $author->first_name ) . '</wp:author_first_name>';
+ echo '<wp:author_last_name>' . wxr_cdata( $author->last_name ) . '</wp:author_last_name>';
+ echo "</wp:author>\n";
+ }
+ }
+
+ /**
+ * Output all navigation menu terms
+ *
+ * @since 3.1.0
+ */
+ function wxr_nav_menu_terms() {
+ $nav_menus = wp_get_nav_menus();
+ if ( empty( $nav_menus ) || ! is_array( $nav_menus ) )
+ return;
+
+ foreach ( $nav_menus as $menu ) {
+ echo "\t<wp:term>";
+ echo '<wp:term_id>' . intval( $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 );
+ echo "</wp:term>\n";
+ }
+ }
+
+ /**
+ * Output list of taxonomy terms, in XML tag format, associated with a post
+ *
+ * @since 2.3.0