本文整理汇总了PHP中wxr_cat_name函数的典型用法代码示例。如果您正苦于以下问题:PHP wxr_cat_name函数的具体用法?PHP wxr_cat_name怎么用?PHP wxr_cat_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxr_cat_name函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: export_wp
//.........这里部分代码省略.........
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) {
?>
<wp:tag><wp:term_id><?php
echo $t->term_id;
?>
</wp:term_id><wp:tag_slug><?php
echo $t->slug;
?>
</wp:tag_slug><?php
wxr_tag_name($t);
wxr_tag_description($t);
?>
</wp:tag>
<?php
}
foreach ($terms as $t) {
?>
<wp:term><wp:term_id><?php
echo $t->term_id;
?>
</wp:term_id><wp:term_taxonomy><?php
echo $t->taxonomy;
?>
</wp:term_taxonomy><wp:term_slug><?php
echo $t->slug;
?>
</wp:term_slug><wp:term_parent><?php
示例2: 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
//.........这里部分代码省略.........
示例3: 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();
//.........这里部分代码省略.........
示例4: export_wp
//.........这里部分代码省略.........
*/
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)) {
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;
}
示例5: uncode_export_wp
//.........这里部分代码省略.........
*/
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;
}
示例6: 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)
//.........这里部分代码省略.........
示例7: export_wp
function export_wp() {
global $wpdb, $posts, $post;
$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 ( 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");
$categories = (array) $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, posts_private, links_private FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (category_id = cat_id) LEFT JOIN $wpdb->posts ON (post_id <=> id) $where GROUP BY cat_id");
function wxr_missing_parents($categories) {
if ( !is_array($categories) || empty($categories) )
return array();
foreach ( $categories as $category )
$parents[$category->cat_ID] = $category->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 = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, posts_private, links_private FROM $wpdb->categories WHERE cat_ID IN (" . 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->category_parent == 0 || isset($cats[$cat->category_parent]) ) {
$cats[$cat->cat_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->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
//.........这里部分代码省略.........
示例8: export_wp
//.........这里部分代码省略.........
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)
{
if (empty($c->description)) {
return;
}
echo '<wp:category_description>' . wxr_cdata($c->description) . '</wp:category_description>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $t Tag Object
*/
function wxr_tag_name($t)
{
if (empty($t->name)) {
return;
}
示例9: export_wp
//.........这里部分代码省略.........
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)
{
if (empty($c->description)) {
return;
}
echo '<wp:category_description>' . wxr_cdata($c->description) . '</wp:category_description>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $t Tag Object
*/
function wxr_tag_name($t)
{
if (empty($t->name)) {
return;
}
示例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)
{
//.........这里部分代码省略.........