~canonical-sysadmins/wordpress/4.8.1

« back to all changes in this revision

Viewing changes to wp-admin/includes/export.php

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        $date = date( 'Y-m-d' );
50
50
        $wp_filename = $sitename . 'wordpress.' . $date . '.xml';
51
51
        /**
52
 
         * Filter the export filename.
 
52
         * Filters the export filename.
53
53
         *
54
54
         * @since 4.4.0
55
55
         *
182
182
                if ( empty( $category->name ) )
183
183
                        return;
184
184
 
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";
186
186
        }
187
187
 
188
188
        /**
196
196
                if ( empty( $category->description ) )
197
197
                        return;
198
198
 
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";
200
200
        }
201
201
 
202
202
        /**
210
210
                if ( empty( $tag->name ) )
211
211
                        return;
212
212
 
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";
214
214
        }
215
215
 
216
216
        /**
224
224
                if ( empty( $tag->description ) )
225
225
                        return;
226
226
 
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";
228
228
        }
229
229
 
230
230
        /**
238
238
                if ( empty( $term->name ) )
239
239
                        return;
240
240
 
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";
242
242
        }
243
243
 
244
244
        /**
252
252
                if ( empty( $term->description ) )
253
253
                        return;
254
254
 
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";
 
256
        }
 
257
 
 
258
        /**
 
259
         * Output term meta XML tags for a given term object.
 
260
         *
 
261
         * @since 4.6.0
 
262
         *
 
263
         * @param WP_Term $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
                         * Filters 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.6.0
 
278
                         *
 
279
                         * @param bool   $skip     Whether to skip the current piece of 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
                }
256
287
        }
257
288
 
258
289
        /**
386
417
<?php wxr_authors_list( $post_ids ); ?>
387
418
 
388
419
<?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>
390
428
<?php endforeach; ?>
391
429
<?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>
393
437
<?php endforeach; ?>
394
438
<?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>
396
448
<?php endforeach; ?>
397
449
<?php if ( 'all' == $args['content'] ) wxr_nav_menu_terms(); ?>
398
450
 
432
484
                <description></description>
433
485
                <content:encoded><?php
434
486
                        /**
435
 
                         * Filter the post content used for WXR exports.
 
487
                         * Filters the post content used for WXR exports.
436
488
                         *
437
489
                         * @since 2.5.0
438
490
                         *
442
494
                ?></content:encoded>
443
495
                <excerpt:encoded><?php
444
496
                        /**
445
 
                         * Filter the post excerpt used for WXR exports.
 
497
                         * Filters the post excerpt used for WXR exports.
446
498
                         *
447
499
                         * @since 2.6.0
448
500
                         *
469
521
<?php   $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
470
522
                foreach ( $postmeta as $meta ) :
471
523
                        /**
472
 
                         * Filter whether to selectively skip post meta used for WXR exports.
 
524
                         * Filters whether to selectively skip post meta used for WXR exports.
473
525
                         *
474
526
                         * Returning a truthy value to the filter will skip the current meta
475
527
                         * object from being exported.
508
560
<?php           $c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
509
561
                        foreach ( $c_meta as $meta ) :
510
562
                                /**
511
 
                                 * Filter whether to selectively skip comment meta used for WXR exports.
 
563
                                 * Filters whether to selectively skip comment meta used for WXR exports.
512
564
                                 *
513
565
                                 * Returning a truthy value to the filter will skip the current meta
514
566
                                 * object from being exported.