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


PHP bbp_get_view_rewrite_id函数代码示例

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


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

示例1: bbp_get_view_url

/**
 * Return the view url
 *
 * @since bbPress (r2789)
 *
 * @param string $view Optional. View id
 * @uses sanitize_title() To sanitize the view id
 * @uses home_url() To get blog home url
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_get_view_url' with the view url,
 *                        used view id
 * @return string View url (or home url if the view was not found)
 */
function bbp_get_view_url($view = false)
{
    global $wp_rewrite;
    $view = bbp_get_view_id($view);
    if (empty($view)) {
        return home_url();
    }
    // Pretty permalinks
    if ($wp_rewrite->using_permalinks()) {
        $url = $wp_rewrite->root . bbp_get_view_slug() . '/' . $view;
        $url = home_url(user_trailingslashit($url));
        // Unpretty permalinks
    } else {
        $url = add_query_arg(array(bbp_get_view_rewrite_id() => $view), home_url('/'));
    }
    return apply_filters('bbp_get_view_link', $url, $view);
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:30,代码来源:template.php

示例2: bbp_breadcrumb

/**
 * Single View Content Part
 *
 * @package bbPress
 * @subpackage Theme
 */
?>

<div id="bbpress-forums">

	<?php 
bbp_breadcrumb();
?>

	<?php 
bbp_set_query_name(bbp_get_view_rewrite_id());
?>

	<?php 
if (bbp_view_query()) {
    ?>

		<?php 
    bbp_get_template_part('pagination', 'topics');
    ?>

		<?php 
    bbp_get_template_part('loop', 'topics');
    ?>

		<?php 
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:31,代码来源:content-single-view.php

示例3: add_permastructs

 /**
  * Add permalink structures for new archive-style destinations.
  *
  * - Users
  * - Topic Views
  * - Search
  *
  * @since bbPress (r4930)
  */
 public static function add_permastructs()
 {
     // Get unique ID's
     $user_id = bbp_get_user_rewrite_id();
     $view_id = bbp_get_view_rewrite_id();
     $search_id = bbp_get_search_rewrite_id();
     // Get root slugs
     $user_slug = bbp_get_user_slug();
     $view_slug = bbp_get_view_slug();
     $search_slug = bbp_get_search_slug();
     // User Permastruct
     add_permastruct($user_id, $user_slug . '/%' . $user_id . '%', array('with_front' => false, 'ep_mask' => EP_NONE, 'paged' => false, 'feed' => false, 'forcomments' => false, 'walk_dirs' => true, 'endpoints' => false));
     // Topic View Permastruct
     add_permastruct($view_id, $view_slug . '/%' . $view_id . '%', array('with_front' => false, 'ep_mask' => EP_NONE, 'paged' => false, 'feed' => false, 'forcomments' => false, 'walk_dirs' => true, 'endpoints' => false));
     // Search Permastruct
     add_permastruct($user_id, $search_slug . '/%' . $search_id . '%', array('with_front' => false, 'ep_mask' => EP_NONE, 'paged' => true, 'feed' => false, 'forcomments' => false, 'walk_dirs' => true, 'endpoints' => false));
 }
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:26,代码来源:bbpress.php

示例4: bbp_request_feed_trap


//.........这里部分代码省略.........
                if (in_array($bbp_pt, $qv_array, true)) {
                    $post_type = $bbp_pt;
                    break;
                }
            }
            // Looking at a bbPress post type
            if (!empty($post_type)) {
                // Supported select query vars
                $select_query_vars = array('p' => false, 'name' => false, $post_type => false);
                // Setup matched variables to select
                foreach ($query_vars as $key => $value) {
                    if (isset($select_query_vars[$key])) {
                        $select_query_vars[$key] = $value;
                    }
                }
                // Remove any empties
                $select_query_vars = array_filter($select_query_vars);
                // What bbPress post type are we looking for feeds on?
                switch ($post_type) {
                    // Forum
                    case bbp_get_forum_post_type():
                        // Define local variable(s)
                        $meta_query = array();
                        // Single forum
                        if (!empty($select_query_vars)) {
                            // Load up our own query
                            query_posts(array_merge(array('post_type' => bbp_get_forum_post_type(), 'feed' => true), $select_query_vars));
                            // Restrict to specific forum ID
                            $meta_query = array(array('key' => '_bbp_forum_id', 'value' => bbp_get_forum_id(), 'type' => 'NUMERIC', 'compare' => '='));
                        }
                        // Only forum replies
                        if (!empty($_GET['type']) && bbp_get_reply_post_type() === $_GET['type']) {
                            // The query
                            $the_query = array('author' => 0, 'feed' => true, 'post_type' => bbp_get_reply_post_type(), 'post_parent' => 'any', 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => bbp_get_replies_per_rss_page(), 'order' => 'DESC', 'meta_query' => $meta_query);
                            // Output the feed
                            bbp_display_replies_feed_rss2($the_query);
                            // Only forum topics
                        } elseif (!empty($_GET['type']) && bbp_get_topic_post_type() === $_GET['type']) {
                            // The query
                            $the_query = array('author' => 0, 'feed' => true, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_forum_id(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => bbp_get_topics_per_rss_page(), 'order' => 'DESC');
                            // Output the feed
                            bbp_display_topics_feed_rss2($the_query);
                            // All forum topics and replies
                        } else {
                            // Exclude private/hidden forums if not looking at single
                            if (empty($select_query_vars)) {
                                $meta_query = array(bbp_exclude_forum_ids('meta_query'));
                            }
                            // The query
                            $the_query = array('author' => 0, 'feed' => true, 'post_type' => array(bbp_get_reply_post_type(), bbp_get_topic_post_type()), 'post_parent' => 'any', 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => bbp_get_replies_per_rss_page(), 'order' => 'DESC', 'meta_query' => $meta_query);
                            // Output the feed
                            bbp_display_replies_feed_rss2($the_query);
                        }
                        break;
                        // Topic feed - Show replies
                    // Topic feed - Show replies
                    case bbp_get_topic_post_type():
                        // Single topic
                        if (!empty($select_query_vars)) {
                            // Load up our own query
                            query_posts(array_merge(array('post_type' => bbp_get_topic_post_type(), 'feed' => true), $select_query_vars));
                            // Output the feed
                            bbp_display_replies_feed_rss2(array('feed' => true));
                            // All topics
                        } else {
                            // The query
                            $the_query = array('author' => 0, 'feed' => true, 'post_parent' => 'any', 'posts_per_page' => bbp_get_topics_per_rss_page(), 'show_stickies' => false);
                            // Output the feed
                            bbp_display_topics_feed_rss2($the_query);
                        }
                        break;
                        // Replies
                    // Replies
                    case bbp_get_reply_post_type():
                        // The query
                        $the_query = array('posts_per_page' => bbp_get_replies_per_rss_page(), 'meta_query' => array(array()), 'feed' => true);
                        // All replies
                        if (empty($select_query_vars)) {
                            bbp_display_replies_feed_rss2($the_query);
                        }
                        break;
                }
            }
            // Single Topic Vview
        } elseif (isset($query_vars[bbp_get_view_rewrite_id()])) {
            // Get the view
            $view = $query_vars[bbp_get_view_rewrite_id()];
            // We have a view to display a feed
            if (!empty($view)) {
                // Get the view query
                $the_query = bbp_get_view_query_args($view);
                // Output the feed
                bbp_display_topics_feed_rss2($the_query);
            }
        }
        // @todo User profile feeds
    }
    // No feed so continue on
    return $query_vars;
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:101,代码来源:functions.php

