本文整理汇总了PHP中wxr_site_url函数的典型用法代码示例。如果您正苦于以下问题:PHP wxr_site_url函数的具体用法?PHP wxr_site_url怎么用?PHP wxr_site_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxr_site_url函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dsq_export_wp
function dsq_export_wp()
{
global $wpdb, $posts, $post, $wp_version;
global $dsq_api;
$filename = dsq_get_temp_dir() . 'disqus-wordpress.' . date('Y-m-d') . '.xml';
$fp = fopen($filename, 'w');
ob_start();
$where = '';
if (isset($_GET['author']) && $_GET['author'] != 'all') {
$author_id = (int) $_GET['author'];
$where = " WHERE post_author = '{$author_id}' ";
}
$posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} {$where} ORDER BY post_date_gmt ASC");
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_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->cat_name)) {
return;
}
echo '<wp:cat_name>' . wxr_cdata($c->cat_name) . '</wp:cat_name>';
}
function wxr_category_description($c)
{
if (empty($c->category_description)) {
return;
}
echo '<wp:category_description>' . wxr_cdata($c->category_description) . '</wp:category_description>';
}
print '<?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 into that blog as an administrator.
2. Go to Manage > Import in the blog's admin.
3. Choose "WordPress" from the list of importers.
4. Upload this file using the form provided on that page.
5. You will first be asked to map the authors in this export file to users
on the blog. For each author, you may choose to map an existing user on
the blog or to create a new user.
6. WordPress will then import each of the posts, comments, and categories
contained in this file onto your blog.
-->
<!-- generator="wordpress/<?php
bloginfo_rss('version');
?>
" created="<?php
echo date('Y-m-d H:i');
?>
"-->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/<?php
echo WXR_VERSION;
?>
/"
>
<channel>
<title><?php
bloginfo_rss('name');
?>
</title>
<link><?php
bloginfo_rss('url');
?>
</link>
<description><?php
bloginfo_rss("description");
?>
</description>
<pubDate><?php
//.........这里部分代码省略.........
示例2: export_wp
//.........这里部分代码省略.........
while ($t = array_shift($custom_terms)) {
if ($t->parent == 0 || isset($terms[$t->parent])) {
$terms[$t->term_id] = $t;
} else {
$custom_terms[] = $t;
}
}
unset($categories, $custom_taxonomies, $custom_terms);
}
/**
* Wrap given string in XML CDATA tag.
*
* @since 2.1.0
*
* @param string $str String to wrap in XML CDATA tag.
* @return string
*/
function wxr_cdata($str)
{
if (!seems_utf8($str)) {
$str = utf8_encode($str);
}
// $str = ent2ncr(esc_html($str));
$str = '<![CDATA[' . str_replace(']]>', ']]]]><![CDATA[>', $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 '<wp:cat_name>' . wxr_cdata($category->name) . '</wp:cat_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)) {
示例3: export_wp
//.........这里部分代码省略.........
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/<?php
echo WXR_VERSION;
?>
/"
>
<channel>
<title><?php
bloginfo_rss('name');
?>
</title>
<link><?php
bloginfo_rss('url');
?>
</link>
<description><?php
bloginfo_rss('description');
?>
</description>
<pubDate><?php
echo date('D, d M Y H:i:s +0000');
?>
</pubDate>
<language><?php
echo get_option('rss_language');
?>
</language>
<wp:wxr_version><?php
echo WXR_VERSION;
?>
</wp:wxr_version>
<wp:base_site_url><?php
echo wxr_site_url();
?>
</wp:base_site_url>
<wp:base_blog_url><?php
bloginfo_rss('url');
?>
</wp:base_blog_url>
<?php
wxr_authors_list();
?>
<?php
foreach ($cats as $c) {
?>
<wp:category><wp:term_id><?php
echo $c->term_id;
?>
</wp:term_id><wp:category_nicename><?php
echo $c->slug;
?>
</wp:category_nicename><wp:category_parent><?php
echo $c->parent ? $cats[$c->parent]->slug : '';
?>
</wp:category_parent><?php
wxr_cat_name($c);
wxr_category_description($c);
?>
</wp:category>
<?php
}
foreach ($tags as $t) {
?>
示例4: dsq_export_wp
function dsq_export_wp($posts)
{
global $wpdb;
$categories = (array) get_categories('get=all');
$tags = (array) get_tags('get=all');
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $categories
*/
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);
/**
* Place string in CDATA tag.
*
* @since unknown
*
* @param string $str String to place in XML CDATA tag.
*/
function wxr_cdata($str)
{
if (seems_utf8($str) == false) {
$str = utf8_encode($str);
}
// $str = ent2ncr(esc_html($str));
$str = "<![CDATA[{$str}" . (substr($str, -1) == ']' ? ' ' : '') . "]]>";
return $str;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @return string Site URL.
*/
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');
}
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $c Category Object
*/
function wxr_cat_name($c)
{
if (empty($c->name)) {
return;
}
echo '<wp:cat_name>' . wxr_cdata($c->name) . '</wp:cat_name>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $c Category Object
*/
function wxr_category_description($c)
//.........这里部分代码省略.........
示例5: 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();
//.........这里部分代码省略.........
示例6: uncode_export_wp
//.........这里部分代码省略.........
if ($t->parent == 0 || isset($terms[$t->parent])) {
$terms[$t->term_id] = $t;
} else {
$custom_terms[] = $t;
}
}
unset($categories, $custom_taxonomies, $custom_terms);
}
}
/**
* Wrap given string in XML CDATA tag.
*
* @since 2.1.0
*
* @param string $str String to wrap in XML CDATA tag.
* @return string
*/
function wxr_cdata($str)
{
if (seems_utf8($str) == false) {
$str = utf8_encode($str);
}
// $str = ent2ncr(esc_html($str));
$str = '<![CDATA[' . str_replace(']]>', ']]]]><![CDATA[>', $str) . ']]>';
return $str;
}
/**
* Return the URL of the site
*
* @since 2.5.0
*
* @return string Site URL.
*/
function wxr_site_url()
{
// ms: 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 '<wp:cat_name>' . wxr_cdata($category->name) . '</wp:cat_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)) {
示例7: date
?>
</description>
<pubDate><?php
echo date('D, d M Y H:i:s +0000');
?>
</pubDate>
<language><?php
echo get_option('rss_language');
?>
</language>
<wp:wxr_version><?php
echo WXR_VERSION;
?>
</wp:wxr_version>
<wp:base_site_url><?php
echo wxr_site_url();
?>
</wp:base_site_url>
<wp:base_blog_url><?php
bloginfo_rss('url');
?>
</wp:base_blog_url>
<?php
wxr_authors_list();
if ($my_options['acf_posts']) {
global $wp_query, $wpdb, $post;
$wp_query->in_the_loop = true;
// Fake being in the loop.
// create SQL with %d placeholders
$where = 'WHERE ID IN (' . substr(str_repeat('%d,', count($my_options['acf_posts'])), 0, -1) . ')';
// now prepare the SQL based on the %d + $_POST data
示例8: export_wp
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $author
*/
function export_wp($author = '')
{
global $wpdb, $post_ids, $post, $wp_taxonomies;
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');
$custom_taxonomies = $wp_taxonomies;
unset($custom_taxonomies['category']);
unset($custom_taxonomies['post_tag']);
unset($custom_taxonomies['link_category']);
$custom_taxonomies = array_keys($custom_taxonomies);
$terms = (array) get_terms($custom_taxonomies, 'get=all');
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $categories
*/
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);
/**
* Place string in CDATA tag.
*
* @since unknown
*
* @param string $str String to place in XML CDATA tag.
*/
function wxr_cdata($str)
{
if (seems_utf8($str) == false) {
$str = utf8_encode($str);
}
// $str = ent2ncr(esc_html($str));
$str = "<![CDATA[{$str}" . (substr($str, -1) == ']' ? ' ' : '') . "]]>";
return $str;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @return string Site URL.
*/
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 {
//.........这里部分代码省略.........
示例9: export_wp
//.........这里部分代码省略.........
$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);
/**
* Place string in CDATA tag.
*
* @since unknown
*
* @param string $str String to place in XML CDATA tag.
*/
function wxr_cdata($str)
{
if (seems_utf8($str) == false) {
$str = utf8_encode($str);
}
// $str = ent2ncr(esc_html($str));
$str = "<![CDATA[{$str}" . (substr($str, -1) == ']' ? ' ' : '') . "]]>";
return $str;
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @return string Site URL.
*/
function wxr_site_url()
{
global $current_site;
// mu: the base url
if (isset($current_site->domain)) {
return network_home_url();
} else {
return get_bloginfo_rss('url');
}
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $c Category Object
*/
function wxr_cat_name($c)
{
if (empty($c->name)) {
return;
}
echo '<wp:cat_name>' . wxr_cdata($c->name) . '</wp:cat_name>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $c Category Object
*/
function wxr_category_description($c)
{
示例10: export_categories_export
function export_categories_export()
{
define( 'WXR_VERSION', '1.2' );
global $wpdb;
$sitename = sanitize_key( get_bloginfo( 'name' ) );
if ( ! empty($sitename) ) $sitename .= '.';
$filename = $sitename . 'wordpress_categories.' . 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 );
// get the requested terms ready, empty unless posts filtered by category or all content
$cats = $terms = array();
{
$categories = (array) get_categories( array( 'get' => 'all' ) );
$custom_taxonomies = get_taxonomies( array( '_builtin' => false ) );
$custom_terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) );
// put categories in order with no child going before its parent
while ( $cat = array_shift( $categories ) ) {
if ( $cat->parent == 0 || isset( $cats[$cat->parent] ) )
$cats[$cat->term_id] = $cat;
else
$categories[] = $cat;
}
// put terms in order with no child going before its parent
while ( $t = array_shift( $custom_terms ) ) {
if ( $t->parent == 0 || isset( $terms[$t->parent] ) )
$terms[$t->term_id] = $t;
else
$custom_terms[] = $t;
}
unset( $categories, $custom_taxonomies, $custom_terms );
}
/**
* Wrap given string in XML CDATA tag.
*
* @since 2.1.0
*
* @param string $str String to wrap in XML CDATA tag.
* @return string
*/
function wxr_cdata( $str ) {
if ( seems_utf8( $str ) == false )
$str = utf8_encode( $str );
// $str = ent2ncr(esc_html($str));
$str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
return $str;
}
/**
* Return the URL of the site
*
* @since 2.5.0
*
* @return string Site URL.
*/
function wxr_site_url() {
// ms: the base url
if ( is_multisite() )
return network_home_url();
// wp: the blog 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 '<wp:cat_name>' . wxr_cdata( $category->name ) . '</wp:cat_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;
//.........这里部分代码省略.........
示例11: export_wp
private function export_wp($args = array())
{
global $wpdb, $post;
/**
* Wrap given string in XML CDATA tag.
*
* @since 2.1.0
*
* @param string $str String to wrap in XML CDATA tag.
*/
function wxr_cdata($str)
{
if (seems_utf8($str) == false) {
$str = utf8_encode($str);
}
// $str = ent2ncr(esc_html($str));
$str = '<![CDATA[' . str_replace(']]>', ']]]]><![CDATA[>', $str) . ']]>';
return $str;
}
/**
* Return the URL of the site
*
* @since 2.5.0
*
* @return string Site URL.
*/
function wxr_site_url()
{
// ms: 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 '<wp:cat_name>' . wxr_cdata($category->name) . '</wp:cat_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 '<wp:category_description>' . wxr_cdata($category->description) . '</wp: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 '<wp:tag_name>' . wxr_cdata($tag->name) . '</wp: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 '<wp:tag_description>' . wxr_cdata($tag->description) . '</wp: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)
{
//.........这里部分代码省略.........
示例12: me_export_wp
/**
* Generates the WXR export file for download - This is a rip of export_wp but supports only exporting menus and it's terms
*
*
* @param array $args Filters defining what should be included in the export
*/
function me_export_wp($args = array())
{
global $wpdb, $post;
$sitename = sanitize_key(get_bloginfo('name'));
if (!empty($sitename)) {
$sitename .= '.';
}
$filename = $sitename . '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 = $wpdb->prepare("{$wpdb->posts}.post_type = %s", 'nav_menu_item');
// grab a snapshot of post IDs, just in case it changes during the export
$post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} {$join} WHERE {$where}");
/**
* Wrap given string in XML CDATA tag.
*
* @since 2.1.0
*
* @param string $str String to wrap in XML CDATA tag.
*/
function wxr_cdata($str)
{
if (seems_utf8($str) == false) {
$str = utf8_encode($str);
}
// $str = ent2ncr(esc_html($str));
$str = "<![CDATA[{$str}" . (substr($str, -1) == ']' ? ' ' : '') . "]]>";
return $str;
}
/**
* Return the URL of the site
*
* @since 2.5.0
*
* @return string Site URL.
*/
function wxr_site_url()
{
// ms: the base url
if (is_multisite()) {
return network_home_url();
} else {
return get_bloginfo_rss('url');
}
}
/**
* 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 '<wp:term_name>' . wxr_cdata($term->name) . '</wp:term_name>';
}
/**
* 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";
}
}
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
//.........这里部分代码省略.........
示例13: handle_export
//.........这里部分代码省略.........
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/<?php
echo WXR_VERSION;
?>
/"
>
<channel>
<title><?php
bloginfo_rss('name');
?>
</title>
<link><?php
bloginfo_rss('url');
?>
</link>
<description><?php
bloginfo_rss('description');
?>
</description>
<pubDate><?php
echo date('D, d M Y H:i:s +0000');
?>
</pubDate>
<language><?php
bloginfo_rss('language');
?>
</language>
<wp:wxr_version><?php
echo WXR_VERSION;
?>
</wp:wxr_version>
<wp:base_site_url><?php
echo wxr_site_url();
?>
</wp:base_site_url>
<wp:base_blog_url><?php
bloginfo_rss('url');
?>
</wp:base_blog_url>
<?php
if ($post_ids) {
global $wp_query;
$wp_query->in_the_loop = true;
// Fake being in the loop.
// fetch 20 posts at a time rather than loading the entire table into memory
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}");
// Begin Loop
foreach ($posts as $post) {
setup_postdata($post);
$is_sticky = is_sticky($post->ID) ? 1 : 0;
?>
<item>
<?php
/** This filter is documented in wp-includes/feed.php */
?>
<title><?php
echo apply_filters('the_title_rss', $post->post_title);
?>
</title>
<link><?php
the_permalink_rss();
?>
</link>
示例14: date
?>
</description>
<pubDate><?php
echo date('D, d M Y H:i:s +0000');
?>
</pubDate>
<language><?php
echo esc_html(get_option('rss_language'));
?>
</language>
<wp:wxr_version><?php
echo esc_html(WXR_VERSION);
?>
</wp:wxr_version>
<wp:base_site_url><?php
echo esc_url(wxr_site_url());
?>
</wp:base_site_url>
<wp:base_blog_url><?php
bloginfo_rss('url');
?>
</wp:base_blog_url>
<?php
wxr_authors_list();
if ($my_options['acf_posts']) {
global $wp_query, $wpdb, $post;
$wp_query->in_the_loop = true;
// Fake being in the loop.
// create SQL with %d placeholders
$where = 'WHERE ID IN (' . substr(str_repeat('%d,', count($my_options['acf_posts'])), 0, -1) . ')';
// now prepare the SQL based on the %d + $_POST data