/** * Create the Notifications menu for the BuddyBar. * * @since BuddyPress (1.9.0) */ function bp_notifications_buddybar_menu() { if (!is_user_logged_in()) { return false; } echo '<li id="bp-adminbar-notifications-menu"><a href="' . esc_url(bp_loggedin_user_domain()) . '">'; _e('Notifications', 'buddypress'); if ($notification_count = bp_notifications_get_unread_notification_count(bp_loggedin_user_id())) { ?> <span><?php echo bp_core_number_format($notification_count); ?> </span> <?php } echo '</a>'; echo '<ul>'; if ($notifications = bp_notifications_get_notifications_for_user(bp_loggedin_user_id())) { $counter = 0; for ($i = 0, $count = count($notifications); $i < $count; ++$i) { $alt = 0 == $counter % 2 ? ' class="alt"' : ''; ?> <li<?php echo $alt; ?> ><?php echo $notifications[$i]; ?> </li> <?php $counter++; } } else { ?> <li><a href="<?php echo esc_url(bp_loggedin_user_domain()); ?> "><?php _e('No new notifications.', 'buddypress'); ?> </a></li> <?php } echo '</ul>'; echo '</li>'; }
function bcg_posts_pagination_count($q) { $posts_per_page = intval(get_query_var('posts_per_page')); $paged = intval(get_query_var('paged')); $numposts = $q->found_posts; $max_page = $q->max_num_pages; if (empty($paged) || $paged == 0) { $paged = 1; } $start_num = intval($posts_per_page * ($paged - 1)) + 1; $from_num = bp_core_number_format($start_num); $to_num = bp_core_number_format($start_num + ($posts_per_page - 1) > $numposts ? $numposts : $start_num + ($posts_per_page - 1)); $total = bp_core_number_format($numposts); //$taxonomy = get_taxonomy( bcg_get_taxonomy() ); $post_type_object = get_post_type_object(bcg_get_post_type()); printf(__('Viewing %1s %2$s to %3$s (of %4$s )', 'bcg'), $post_type_object->labels->name, $from_num, $to_num, $total) . " "; //$term = get_term_name ( $q->query_vars['cat'] ); //if( bcg_is_category() ) // printf( __( "In the %s %s ","bcg" ), $taxonomy->label, "<span class='bcg-cat-name'>". $term_name ."</span>" ); ?> <span class="ajax-loader"></span><?php }
function bp_the_topic_pagination_count() { global $bp, $topic_template; $start_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1; $from_num = bp_core_number_format( $start_num ); $to_num = bp_core_number_format( ( $start_num + ( $topic_template->pag_num - 1 ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $start_num + ( $topic_template->pag_num - 1 ) ); $total = bp_core_number_format( $topic_template->total_post_count ); echo apply_filters( 'bp_the_topic_pagination_count', sprintf( __( 'Viewing post %1$s to %2$s (%3$s total posts)', 'buddypress' ), $from_num, $to_num, $total ) ); ?> <span class="ajax-loader"></span> <?php }
/** * Return the pagination count for the current topic page. * * The "count" is a string of the form "Viewing x of y posts". * * @return string */ function bp_the_topic_pagination_count() { global $bp, $topic_template; $start_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1; $from_num = bp_core_number_format( $start_num ); $to_num = bp_core_number_format( ( $start_num + ( $topic_template->pag_num - 1 ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $start_num + ( $topic_template->pag_num - 1 ) ); $total = bp_core_number_format( $topic_template->total_post_count ); /** * Filters the pagination count for the current topic page. * * @since BuddyPress (1.0.0) * * @param string $value Pagination count for the current topic page. * @param string $from_num Low end count in the view. * @param string $to_num High end count in the view. * @param string $total Total count of topics found. */ echo apply_filters( 'bp_the_topic_pagination_count', sprintf( _n( 'Viewing 1 post', 'Viewing %1$s - %2$s of %3$s posts', (int) $topic_template->total_post_count, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total ); }
/** * Set up the component entries in the WordPress Admin Bar. * * @since 1.5.0 * * @see BP_Component::setup_nav() for a description of the $wp_admin_nav * parameter array. * @uses is_user_logged_in() * @uses trailingslashit() * @uses bp_get_total_mention_count_for_user() * @uses bp_loggedin_user_id() * @uses bp_is_active() * @uses bp_get_friends_slug() * @uses bp_get_groups_slug() * * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a * description. */ public function setup_admin_bar($wp_admin_nav = array()) { // Menus for logged in user. if (is_user_logged_in()) { // Setup the logged in user variables. $activity_link = trailingslashit(bp_loggedin_user_domain() . bp_get_activity_slug()); // Unread message count. if (bp_activity_do_mentions()) { $count = bp_get_total_mention_count_for_user(bp_loggedin_user_id()); if (!empty($count)) { $title = sprintf(_x('Mentions <span class="count">%s</span>', 'Toolbar Mention logged in user', 'buddypress'), bp_core_number_format($count)); } else { $title = _x('Mentions', 'Toolbar Mention logged in user', 'buddypress'); } } // Add the "Activity" sub menu. $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => _x('Activity', 'My Account Activity sub nav', 'buddypress'), 'href' => $activity_link); // Personal. $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-personal', 'title' => _x('Personal', 'My Account Activity sub nav', 'buddypress'), 'href' => $activity_link); // Mentions. if (bp_activity_do_mentions()) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-mentions', 'title' => $title, 'href' => trailingslashit($activity_link . 'mentions')); } // Favorite activity items. if (bp_activity_can_favorite()) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-favorites', 'title' => _x('Favorites', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . 'favorites')); } // Friends? if (bp_is_active('friends')) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-friends', 'title' => _x('Friends', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_friends_slug())); } // Groups? if (bp_is_active('groups')) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-groups', 'title' => _x('Groups', 'My Account Activity sub nav', 'buddypress'), 'href' => trailingslashit($activity_link . bp_get_groups_slug())); } } parent::setup_admin_bar($wp_admin_nav); }
/** * Set up bp-friends integration with the WordPress admin bar. * * @since 1.5.0 * * @see BP_Component::setup_admin_bar() for a description of arguments. * * @param array $wp_admin_nav See BP_Component::setup_admin_bar() * for description. */ public function setup_admin_bar($wp_admin_nav = array()) { // Menus for logged in user. if (is_user_logged_in()) { // Setup the logged in user variables. $friends_link = trailingslashit(bp_loggedin_user_domain() . bp_get_friends_slug()); // Pending friend requests. $count = count(friends_get_friendship_request_user_ids(bp_loggedin_user_id())); if (!empty($count)) { $title = sprintf(_x('Friends <span class="count">%s</span>', 'My Account Friends menu', 'buddypress'), bp_core_number_format($count)); $pending = sprintf(_x('Pending Requests <span class="count">%s</span>', 'My Account Friends menu sub nav', 'buddypress'), bp_core_number_format($count)); } else { $title = _x('Friends', 'My Account Friends menu', 'buddypress'); $pending = _x('No Pending Requests', 'My Account Friends menu sub nav', 'buddypress'); } // Add the "My Account" sub menus. $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => $title, 'href' => $friends_link); // My Friends. $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-friendships', 'title' => _x('Friendships', 'My Account Friends menu sub nav', 'buddypress'), 'href' => $friends_link, 'position' => 10); // Requests. $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-requests', 'title' => $pending, 'href' => trailingslashit($friends_link . 'requests'), 'position' => 20); } parent::setup_admin_bar($wp_admin_nav); }
/** * Get the total site member count. * * @return int */ function bp_get_total_site_member_count() { /** * Filters the total site member count. * * @since 1.2.0 * * @param int $value Number-formatted total site member count. */ return apply_filters('bp_get_total_site_member_count', bp_core_number_format(bp_core_get_total_member_count())); }
/** * Output the blogs pagination count. * * @global object $blogs_template {@link BP_Blogs_Template} */ function bp_blogs_pagination_count() { global $blogs_template; $start_num = intval(($blogs_template->pag_page - 1) * $blogs_template->pag_num) + 1; $from_num = bp_core_number_format($start_num); $to_num = bp_core_number_format($start_num + ($blogs_template->pag_num - 1) > $blogs_template->total_blog_count ? $blogs_template->total_blog_count : $start_num + ($blogs_template->pag_num - 1)); $total = bp_core_number_format($blogs_template->total_blog_count); if (1 == $blogs_template->total_blog_count) { $message = __('Viewing 1 site', 'buddypress'); } else { $message = sprintf(_n('Viewing %1$s - %2$s of %3$s site', 'Viewing %1$s - %2$s of %3$s sites', $blogs_template->total_blog_count, 'buddypress'), $from_num, $to_num, $total); } echo $message; }
function bp_messages_pagination_count() { global $messages_template; $start_num = intval(($messages_template->pag_page - 1) * $messages_template->pag_num) + 1; $from_num = bp_core_number_format($start_num); $to_num = bp_core_number_format($start_num + ($messages_template->pag_num - 1) > $messages_template->total_thread_count ? $messages_template->total_thread_count : $start_num + ($messages_template->pag_num - 1)); $total = bp_core_number_format($messages_template->total_thread_count); echo sprintf(__('Viewing message %1$s to %2$s (of %3$s messages)', 'buddypress'), $from_num, $to_num, $total); }
/** * Returns the activity pagination count * * @since 1.2.0 * * @global object $bp BuddyPress global settings * @global object $activities_template {@link BP_Activity_Template} * @uses bp_core_number_format() * * @return string The pagination text */ function bp_get_activity_pagination_count() { global $bp, $activities_template; $start_num = intval(($activities_template->pag_page - 1) * $activities_template->pag_num) + 1; $from_num = bp_core_number_format($start_num); $to_num = bp_core_number_format($start_num + ($activities_template->pag_num - 1) > $activities_template->total_activity_count ? $activities_template->total_activity_count : $start_num + ($activities_template->pag_num - 1)); $total = bp_core_number_format($activities_template->total_activity_count); return sprintf(__('Viewing item %1$s to %2$s (of %3$s items)', 'buddypress'), $from_num, $to_num, $total); }
/** * Outputs the HTML for this widget. * * @global DPA_Achievement_Template $achievements_template Achievements template tag object * @global object $bp BuddyPress global settings * @param array $args An array of standard parameters for widgets * @param array $instance An array of settings for this widget instance * @since 2.0 */ function widget($args, $instance) { global $achievements_template, $bp; extract($args, EXTR_SKIP); if (dpa_has_achievements(array('slug' => $instance['achievement_slug'], 'populate_extras' => false, 'type' => 'single'))) { echo $before_widget; if ($instance['title']) { echo $before_title; echo esc_html(apply_filters('dpa_widget_title', $instance['title'])); echo $after_title; } ?> <?php while (dpa_achievements()) { dpa_the_achievement(); ?> <div class="item-avatar"> <a href="<?php dpa_achievement_slug_permalink(); ?> "><?php dpa_achievement_picture(); ?> </a> <div class="item-title"><a href="<?php dpa_achievement_slug_permalink(); ?> "><?php dpa_achievement_name(); ?> </a></div> <div class="item-meta"><span class="activity"><?php printf(__("%s points", 'dpa'), bp_core_number_format(dpa_get_achievement_points())); ?> </span></div> <div class="item-desc"><?php dpa_achievement_description_excerpt(); ?> </div> </div> <?php } ?> <p class="achievements-widget-showall"><a href="<?php dpa_achievement_slug_permalink(); ?> "><?php _e('Show More', 'dpa'); ?> </a></p> <div style="clear: right;"></div> <?php echo $after_widget; } $achievements_template = null; }
/** * Format notifications for the Messages component. * * @since 1.0.0 * * @param string $action The kind of notification being rendered. * @param int $item_id The primary item id. * @param int $secondary_item_id The secondary item id. * @param int $total_items The total number of messaging-related notifications * waiting for the user. * @param string $format Return value format. 'string' for BuddyBar-compatible * notifications; 'array' for WP Toolbar. Default: 'string'. * @return string|array Formatted notifications. */ function messages_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string') { $total_items = (int) $total_items; $text = ''; $link = trailingslashit(bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox'); $title = __('Inbox', 'buddypress'); $amount = 'single'; if ('new_message' === $action) { if ($total_items > 1) { $amount = 'multiple'; $text = sprintf(__('You have %d new messages', 'buddypress'), $total_items); } else { // Get message thread ID. $message = new BP_Messages_Message($item_id); $thread_id = $message->thread_id; $link = !empty($thread_id) ? bp_get_message_thread_view_link($thread_id) : false; if (!empty($secondary_item_id)) { $text = sprintf(__('%s sent you a new private message', 'buddypress'), bp_core_get_user_displayname($secondary_item_id)); } else { $text = sprintf(_n('You have %s new private message', 'You have %s new private messages', $total_items, 'buddypress'), bp_core_number_format($total_items)); } } if ('string' === $format) { if (!empty($link)) { $return = '<a href="' . esc_url($link) . '" title="' . esc_attr($title) . '">' . esc_html($text) . '</a>'; } else { $return = esc_html($text); } /** * Filters the new message notification text before the notification is created. * * This is a dynamic filter. Possible filter names are: * - 'bp_messages_multiple_new_message_notification'. * - 'bp_messages_single_new_message_notification'. * * @param string $return Notification text. * @param int $total_items Number of messages referred to by the notification. * @param string $text The raw notification test (ie, not wrapped in a link). * @param int $item_id ID of the associated item. * @param int $secondary_item_id ID of the secondary associated item. */ $return = apply_filters('bp_messages_' . $amount . '_new_message_notification', $return, (int) $total_items, $text, $link, $item_id, $secondary_item_id); } else { /** This filter is documented in bp-messages/bp-messages-notifications.php */ $return = apply_filters('bp_messages_' . $amount . '_new_message_notification', array('text' => $text, 'link' => $link), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id); } // Custom notification action for the Messages component } else { if ('string' === $format) { $return = $text; } else { $return = array('text' => $text, 'link' => $link); } /** * Backcompat for plugins that used to filter bp_messages_single_new_message_notification * for their custom actions. These plugins should now use 'bp_messages_' . $action . '_notification' */ if (has_filter('bp_messages_single_new_message_notification')) { if ('string' === $format) { /** This filter is documented in bp-messages/bp-messages-notifications.php */ $return = apply_filters('bp_messages_single_new_message_notification', $return, (int) $total_items, $text, $link, $item_id, $secondary_item_id); // Notice that there are seven parameters instead of six? Ugh... } else { /** This filter is documented in bp-messages/bp-messages-notifications.php */ $return = apply_filters('bp_messages_single_new_message_notification', $return, $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id); } } /** * Filters the custom action notification before the notification is created. * * This is a dynamic filter based on the message notification action. * * @since 2.6.0 * * @param array $value An associative array containing the text and the link of the notification * @param int $item_id ID of the associated item. * @param int $secondary_item_id ID of the secondary associated item. * @param int $total_items Number of messages referred to by the notification. * @param string $format Return value format. 'string' for BuddyBar-compatible * notifications; 'array' for WP Toolbar. Default: 'string'. */ $return = apply_filters("bp_messages_{$action}_notification", $return, $item_id, $secondary_item_id, $total_items, $format); } /** * Fires right before returning the formatted message notifications. * * @since 1.0.0 * * @param string $action The type of message notification. * @param int $item_id The primary item ID. * @param int $secondary_item_id The secondary item ID. * @param int $total_items Total amount of items to format. */ do_action('messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items); return $return; }
function bp_blogs_pagination_count() { global $bp, $blogs_template; $start_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1; $from_num = bp_core_number_format( $start_num ); $to_num = bp_core_number_format( ( $start_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $start_num + ( $blogs_template->pag_num - 1 ) ); $total = bp_core_number_format( $blogs_template->total_blog_count ); echo sprintf( __( 'Viewing blog %1$s to %2$s (of %3$s blogs)', 'buddypress' ), $from_num, $to_num, $total ); ?> <span class="ajax-loader"></span><?php }
/** * Set up component navigation. * * @since BuddyPress (1.5.0) * * @see BP_Component::setup_nav() for a description of arguments. * * @param array $main_nav Optional. See BP_Component::setup_nav() for * description. * @param array $sub_nav Optional. See BP_Component::setup_nav() for * description. */ public function setup_nav($main_nav = array(), $sub_nav = array()) { if (bp_displayed_user_id() === 0 || bp_displayed_user_id() === get_current_user_id()) { return; } // Determine user to use if (bp_displayed_user_domain()) { $user_domain = bp_displayed_user_domain(); } $mutual_friends_link = trailingslashit($user_domain . BP_MUTUAL_FRIENDS_SLUG); // Add 'Friends' to the main navigation // Add 'Friends' to the main navigation $count = bp_mutual_friend_total_count(); $class = 0 === $count ? 'no-count' : 'count'; $main_nav = array('name' => sprintf(__('Mutual Friends <span class="%s">%s</span>', 'buddypress'), esc_attr($class), bp_core_number_format($count)), 'slug' => BP_MUTUAL_FRIENDS_SLUG, 'position' => 65, 'screen_function' => 'bp_mutual_friends_screen', 'default_subnav_slug' => 'my-mutual-friends', 'item_css_id' => 'members'); // Add the subnav items to the mutual-friends nav item $sub_nav[] = array('name' => _x('Mutual Friends', 'Friends screen sub nav', 'buddypress'), 'slug' => 'my-mutual-friends', 'parent_url' => $mutual_friends_link, 'parent_slug' => BP_MUTUAL_FRIENDS_SLUG, 'screen_function' => 'bp_my_mutual_friends_screen', 'position' => 10); parent::setup_nav($main_nav, $sub_nav); }
/** * Set up component navigation for bp-blogs. * * @see BP_Component::setup_nav() for a description of arguments. * * @param array $main_nav Optional. See BP_Component::setup_nav() for * description. * @param array $sub_nav Optional. See BP_Component::setup_nav() for * description. */ public function setup_nav($main_nav = array(), $sub_nav = array()) { /** * Blog/post/comment menus should not appear on single WordPress setups. * Although comments and posts made by users will still show on their * activity stream. */ if (!is_multisite()) { return false; } // Determine user to use. if (bp_displayed_user_domain()) { $user_domain = bp_displayed_user_domain(); } elseif (bp_loggedin_user_domain()) { $user_domain = bp_loggedin_user_domain(); } else { return; } $slug = bp_get_blogs_slug(); $parent_url = trailingslashit($user_domain . $slug); // Add 'Sites' to the main navigation. $count = (int) bp_get_total_blog_count_for_user(); $class = 0 === $count ? 'no-count' : 'count'; $nav_text = sprintf(__('Sites <span class="%s">%s</span>', 'buddypress'), esc_attr($class), bp_core_number_format($count)); $main_nav = array('name' => $nav_text, 'slug' => $slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-sites', 'item_css_id' => $this->id); $sub_nav[] = array('name' => __('My Sites', 'buddypress'), 'slug' => 'my-sites', 'parent_url' => $parent_url, 'parent_slug' => $slug, 'screen_function' => 'bp_blogs_screen_my_blogs', 'position' => 10); // Setup navigation. parent::setup_nav($main_nav, $sub_nav); }
?> </span> <?php if (!dpa_get_achievement_is_active() && dpa_permission_can_user_edit()) { ?> <span class="highlight"><?php _e('Inactive Achievement', 'dpa'); ?> </span> <?php } ?> <span class="activity"><?php printf(_n('Only %s person has unlocked this Achievement', '%s people have unlocked this Achievement', bp_core_number_format(dpa_get_achievement_unlocked_count()), 'dpa'), bp_core_number_format(dpa_get_achievement_unlocked_count())); ?> </span> </p> <?php do_action('dpa_before_achievement_header_meta'); ?> <div id="item-meta"> <?php dpa_achievement_description_excerpt(); ?> <div id="item-buttons"> <?php
/** * Load an individual conversation screen. * * @since 1.0.0 * * @return bool|null False on failure. */ function messages_screen_conversation() { // Bail if not viewing a single message. if (!bp_is_messages_component() || !bp_is_current_action('view')) { return false; } $thread_id = (int) bp_action_variable(0); if (empty($thread_id) || !messages_is_valid_thread($thread_id) || !messages_check_thread_access($thread_id) && !bp_current_user_can('bp_moderate')) { bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug())); } // Load up BuddyPress one time. $bp = buddypress(); // Decrease the unread count in the nav before it's rendered. $count = bp_get_total_unread_messages_count(); $class = 0 === $count ? 'no-count' : 'count'; $nav_name = sprintf(__('Messages <span class="%s">%s</span>', 'buddypress'), esc_attr($class), bp_core_number_format($count)); $bp->bp_nav[$bp->messages->slug]['name'] = $nav_name; /** * Fires right before the loading of the Messages view screen template file. * * @since 1.7.0 */ do_action('messages_screen_conversation'); /** * Filters the template to load for the Messages view screen. * * @since 1.0.0 * * @param string $template Path to the messages template to load. */ bp_core_load_template(apply_filters('messages_template_view_message', 'members/single/home')); }
/** * Set up the component entries in the WordPress Admin Bar. * * @see BP_Component::setup_nav() for a description of the $wp_admin_nav * parameter array. * * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a description. */ public function setup_admin_bar($wp_admin_nav = array()) { // Menus for logged in user. if (is_user_logged_in()) { // Setup the logged in user variables. $groups_link = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug()); // Pending group invites. $count = groups_get_invite_count_for_user(); $title = _x('Groups', 'My Account Groups', 'buddypress'); $pending = _x('No Pending Invites', 'My Account Groups sub nav', 'buddypress'); if (!empty($count['total'])) { $title = sprintf(_x('Groups <span class="count">%s</span>', 'My Account Groups nav', 'buddypress'), bp_core_number_format($count)); $pending = sprintf(_x('Pending Invites <span class="count">%s</span>', 'My Account Groups sub nav', 'buddypress'), bp_core_number_format($count)); } // Add the "My Account" sub menus. $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => $title, 'href' => $groups_link); // My Groups. $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-memberships', 'title' => _x('Memberships', 'My Account Groups sub nav', 'buddypress'), 'href' => $groups_link); // Invitations. $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-invites', 'title' => $pending, 'href' => trailingslashit($groups_link . 'invites')); // Create a Group. if (bp_user_can_create_groups()) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-create', 'title' => _x('Create a Group', 'My Account Groups sub nav', 'buddypress'), 'href' => trailingslashit(bp_get_groups_directory_permalink() . 'create')); } } parent::setup_admin_bar($wp_admin_nav); }
/** * Roll our custom Bootstrap Notifications * * @since 1.0 */ function wff_bp_notifications_menu() { if (!is_user_logged_in()) { return false; } echo '<li class="dropdown menu-groups notification-nav" id="bp-adminbar-notifications-menu"><a data-toggle="dropdown" class="dropdown-toggle has-submenu" href="' . esc_url(bp_loggedin_user_domain()) . '"><i class="fa fa-bell"></i>'; _e('', 'buddypress'); if ($notification_count = bp_notifications_get_unread_notification_count(bp_loggedin_user_id())) { ?> <span id="notification-counter"><?php echo bp_core_number_format($notification_count); ?> </span> <?php } echo '</a>'; echo '<ul class="dropdown-menu">'; if ($notifications = bp_notifications_get_notifications_for_user(bp_loggedin_user_id())) { $counter = 0; for ($i = 0, $count = count($notifications); $i < $count; ++$i) { $alt = 0 == $counter % 2 ? ' class="alt"' : ''; ?> <li<?php echo $alt; ?> ><?php echo $notifications[$i]; ?> </li> <?php $counter++; } } else { ?> <li> <a href="<?php echo esc_url(bp_loggedin_user_domain()); ?> "> <?php _e('No new notifications.', 'buddypress'); ?> </a> </li> <?php } echo '</ul>'; echo '</li>'; }
/** * Create pagination links out of a BP_Group_Member_Query. * * This function is intended to create pagination links for use under the * Manage Members section of the Groups Admin Dashboard pages. It is a stopgap * measure until a more general pagination solution is in place for BuddyPress. * Plugin authors should not use this function, as it is likely to be * deprecated soon. * * @since 1.8.0 * * @param BP_Group_Member_Query $query A BP_Group_Member_Query object. * @param string $member_type member|mod|admin|banned. * * @return string Pagination links HTML. */ function bp_groups_admin_create_pagination_links(BP_Group_Member_Query $query, $member_type) { $pagination = ''; if (!in_array($member_type, array('admin', 'mod', 'member', 'banned'))) { return $pagination; } // The key used to paginate this member type in the $_GET global $qs_key = $member_type . '_page'; $url_base = remove_query_arg(array($qs_key, 'updated', 'success_modified'), $_SERVER['REQUEST_URI']); $page = isset($_GET[$qs_key]) ? absint($_GET[$qs_key]) : 1; $per_page = 10; // @todo Make this customizable? // Don't show anything if there's no pagination if (1 === $page && $query->total_users <= $per_page) { return $pagination; } $current_page_start = ($page - 1) * $per_page + 1; $current_page_end = $page * $per_page > intval($query->total_users) ? $query->total_users : $page * $per_page; $pag_links = paginate_links(array('base' => add_query_arg($qs_key, '%#%', $url_base), 'format' => '', 'prev_text' => __('«', 'buddypress'), 'next_text' => __('»', 'buddypress'), 'total' => ceil($query->total_users / $per_page), 'current' => $page)); if (1 == $query->total_users) { $viewing_text = __('Viewing 1 member', 'buddypress'); } else { $viewing_text = sprintf(_n('Viewing %1$s - %2$s of %3$s member', 'Viewing %1$s - %2$s of %3$s members', $query->total_users, 'buddypress'), bp_core_number_format($current_page_start), bp_core_number_format($current_page_end), bp_core_number_format($query->total_users)); } $pagination .= '<span class="bp-group-admin-pagination-viewing">' . $viewing_text . '</span>'; $pagination .= '<span class="bp-group-admin-pagination-links">' . $pag_links . '</span>'; return $pagination; }
function bp_get_total_site_member_count() { return apply_filters('bp_get_total_site_member_count', bp_core_number_format(bp_core_get_total_member_count())); }
/** * Return the pagination count for the current topic page. * * The "count" is a string of the form "Viewing x of y posts". * * @return string */ function bp_the_topic_pagination_count() { global $bp, $topic_template; $start_num = intval(($topic_template->pag_page - 1) * $topic_template->pag_num) + 1; $from_num = bp_core_number_format($start_num); $to_num = bp_core_number_format($start_num + ($topic_template->pag_num - 1) > $topic_template->total_post_count ? $topic_template->total_post_count : $start_num + ($topic_template->pag_num - 1)); $total = bp_core_number_format($topic_template->total_post_count); echo apply_filters('bp_the_topic_pagination_count', sprintf(_n('Viewing post %1$s to %2$s (%3$s post)', 'Viewing post %1$s to %2$s (%3$s total posts)', $total, 'buddypress'), $from_num, $to_num, $total), $from_num, $to_num, $total); }
/** * Get pagination count text for group invitations. * * @since BuddyPress (2.0.0) * * @return string */ function bp_get_group_invite_pagination_count() { global $invites_template; $start_num = intval(($invites_template->pag_page - 1) * $invites_template->pag_num) + 1; $from_num = bp_core_number_format($start_num); $to_num = bp_core_number_format($start_num + ($invites_template->pag_num - 1) > $invites_template->total_invite_count ? $invites_template->total_invite_count : $start_num + ($invites_template->pag_num - 1)); $total = bp_core_number_format($invites_template->total_invite_count); return apply_filters('bp_get_groups_pagination_count', sprintf(_n('Viewing invitation %1$s to %2$s (of %3$s invitation)', 'Viewing invitation %1$s to %2$s (of %3$s invitations)', $total, 'buddypress'), $from_num, $to_num, $total), $from_num, $to_num, $total); }
/** * Get pagination count text for group invitations. * * @since 2.0.0 * * @return string */ function bp_get_group_invite_pagination_count() { global $invites_template; $start_num = intval(($invites_template->pag_page - 1) * $invites_template->pag_num) + 1; $from_num = bp_core_number_format($start_num); $to_num = bp_core_number_format($start_num + ($invites_template->pag_num - 1) > $invites_template->total_invite_count ? $invites_template->total_invite_count : $start_num + ($invites_template->pag_num - 1)); $total = bp_core_number_format($invites_template->total_invite_count); if (1 == $invites_template->total_invite_count) { $message = __('Viewing 1 invitation', 'buddypress'); } else { $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invitation', 'Viewing %1$s - %2$s of %3$s invitations', $invites_template->total_invite_count, 'buddypress'), $from_num, $to_num, $total); } /** This filter is documented in bp-groups/bp-groups-template.php */ return apply_filters('bp_get_groups_pagination_count', $message, $from_num, $to_num, $total); }
/** * Return the pagination count for the current notification loop. * * @since BuddyPress (1.9.0) * * @return string HTML for the pagination count. */ function bp_get_notifications_pagination_count() { $query_loop = buddypress()->notifications->query_loop; $start_num = intval(($query_loop->pag_page - 1) * $query_loop->pag_num) + 1; $from_num = bp_core_number_format($start_num); $to_num = bp_core_number_format($start_num + ($query_loop->pag_num - 1) > $query_loop->total_notification_count ? $query_loop->total_notification_count : $start_num + ($query_loop->pag_num - 1)); $total = bp_core_number_format($query_loop->total_notification_count); if (1 == $query_loop->total_notification_count) { $pag = __('Viewing 1 notification', 'buddypress'); } else { $pag = sprintf(_n('Viewing %1$s - %2$s of %3$s notification', 'Viewing %1$s - %2$s of %3$s notifications', $query_loop->total_notification_count, 'buddypress'), $from_num, $to_num, $total); } /** * Filters the pagination count for the current notification loop. * * @since BuddyPress (1.9.0) * * @param string $pag HTML for the pagination count. */ return apply_filters('bp_notifications_pagination_count', $pag); }
/** * Format notifications for the Messages component. * * @since BuddyPress (1.0.0) * * @param string $action The kind of notification being rendered. * @param int $item_id The primary item id. * @param int $secondary_item_id The secondary item id. * @param int $total_items The total number of messaging-related notifications * waiting for the user. * @param string $format Return value format. 'string' for BuddyBar-compatible * notifications; 'array' for WP Toolbar. Default: 'string'. * * @return string|array Formatted notifications. */ function messages_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string') { $total_items = (int) $total_items; $link = trailingslashit(bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox'); $title = __('Inbox', 'buddypress'); $amount = 'single'; if ('new_message' === $action) { if ($total_items > 1) { $amount = 'multiple'; $text = sprintf(__('You have %d new messages', 'buddypress'), $total_items); } else { $amount = 'single'; // get message thread ID $message = new BP_Messages_Message($item_id); $thread_id = $message->thread_id; $link = !empty($thread_id) ? bp_get_message_thread_view_link($thread_id) : false; if (!empty($secondary_item_id)) { $text = sprintf(__('%s sent you a new private message', 'buddypress'), bp_core_get_user_displayname($secondary_item_id)); } else { $text = sprintf(_n('You have %s new private message', 'You have %s new private messages', $total_items, 'buddypress'), bp_core_number_format($total_items)); } } } if ('string' === $format) { if (!empty($link)) { $retval = '<a href="' . esc_url($link) . '" title="' . esc_attr($title) . '">' . esc_html($text) . '</a>'; } else { $retval = esc_html($text); } /** * Filters the new message notification text before the notification is created. * * This is a dynamic filter. Possible filter names are: * - 'bp_messages_multiple_new_message_notification'. * - 'bp_messages_single_new_message_notification'. * * @param string $retval Notification text. * @param int $total_items Number of messages referred to by the notification. * @param string $text The raw notification test (ie, not wrapped in a link). * @param int $item_id ID of the associated item. * @param int $secondary_item_id ID of the secondary associated item. */ $return = apply_filters('bp_messages_' . $amount . '_new_message_notification', $retval, (int) $total_items, $text, $link, $item_id, $secondary_item_id); } else { /** This filter is documented in bp-messages/bp-messages-notifications.php */ $return = apply_filters('bp_messages_' . $amount . '_new_message_notification', array('text' => $text, 'link' => $link), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id); } /** * Fires right before returning the formatted message notifications. * * @since BuddyPress (1.0.0) * * @param string $action The type of message notification. * @param int $item_id The primary item ID. * @param int $secondary_item_id The secondary item ID. * @param int $total_items Total amount of items to format. */ do_action('messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items); return $return; }
/** * Set up the component entries in the WordPress Admin Bar. * * @since 1.9.0 * * @see BP_Component::setup_nav() for a description of the $wp_admin_nav * parameter array. * * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a * description. */ public function setup_admin_bar($wp_admin_nav = array()) { // Menus for logged in user. if (is_user_logged_in()) { // Setup the logged in user variables. $notifications_link = trailingslashit(bp_loggedin_user_domain() . bp_get_notifications_slug()); // Pending notification requests. $count = bp_notifications_get_unread_notification_count(bp_loggedin_user_id()); if (!empty($count)) { $title = sprintf(_x('Notifications <span class="count">%s</span>', 'My Account Notification pending', 'buddypress'), bp_core_number_format($count)); $unread = sprintf(_x('Unread <span class="count">%s</span>', 'My Account Notification pending', 'buddypress'), bp_core_number_format($count)); } else { $title = _x('Notifications', 'My Account Notification', 'buddypress'); $unread = _x('Unread', 'My Account Notification sub nav', 'buddypress'); } // Add the "My Account" sub menus. $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => $title, 'href' => $notifications_link); // Unread. $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-unread', 'title' => $unread, 'href' => $notifications_link, 'position' => 10); // Read. $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-read', 'title' => _x('Read', 'My Account Notification sub nav', 'buddypress'), 'href' => trailingslashit($notifications_link . 'read'), 'position' => 20); } parent::setup_admin_bar($wp_admin_nav); }
function bp_get_group_member_pagination_count() { global $members_template; $start_num = intval(($members_template->pag_page - 1) * $members_template->pag_num) + 1; $from_num = bp_core_number_format($start_num); $to_num = bp_core_number_format($start_num + ($members_template->pag_num - 1) > $members_template->total_member_count ? $members_template->total_member_count : $start_num + ($members_template->pag_num - 1)); $total = bp_core_number_format($members_template->total_member_count); return apply_filters('bp_get_group_member_pagination_count', sprintf(__('Viewing members %1$s to %2$s (of %3$s members)', 'buddypress'), $from_num, $to_num, $total)); }
/** * Generate the "Viewing message x to y (of z messages)" string for a loop. */ function bp_messages_pagination_count() { global $messages_template; $start_num = intval(($messages_template->pag_page - 1) * $messages_template->pag_num) + 1; $from_num = bp_core_number_format($start_num); $to_num = bp_core_number_format($start_num + ($messages_template->pag_num - 1) > $messages_template->total_thread_count ? $messages_template->total_thread_count : $start_num + ($messages_template->pag_num - 1)); $total = bp_core_number_format($messages_template->total_thread_count); if (1 == $messages_template->total_thread_count) { $message = __('Viewing 1 message', 'buddypress'); } else { $message = sprintf(_n('Viewing %1$s - %2$s of %3$s message', 'Viewing %1$s - %2$s of %3$s messages', $messages_template->total_thread_count, 'buddypress'), $from_num, $to_num, $total); } echo esc_html($message); }
/** * Set up the Toolbar. * * @param array $wp_admin_nav See {BP_Component::setup_admin_bar()} * for details. */ public function setup_admin_bar($wp_admin_nav = array()) { // Menus for logged in user if (is_user_logged_in()) { // Setup the logged in user variables $messages_link = trailingslashit(bp_loggedin_user_domain() . bp_get_messages_slug()); // Unread message count $count = messages_get_unread_count(); if (!empty($count)) { $title = sprintf(__('Messages <span class="count">%s</span>', 'buddypress'), bp_core_number_format($count)); $inbox = sprintf(__('Inbox <span class="count">%s</span>', 'buddypress'), bp_core_number_format($count)); } else { $title = __('Messages', 'buddypress'); $inbox = __('Inbox', 'buddypress'); } // Add main Messages menu $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => $title, 'href' => $messages_link); // Inbox $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-inbox', 'title' => $inbox, 'href' => $messages_link); // Starred if (bp_is_active($this->id, 'star')) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-starred', 'title' => __('Starred', 'buddypress'), 'href' => trailingslashit($messages_link . bp_get_messages_starred_slug())); } // Sent Messages $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-sentbox', 'title' => __('Sent', 'buddypress'), 'href' => trailingslashit($messages_link . 'sentbox')); // Compose Message $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-compose', 'title' => __('Compose', 'buddypress'), 'href' => trailingslashit($messages_link . 'compose')); // Site Wide Notices if (bp_current_user_can('bp_moderate')) { $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-notices', 'title' => __('All Member Notices', 'buddypress'), 'href' => trailingslashit($messages_link . 'notices')); } } parent::setup_admin_bar($wp_admin_nav); }