示例5: bbp_get_view_url

/**
 * Return the view url
 *
 * @since 2.0.0 bbPress (r2789)
 *
 * @param string $view Optional. View id
 * @uses sanitize_title() To sanitize the view id
 * @uses home_url() To get blog home url
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_get_view_url' with the view url,
 *                        used view id
 * @return string View url (or home url if the view was not found)
 */
function bbp_get_view_url($view = false)
{
    $view = bbp_get_view_id($view);
    if (empty($view)) {
        return home_url();
    }
    // Pretty permalinks
    if (bbp_use_pretty_urls()) {
        $url = trailingslashit(bbp_get_root_url() . bbp_get_view_slug()) . $view;
        $url = user_trailingslashit($url);
        $url = home_url($url);
        // Unpretty permalinks
    } else {
        $url = add_query_arg(array(bbp_get_view_rewrite_id() => $view), home_url('/'));
    }
    return apply_filters('bbp_get_view_link', $url, $view);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:30,代码来源:template.php

示例6: bbp_parse_query

/**
 * Add checks for bbPress conditions to parse_query action
 *
 * If it's a user page, WP_Query::bbp_is_single_user is set to true.
 * If it's a user edit page, WP_Query::bbp_is_single_user_edit is set to true
 * and the the 'wp-admin/includes/user.php' file is included.
 * In addition, on user/user edit pages, WP_Query::home is set to false & query
 * vars 'bbp_user_id' with the displayed user id and 'author_name' with the
 * displayed user's nicename are added.
 *
 * If it's a forum edit, WP_Query::bbp_is_forum_edit is set to true
 * If it's a topic edit, WP_Query::bbp_is_topic_edit is set to true
 * If it's a reply edit, WP_Query::bbp_is_reply_edit is set to true.
 *
 * If it's a view page, WP_Query::bbp_is_view is set to true
 * If it's a search page, WP_Query::bbp_is_search is set to true
 *
 * @since bbPress (r2688)
 *
 * @param WP_Query $posts_query
 *
 * @uses get_query_var() To get {@link WP_Query} query var
 * @uses is_email() To check if the string is an email
 * @uses get_user_by() To try to get the user by email and nicename
 * @uses get_userdata() to get the user data
 * @uses current_user_can() To check if the current user can edit the user
 * @uses is_user_member_of_blog() To check if user profile page exists
 * @uses WP_Query::set_404() To set a 404 status
 * @uses apply_filters() Calls 'enable_edit_any_user_configuration' with true
 * @uses bbp_get_view_query_args() To get the view query args
 * @uses bbp_get_forum_post_type() To get the forum post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses remove_action() To remove the auto save post revision action
 */
function bbp_parse_query($posts_query)
{
    // Bail if $posts_query is not the main loop
    if (!$posts_query->is_main_query()) {
        return;
    }
    // Bail if filters are suppressed on this query
    if (true === $posts_query->get('suppress_filters')) {
        return;
    }
    // Bail if in admin
    if (is_admin()) {
        return;
    }
    // Get query variables
    $bbp_view = $posts_query->get(bbp_get_view_rewrite_id());
    $bbp_user = $posts_query->get(bbp_get_user_rewrite_id());
    $is_edit = $posts_query->get(bbp_get_edit_rewrite_id());
    // It is a user page - We'll also check if it is user edit
    if (!empty($bbp_user)) {
        /** Find User *********************************************************/
        // Setup the default user variable
        $the_user = false;
        // If using pretty permalinks, use the email or slug
        if (get_option('permalink_structure')) {
            // Email was passed
            if (is_email($bbp_user)) {
                $the_user = get_user_by('email', $bbp_user);
                // Try nicename
            } else {
                $the_user = get_user_by('slug', $bbp_user);
            }
        }
        // No user found by slug/email, so try the ID if it's numeric
        if (empty($the_user) && is_numeric($bbp_user)) {
            $the_user = get_user_by('id', $bbp_user);
        }
        // 404 and bail if user does not have a profile
        if (empty($the_user->ID) || !bbp_user_has_profile($the_user->ID)) {
            $posts_query->set_404();
            return;
        }
        /** User Exists *******************************************************/
        $is_favs = $posts_query->get(bbp_get_user_favorites_rewrite_id());
        $is_subs = $posts_query->get(bbp_get_user_subscriptions_rewrite_id());
        $is_topics = $posts_query->get(bbp_get_user_topics_rewrite_id());
        $is_replies = $posts_query->get(bbp_get_user_replies_rewrite_id());
        // View or edit?
        if (!empty($is_edit)) {
            // We are editing a profile
            $posts_query->bbp_is_single_user_edit = true;
            // Load the core WordPress contact methods
            if (!function_exists('_wp_get_user_contactmethods')) {
                include_once ABSPATH . 'wp-includes/registration.php';
            }
            // Load the edit_user functions
            if (!function_exists('edit_user')) {
                require_once ABSPATH . 'wp-admin/includes/user.php';
            }
            // Load the grant/revoke super admin functions
            if (is_multisite() && !function_exists('revoke_super_admin')) {
                require_once ABSPATH . 'wp-admin/includes/ms.php';
            }
            // Editing a user
            $posts_query->bbp_is_edit = true;
//.........这里部分代码省略.........
开发者ID:donwea,项目名称:nhap.org,代码行数:101,代码来源:template-functions.php

示例7: bbp_template_include_theme_compat


//.........这里部分代码省略.........
        } else {
            $new_title = apply_filters('the_title', $page->post_title);
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => !empty($page->ID) ? $page->ID : 0, 'post_title' => bbp_get_topic_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Topic
    } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
        // Split
        if (bbp_is_topic_split()) {
            $new_content = bbp_buffer_template_part('form', 'topic-split', false);
            // Merge
        } elseif (bbp_is_topic_merge()) {
            $new_content = bbp_buffer_template_part('form', 'topic-merge', false);
            // Edit
        } elseif (bbp_is_topic_edit()) {
            $new_content = $bbp_shortcodes->display_topic_form();
            // Single
        } else {
            $new_content = $bbp_shortcodes->display_topic(array('id' => bbp_get_topic_id()));
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_topic_id(), 'post_title' => bbp_get_topic_title(), 'post_author' => bbp_get_topic_author_id(), 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_topic_status(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Replies ***********************************************************/
        // Reply archive
    } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => __('Replies', 'bbpress'), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_reply_index(), 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        // Single Reply
    } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
        // Move
        if (bbp_is_reply_move()) {
            $new_content = bbp_buffer_template_part('form', 'reply-move', false);
            // Edit
        } elseif (bbp_is_reply_edit()) {
            $new_content = $bbp_shortcodes->display_reply_form();
            // Single
        } else {
            $new_content = $bbp_shortcodes->display_reply(array('id' => get_the_ID()));
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_reply_id(), 'post_title' => bbp_get_reply_title(), 'post_author' => bbp_get_reply_author_id(), 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_reply_status(), 'comment_status' => 'closed'));
        /** Views *************************************************************/
    } elseif (bbp_is_single_view()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_view_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_view(array('id' => get_query_var(bbp_get_view_rewrite_id()))), 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        /** Search ************************************************************/
    } elseif (bbp_is_search()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_search_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_search(array('search' => get_query_var(bbp_get_search_rewrite_id()))), 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        /** Topic Tags ********************************************************/
        // Topic Tag Edit
    } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
        // Stash the current term in a new var
        set_query_var('bbp_topic_tag', get_query_var('term'));
        // Show topics of tag
        if (bbp_is_topic_tag()) {
            $new_content = $bbp_shortcodes->display_topics_of_tag(array('id' => bbp_get_topic_tag_id()));
            // Edit topic tag
        } elseif (bbp_is_topic_tag_edit()) {
            $new_content = $bbp_shortcodes->display_topic_tag_form();
        }
        // Reset the post with our new title
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => '', 'post_title' => sprintf(__('Topic Tag: %s', 'bbpress'), '<span>' . bbp_get_topic_tag_name() . '</span>'), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed', 'is_tax' => true));
    }
    /**
     * Bail if the template already matches a bbPress template. This includes
     * archive-* and single-* WordPress post_type matches (allowing
     * themes to use the expected format) as well as all bbPress-specific
     * template files for users, topics, forums, etc...
     *
     * We do this after the above checks to prevent incorrect 404 body classes
     * and header statuses, as well as to set the post global as needed.
     *
     * @see https://bbpress.trac.wordpress.org/ticket/1478/
     */
    if (bbp_is_template_included()) {
        return $template;
        /**
         * If we are relying on bbPress's built in theme compatibility to load
         * the proper content, we need to intercept the_content, replace the
         * output, and display ours instead.
         *
         * To do this, we first remove all filters from 'the_content' and hook
         * our own function into it, which runs a series of checks to determine
         * the context, and then uses the built in shortcodes to output the
         * correct results from inside an output buffer.
         *
         * Uses bbp_get_theme_compat_templates() to provide fall-backs that
         * should be coded without superfluous mark-up and logic (prev/next
         * navigation, comments, date/time, etc...)
         *
         * Hook into the 'bbp_get_bbpress_template' to override the array of
         * possible templates, or 'bbp_bbpress_template' to override the result.
         */
    } elseif (bbp_is_theme_compat_active()) {
        bbp_remove_all_filters('the_content');
        $template = bbp_get_theme_compat_templates();
    }
    return apply_filters('bbp_template_include_theme_compat', $template);
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:101,代码来源:theme-compat.php

