WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/09/2011 07:32:44 PM (9 years ago)
Author:
nacin
Message:

Add wxr_export_skip_postmeta filter for skipping postmeta in exports. props westi, fixes #18280.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/export.php

    r17989 r19233  
    244244        $authors = array_filter( $authors );
    245245
    246         foreach( $authors as $author ) {
     246        foreach ( $authors as $author ) {
    247247            echo "\t<wp:author>";
    248248            echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
     
    290290        }
    291291    }
     292
     293    function wxr_filter_postmeta( $return_me, $meta_key ) {
     294        if ( '_edit_lock' == $meta_key )
     295            $return_me = true;
     296        return $return_me;
     297    }
     298    add_filter( 'wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2 );
    292299
    293300    echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
     
    385392<?php   wxr_post_taxonomy(); ?>
    386393<?php   $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
    387         foreach( $postmeta as $meta ) : if ( $meta->meta_key != '_edit_lock' ) : ?>
     394        foreach ( $postmeta as $meta ) :
     395            if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) )
     396                continue;
     397        ?>
    388398        <wp:postmeta>
    389399            <wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
    390400            <wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
    391401        </wp:postmeta>
    392 <?php   endif; endforeach; ?>
     402<?php   endforeach; ?>
    393403<?php   $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
    394404        foreach ( $comments as $c ) : ?>
Note: See TracChangeset for help on using the changeset viewer.