', ']]]]>', $str ) . ']]>';
return $str;
}
/**
* Return the URL of the site
*
* @since 2.5.0
*
* @return string Site URL.
*/
function wxr_site_url() {
// Multisite: the base URL.
if ( is_multisite() ) {
return network_home_url();
} else {
return get_bloginfo_rss( 'url' );
}
}
/**
* Output a cat_name XML tag from a given category object
*
* @since 2.1.0
*
* @param object $category Category Object
*/
function wxr_cat_name( $category ) {
if ( empty( $category->name ) ) {
return;
}
echo '' . wxr_cdata( $category->name ) . '';
}
/**
* Output a category_description XML tag from a given category object
*
* @since 2.1.0
*
* @param object $category Category Object
*/
function wxr_category_description( $category ) {
if ( empty( $category->description ) ) {
return;
}
echo '' . wxr_cdata( $category->description ) . '';
}
/**
* Output a tag_name XML tag from a given tag object
*
* @since 2.3.0
*
* @param object $tag Tag Object
*/
function wxr_tag_name( $tag ) {
if ( empty( $tag->name ) ) {
return;
}
echo '' . wxr_cdata( $tag->name ) . '';
}
/**
* Output a tag_description XML tag from a given tag object
*
* @since 2.3.0
*
* @param object $tag Tag Object
*/
function wxr_tag_description( $tag ) {
if ( empty( $tag->description ) ) {
return;
}
echo '' . wxr_cdata( $tag->description ) . '';
}
/**
* Output a term_name XML tag from a given term object
*
* @since 2.9.0
*
* @param object $term Term Object
*/
function wxr_term_name( $term ) {
if ( empty( $term->name ) ) {
return;
}
echo '' . wxr_cdata( $term->name ) . '';
}
/**
* Output a term_description XML tag from a given term object
*
* @since 2.9.0
*
* @param object $term Term Object
*/
function wxr_term_description( $term ) {
if ( empty( $term->description ) ) {
return;
}
echo '' . wxr_cdata( $term->description ) . '';
}
/**
* 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();
// @codingStandardsIgnoreStart
$results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and" );
// @codingStandardsIgnoreEnd
foreach ( (array) $results as $result ) {
$authors[] = get_userdata( $result->post_author );
}
$authors = array_filter( $authors );
foreach ( $authors as $author ) {
echo "\t";
echo '' . intval( $author->ID ) . '';
echo '' . wxr_cdata( $author->user_login ) . '';
echo '' . wxr_cdata( $author->user_email ) . '';
echo '' . wxr_cdata( $author->display_name ) . '';
echo '' . wxr_cdata( $author->first_name ) . '';
echo '' . wxr_cdata( $author->last_name ) . '';
echo "\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";
echo '' . intval( $menu->term_id ) . '';
echo 'nav_menu';
echo '' . wxr_cdata( $menu->slug ) . '';
wxr_term_name( $menu );
echo "\n";
}
}
/**
* Output list of taxonomy terms, in XML tag format, associated with a post
*
* @since 2.3.0
*/
function wxr_post_taxonomy() {
$post = get_post();
$taxonomies = get_object_taxonomies( $post->post_type );
if ( empty( $taxonomies ) ) {
return;
}
$terms = wp_get_object_terms( $post->ID, $taxonomies );
foreach ( (array) $terms as $term ) {
echo "\t\ttaxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata( $term->name ) . "\n";
}
}
/**
*
* @param bool $return_me
* @param string $meta_key
* @return bool
*/
function wxr_filter_postmeta( $return_me, $meta_key ) {
if ( '_edit_lock' == $meta_key ) {
$return_me = true;
}
if ( false !== strpos( $meta_key, '_fl_builder_history' ) ) {
$return_me = true;
}
return $return_me;
}
add_filter( 'wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2 );
echo '\n";
?>
in_the_loop = true;
// Fetch 20 posts at a time rather than loading the entire table into memory.
// @codingStandardsIgnoreStart
while ( $next_posts = array_splice( $post_ids, 0, 20 ) ) {
$where = 'WHERE ID IN (' . join( ',', $next_posts ) . ')';
$posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" );
// @codingStandardsIgnoreEnd
// Begin Loop.
foreach ( $posts as $post ) {
setup_postdata( $post );
$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
?>
-
post_title );
?>
post_content ) );
?>
post_excerpt ) );
?>
ID ); ?>
post_date ); ?>
post_date_gmt ); ?>
comment_status ); ?>
ping_status ); ?>
post_name ); ?>
post_status ); ?>
post_parent ); ?>
menu_order ); ?>
post_type ); ?>
post_password ); ?>
post_type ) : ?>
ID ) ); ?>
get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
foreach ( $postmeta as $meta ) :
/**
* Filter whether to selectively skip post meta used for WXR exports.
*
* Returning a truthy value to the filter will skip the current meta
* object from being exported.
*
* @since 3.3.0
*
* @param bool $skip Whether to skip the current post meta. Default false.
* @param string $meta_key Current meta key.
* @param object $meta Current meta object.
*/
if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) {
continue;
}
?>
meta_key ); ?>
meta_value ); ?>
get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
$comments = array_map( 'get_comment', $_comments );
foreach ( $comments as $c ) :
?>
comment_ID ); ?>
comment_author ); ?>
comment_author_email ); ?>
comment_author_url ); ?>
comment_author_IP ); ?>
comment_date ); ?>
comment_date_gmt ); ?>
comment_content ); ?>
comment_approved ); ?>
comment_type ); ?>
comment_parent ); ?>
user_id ); ?>
get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
foreach ( $c_meta as $meta ) :
/**
* Filter whether to selectively skip comment meta used for WXR exports.
*
* Returning a truthy value to the filter will skip the current meta
* object from being exported.
*
* @since 4.0.0
*
* @param bool $skip Whether to skip the current comment meta. Default false.
* @param string $meta_key Current meta key.
* @param object $meta Current meta object.
*/
if ( apply_filters( 'wxr_export_skip_commentmeta', false, $meta->meta_key, $meta ) ) {
continue;
}
?>
meta_key ); ?>
meta_value ); ?>