wp_dashboard_right_now()
Dashboard widget that displays some basic stats about the site.
Description
Formerly ‘Right Now’. A streamlined ‘At a Glance’ as of 3.8.
Source
File: wp-admin/includes/dashboard.php
function wp_dashboard_right_now() {
?>
<div class="main">
<ul>
<?php
// Posts and Pages
foreach ( array( 'post', 'page' ) as $post_type ) {
$num_posts = wp_count_posts( $post_type );
if ( $num_posts && $num_posts->publish ) {
if ( 'post' == $post_type ) {
$text = _n( '%s Post', '%s Posts', $num_posts->publish );
} else {
$text = _n( '%s Page', '%s Pages', $num_posts->publish );
}
$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
$post_type_object = get_post_type_object( $post_type );
if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
} else {
printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text );
}
}
}
// Comments
$num_comm = wp_count_comments();
if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) {
$text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
?>
<li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
<?php
$moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
/* translators: %s: number of comments in moderation */
$text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
/* translators: %s: number of comments in moderation */
$aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
?>
<li class="comment-mod-count<?php
if ( ! $num_comm->moderated ) {
echo ' hidden';
}
?>"><a href="edit-comments.php?comment_status=moderated" aria-label="<?php esc_attr_e( $aria_label ); ?>"><?php echo $text; ?></a></li>
<?php
}
/**
* Filters the array of extra elements to list in the 'At a Glance'
* dashboard widget.
*
* Prior to WP-3.8.0, the widget was named 'Right Now'. Each element
* is wrapped in list-item tags on output.
*
* @since WP-3.8.0
*
* @param array $items Array of extra 'At a Glance' widget items.
*/
$elements = apply_filters( 'dashboard_glance_items', array() );
if ( $elements ) {
echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n";
}
?>
</ul>
<?php
update_right_now_message();
// Check if search engines are asked not to index this site.
if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) {
/**
* Filters the link title attribute for the 'Search Engines Discouraged'
* message displayed in the 'At a Glance' dashboard widget.
*
* Prior to WP-3.8.0, the widget was named 'Right Now'.
*
* @since WP-3.0.0
* @since WP-4.5.0 The default for `$title` was updated to an empty string.
*
* @param string $title Default attribute text.
*/
$title = apply_filters( 'privacy_on_link_title', '' );
/**
* Filters the link label for the 'Search Engines Discouraged' message
* displayed in the 'At a Glance' dashboard widget.
*
* Prior to WP-3.8.0, the widget was named 'Right Now'.
*
* @since WP-3.0.0
*
* @param string $content Default text.
*/
$content = apply_filters( 'privacy_on_link_text' , __( 'Search Engines Discouraged' ) );
$title_attr = '' === $title ? '' : " title='$title'";
echo "<p><a href='options-reading.php'$title_attr>$content</a></p>";
}
?>
</div>
<?php
/*
* activity_box_end has a core action, but only prints content when multisite.
* Using an output buffer is the only way to really check if anything's displayed here.
*/
ob_start();
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to WP-3.8.0, the widget was named 'Right Now'.
*
* @since WP-2.5.0
*/
do_action( 'rightnow_end' );
/**
* Fires at the end of the 'At a Glance' dashboard widget.
*
* Prior to WP-3.8.0, the widget was named 'Right Now'.
*
* @since WP-2.0.0
*/
do_action( 'activity_box_end' );
$actions = ob_get_clean();
if ( !empty( $actions ) ) : ?>
<div class="sub">
<?php echo $actions; ?>
</div>
<?php endif;
}
Changelog
Version | Description |
---|---|
WP-2.7.0 | Introduced. |