本文整理汇总了PHP中bp_core_number_format函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_number_format函数的具体用法?PHP bp_core_number_format怎么用?PHP bp_core_number_format使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_core_number_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_notifications_buddybar_menu
/**
* 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>';
}
示例2: bcg_posts_pagination_count
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
}
示例3: bp_the_topic_pagination_count
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
}
示例4: bp_the_topic_pagination_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 );
/**
* 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 );
}
示例5: setup_admin_bar
/**
* 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);
}
示例6: setup_admin_bar
/**
* 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);
}
示例7: bp_get_total_site_member_count
/**
* 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()));
}
示例8: bp_blogs_pagination_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;
}
示例9: bp_messages_pagination_count
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);
}
示例10: bp_get_activity_pagination_count
/**
* 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);
}
示例11: widget
/**
* 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;
}
示例12: messages_format_notifications
/**
* 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.
*
//.........这里部分代码省略.........
示例13: bp_blogs_pagination_count
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
}
示例14: setup_nav
/**
* 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);
}
示例15: setup_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);
}