示例8: generate_rewrite_rules

 /**
  * Register bbPress-specific rewrite rules for uri's that are not
  * setup for us by way of custom post types or taxonomies. This includes:
  * - Front-end editing
  * - Topic views
  * - User profiles
  *
  * @since bbPress (r2688)
  * @param WP_Rewrite $wp_rewrite bbPress-sepecific rules are appended in
  *                                $wp_rewrite->rules
  */
 public static function generate_rewrite_rules($wp_rewrite)
 {
     // Slugs
     $view_slug = bbp_get_view_slug();
     $user_slug = bbp_get_user_slug();
     // Unique rewrite ID's
     $edit_id = bbp_get_edit_rewrite_id();
     $view_id = bbp_get_view_rewrite_id();
     $user_id = bbp_get_user_rewrite_id();
     $favs_id = bbp_get_user_favorites_rewrite_id();
     $subs_id = bbp_get_user_subscriptions_rewrite_id();
     $tops_id = bbp_get_user_topics_rewrite_id();
     $reps_id = bbp_get_user_replies_rewrite_id();
     // Rewrite rule matches used repeatedly below
     $root_rule = '/([^/]+)/?$';
     $edit_rule = '/([^/]+)/edit/?$';
     $feed_rule = '/([^/]+)/feed/?$';
     $page_rule = '/([^/]+)/page/?([0-9]{1,})/?$';
     // User profile rules
     $tops_rule = '/([^/]+)/topics/?$';
     $reps_rule = '/([^/]+)/replies/?$';
     $favs_rule = '/([^/]+)/' . bbp_get_user_favorites_slug() . '/?$';
     $subs_rule = '/([^/]+)/' . bbp_get_user_subscriptions_slug() . '/?$';
     $tops_page_rule = '/([^/]+)/topics/page/?([0-9]{1,})/?$';
     $reps_page_rule = '/([^/]+)/replies/page/?([0-9]{1,})/?$';
     $favs_page_rule = '/([^/]+)/' . bbp_get_user_favorites_slug() . '/page/?([0-9]{1,})/?$';
     $subs_page_rule = '/([^/]+)/' . bbp_get_user_subscriptions_slug() . '/page/?([0-9]{1,})/?$';
     // New bbPress specific rules to merge with existing that are not
     // handled automatically by custom post types or taxonomy types
     $bbp_rules = array(bbp_get_forum_slug() . $edit_rule => 'index.php?' . bbp_get_forum_post_type() . '=' . $wp_rewrite->preg_index(1) . '&' . $edit_id . '=1', bbp_get_topic_slug() . $edit_rule => 'index.php?' . bbp_get_topic_post_type() . '=' . $wp_rewrite->preg_index(1) . '&' . $edit_id . '=1', bbp_get_reply_slug() . $edit_rule => 'index.php?' . bbp_get_reply_post_type() . '=' . $wp_rewrite->preg_index(1) . '&' . $edit_id . '=1', bbp_get_topic_tag_tax_slug() . $edit_rule => 'index.php?' . bbp_get_topic_tag_tax_id() . '=' . $wp_rewrite->preg_index(1) . '&' . $edit_id . '=1', $user_slug . $tops_page_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $tops_id . '=1&paged=' . $wp_rewrite->preg_index(2), $user_slug . $reps_page_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $reps_id . '=1&paged=' . $wp_rewrite->preg_index(2), $user_slug . $favs_page_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $favs_id . '=1&paged=' . $wp_rewrite->preg_index(2), $user_slug . $subs_page_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $subs_id . '=1&paged=' . $wp_rewrite->preg_index(2), $user_slug . $tops_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $tops_id . '=1', $user_slug . $reps_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $reps_id . '=1', $user_slug . $favs_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $favs_id . '=1', $user_slug . $subs_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $subs_id . '=1', $user_slug . $edit_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1) . '&' . $edit_id . '=1', $user_slug . $root_rule => 'index.php?' . $user_id . '=' . $wp_rewrite->preg_index(1), $view_slug . $page_rule => 'index.php?' . $view_id . '=' . $wp_rewrite->preg_index(1) . '&paged=' . $wp_rewrite->preg_index(2), $view_slug . $feed_rule => 'index.php?' . $view_id . '=' . $wp_rewrite->preg_index(1) . '&feed=' . $wp_rewrite->preg_index(2), $view_slug . $root_rule => 'index.php?' . $view_id . '=' . $wp_rewrite->preg_index(1));
     // Merge bbPress rules with existing
     $wp_rewrite->rules = array_merge($bbp_rules, $wp_rewrite->rules);
     // Return merged rules
     return $wp_rewrite;
 }
