WordPress.org

Make WordPress Core

Ticket #34062: 34062.patch

File 34062.patch, 5.1 KB (added by Chouby, 5 years ago)
  • wp-admin/includes/export.php

     
    182182                if ( empty( $category->name ) )
    183183                        return;
    184184
    185                 echo '<wp:cat_name>' . wxr_cdata( $category->name ) . '</wp:cat_name>';
     185                echo '<wp:cat_name>' . wxr_cdata( $category->name ) . "</wp:cat_name>\n";
    186186        }
    187187
    188188        /**
     
    196196                if ( empty( $category->description ) )
    197197                        return;
    198198
    199                 echo '<wp:category_description>' . wxr_cdata( $category->description ) . '</wp:category_description>';
     199                echo '<wp:category_description>' . wxr_cdata( $category->description ) . "</wp:category_description>\n";
    200200        }
    201201
    202202        /**
     
    210210                if ( empty( $tag->name ) )
    211211                        return;
    212212
    213                 echo '<wp:tag_name>' . wxr_cdata( $tag->name ) . '</wp:tag_name>';
     213                echo '<wp:tag_name>' . wxr_cdata( $tag->name ) . "</wp:tag_name>\n";
    214214        }
    215215
    216216        /**
     
    224224                if ( empty( $tag->description ) )
    225225                        return;
    226226
    227                 echo '<wp:tag_description>' . wxr_cdata( $tag->description ) . '</wp:tag_description>';
     227                echo '<wp:tag_description>' . wxr_cdata( $tag->description ) . "</wp:tag_description>\n";
    228228        }
    229229
    230230        /**
     
    238238                if ( empty( $term->name ) )
    239239                        return;
    240240
    241                 echo '<wp:term_name>' . wxr_cdata( $term->name ) . '</wp:term_name>';
     241                echo '<wp:term_name>' . wxr_cdata( $term->name ) . "</wp:term_name>\n";
    242242        }
    243243
    244244        /**
     
    252252                if ( empty( $term->description ) )
    253253                        return;
    254254
    255                 echo '<wp:term_description>' . wxr_cdata( $term->description ) . '</wp:term_description>';
     255                echo "\t\t<wp:term_description>" . wxr_cdata( $term->description ) . "</wp:term_description>\n";
    256256        }
    257257
    258258        /**
     259         * Output termmeta XML tags for a given term object
     260         *
     261         * @since 4.4.0
     262         *
     263         * @param object $term Term Object
     264         */
     265        function wxr_term_meta( $term ) {
     266                global $wpdb;
     267
     268                $termmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->termmeta WHERE term_id = %d", $term->term_id ) );
     269
     270                foreach ( $termmeta as $meta ) {
     271                        /**
     272                         * Filter whether to selectively skip term meta used for WXR exports.
     273                         *
     274                         * Returning a truthy value to the filter will skip the current meta
     275                         * object from being exported.
     276                         *
     277                         * @since 4.4.0
     278                         *
     279                         * @param bool   $skip     Whether to skip the current term meta. Default false.
     280                         * @param string $meta_key Current meta key.
     281                         * @param object $meta     Current meta object.
     282                         */
     283                        if ( ! apply_filters( 'wxr_export_skip_termmeta', false, $meta->meta_key, $meta ) ) {
     284                                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 ) );
     285                        }
     286                }
     287        }
     288
     289        /**
    259290         * Output list of authors with posts
    260291         *
    261292         * @since 3.1.0
     
    386417<?php wxr_authors_list( $post_ids ); ?>
    387418
    388419<?php foreach ( $cats as $c ) : ?>
    389         <wp:category><wp:term_id><?php echo intval( $c->term_id ); ?></wp:term_id><wp:category_nicename><?php echo wxr_cdata( $c->slug ); ?></wp:category_nicename><wp:category_parent><?php echo wxr_cdata( $c->parent ? $cats[$c->parent]->slug : '' ); ?></wp:category_parent><?php wxr_cat_name( $c ); ?><?php wxr_category_description( $c ); ?></wp:category>
     420        <wp:category>
     421                <wp:term_id><?php echo intval( $c->term_id ); ?></wp:term_id>
     422                <wp:category_nicename><?php echo wxr_cdata( $c->slug ); ?></wp:category_nicename>
     423                <wp:category_parent><?php echo wxr_cdata( $c->parent ? $cats[$c->parent]->slug : '' ); ?></wp:category_parent>
     424                <?php wxr_cat_name( $c );
     425                wxr_category_description( $c );
     426                wxr_term_meta( $c ); ?>
     427        </wp:category>
    390428<?php endforeach; ?>
    391429<?php foreach ( $tags as $t ) : ?>
    392         <wp:tag><wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id><wp:tag_slug><?php echo wxr_cdata( $t->slug ); ?></wp:tag_slug><?php wxr_tag_name( $t ); ?><?php wxr_tag_description( $t ); ?></wp:tag>
     430        <wp:tag>
     431                <wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id>
     432                <wp:tag_slug><?php echo wxr_cdata( $t->slug ); ?></wp:tag_slug>
     433                <?php wxr_tag_name( $t );
     434                wxr_tag_description( $t );
     435                wxr_term_meta( $t ); ?>
     436        </wp:tag>
    393437<?php endforeach; ?>
    394438<?php foreach ( $terms as $t ) : ?>
    395         <wp:term><wp:term_id><?php echo wxr_cdata( $t->term_id ); ?></wp:term_id><wp:term_taxonomy><?php echo wxr_cdata( $t->taxonomy ); ?></wp:term_taxonomy><wp:term_slug><?php echo wxr_cdata( $t->slug ); ?></wp:term_slug><wp:term_parent><?php echo wxr_cdata( $t->parent ? $terms[$t->parent]->slug : '' ); ?></wp:term_parent><?php wxr_term_name( $t ); ?><?php wxr_term_description( $t ); ?></wp:term>
     439        <wp:term>
     440                <wp:term_id><?php echo wxr_cdata( $t->term_id ); ?></wp:term_id>
     441                <wp:term_taxonomy><?php echo wxr_cdata( $t->taxonomy ); ?></wp:term_taxonomy>
     442                <wp:term_slug><?php echo wxr_cdata( $t->slug ); ?></wp:term_slug>
     443                <wp:term_parent><?php echo wxr_cdata( $t->parent ? $terms[$t->parent]->slug : '' ); ?></wp:term_parent>
     444                <?php wxr_term_name( $t );
     445                wxr_term_description( $t );
     446                wxr_term_meta( $t ); ?>
     447        </wp:term>
    396448<?php endforeach; ?>
    397449<?php if ( 'all' == $args['content'] ) wxr_nav_menu_terms(); ?>