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


PHP bbp_get_favorites_permalink函数代码示例

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


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

示例1: stachestack_bbp_get_user_favorites_link

/**
 * User favorites link
 *
 * Return the link to make a topic favorite/remove a topic from
 * favorites
 *
 * @since bbPress (r2652)
 *
 * @param mixed $args This function supports these arguments:
 *  - subscribe: Favorite text
 *  - unsubscribe: Unfavorite text
 *  - user_id: User id
 *  - topic_id: Topic id
 *  - before: Before the link
 *  - after: After the link
 * @param int $user_id Optional. User id
 * @param int $topic_id Optional. Topic id
 * @param bool $wrap Optional. If you want to wrap the link in <span id="favorite-toggle">. See ajax_favorite()
 * @uses bbp_get_user_id() To get the user id
 * @uses current_user_can() If the current user can edit the user
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_is_user_favorite() To check if the topic is user's favorite
 * @uses bbp_get_favorites_permalink() To get the favorites permalink
 * @uses bbp_get_topic_permalink() To get the topic permalink
 * @uses bbp_is_favorites() Is it the favorites page?
 * @uses apply_filters() Calls 'bbp_get_user_favorites_link' with the
 *                        html, add args, remove args, user & topic id
 * @return string User favorites link
 */
function stachestack_bbp_get_user_favorites_link($args = '', $user_id = 0, $wrap = true)
{
    if (!bbp_is_favorites_active()) {
        return false;
    }
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('favorite' => __('Favorite', 'bbpress'), 'favorited' => __('Favorited', 'bbpress'), 'user_id' => 0, 'topic_id' => 0, 'before' => '', 'after' => ''), 'get_user_favorites_link');
    // Validate user and topic ID's
    $user_id = bbp_get_user_id($r['user_id'], true, true);
    $topic_id = bbp_get_topic_id($r['topic_id']);
    if (empty($user_id) || empty($topic_id)) {
        return false;
    }
    // No link if you can't edit yourself
    if (!current_user_can('edit_user', (int) $user_id)) {
        return false;
    }
    // Decide which link to show
    $is_fav = bbp_is_user_favorite($user_id, $topic_id);
    if (!empty($is_fav)) {
        $text = $r['favorited'];
        $query_args = array('action' => 'bbp_favorite_remove', 'topic_id' => $topic_id);
    } else {
        $text = $r['favorite'];
        $query_args = array('action' => 'bbp_favorite_add', 'topic_id' => $topic_id);
    }
    // Create the link based where the user is and if the topic is
    // already the user's favorite
    if (bbp_is_favorites()) {
        $permalink = bbp_get_favorites_permalink($user_id);
    } elseif (bbp_is_single_topic() || bbp_is_single_reply()) {
        $permalink = bbp_get_topic_permalink($topic_id);
    } else {
        $permalink = get_permalink();
    }
    $url = esc_url(wp_nonce_url(add_query_arg($query_args, $permalink), 'toggle-favorite_' . $topic_id));
    $sub = $is_fav ? ' class="is-favorite"' : '';
    $html = sprintf('%s<span id="favorite-%d"  %s><a href="%s" class="btn btn-success btn-xs favorite-toggle" data-topic="%d">%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, $text, $r['after']);
    // Initial output is wrapped in a span, ajax output is hooked to this
    if (!empty($wrap)) {
        $html = '<span id="favorite-toggle">' . $html . '</span>';
    }
    // Return the link
    return apply_filters('bbp_get_user_favorites_link', $html, $r, $user_id, $topic_id);
}
开发者ID:BeardandFedora,项目名称:StacheStack,代码行数:74,代码来源:bbpress.php

示例2: bbp_favorites_handler

/**
 * Handles the front end adding and removing of favorite topics
 *
 * @uses bbp_get_user_id() To get the user id
 * @uses bbp_verify_nonce_request() To verify the nonce and check the request
 * @uses current_user_can() To check if the current user can edit the user
 * @uses bbPress:errors:add() To log the error messages
 * @uses bbp_is_user_favorite() To check if the topic is in user's favorites
 * @uses bbp_remove_user_favorite() To remove the user favorite
 * @uses bbp_add_user_favorite() To add the user favorite
 * @uses do_action() Calls 'bbp_favorites_handler' with success, user id, topic
 *                    id and action
 * @uses bbp_is_favorites() To check if it's the favorites page
 * @uses bbp_get_favorites_link() To get the favorites page link
 * @uses bbp_get_topic_permalink() To get the topic permalink
 * @uses wp_safe_redirect() To redirect to the url
 */