开发者ID:hscale,项目名称:webento,代码行数:46,代码来源:bbpress.php

示例9: bbp_parse_query

/**
 * Add checks for bbPress conditions to parse_query action
 *
 * If it's a user page, WP_Query::bbp_is_single_user is set to true.
 * If it's a user edit page, WP_Query::bbp_is_single_user_edit is set to true
 * and the the 'wp-admin/includes/user.php' file is included.
 * In addition, on user/user edit pages, WP_Query::home is set to false & query
 * vars 'bbp_user_id' with the displayed user id and 'author_name' with the
 * displayed user's nicename are added.
 *
 * If it's a forum edit, WP_Query::bbp_is_forum_edit is set to true
 * If it's a topic edit, WP_Query::bbp_is_topic_edit is set to true
 * If it's a reply edit, WP_Query::bbp_is_reply_edit is set to true.
 *
 * If it's a view page, WP_Query::bbp_is_view is set to true
 *
 * @since bbPress (r2688)
 *
 * @param WP_Query $posts_query
 *
 * @uses get_query_var() To get {@link WP_Query} query var
 * @uses is_email() To check if the string is an email
 * @uses get_user_by() To try to get the user by email and nicename
 * @uses WP_User to get the user data
 * @uses WP_Query::set_404() To set a 404 status
 * @uses current_user_can() To check if the current user can edit the user
 * @uses apply_filters() Calls 'enable_edit_any_user_configuration' with true
 * @uses bbp_get_view_query_args() To get the view query args
 * @uses bbp_get_forum_post_type() To get the forum post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses remove_action() To remove the auto save post revision action
 */
