本文整理汇总了PHP中wxr_post_taxonomy函数的典型用法代码示例。如果您正苦于以下问题:PHP wxr_post_taxonomy函数的具体用法?PHP wxr_post_taxonomy怎么用?PHP wxr_post_taxonomy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxr_post_taxonomy函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: export_wp
//.........这里部分代码省略.........
<wp:status><?php
echo $post->post_status;
?>
</wp:status>
<wp:post_parent><?php
echo $post->post_parent;
?>
</wp:post_parent>
<wp:menu_order><?php
echo $post->menu_order;
?>
</wp:menu_order>
<wp:post_type><?php
echo $post->post_type;
?>
</wp:post_type>
<wp:post_password><?php
echo $post->post_password;
?>
</wp:post_password>
<wp:is_sticky><?php
echo $is_sticky;
?>
</wp:is_sticky>
<?php
if ($post->post_type == 'attachment') {
?>
<wp:attachment_url><?php
echo wp_get_attachment_url($post->ID);
?>
</wp:attachment_url>
<?php
}
wxr_post_taxonomy();
$postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE post_id = %d", $post->ID));
foreach ($postmeta as $meta) {
if (apply_filters('wxr_export_skip_postmeta', false, $meta->meta_key, $meta)) {
continue;
}
?>
<wp:postmeta>
<wp:meta_key><?php
echo $meta->meta_key;
?>
</wp:meta_key>
<wp:meta_value><?php
echo wxr_cdata($meta->meta_value);
?>
</wp:meta_value>
</wp:postmeta>
<?php
}
if (false === $args['skip_comments']) {
$comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID));
foreach ($comments as $c) {
?>
<wp:comment>
<wp:comment_id><?php
echo $c->comment_ID;
?>
</wp:comment_id>
<wp:comment_author><?php
echo wxr_cdata($c->comment_author);
?>
</wp:comment_author>
<wp:comment_author_email><?php
示例2: export_wp
function export_wp($author = '')
{
global $wpdb, $post_ids, $post;
do_action('export_wp');
$filename = 'wordpress.' . date('Y-m-d') . '.xml';
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
$where = '';
if ($author and $author != 'all') {
$author_id = (int) $author;
$where = $wpdb->prepare(" WHERE post_author = %d ", $author_id);
}
// grab a snapshot of post IDs, just in case it changes during the export
$post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} {$where} ORDER BY post_date_gmt ASC");
$categories = (array) get_categories('get=all');
$tags = (array) get_tags('get=all');
function wxr_missing_parents($categories)
{
if (!is_array($categories) || empty($categories)) {
return array();
}
foreach ($categories as $category) {
$parents[$category->term_id] = $category->parent;
}
$parents = array_unique(array_diff($parents, array_keys($parents)));
if ($zero = array_search('0', $parents)) {
unset($parents[$zero]);
}
return $parents;
}
while ($parents = wxr_missing_parents($categories)) {
$found_parents = get_categories("include=" . join(', ', $parents));
if (is_array($found_parents) && count($found_parents)) {
$categories = array_merge($categories, $found_parents);
} else {
break;
}
}
// Put them in order to be inserted with no child going before its parent
$pass = 0;
$passes = 1000 + count($categories);
while (($cat = array_shift($categories)) && ++$pass < $passes) {
if ($cat->parent == 0 || isset($cats[$cat->parent])) {
$cats[$cat->term_id] = $cat;
} else {
$categories[] = $cat;
}
}
unset($categories);
function wxr_cdata($str)
{
if (seems_utf8($str) == false) {
$str = utf8_encode($str);
}
// $str = ent2ncr(wp_specialchars($str));
$str = "<![CDATA[{$str}" . (substr($str, -1) == ']' ? ' ' : '') . "]]>";
return $str;
}
function wxr_site_url()
{
global $current_site;
// mu: the base url
if (isset($current_site->domain)) {
return 'http://' . $current_site->domain . $current_site->path;
} else {
return get_bloginfo_rss('url');
}
}
function wxr_cat_name($c)
{
if (empty($c->name)) {
return;
}
echo '<wp:cat_name>' . wxr_cdata($c->name) . '</wp:cat_name>';
}
function wxr_category_description($c)
{
if (empty($c->description)) {
return;
}
echo '<wp:category_description>' . wxr_cdata($c->description) . '</wp:category_description>';
}
function wxr_tag_name($t)
{
if (empty($t->name)) {
return;
}
echo '<wp:tag_name>' . wxr_cdata($t->name) . '</wp:tag_name>';
}
function wxr_tag_description($t)
{
if (empty($t->description)) {
return;
}
echo '<wp:tag_description>' . wxr_cdata($t->description) . '</wp:tag_description>';
}
function wxr_post_taxonomy()
{
$categories = get_the_category();
//.........这里部分代码省略.........
示例3: export_wp
//.........这里部分代码省略.........
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";
}
}
/**
* Ouput 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
*/
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\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata($term->name) . "</category>\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;
}
return $return_me;
}
add_filter('wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2);
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
示例4: uncode_export_wp
//.........这里部分代码省略.........
foreach ($authors as $author) {
echo "\t<wp:author>";
echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
echo '<wp:author_login>' . $author->user_login . '</wp:author_login>';
echo '<wp:author_email>' . $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->user_firstname) . '</wp:author_first_name>';
echo '<wp:author_last_name>' . wxr_cdata($author->user_lastname) . '</wp:author_last_name>';
echo "</wp:author>\n";
}
}
/**
* Ouput 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><wp:term_id>{$menu->term_id}</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>{$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
*/
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\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata($term->name) . "</category>\n";
}
}
function wxr_filter_postmeta($return_me, $meta_key)
{
if ('_edit_lock' == $meta_key) {
$return_me = true;
}
return $return_me;
}
add_filter('wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2);
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
<!-- 4. Activate & Run Importer. -->
<!-- 5. Upload this file using the form provided on that page. -->
示例5: dsq_export_wp
//.........这里部分代码省略.........
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $t Tag Object
*/
function wxr_tag_name($t)
{
if (empty($t->name)) {
return;
}
echo '<wp:tag_name>' . wxr_cdata($t->name) . '</wp:tag_name>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $t Tag Object
*/
function wxr_tag_description($t)
{
if (empty($t->description)) {
return;
}
echo '<wp:tag_description>' . wxr_cdata($t->description) . '</wp:tag_description>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*/
function wxr_post_taxonomy()
{
$categories = get_the_category();
$tags = get_the_tags();
$the_list = '';
$filter = 'rss';
if (!empty($categories)) {
foreach ((array) $categories as $category) {
$cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
// for backwards compatibility
$the_list .= "\n\t\t<category><![CDATA[{$cat_name}]]></category>\n";
// forwards compatibility: use a unique identifier for each cat to avoid clashes
// http://trac.wordpress.org/ticket/5447
$the_list .= "\n\t\t<category domain=\"category\" nicename=\"{$category->slug}\"><![CDATA[{$cat_name}]]></category>\n";
}
}
if (!empty($tags)) {
foreach ((array) $tags as $tag) {
$tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
$the_list .= "\n\t\t<category domain=\"tag\"><![CDATA[{$tag_name}]]></category>\n";
// forwards compatibility as above
$the_list .= "\n\t\t<category domain=\"tag\" nicename=\"{$tag->slug}\"><![CDATA[{$tag_name}]]></category>\n";
}
}
echo $the_list;
}
// start catching output
ob_start();
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->
<!-- It contains information about your blog's posts, comments, and categories. -->
<!-- You may use this file to transfer that content from one site to another. -->
示例6: export_wp
//.........这里部分代码省略.........
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $t Term Object
*/
function wxr_term_name($t)
{
if (empty($t->name)) {
return;
}
echo '<wp:term_name>' . wxr_cdata($t->name) . '</wp:term_name>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $t Term Object
*/
function wxr_term_description($t)
{
if (empty($t->description)) {
return;
}
echo '<wp:term_description>' . wxr_cdata($t->description) . '</wp:term_description>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*/
function wxr_post_taxonomy()
{
$categories = get_the_category();
$tags = get_the_tags();
$the_list = '';
$filter = 'rss';
if (!empty($categories)) {
foreach ((array) $categories as $category) {
$cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
// for backwards compatibility
$the_list .= "\n\t\t<category><![CDATA[{$cat_name}]]></category>\n";
// forwards compatibility: use a unique identifier for each cat to avoid clashes
// http://trac.wordpress.org/ticket/5447
$the_list .= "\n\t\t<category domain=\"category\" nicename=\"{$category->slug}\"><![CDATA[{$cat_name}]]></category>\n";
}
}
if (!empty($tags)) {
foreach ((array) $tags as $tag) {
$tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
$the_list .= "\n\t\t<category domain=\"tag\"><![CDATA[{$tag_name}]]></category>\n";
// forwards compatibility as above
$the_list .= "\n\t\t<category domain=\"tag\" nicename=\"{$tag->slug}\"><![CDATA[{$tag_name}]]></category>\n";
}
}
echo $the_list;
}
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->
<!-- It contains information about your blog's posts, comments, and categories. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your blog. -->
示例7: export_wp
//.........这里部分代码省略.........
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $t Term Object
*/
function wxr_term_name($t)
{
if (empty($t->name)) {
return;
}
echo '<wp:term_name>' . wxr_cdata($t->name) . '</wp:term_name>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $t Term Object
*/
function wxr_term_description($t)
{
if (empty($t->description)) {
return;
}
echo '<wp:term_description>' . wxr_cdata($t->description) . '</wp:term_description>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*/
function wxr_post_taxonomy()
{
global $post;
$the_list = '';
$filter = 'rss';
$taxonomies = get_object_taxonomies('post');
$terms = wp_get_post_terms($post->ID, $taxonomies);
foreach ((array) $terms as $term) {
$domain = 'post_tag' == $term->taxonomy ? 'tag' : $term->taxonomy;
$term_name = sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, $filter);
// Back compat.
if ('category' == $term->taxonomy) {
$the_list .= "\n\t\t<category><![CDATA[{$term_name}]]></category>\n";
} elseif ('post_tag' == $term->taxonomy) {
$the_list .= "\n\t\t<category domain=\"{$domain}\"><![CDATA[{$term_name}]]></category>\n";
}
// forwards compatibility as above
$the_list .= "\n\t\t<category domain=\"{$domain}\" nicename=\"{$term->slug}\"><![CDATA[{$term_name}]]></category>\n";
}
echo $the_list;
}
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->
<!-- It contains information about your blog's posts, comments, and categories. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your blog. -->
<!-- To import this information into a WordPress blog follow these steps. -->
<!-- 1. Log in to that blog as an administrator. -->
<!-- 2. Go to Tools: Import in the blog's admin panels (or Manage: Import in older versions of WordPress). -->
<!-- 3. Choose "WordPress" from the list. -->
<!-- 4. Upload this file using the form provided on that page. -->
示例8: export_wp
function export_wp()
{
global $wpdb, $post_ids, $post;
do_action('export_wp');
$filename = 'wordpress.' . date('Y-m-d') . '.xml';
// ограничения по кол-ву записей
$limit = '';
if (isset($_GET['limit_start']) and $_GET['limit_start'] and isset($_GET['limit_count']) and $_GET['limit_count']) {
$limit_start = (int) $_GET['limit_start'];
$limit_count = (int) $_GET['limit_count'];
if ($limit_start and $limit_count) {
$limit = ' LIMIT ' . $limit_start . ', ' . $limit_count;
$filename = 'wp-' . $limit_start . '-' . ($limit_count + $limit_start) . '.xml';
}
}
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
$where = '';
if (isset($_GET['author']) && $_GET['author'] != 'all') {
$author_id = (int) $_GET['author'];
$where = " WHERE post_author = '{$author_id}' and post_status != 'inherit'";
} else {
$where = " WHERE post_status != 'inherit'";
}
// grab a snapshot of post IDs, just in case it changes during the export
$post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} {$where} ORDER BY post_date_gmt ASC{$limit}");
$categories = (array) get_categories('get=all');
$tags = (array) get_tags('get=all');
function wxr_missing_parents($categories)
{
if (!is_array($categories) || empty($categories)) {
return array();
}
foreach ($categories as $category) {
$parents[$category->term_id] = $category->parent;
}
$parents = array_unique(array_diff($parents, array_keys($parents)));
if ($zero = array_search('0', $parents)) {
unset($parents[$zero]);
}
return $parents;
}
while ($parents = wxr_missing_parents($categories)) {
$found_parents = get_categories("include=" . join(', ', $parents));
if (is_array($found_parents) && count($found_parents)) {
$categories = array_merge($categories, $found_parents);
} else {
break;
}
}
// Put them in order to be inserted with no child going before its parent
$pass = 0;
$passes = 1000 + count($categories);
while (($cat = array_shift($categories)) && ++$pass < $passes) {
if ($cat->parent == 0 || isset($cats[$cat->parent])) {
$cats[$cat->term_id] = $cat;
} else {
$categories[] = $cat;
}
}
unset($categories);
function wxr_cdata($str)
{
if (seems_utf8($str) == false) {
$str = utf8_encode($str);
}
// $str = ent2ncr(wp_specialchars($str));
$str = "<![CDATA[{$str}" . (substr($str, -1) == ']' ? ' ' : '') . "]]>";
return $str;
}
function wxr_cat_name($c)
{
if (empty($c->name)) {
return;
}
echo '<wp:cat_name>' . wxr_cdata($c->name) . '</wp:cat_name>';
}
function wxr_category_description($c)
{
if (empty($c->description)) {
return;
}
echo '<wp:category_description>' . wxr_cdata($c->description) . '</wp:category_description>';
}
function wxr_tag_name($t)
{
if (empty($t->name)) {
return;
}
echo '<wp:tag_name>' . wxr_cdata($t->name) . '</wp:tag_name>';
}
function wxr_tag_description($t)
{
if (empty($t->description)) {
return;
}
echo '<wp:tag_description>' . wxr_cdata($t->description) . '</wp:tag_description>';
}
function wxr_post_taxonomy()
//.........这里部分代码省略.........
示例9: lpr_export_attachment
echo $post->post_password;
?>
</wp:post_password>
<wp:post_author_id><?php
echo $post->post_author;
?>
</wp:post_author_id>
<wp:is_sticky><?php
echo $is_sticky;
?>
</wp:is_sticky>
<?php
lpr_export_attachment($post);
?>
<?php
wxr_post_taxonomy();
?>
<?php
if (!in_array($post->post_author, $_lpr_course_author_ids)) {
$_lpr_course_author_ids[] = $post->post_author;
}
$postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE post_id = %d", $post->ID));
foreach ($postmeta as $meta) {
if (apply_filters('wxr_export_skip_postmeta', false, $meta->meta_key, $meta)) {
continue;
}
do_action('lpr_export_postmeta', $meta->meta_key, $meta);
switch ($meta->meta_key) {
case '_lpr_course_prerequisite':
continue;
$_lpr_course_prerequisite[] = $meta->meta_value;
示例10: export_wp
//.........这里部分代码省略.........
foreach ($authors as $author) {
echo "\t<wp:author>";
echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
echo '<wp:author_login>' . $author->user_login . '</wp:author_login>';
echo '<wp:author_email>' . $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->user_firstname) . '</wp:author_first_name>';
echo '<wp:author_last_name>' . wxr_cdata($author->user_lastname) . '</wp:author_last_name>';
echo "</wp:author>\n";
}
}
/**
* Ouput 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><wp:term_id>{$menu->term_id}</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>{$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
*/
function wxr_post_taxonomy()
{
global $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\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata($term->name) . "</category>\n";
}
}
function wxr_filter_postmeta($return_me, $meta_key)
{
// We ignore the attachment metadata on import so no point in exporting it
if (in_array($meta_key, array('_edit_lock', '_wp_attachment_metadata', '_wp_attached_file'))) {
$return_me = true;
}
return $return_me;
}
add_filter('wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2);
// now we can use the functions we need.
$this->debug_msg("Initialized all functions we need");
/**
* This is mostly the original code of export_wp defined in wp-admin/includes/export.php
*/
$defaults = array('post_type' => 'all', 'author' => false, 'category' => false, 'start_date' => false, 'end_date' => false, 'status' => false, 'skip_comments' => false, 'file_item_count' => 1000);
$args = wp_parse_args($args, $defaults);
$this->debug_msg("Exporting with export_wp with arguments: " . var_export($args, true));
do_action('export_wp');
if ('all' != $args['post_type'] && post_type_exists($args['post_type'])) {
$ptype = get_post_type_object($args['post_type']);
if (!$ptype->can_export) {
示例11: me_export_wp
//.........这里部分代码省略.........
*/
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><wp:term_id>{$menu->term_id}</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>{$menu->slug}</wp:term_slug>";
wxr_term_name($menu);
echo "</wp:term>\n";
}
}
function me_wxr_nav_menu_item_terms_and_posts(&$post_ids)
{
$posts_to_add = array();
foreach ($post_ids as $post_id) {
if (($type = get_post_meta($post_id, '_menu_item_type', true)) == 'taxonomy') {
$term = get_term(get_post_meta($post_id, '_menu_item_object_id', true), $tax = get_post_meta($post_id, '_menu_item_object', true));
echo "\t<wp:term><wp:term_id>{$term->term_id}</wp:term_id><wp:term_taxonomy>{$tax}</wp:term_taxonomy><wp:term_slug>{$term->slug}</wp:term_slug>";
wxr_term_name($term);
echo "</wp:term>\n";
} elseif ($type == 'post_type' && in_array(get_post_meta($post_id, '_menu_item_object', true), array('post', 'page'))) {
$posts_to_add[] = get_post_meta($post_id, '_menu_item_object_id', true);
}
}
$post_ids = array_merge($posts_to_add, $post_ids);
}
/**
* Output list of taxonomy terms, in XML tag format, associated with a post
*
* @since 2.3.0
*/
function wxr_post_taxonomy()
{
global $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\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata($term->name) . "</category>\n";
}
}
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
<!-- 4. Activate & Run Importer. -->
<!-- 5. Upload this file using the form provided on that page. -->
<!-- 6. You will first be asked to map the authors in this export file to users -->
<!-- on the site. For each author, you may choose to map to an -->
<!-- existing user on the site or to create a new user. -->
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
<!-- contained in this file into your site. -->
<?php
the_generator('export');
示例12: handle_export
//.........这里部分代码省略.........
</content:encoded>
<excerpt:encoded><?php
echo wxr_cdata(apply_filters('the_excerpt_export', $post->post_excerpt));
?>
</excerpt:encoded>
<wp:post_id><?php
echo $post->ID;
?>
</wp:post_id>
<wp:post_date><?php
echo $post->post_date;
?>
</wp:post_date>
<wp:post_date_gmt><?php
echo $post->post_date_gmt;
?>
</wp:post_date_gmt>
<wp:comment_status><?php
echo $post->comment_status;
?>
</wp:comment_status>
<wp:ping_status><?php
echo $post->ping_status;
?>
</wp:ping_status>
<wp:post_name><?php
echo $post->post_name;
?>
</wp:post_name>
<wp:status><?php
echo $post->post_status;
?>
</wp:status>
<wp:post_parent><?php
echo $post->post_parent;
?>
</wp:post_parent>
<wp:menu_order><?php
echo $post->menu_order;
?>
</wp:menu_order>
<wp:post_type><?php
echo $post->post_type;
?>
</wp:post_type>
<wp:post_password><?php
echo $post->post_password;
?>
</wp:post_password>
<wp:is_sticky><?php
echo $is_sticky;
?>
</wp:is_sticky>
<?php
if ($post->post_type == 'attachment') {
?>
<wp:attachment_url><?php
echo wp_get_attachment_url($post->ID);
?>
</wp:attachment_url>
<?php
}
?>
<?php
wxr_post_taxonomy();
?>
<?php
$postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE post_id = %d", $post->ID));
foreach ($postmeta as $meta) {
if (apply_filters('wxr_export_skip_postmeta', false, $meta->meta_key, $meta)) {
continue;
}
?>
<wp:postmeta>
<wp:meta_key><?php
echo $meta->meta_key;
?>
</wp:meta_key>
<wp:meta_value><?php
echo wxr_cdata($meta->meta_value);
?>
</wp:meta_value>
</wp:postmeta>
<?php
}
?>
</item>
<?php
}
}
}
?>
<?php
do_action('rss2_head');
?>
</channel>
</rss><?php
die;
}