function bbp_favorites_handler()
{
    if (!bbp_is_favorites_active()) {
        return false;
    }
    // Bail if not a GET action
    if ('GET' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if required GET actions aren't passed
    if (empty($_GET['topic_id']) || empty($_GET['action'])) {
        return;
    }
    // Setup possible get actions
    $possible_actions = array('bbp_favorite_add', 'bbp_favorite_remove');
    // Bail if actions aren't meant for this function
    if (!in_array($_GET['action'], $possible_actions)) {
        return;
    }
    // What action is taking place?
    $action = $_GET['action'];
    $topic_id = intval($_GET['topic_id']);
    $user_id = bbp_get_user_id(0, true, true);
    // Check for empty topic
    if (empty($topic_id)) {
        bbp_add_error('bbp_favorite_topic_id', __('<strong>ERROR</strong>: No topic was found! Which topic are you marking/unmarking as favorite?', 'bbpress'));
        // Check nonce
    } elseif (!bbp_verify_nonce_request('toggle-favorite_' . $topic_id)) {
        bbp_add_error('bbp_favorite_nonce', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress'));
        // Check current user's ability to edit the user
    } elseif (!current_user_can('edit_user', $user_id)) {
        bbp_add_error('bbp_favorite_permissions', __('<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress'));
    }
    // Bail if errors
    if (bbp_has_errors()) {
        return;
    }
    /** No errors *************************************************************/
    $is_favorite = bbp_is_user_favorite($user_id, $topic_id);
    $success = false;
    if (true == $is_favorite && 'bbp_favorite_remove' == $action) {
        $success = bbp_remove_user_favorite($user_id, $topic_id);
    } elseif (false == $is_favorite && 'bbp_favorite_add' == $action) {
        $success = bbp_add_user_favorite($user_id, $topic_id);
    }
    // Do additional favorites actions
    do_action('bbp_favorites_handler', $success, $user_id, $topic_id, $action);
    // Success!
    if (true == $success) {
        // Redirect back from whence we came
        if (bbp_is_favorites()) {
            $redirect = bbp_get_favorites_permalink($user_id);
        } elseif (bbp_is_single_user()) {
            $redirect = bbp_get_user_profile_url();
        } elseif (is_singular(bbp_get_topic_post_type())) {
            $redirect = bbp_get_topic_permalink($topic_id);
        } elseif (is_single() || is_page()) {
            $redirect = get_permalink();
        }
        wp_safe_redirect($redirect);
        // For good measure
        exit;
        // Fail! Handle errors
    } elseif (true == $is_favorite && 'bbp_favorite_remove' == $action) {
        bbp_add_error('bbp_favorite_remove', __('<strong>ERROR</strong>: There was a problem removing that topic from favorites!', 'bbpress'));
    } elseif (false == $is_favorite && 'bbp_favorite_add' == $action) {
        bbp_add_error('bbp_favorite_add', __('<strong>ERROR</strong>: There was a problem favoriting that topic!', 'bbpress'));
    }
}
开发者ID:hscale,项目名称:webento,代码行数:86,代码来源:functions.php

示例3: bbp_has_topics


//.........这里部分代码省略.........
            // If any posts have been excluded specifically, Ignore those that are sticky.
            if (!empty($stickies) && !empty($r['post__not_in'])) {
                $stickies = array_diff($stickies, $r['post__not_in']);
            }
            // Fetch sticky posts that weren't in the query results
            if (!empty($stickies)) {
                // Query to use in get_posts to get sticky posts
                $sticky_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => 'any', 'meta_key' => '_bbp_last_active_time', 'meta_type' => 'DATETIME', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies);
                // Cleanup
                unset($stickies);
                // Conditionally exclude private/hidden forum ID's
                $exclude_forum_ids = bbp_exclude_forum_ids('array');
                if (!empty($exclude_forum_ids)) {
                    $sticky_query['post_parent__not_in'] = $exclude_forum_ids;
                }
                // What are the default allowed statuses (based on user caps)
                if (bbp_get_view_all()) {
                    $sticky_query['post_status'] = $r['post_status'];
                    // Lean on the 'perm' query var value of 'readable' to provide statuses
                } else {
                    $sticky_query['post_status'] = $r['perm'];
                }
                // Get all stickies
                $sticky_posts = get_posts($sticky_query);
                if (!empty($sticky_posts)) {
                    // Get a count of the visible stickies
                    $sticky_count = count($sticky_posts);
                    // Merge the stickies topics with the query topics .
                    $bbp->topic_query->posts = array_merge($sticky_posts, $bbp->topic_query->posts);
                    // Adjust loop and counts for new sticky positions
                    $bbp->topic_query->found_posts = (int) $bbp->topic_query->found_posts + (int) $sticky_count;
                    $bbp->topic_query->post_count = (int) $bbp->topic_query->post_count + (int) $sticky_count;
                    // Cleanup
                    unset($sticky_posts);
                }
            }
        }
    }
    // If no limit to posts per page, set it to the current post_count
    if (-1 === $r['posts_per_page']) {
        $r['posts_per_page'] = $bbp->topic_query->post_count;
    }
    // Add pagination values to query object
    $bbp->topic_query->posts_per_page = $r['posts_per_page'];
    $bbp->topic_query->paged = $r['paged'];
    // Only add pagination if query returned results
    if (((int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts) && (int) $bbp->topic_query->posts_per_page) {
        // Limit the number of topics shown based on maximum allowed pages
        if (!empty($r['max_num_pages']) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count) {
            $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
        }
        // If pretty permalinks are enabled, make our pagination pretty
        if (bbp_use_pretty_urls()) {
            // User's topics
            if (bbp_is_single_user_topics()) {
                $base = bbp_get_user_topics_created_url(bbp_get_displayed_user_id());
                // User's favorites
            } elseif (bbp_is_favorites()) {
                $base = bbp_get_favorites_permalink(bbp_get_displayed_user_id());
                // User's subscriptions
            } elseif (bbp_is_subscriptions()) {
                $base = bbp_get_subscriptions_permalink(bbp_get_displayed_user_id());
                // Root profile page
            } elseif (bbp_is_single_user()) {
                $base = bbp_get_user_profile_url(bbp_get_displayed_user_id());
                // View
            } elseif (bbp_is_single_view()) {
                $base = bbp_get_view_url();
                // Topic tag
            } elseif (bbp_is_topic_tag()) {
                $base = bbp_get_topic_tag_link();
                // Page or single post
            } elseif (is_page() || is_single()) {
                $base = get_permalink();
                // Forum archive
            } elseif (bbp_is_forum_archive()) {
                $base = bbp_get_forums_url();
                // Topic archive
            } elseif (bbp_is_topic_archive()) {
                $base = bbp_get_topics_url();
                // Default
            } else {
                $base = get_permalink((int) $r['post_parent']);
            }
            // Use pagination base
            $base = trailingslashit($base) . user_trailingslashit(bbp_get_paged_slug() . '/%#%/');
            // Unpretty pagination
        } else {
            $base = add_query_arg('paged', '%#%');
        }
        // Pagination settings with filter
        $bbp_topic_pagination = apply_filters('bbp_topic_pagination', array('base' => $base, 'format' => '', 'total' => $r['posts_per_page'] === $bbp->topic_query->found_posts ? 1 : ceil((int) $bbp->topic_query->found_posts / (int) $r['posts_per_page']), 'current' => (int) $bbp->topic_query->paged, 'prev_text' => is_rtl() ? '&rarr;' : '&larr;', 'next_text' => is_rtl() ? '&larr;' : '&rarr;', 'mid_size' => 1));
        // Add pagination to query object
        $bbp->topic_query->pagination_links = paginate_links($bbp_topic_pagination);
        // Remove first page from pagination
        $bbp->topic_query->pagination_links = str_replace(bbp_get_paged_slug() . "/1/'", "'", $bbp->topic_query->pagination_links);
    }
    // Return object
    return apply_filters('bbp_has_topics', $bbp->topic_query->have_posts(), $bbp->topic_query);
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:101,代码来源:template.php

示例4: x_bbpress_navbar_menu

 function x_bbpress_navbar_menu($items, $args)
 {
     if (X_BBPRESS_IS_ACTIVE && x_get_option('x_bbpress_header_menu_enable', '') == '1') {
         $submenu_items = '';
         $submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . bbp_get_search_url() . '" class="cf"><i class="x-icon-search" data-x-icon="&#xf002;"></i> <span>' . __('Forums Search', '__x__') . '</span></a></li>';
         if (is_user_logged_in()) {
             $submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . bbp_get_favorites_permalink(get_current_user_id()) . '" class="cf"><i class="x-icon-star" data-x-icon="&#xf005;"></i> <span>' . __('Favorites', '__x__') . '</span></a></li>';
             $submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . bbp_get_subscriptions_permalink(get_current_user_id()) . '" class="cf"><i class="x-icon-bookmark" data-x-icon="&#xf02e;"></i> <span>' . __('Subscriptions', '__x__') . '</span></a></li>';
         }
         if (!X_BUDDYPRESS_IS_ACTIVE || X_BUDDYPRESS_IS_ACTIVE && x_get_option('x_buddypress_header_menu_enable', '') == '') {
             if (!is_user_logged_in()) {
                 $submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . wp_login_url() . '" class="cf"><i class="x-icon-sign-in" data-x-icon="&#xf090;"></i> <span>' . __('Log in', '__x__') . '</span></a></li>';
             } else {
                 $submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . bbp_get_user_profile_url(get_current_user_id()) . '" class="cf"><i class="x-icon-cog" data-x-icon="&#xf013;"></i> <span>' . __('Profile', '__x__') . '</span></a></li>';
             }
         }
         if ($args->theme_location == 'primary') {
             $items .= '<li class="menu-item current-menu-parent menu-item-has-children x-menu-item x-menu-item-bbpress">' . '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '" class="x-btn-navbar-bbpress">' . '<span><i class="x-icon-comment" data-x-icon="&#xf075;"></i><span class="x-hidden-desktop"> ' . __('Forums', '__x__') . '</span></span>' . '</a>' . '<ul class="sub-menu">' . $submenu_items . '</ul>' . '</li>';
         }
     }
     return $items;
 }
开发者ID:datracka,项目名称:datalook.io,代码行数:22,代码来源:bbpress.php

示例5: bbp_skeleton_topic_script_localization

 /**
  * Load localizations for topic script.
  *
  * These localizations require information that may not be loaded even by init.
  *
  * @since bbPress (r2652)
  *
  * @uses bbp_is_single_topic() To check if it's the topic page
  * @uses bbp_get_current_user_id() To get the current user id
  * @uses bbp_get_topic_id() To get the topic id
  * @uses bbp_get_favorites_permalink() To get the favorites permalink
  * @uses bbp_is_user_favorite() To check if the topic is in user's favorites
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
  * @uses bbp_is_user_subscribed() To check if the user is subscribed to topic
  * @uses bbp_get_topic_permalink() To get the topic permalink
  * @uses wp_localize_script() To localize the script
 */
 function bbp_skeleton_topic_script_localization()
 {
     if (!bbp_is_single_topic()) {
         return;
     }
     $user_id = bbp_get_current_user_id();
     $localizations = array('currentUserId' => $user_id, 'topicId' => bbp_get_topic_id());
     // Favorites
     if (bbp_is_favorites_active()) {
         $localizations['favoritesActive'] = 1;
         $localizations['favoritesLink'] = bbp_get_favorites_permalink($user_id);
         $localizations['isFav'] = (int) bbp_is_user_favorite($user_id);
         $localizations['favLinkYes'] = __('favorites', 'bbpress');
         $localizations['favLinkNo'] = __('?', 'bbpress');
         $localizations['favYes'] = __('This topic is one of your %favLinkYes% [%favDel%]', 'bbpress');
         $localizations['favNo'] = __('%favAdd% (%favLinkNo%)', 'bbpress');
         $localizations['favDel'] = __('&times;', 'bbpress');
         $localizations['favAdd'] = __('Add this topic to your favorites', 'bbpress');
     } else {
         $localizations['favoritesActive'] = 0;
     }
     // Subscriptions
     if (bbp_is_subscriptions_active()) {
         $localizations['subsActive'] = 1;
         $localizations['isSubscribed'] = (int) bbp_is_user_subscribed($user_id);
         $localizations['subsSub'] = __('Subscribe', 'bbpress');
         $localizations['subsUns'] = __('Unsubscribe', 'bbpress');
         $localizations['subsLink'] = bbp_get_topic_permalink();
     } else {
         $localizations['subsActive'] = 0;
     }
     wp_localize_script('bbp_topic', 'bbpTopicJS', $localizations);
 }
开发者ID:besimhu,项目名称:legacy,代码行数:50,代码来源:functions.php

示例6: test_bbp_get_favorites_permalink

 /**
  * @covers ::bbp_get_favorites_permalink
  */
 public function test_bbp_get_favorites_permalink()
 {
     // Pretty permalinks
     $this->set_permalink_structure('/%postname%/');
     $favorites_url = 'http://' . WP_TESTS_DOMAIN . '/forums/users/' . $this->keymaster_userdata->user_nicename . '/favorites/';
     // String.
     $this->assertSame($favorites_url, bbp_get_favorites_permalink($this->keymaster_id));
     // Ugly permalinks
     $this->set_permalink_structure();
     $favorites_url = 'http://' . WP_TESTS_DOMAIN . '/?bbp_user=' . $this->keymaster_id . '&bbp_favs=favorites';
     // String.
     $this->assertSame($favorites_url, bbp_get_favorites_permalink($this->keymaster_id));
 }
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:16,代码来源:user.php

示例7: bbp_get_user_favorites_link

/**
 * User favorites link
 *
 * Return the link to make a topic favorite/remove a topic from
 * favorites
 *
 * @since bbPress (r2652)
 *
 * @param array $add Optional. Add to favorites args
 * @param array $rem Optional. Remove from favorites args
 * @param int $user_id Optional. User id
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_user_id() To get the user id
 * @uses current_user_can() If the current user can edit the user
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_is_user_favorite() To check if the topic is user's favorite
 * @uses bbp_get_favorites_permalink() To get the favorites permalink
 * @uses bbp_get_topic_permalink() To get the topic permalink
 * @uses bbp_is_favorites() Is it the favorites page?
 * @uses apply_filters() Calls 'bbp_get_user_favorites_link' with the
 *                        html, add args, remove args, user & topic id
 * @return string User favorites link
 */
function bbp_get_user_favorites_link($add = array(), $rem = array(), $user_id = 0, $topic_id = 0)
{
    if (!bbp_is_favorites_active()) {
        return false;
    }
    // Validate user and topic ID's
    $user_id = bbp_get_user_id($user_id, true, true);
    $topic_id = bbp_get_topic_id($topic_id);
    if (empty($user_id) || empty($topic_id)) {
        return false;
    }
    if (!current_user_can('edit_user', (int) $user_id)) {
        return false;
    }
    if (empty($add) || !is_array($add)) {
        $add = array('mid' => __('Add this topic to your favorites', 'bbpress'), 'post' => __(' (%?%)', 'bbpress'));
    }
    if (empty($rem) || !is_array($rem)) {
        $rem = array('pre' => __('This topic is one of your %favorites% [', 'bbpress'), 'mid' => __('&times;', 'bbpress'), 'post' => __(']', 'bbpress'));
    }
    $is_fav = bbp_is_user_favorite($user_id, $topic_id);
    if (!empty($is_fav)) {
        $url = esc_url(bbp_get_favorites_permalink($user_id));
        $rem = preg_replace('|%(.+)%|', "<a href='{$url}'>\$1</a>", $rem);
        $favs = array('action' => 'bbp_favorite_remove', 'topic_id' => $topic_id);
        $pre = is_array($rem) && isset($rem['pre']) ? $rem['pre'] : '';
        $mid = is_array($rem) && isset($rem['mid']) ? $rem['mid'] : (is_string($rem) ? $rem : '');
        $_post = is_array($rem) && isset($rem['post']) ? $rem['post'] : '';
    } else {
        $url = esc_url(bbp_get_favorites_permalink($user_id));
        $add = preg_replace('|%(.+)%|', "<a href='{$url}'>\$1</a>", $add);
        $favs = array('action' => 'bbp_favorite_add', 'topic_id' => $topic_id);
        $pre = is_array($add) && isset($add['pre']) ? $add['pre'] : '';
        $mid = is_array($add) && isset($add['mid']) ? $add['mid'] : (is_string($add) ? $add : '');
        $_post = is_array($add) && isset($add['post']) ? $add['post'] : '';
    }
    // Create the link based where the user is and if the topic is
    // already the user's favorite
    if (bbp_is_favorites()) {
        $permalink = bbp_get_favorites_permalink($user_id);
    } elseif (is_singular(bbp_get_topic_post_type())) {
        $permalink = bbp_get_topic_permalink($topic_id);
    } elseif (is_singular(bbp_get_reply_post_type())) {
        $permalink = bbp_get_topic_permalink($topic_id);
    } elseif (bbp_is_query_name('bbp_single_topic')) {
        $permalink = get_permalink();
    }
    $url = esc_url(wp_nonce_url(add_query_arg($favs, $permalink), 'toggle-favorite_' . $topic_id));
    $is_fav = $is_fav ? 'is-favorite' : '';
    $html = '<span id="favorite-toggle"><span id="favorite-' . $topic_id . '" class="' . $is_fav . '">' . $pre . '<a href="' . $url . '" class="dim:favorite-toggle:favorite-' . $topic_id . ':is-favorite">' . $mid . '</a>' . $_post . '</span></span>';
    // Return the link
    return apply_filters('bbp_get_user_favorites_link', $html, $add, $rem, $user_id, $topic_id);
}
开发者ID:rmccue,项目名称:bbPress,代码行数:76,代码来源:bbp-user-template.php

示例8: cb_bbp_author_details

 function cb_bbp_author_details($cb_author_id, $cb_desc = true)
 {
     $cb_author_email = get_the_author_meta('publicemail', $cb_author_id);
     $cb_author_name = get_the_author_meta('display_name', $cb_author_id);
     $cb_author_position = get_the_author_meta('position', $cb_author_id);
     $cb_author_tw = get_the_author_meta('twitter', $cb_author_id);
     $cb_author_go = get_the_author_meta('googleplus', $cb_author_id);
     $cb_author_www = get_the_author_meta('url', $cb_author_id);
     $cb_author_desc = get_the_author_meta('description', $cb_author_id);
     $cb_author_posts = count_user_posts($cb_author_id);
     $cb_author_output = NULL;
     $cb_author_output .= '<div class="cb-author-details cb-bbp clearfix"><div class="cb-mask"><a href="' . bbp_get_user_profile_url() . '" title="' . bbp_get_displayed_user_field('display_name') . '" rel="me">' . get_avatar(bbp_get_displayed_user_field('user_email', 'raw'), apply_filters('bbp_single_user_details_avatar_size', 150)) . '</a></div><div class="cb-meta"><h3><a href="' . bbp_get_user_profile_url() . '" title="' . bbp_get_displayed_user_field('display_name') . '">' . $cb_author_name . '</a></h3>';
     if ($cb_author_position != NULL) {
         $cb_author_output .= '<div class="cb-author-position">' . $cb_author_position . '</div>';
     }
     if ($cb_author_desc != NULL && $cb_desc == true) {
         $cb_author_output .= '<p class="cb-author-bio">' . $cb_author_desc . '</p>';
     }
     if ($cb_author_email != NULL || $cb_author_www != NULL || $cb_author_tw != NULL || $cb_author_go != NULL) {
         $cb_author_output .= '<div class="cb-author-page-contact">';
     }
     if ($cb_author_email != NULL) {
         $cb_author_output .= '<a href="mailto:' . $cb_author_email . '"><i class="icon-envelope-alt cb-tip-bot" title="' . __('Email', 'cubell') . '"></i></a>';
     }
     if ($cb_author_www != NULL) {
         $cb_author_output .= ' <a href="' . $cb_author_www . '" target="_blank"><i class="icon-link cb-tip-bot" title="' . __('Website', 'cubell') . '"></i></a> ';
     }
     if ($cb_author_tw != NULL) {
         $cb_author_output .= ' <a href="//www.twitter.com/' . $cb_author_tw . '" target="_blank" ><i class="icon-twitter cb-tip-bot" title="Twitter"></i></a>';
     }
     if ($cb_author_go != NULL) {
         $cb_author_output .= ' <a href="' . $cb_author_go . '" rel="publisher" target="_top" title="Google+" class="cb-googleplus cb-tip-bot" ><img src="//ssl.gstatic.com/images/icons/gplus-32.png"  data-src-retina="//ssl.gstatic.com/images/icons/gplus-64.png" alt="Google+" ></a>';
     }
     if ($cb_author_email != NULL || $cb_author_www != NULL || $cb_author_go != NULL || $cb_author_tw != NULL) {
         $cb_author_output .= '</div>';
     }
     $cb_author_output .= '<div id="cb-user-nav"><ul>';
     if (bbp_is_single_user_replies()) {
         $cb_user_current = 'current';
     }
     $cb_author_output .= '<li class="';
     if (bbp_is_single_user_topics()) {
         $cb_author_output .= 'current';
     }
     $cb_author_output .= '"><span class="bbp-user-topics-created-link"><a href="' . bbp_get_user_topics_created_url() . '">' . __('Topics Started', 'bbpress') . '</a></span></li>';
     $cb_author_output .= '<li class="';
     if (bbp_is_single_user_replies()) {
         $cb_author_output .= 'current';
     }
     $cb_author_output .= '"><span class="bbp-user-replies-created-link"><a href="' . bbp_get_user_replies_created_url() . '">' . __('Replies Created', 'bbpress') . '</a></span></li>';
     if (bbp_is_favorites_active()) {
         $cb_author_output .= '<li class="';
         if (bbp_is_favorites()) {
             $cb_author_output .= 'current';
         }
         $cb_author_output .= '"><span class="bbp-user-favorites-link"><a href="' . bbp_get_favorites_permalink() . '">' . __('Favorites', 'bbpress') . '</a></span></li>';
     }
     if (bbp_is_user_home() || current_user_can('edit_users')) {
         if (bbp_is_subscriptions_active()) {
             $cb_author_output .= '<li class="';
             if (bbp_is_subscriptions()) {
                 $cb_author_output .= 'current';
             }
             $cb_author_output .= '"><span class="bbp-user-subscriptions-link"><a href="' . bbp_get_subscriptions_permalink() . '">' . __('Subscriptions', 'bbpress') . '</a></span></li>';
         }
         $cb_author_output .= '<li class="';
         if (bbp_is_single_user_edit()) {
             $cb_author_output .= 'current';
         }
         $cb_author_output .= '"><span class="bbp-user-edit-link"><a href="' . bbp_get_user_profile_edit_url() . '">' . __('Edit', 'bbpress') . '</a></span></li>';
     }
     $cb_author_output .= '</ul></div><!-- #cb-user-nav -->';
     $cb_author_output .= '</div></div>';
     return $cb_author_output;
 }
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:75,代码来源:core.php

示例9: setup_admin_bar

 /**
  * Set up the admin bar
  *
  * @since 2.1.0 bbPress (r3552)
  */
 public function setup_admin_bar($wp_admin_nav = array())
 {
     // Menus for logged in user
     if (is_user_logged_in()) {
         // If BuddyPress is network activated and bbPress is
         // not activated on a the root blog but on any child one
         if (!bp_is_root_blog()) {
             $user_id = bbp_get_current_user_id();
             $my_account_link = bbp_get_user_profile_url($user_id);
             $my_topics_link = bbp_get_user_topics_created_url($user_id);
             $my_replies_link = bbp_get_user_replies_created_url($user_id);
             $my_favorites_link = bbp_get_favorites_permalink($user_id);
             $my_subscriptions_link = bbp_get_subscriptions_permalink($user_id);
         } else {
             // Setup the logged in user variables
             $user_domain = bp_loggedin_user_domain();
             $forums_link = trailingslashit($user_domain . $this->slug);
             $my_account_link = trailingslashit($forums_link);
             $my_topics_link = trailingslashit($forums_link . bbp_get_topic_archive_slug());
             $my_replies_link = trailingslashit($forums_link . bbp_get_reply_archive_slug());
             $my_favorites_link = trailingslashit($forums_link . bbp_get_user_favorites_slug());
             $my_subscriptions_link = trailingslashit($forums_link . bbp_get_user_subscriptions_slug());
         }
         // Add the "My Account" sub menus
         $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => __('Forums', 'bbpress'), 'href' => $my_account_link);
         // Topics
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-topics', 'title' => __('Topics Started', 'bbpress'), 'href' => $my_topics_link);
         // Replies
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-replies', 'title' => __('Replies Created', 'bbpress'), 'href' => $my_replies_link);
         // Favorites
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-favorites', 'title' => __('Favorite Topics', 'bbpress'), 'href' => $my_favorites_link);
         // Subscriptions
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-subscriptions', 'title' => __('Subscribed Topics', 'bbpress'), 'href' => $my_subscriptions_link);
     }
     parent::setup_admin_bar($wp_admin_nav);
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:41,代码来源:loader.php

示例10: bbp_has_topics


//.........这里部分代码省略.........
                    $sticky_offset++;
                    // Remove post from sticky posts array
                    $offset = array_search($sticky->ID, $stickies);
                    // Cleanup
                    unset($stickies[$offset]);
                    unset($sticky);
                }
            }
            // If any posts have been excluded specifically, Ignore those that are sticky.
            if (!empty($stickies) && !empty($post__not_in)) {
                $stickies = array_diff($stickies, $post__not_in);
            }
            // Fetch sticky posts that weren't in the query results
            if (!empty($stickies)) {
                // Query to use in get_posts to get sticky posts
                $sticky_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => 'any', 'post_status' => $default_post_status, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies);
                // Get all stickies
                $sticky_posts = get_posts($sticky_query);
                if (!empty($sticky_posts)) {
                    // Get a count of the visible stickies
                    $sticky_count = count($sticky_posts);
                    // Loop through stickies and add them to beginning of array
                    foreach ($sticky_posts as $sticky) {
                        $topics[] = $sticky;
                    }
                    // Loop through topics and add them to end of array
                    foreach ($bbp->topic_query->posts as $topic) {
                        $topics[] = $topic;
                    }
                    // Adjust loop and counts for new sticky positions
                    $bbp->topic_query->posts = $topics;
                    $bbp->topic_query->found_posts = (int) $bbp->topic_query->found_posts + (int) $sticky_count;
                    $bbp->topic_query->post_count = (int) $bbp->topic_query->post_count + (int) $sticky_count;
                    // Cleanup
                    unset($topics);
                    unset($stickies);
                    unset($sticky_posts);
                }
            }
        }
    }
    // If no limit to posts per page, set it to the current post_count
    if (-1 == $posts_per_page) {
        $posts_per_page = $bbp->topic_query->post_count;
    }
    // Add pagination values to query object
    $bbp->topic_query->posts_per_page = $posts_per_page;
    $bbp->topic_query->paged = $paged;
    // Only add pagination if query returned results
    if (((int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts) && (int) $bbp->topic_query->posts_per_page) {
        // Limit the number of topics shown based on maximum allowed pages
        if (!empty($max_num_pages) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count) {
            $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
        }
        // If pretty permalinks are enabled, make our pagination pretty
        if ($wp_rewrite->using_permalinks()) {
            // User's topics
            if (bbp_is_single_user_topics()) {
                $base = bbp_get_user_topics_created_url(bbp_get_displayed_user_id());
                // User's favorites
            } elseif (bbp_is_favorites()) {
                $base = bbp_get_favorites_permalink(bbp_get_displayed_user_id());
                // User's subscriptions
            } elseif (bbp_is_subscriptions()) {
                $base = bbp_get_subscriptions_permalink(bbp_get_displayed_user_id());
                // Root profile page
            } elseif (bbp_is_single_user()) {
                $base = bbp_get_user_profile_url(bbp_get_displayed_user_id());
                // View
            } elseif (bbp_is_single_view()) {
                $base = bbp_get_view_url();
                // Topic tag
            } elseif (bbp_is_topic_tag()) {
                $base = bbp_get_topic_tag_link();
                // Page or single post
            } elseif (is_page() || is_single()) {
                $base = get_permalink();
                // Topic archive
            } elseif (bbp_is_topic_archive()) {
                $base = bbp_get_topics_url();
                // Default
            } else {
                $base = get_permalink($post_parent);
            }
            // Use pagination base
            $base = trailingslashit($base) . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
            // Unpretty pagination
        } else {
            $base = add_query_arg('paged', '%#%');
        }
        // Pagination settings with filter
        $bbp_topic_pagination = apply_filters('bbp_topic_pagination', array('base' => $base, 'format' => '', 'total' => $posts_per_page == $bbp->topic_query->found_posts ? 1 : ceil((int) $bbp->topic_query->found_posts / (int) $posts_per_page), 'current' => (int) $bbp->topic_query->paged, 'prev_text' => '&larr;', 'next_text' => '&rarr;', 'mid_size' => 1));
        // Add pagination to query object
        $bbp->topic_query->pagination_links = paginate_links($bbp_topic_pagination);
        // Remove first page from pagination
        $bbp->topic_query->pagination_links = str_replace($wp_rewrite->pagination_base . "/1/'", "'", $bbp->topic_query->pagination_links);
    }
    // Return object
    return apply_filters('bbp_has_topics', $bbp->topic_query->have_posts(), $bbp->topic_query);
}
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:template-tags.php


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