当前位置: 首页>>代码示例>>PHP>>正文


PHP wxr_nav_menu_terms函数代码示例

本文整理汇总了PHP中wxr_nav_menu_terms函数的典型用法代码示例。如果您正苦于以下问题:PHP wxr_nav_menu_terms函数的具体用法?PHP wxr_nav_menu_terms怎么用?PHP wxr_nav_menu_terms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wxr_nav_menu_terms函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: export_wp


//.........这里部分代码省略.........
                ?>
</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 
                echo $t->parent ? $terms[$t->parent]->slug : '';
                ?>
</wp:term_parent><?php 
                wxr_term_name($t);
                wxr_term_description($t);
                ?>
</wp:term>
<?php 
            }
            if ('all' == $args['post_type']) {
                wxr_nav_menu_terms();
            }
            ?>

	<?php 
            do_action('rss2_head');
            ?>
	<?php 
            $this->flush_export($full_path, false);
            ?>

<?php 
            if ($post_ids) {
                global $wp_query, $post;
                $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) {
                        $progress->tick();
                        setup_postdata($post);
                        $is_sticky = is_sticky($post->ID) ? 1 : 0;
                        ?>
	<item>
		<title><?php 
                        echo apply_filters('the_title_rss', $post->post_title);
                        ?>
</title>
		<link><?php 
                        the_permalink_rss();
开发者ID:rmccue,项目名称:wp-cli,代码行数:67,代码来源:export.php

示例2: export_wp


//.........这里部分代码省略.........
     * @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();
        $results = $wpdb->get_results("SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_status != 'auto-draft' {$and}");
        foreach ((array) $results as $result) {
            $authors[] = get_userdata($result->post_author);
        }
        $authors = array_filter($authors);
        foreach ($authors as $author) {
            echo "\t<wp:author>";
            echo '<wp:author_id>' . intval($author->ID) . '</wp:author_id>';
            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";
        }
    }
    /**
开发者ID:AndyMarkle,项目名称:rocket,代码行数:67,代码来源:export.php

示例3: export_wp


//.........这里部分代码省略.........
            }
            echo '<wp:term_description>' . wxr_cdata($term->description) . '</wp:term_description>';
        }
        /**
         * Output list of authors with posts
         *
         * @since 3.1.0
         */
        function wxr_authors_list()
        {
            global $wpdb;
            $authors = array();
            $results = $wpdb->get_results("SELECT DISTINCT post_author FROM {$wpdb->posts}");
            foreach ((array) $results as $result) {
                $authors[] = get_userdata($result->post_author);
            }
            $authors = array_filter($authors);
            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'))) {
开发者ID:netaustin,项目名称:WordPress-CLI-Exporter,代码行数:67,代码来源:cli-exporter.php

示例4: uncode_export_wp


//.........这里部分代码省略.........
        }
        echo '<wp:term_description>' . wxr_cdata($term->description) . '</wp:term_description>';
    }
    /**
     * Output list of authors with posts
     *
     * @since 3.1.0
     */
    function wxr_authors_list()
    {
        global $wpdb;
        $authors = array();
        $results = $wpdb->get_results("SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_status != 'auto-draft'");
        foreach ((array) $results as $result) {
            $authors[] = get_userdata($result->post_author);
        }
        $authors = array_filter($authors);
        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;
开发者ID:b0123498765,项目名称:fithealthyandwealthy,代码行数:67,代码来源:uncode_export_template.php

示例5: 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
//.........这里部分代码省略.........
开发者ID:lenguyenitc,项目名称:donations,代码行数:101,代码来源:menu-exporter.php


注:本文中的wxr_nav_menu_terms函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。