+
id, 'column3', '' ); ?>
-
+
id, 'column4', '' ); ?>
@@ -165,7 +198,9 @@ function wp_dashboard() {
}
-/* Dashboard Widgets */
+//
+// Dashboard Widgets
+//
/**
* Dashboard widget that displays some basic stats about the site.
@@ -175,11 +210,6 @@ function wp_dashboard() {
* @since 2.7.0
*/
function wp_dashboard_right_now() {
- $theme = wp_get_theme();
- if ( current_user_can( 'switch_themes' ) )
- $theme_name = sprintf( '
%1$s', $theme->display('Name') );
- else
- $theme_name = $theme->display('Name');
?>
@@ -205,8 +235,8 @@ function wp_dashboard_right_now() {
}
// Comments
$num_comm = wp_count_comments();
- if ( $num_comm && $num_comm->total_comments ) {
- $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->total_comments ), number_format_i18n( $num_comm->total_comments ) );
+ if ( $num_comm && $num_comm->approved ) {
+ $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) );
?>
' . implode( "\n- ", $elements ) . "
\n";
}
?>
-
@@ -303,7 +363,19 @@ function wp_network_dashboard_right_now() {
-
+
+
+
-
+
-
+
@@ -429,14 +518,20 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
$GLOBALS['comment'] =& $comment;
- $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
- $comment_post_title = strip_tags(get_the_title( $comment->comment_post_ID ));
- $comment_post_link = "$comment_post_title";
+ $comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
+
+ if ( current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
+ $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
+ $comment_post_link = "$comment_post_title";
+ } else {
+ $comment_post_link = $comment_post_title;
+ }
+
$comment_link = '';
$actions_string = '';
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
- // preorder it: Approve | Reply | Edit | Spam | Trash
+ // Pre-order it: Approve | Reply | Edit | Spam | Trash.
$actions = array(
'approve' => '', 'unapprove' => '',
'reply' => '',
@@ -457,13 +552,24 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
$actions['approve'] = "" . __( 'Approve' ) . '';
$actions['unapprove'] = "" . __( 'Unapprove' ) . '';
$actions['edit'] = "". __('Edit') . '';
- $actions['reply'] = '' . __('Reply') . '';
+ $actions['reply'] = '' . __('Reply') . '';
$actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '';
if ( !EMPTY_TRASH_DAYS )
$actions['delete'] = "" . __('Delete Permanently') . '';
else
$actions['trash'] = "" . _x('Trash', 'verb') . '';
+ /**
+ * Filter the action links displayed for each comment in the 'Recent Comments'
+ * dashboard widget.
+ *
+ * @since 2.6.0
+ *
+ * @param array $actions An array of comment actions. Default actions include:
+ * 'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
+ * 'Delete', and 'Trash'.
+ * @param object $comment The comment object.
+ */
$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
$i = 0;
@@ -482,10 +588,11 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
?>
comment_type ) : - case 'pingback' : - $type = __( 'Pingback' ); - break; - case 'trackback' : - $type = __( 'Trackback' ); - break; - default : - $type = ucwords( $comment->comment_type ); - endswitch; + switch ( $comment->comment_type ) { + case 'pingback' : + $type = __( 'Pingback' ); + break; + case 'trackback' : + $type = __( 'Trackback' ); + break; + default : + $type = ucwords( $comment->comment_type ); + } $type = esc_html( $type ); ?>
@@ -529,7 +636,6 @@ function wp_dashboard_site_activity() {
echo '';
$future_posts = wp_dashboard_recent_posts( array(
- 'display' => 2,
'max' => 5,
'status' => 'future',
'order' => 'ASC',
@@ -537,7 +643,6 @@ function wp_dashboard_site_activity() {
'id' => 'future-posts',
) );
$recent_posts = wp_dashboard_recent_posts( array(
- 'display' => 2,
'max' => 5,
'status' => 'publish',
'order' => 'DESC',
@@ -565,8 +670,7 @@ function wp_dashboard_site_activity() {
* @param array $args {
* An array of query and display arguments.
*
- * @type int $display Number of posts to display.
- * @type int $max Maximum number of posts to query.
+ * @type int $max Number of posts to display.
* @type string $status Post status.
* @type string $order Designates ascending ('ASC') or descending ('DESC') order.
* @type string $title Section title.
@@ -582,7 +686,8 @@ function wp_dashboard_recent_posts( $args ) {
'order' => $args['order'],
'posts_per_page' => intval( $args['max'] ),
'no_found_rows' => true,
- 'cache_results' => false
+ 'cache_results' => false,
+ 'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
);
$posts = new WP_Query( $query_args );
@@ -590,15 +695,10 @@ function wp_dashboard_recent_posts( $args ) {
echo '';
- if ( $posts->post_count > $args['display'] ) {
- echo '' . sprintf( __( 'See %s more…'), $posts->post_count - intval( $args['display'] ) ) . '';
- }
-
echo '';
echo '
-
-
+
+
+
+
true ) ) ) > 1 ) ) : ?>
', admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); ?>
+
+ widgets or menus' ),
+ admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) );
+ } elseif ( current_theme_supports( 'widgets' ) ) {
+ echo '' . __( 'Manage widgets' ) . '';
+ } else {
+ echo '' . __( 'Manage menus' ) . '';
+ }
+ ?>
+
+
' . __( 'Turn comments on or off' ) . '', admin_url( 'options-discussion.php' ) ); ?>
+
' . __( 'Learn more about getting started' ) . '', __( 'http://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?>
' . $args['title'] . '
'; echo ''; - $i = 0; $today = date( 'Y-m-d', current_time( 'timestamp' ) ); $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) ); @@ -615,18 +715,15 @@ function wp_dashboard_recent_posts( $args ) { $relative = date_i18n( __( 'M jS' ), $time ); } - $text = sprintf( - /* translators: 1: relative date, 2: time, 4: post title */ - __( '%1$s, %2$s %4$s' ), - $relative, - get_the_time(), - get_edit_post_link(), - _draft_or_post_title() - ); - - $hidden = $i >= $args['display'] ? ' class="hidden"' : ''; - echo "- $text
";
- $i++;
+ if ( current_user_can( 'edit_post', get_the_ID() ) ) {
+ /* translators: 1: relative date, 2: time, 3: post edit link, 4: post title */
+ $format = __( '%1$s, %2$s %4$s' );
+ printf( "- $format
", $relative, get_the_time(), get_edit_post_link(), _draft_or_post_title() );
+ } else {
+ /* translators: 1: relative date, 2: time, 3: post title */
+ $format = __( '%1$s, %2$s %3$s' );
+ printf( "- $format
", $relative, get_the_time(), _draft_or_post_title() );
+ }
}
echo '
'; @@ -650,11 +747,8 @@ function wp_dashboard_recent_posts( $args ) { * @return bool False if no comments were found. True otherwise. */ function wp_dashboard_recent_comments( $total_items = 5 ) { - global $wpdb; - // Select all comment types and filter out spam later for better query performance. $comments = array(); - $start = 0; $comments_query = array( 'number' => $total_items * 5, @@ -675,8 +769,6 @@ function wp_dashboard_recent_comments( $total_items = 5 ) { $comments_query['number'] = $total_items * 10; } - - if ( $comments ) { echo '' . __( 'Comments' ) . '
'; @@ -753,8 +845,8 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar } if ( $callback && is_callable( $callback ) ) { - $args = array_slice( func_get_args(), 2 ); - array_unshift( $args, $widget_id ); + $args = array_slice( func_get_args(), 3 ); + array_unshift( $args, $widget_id, $check_urls ); ob_start(); call_user_func_array( $callback, $args ); set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds) @@ -806,7 +898,8 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { $_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] ); $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); $widget_options[$widget_id]['number'] = $number; - // title is optional. If black, fill it if possible + + // Title is optional. If black, fill it if possible. if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { $rss = fetch_feed($widget_options[$widget_id]['url']); if ( is_wp_error($rss) ) { @@ -832,9 +925,33 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { */ function wp_dashboard_primary() { $feeds = array( - 'news' => array( - 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ), - 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ), + 'news' => array( + + /** + * Filter the primary link URL for the 'WordPress News' dashboard widget. + * + * @since 2.5.0 + * + * @param string $link The widget's primary link URL. + */ + 'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ), + + /** + * Filter the primary feed URL for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $url The widget's primary feed URL. + */ + 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ), + + /** + * Filter the primary link title for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $title Title attribute for the widget's primary link. + */ 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ), 'items' => 1, 'show_summary' => 1, @@ -842,8 +959,32 @@ function wp_dashboard_primary() { 'show_date' => 1, ), 'planet' => array( - 'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ), - 'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ), + + /** + * Filter the secondary link URL for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $link The widget's secondary link URL. + */ + 'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ), + + /** + * Filter the secondary feed URL for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $url The widget's secondary feed URL. + */ + 'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ), + + /** + * Filter the secondary link title for the 'WordPress News' dashboard widget. + * + * @since 2.3.0 + * + * @param string $title Title attribute for the widget's secondary link. + */ 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), 'items' => 3, 'show_summary' => 0, @@ -906,13 +1047,11 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) { echo ''; - foreach ( array( - 'popular' => __( 'Popular Plugin' ) - ) as $feed => $label ) { - if ( is_wp_error($$feed) || !$$feed->get_item_quantity() ) + foreach ( array( $popular ) as $feed ) { + if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() ) continue; - $items = $$feed->get_items(0, 5); + $items = $feed->get_items(0, 5); // Pick a random, non-installed plugin while ( true ) { @@ -955,14 +1094,11 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) { $title = esc_html( $item->get_title() ); - $description = esc_html( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) ); - $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&TB_iframe=true&width=600&height=800'; + echo "- " . __( 'Popular Plugin' ) . ": $title (" . __( 'Install' ) . ")
";
- echo "- $label: $title (" . __( 'Install' ) . ")
";
-
- $$feed->__destruct();
- unset( $$feed );
+ $feed->__destruct();
+ unset( $feed );
}
echo '
'; @@ -975,7 +1111,7 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) { * * @since 3.0.0 * - * @return bool True if not multisite, user can't upload files, or the space check option is disabled. + * @return bool|null True if not multisite, user can't upload files, or the space check option is disabled. */ function wp_dashboard_quota() { if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) @@ -1059,6 +1195,14 @@ function wp_dashboard_browser_nag() { $notice .= ''; } + /** + * Filter the notice output for the 'Browse Happy' nag meta box. + * + * @since 3.2.0 + * + * @param string $notice The notice content. + * @param array $response An array containing web browser information. + */ echo apply_filters( 'browse-happy-notice', $notice, $response ); } @@ -1136,8 +1280,10 @@ function wp_welcome_panel() {change your theme completely' ), admin_url( 'themes.php' ) ); ?>
@@ -1163,8 +1309,21 @@ function wp_welcome_panel() {-- ' . __( 'Manage widgets or menus' ) . '