function bbp_parse_query($posts_query)
{
    // Bail if $posts_query is not the main loop
    if (!$posts_query->is_main_query()) {
        return;
    }
    // Bail if filters are suppressed on this query
    if (true == $posts_query->get('suppress_filters')) {
        return;
    }
    // Bail if in admin
    if (is_admin()) {
        return;
    }
    // Get query variables
    $bbp_user = $posts_query->get(bbp_get_user_rewrite_id());
    $bbp_view = $posts_query->get(bbp_get_view_rewrite_id());
    $is_edit = $posts_query->get(bbp_get_edit_rewrite_id());
    // It is a user page - We'll also check if it is user edit
    if (!empty($bbp_user)) {
        // Not a user_id so try email and slug
        if (!is_numeric($bbp_user)) {
            // Email was passed
            if (is_email($bbp_user)) {
                $bbp_user = get_user_by('email', $bbp_user);
                // Try nicename
            } else {
                $bbp_user = get_user_by('slug', $bbp_user);
            }
            // If we were successful, set to ID
            if (is_object($bbp_user)) {
                $bbp_user = $bbp_user->ID;
            }
        }
        // Create new user
        $user = new WP_User($bbp_user);
        // Bail if no user
        if (!isset($user) || empty($user) || empty($user->ID)) {
            $posts_query->set_404();
            return;
        }
        /** User Exists *******************************************************/
        // View or edit?
        if (!empty($is_edit)) {
            // We are editing a profile
            $posts_query->bbp_is_single_user_edit = true;
            // Load the core WordPress contact methods
            if (!function_exists('_wp_get_user_contactmethods')) {
                include_once ABSPATH . 'wp-includes/registration.php';
            }
            // Load the edit_user functions
            if (!function_exists('edit_user')) {
                require_once ABSPATH . 'wp-admin/includes/user.php';
            }
            // Editing a user
            $posts_query->bbp_is_edit = true;
            // We are viewing a profile
        } else {
            $posts_query->bbp_is_single_user = true;
        }
        // Make sure 404 is not set
        $posts_query->is_404 = false;
        // Correct is_home variable
        $posts_query->is_home = false;
        // Set bbp_user_id for future reference
        $posts_query->set('bbp_user_id', $user->ID);
        // Set author_name as current user's nicename to get correct posts
//.........这里部分代码省略.........
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:bbp-template-functions.php


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