]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/dashboard.php
WordPress 4.5-scripts
[autoinstalls/wordpress.git] / wp-admin / includes / dashboard.php
index 75a5b1cb843374e15bfdc9ed9e52f7e3b009375a..5a234857d879df49090507201227ec89e62de77d 100644 (file)
  * Handles POST data, sets up filters.
  *
  * @since 2.5.0
+ *
+ * @global array $wp_registered_widgets
+ * @global array $wp_registered_widget_controls
+ * @global array $wp_dashboard_control_callbacks
  */
 function wp_dashboard_setup() {
        global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
@@ -43,7 +47,7 @@ function wp_dashboard_setup() {
        }
 
        // QuickPress Widget
-       if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) {
+       if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
                $quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Drafts' ) );
                wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' );
        }
@@ -125,6 +129,21 @@ function wp_dashboard_setup() {
        do_action( 'do_meta_boxes', $screen->id, 'side', '' );
 }
 
+/**
+ * Adds a new dashboard widget.
+ *
+ * @since 2.7.0
+ *
+ * @global array $wp_dashboard_control_callbacks
+ *
+ * @param string   $widget_id        Widget ID  (used in the 'id' attribute for the widget).
+ * @param string   $widget_name      Title of the widget.
+ * @param callable $callback         Function that fills the widget with the desired content.
+ *                                   The function should echo its output.
+ * @param callable $control_callback Optional. Function that outputs controls for the widget. Default null.
+ * @param array    $callback_args    Optional. Data that should be set as the $args property of the widget array
+ *                                   (which is the second parameter passed to your callback). Default null.
+ */
 function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) {
        $screen = get_current_screen();
        global $wp_dashboard_control_callbacks;
@@ -154,8 +173,17 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_
        add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args );
 }
 
+/**
+ * Outputs controls for the current dashboard widget.
+ *
+ * @access private
+ * @since 2.7.0
+ *
+ * @param mixed $dashboard
+ * @param array $meta_box
+ */
 function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
-       echo '<form action="" method="post" class="dashboard-widget-control-form">';
+       echo '<form method="post" class="dashboard-widget-control-form">';
        wp_dashboard_trigger_widget_control( $meta_box['id'] );
        wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' );
        echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
@@ -240,13 +268,18 @@ function wp_dashboard_right_now() {
                ?>
                <li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li>
                <?php
-               if ( $num_comm->moderated ) {
-                       /* translators: Number of comments in moderation */
-                       $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), number_format_i18n( $num_comm->moderated ) );
-                       ?>
-                       <li class="comment-mod-count"><a href="edit-comments.php?comment_status=moderated"><?php echo $text; ?></a></li>
-                       <?php
-               }
+               $moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated );
+               /* translators: Number of comments in moderation */
+               $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
+               /* translators: 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
        }
 
        /**
@@ -272,7 +305,7 @@ function wp_dashboard_right_now() {
        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' ) && '1' != get_option( 'blog_public' ) ) {
+       if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) {
 
                /**
                 * Filter the link title attribute for the 'Search Engines Discouraged'
@@ -281,10 +314,11 @@ function wp_dashboard_right_now() {
                 * Prior to 3.8.0, the widget was named 'Right Now'.
                 *
                 * @since 3.0.0
+                * @since 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', __( 'Your site is asking search engines not to index its content' ) );
+               $title = apply_filters( 'privacy_on_link_title', '' );
 
                /**
                 * Filter the link label for the 'Search Engines Discouraged' message
@@ -297,8 +331,9 @@ function wp_dashboard_right_now() {
                 * @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='$title'>$content</a></p>";
+               echo "<p><a href='options-reading.php'$title_attr>$content</a></p>";
        }
        ?>
        </div>
@@ -336,6 +371,9 @@ function wp_dashboard_right_now() {
        <?php endif;
 }
 
+/**
+ * @since 3.1.0
+ */
 function wp_network_dashboard_right_now() {
        $actions = array();
        if ( current_user_can('create_sites') )
@@ -379,15 +417,17 @@ function wp_network_dashboard_right_now() {
 
        <form action="<?php echo network_admin_url('users.php'); ?>" method="get">
                <p>
-                       <input type="search" name="s" value="" size="30" autocomplete="off" />
-                       <?php submit_button( __( 'Search Users' ), 'button', 'submit', false, array( 'id' => 'submit_users' ) ); ?>
+                       <label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label>
+                       <input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/>
+                       <?php submit_button( __( 'Search Users' ), 'button', false, false, array( 'id' => 'submit_users' ) ); ?>
                </p>
        </form>
 
        <form action="<?php echo network_admin_url('sites.php'); ?>" method="get">
                <p>
-                       <input type="search" name="s" value="" size="30" autocomplete="off" />
-                       <?php submit_button( __( 'Search Sites' ), 'button', 'submit', false, array( 'id' => 'submit_sites' ) ); ?>
+                       <label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label>
+                       <input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/>
+                       <?php submit_button( __( 'Search Sites' ), 'button', false, false, array( 'id' => 'submit_sites' ) ); ?>
                </p>
        </form>
 <?php
@@ -411,11 +451,17 @@ function wp_network_dashboard_right_now() {
  *
  * @since 3.8.0
  *
+ * @global int $post_ID
+ *
  * @param string $error_msg Optional. Error message. Default false.
  */
 function wp_dashboard_quick_press( $error_msg = false ) {
        global $post_ID;
 
+       if ( ! current_user_can( 'edit_posts' ) ) {
+               return;
+       }
+
        /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
        $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
        if ( $last_post_id ) {
@@ -477,6 +523,8 @@ function wp_dashboard_quick_press( $error_msg = false ) {
  * Show recent drafts of the user on the dashboard.
  *
  * @since 2.7.0
+ *
+ * @param array $drafts
  */
 function wp_dashboard_recent_drafts( $drafts = false ) {
        if ( ! $drafts ) {
@@ -488,6 +536,16 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
                        'orderby'        => 'modified',
                        'order'          => 'DESC'
                );
+
+               /**
+                * Filter the post query arguments for the 'Recent Drafts' dashboard widget.
+                *
+                * @since 4.4.0
+                *
+                * @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
+                */
+               $query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );
+
                $drafts = get_posts( $query_args );
                if ( ! $drafts ) {
                        return;
@@ -496,17 +554,18 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
 
        echo '<div class="drafts">';
        if ( count( $drafts ) > 3 ) {
-               echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . _x( 'View all', 'drafts' ) . "</a></p>\n";
+               echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '" aria-label="' . __( 'View all drafts' ) . '">' . _x( 'View all', 'drafts' ) . "</a></p>\n";
        }
-       echo '<h4 class="hide-if-no-js">' . __( 'Drafts' ) . "</h4>\n<ul>";
+       echo '<h2 class="hide-if-no-js">' . __( 'Drafts' ) . "</h2>\n<ul>";
 
        $drafts = array_slice( $drafts, 0, 3 );
        foreach ( $drafts as $draft ) {
                $url = get_edit_post_link( $draft->ID );
                $title = _draft_or_post_title( $draft->ID );
                echo "<li>\n";
-               echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
-               echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( get_option( 'date_format' ), $draft ) . '</time></div>';
+               /* translators: %s: post title */
+               echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
+               echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>';
                if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
                        echo '<p>' . $the_content . '</p>';
                }
@@ -515,20 +574,29 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
        echo "</ul>\n</div>";
 }
 
+/**
+ * Outputs a row for the Recent Comments widget.
+ *
+ * @access private
+ * @since 2.7.0
+ *
+ * @global WP_Comment $comment
+ *
+ * @param WP_Comment $comment   The current comment.
+ * @param bool       $show_date Optional. Whether to display the date.
+ */
 function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
-       $GLOBALS['comment'] =& $comment;
+       $GLOBALS['comment'] = clone $comment;
 
-       $comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
+       if ( $comment->comment_post_ID > 0 ) {
 
-       if ( current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
-               $comment_post_url = get_edit_post_link( $comment->comment_post_ID );
+               $comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
+               $comment_post_url = get_the_permalink( $comment->comment_post_ID );
                $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
        } else {
-               $comment_post_link = $comment_post_title;
+               $comment_post_link = '';
        }
 
-       $comment_link = '<a class="comment-link" href="' . esc_url(get_comment_link()) . '">#</a>';
-
        $actions_string = '';
        if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
                // Pre-order it: Approve | Reply | Edit | Spam | Trash.
@@ -537,7 +605,8 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
                        'reply' => '',
                        'edit' => '',
                        'spam' => '',
-                       'trash' => '', 'delete' => ''
+                       'trash' => '', 'delete' => '',
+                       'view' => '',
                );
 
                $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
@@ -549,15 +618,21 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
                $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
                $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
 
-               $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
-               $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
-               $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';
-               $actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
-               $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
-               if ( !EMPTY_TRASH_DAYS )
-                       $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
-               else
-                       $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
+               $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
+               $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
+               $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>". __( 'Edit' ) . '</a>';
+               $actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '" href="#">' . __( 'Reply' ) . '</a>';
+               $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
+
+               if ( ! EMPTY_TRASH_DAYS ) {
+                       $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
+               } else {
+                       $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
+               }
+
+               if ( '1' === $comment->comment_approved ) {
+                       $actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>';
+               }
 
                /**
                 * Filter the action links displayed for each comment in the 'Recent Comments'
@@ -565,10 +640,10 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
                 *
                 * @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.
+                * @param array      $actions An array of comment actions. Default actions include:
+                *                            'Approve', 'Unapprove', 'Edit', 'Reply', 'Spam',
+                *                            'Delete', and 'Trash'.
+                * @param WP_Comment $comment The comment object.
                 */
                $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
 
@@ -584,20 +659,36 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
                        $actions_string .= "<span class='$action'>$sep$link</span>";
                }
        }
-
 ?>
 
-               <div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status($comment->comment_ID) ) ); ?>>
+               <li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>>
 
                        <?php echo get_avatar( $comment, 50, 'mystery' ); ?>
 
                        <?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
 
-                       <div class="dashboard-comment-wrap">
-                       <h4 class="comment-meta">
-                               <?php printf( /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */__( 'From %1$s on %2$s%3$s' ),
-                                       '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link.' '.$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?>
-                       </h4>
+                       <div class="dashboard-comment-wrap has-row-actions">
+                       <p class="comment-meta">
+                       <?php
+                               // Comments might not have a post they relate to, e.g. programmatically created ones.
+                               if ( $comment_post_link ) {
+                                       printf(
+                                               /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
+                                               __( 'From %1$s on %2$s %3$s' ),
+                                               '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
+                                               $comment_post_link,
+                                               '<span class="approve">' . __( '[Pending]' ) . '</span>'
+                                       );
+                               } else {
+                                       printf(
+                                               /* translators: 1: comment author, 2: notification if the comment is pending */
+                                               __( 'From %1$s %2$s' ),
+                                               '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
+                                               '<span class="approve">' . __( '[Pending]' ) . '</span>'
+                                       );
+                               }
+                       ?>
+                       </p>
 
                        <?php
                        else :
@@ -613,17 +704,39 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
                                }
                                $type = esc_html( $type );
                        ?>
-                       <div class="dashboard-comment-wrap">
-                       <?php /* translators: %1$s is type of comment, %2$s is link to the post */ ?>
-                       <h4 class="comment-meta"><?php printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link." ".$comment_link ); ?></h4>
-                       <p class="comment-author"><?php comment_author_link(); ?></p>
+                       <div class="dashboard-comment-wrap has-row-actions">
+                       <p class="comment-meta">
+                       <?php
+                               // Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones.
+                               if ( $comment_post_link ) {
+                                       printf(
+                                               /* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */
+                                               _x( '%1$s on %2$s %3$s', 'dashboard' ),
+                                               "<strong>$type</strong>",
+                                               $comment_post_link,
+                                               '<span class="approve">' . __( '[Pending]' ) . '</span>'
+                                       );
+                               } else {
+                                       printf(
+                                               /* translators: 1: type of comment, 2: notification if the comment is pending */
+                                               _x( '%1$s %2$s', 'dashboard' ),
+                                               "<strong>$type</strong>",
+                                               '<span class="approve">' . __( '[Pending]' ) . '</span>'
+                                       );
+                               }
+                       ?>
+                       </p>
+                       <p class="comment-author"><?php comment_author_link( $comment ); ?></p>
 
                        <?php endif; // comment_type ?>
-                       <blockquote><p><?php comment_excerpt(); ?></p></blockquote>
+                       <blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote>
+                       <?php if ( $actions_string ) : ?>
                        <p class="row-actions"><?php echo $actions_string; ?></p>
+                       <?php endif; ?>
                        </div>
-               </div>
+               </li>
 <?php
+       $GLOBALS['comment'] = null;
 }
 
 /**
@@ -689,13 +802,22 @@ function wp_dashboard_recent_posts( $args ) {
                'cache_results'  => false,
                'perm'           => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
        );
+
+       /**
+        * Filter the query arguments used for the Recent Posts widget.
+        *
+        * @since 4.2.0
+        *
+        * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
+        */
+       $query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
        $posts = new WP_Query( $query_args );
 
        if ( $posts->have_posts() ) {
 
                echo '<div id="' . $args['id'] . '" class="activity-block">';
 
-               echo '<h4>' . $args['title'] . '</h4>';
+               echo '<h3>' . $args['title'] . '</h3>';
 
                echo '<ul>';
 
@@ -710,20 +832,27 @@ function wp_dashboard_recent_posts( $args ) {
                                $relative = __( 'Today' );
                        } elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
                                $relative = __( 'Tomorrow' );
+                       } elseif ( date( 'Y', $time ) !== date( 'Y', current_time( 'timestamp' ) ) ) {
+                               /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see http://php.net/date */
+                               $relative = date_i18n( __( 'M jS Y' ), $time );
                        } else {
                                /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
                                $relative = date_i18n( __( 'M jS' ), $time );
                        }
 
-                       if ( current_user_can( 'edit_post', get_the_ID() ) ) {
-                               /* translators: 1: relative date, 2: time, 3: post edit link, 4: post title */
-                               $format = __( '<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>' );
-                               printf( "<li>$format</li>", $relative, get_the_time(), get_edit_post_link(), _draft_or_post_title() );
-                       } else {
-                               /* translators: 1: relative date, 2: time, 3: post title */
-                               $format = __( '<span>%1$s, %2$s</span> %3$s' );
-                               printf( "<li>$format</li>", $relative, get_the_time(), _draft_or_post_title() );
-                       }
+                       // Use the post edit link for those who can edit, the permalink otherwise.
+                       $recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink();
+
+                       $draft_or_post_title = _draft_or_post_title();
+                       printf(
+                               '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
+                               /* translators: 1: relative date, 2: time */
+                               sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ),
+                               $recent_post_link,
+                               /* translators: %s: post title */
+                               esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $draft_or_post_title ) ),
+                               $draft_or_post_title
+                       );
                }
 
                echo '</ul>';
@@ -758,6 +887,9 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
                $comments_query['status'] = 'approve';
 
        while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
+               if ( ! is_array( $possible ) ) {
+                       break;
+               }
                foreach ( $possible as $comment ) {
                        if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) )
                                continue;
@@ -771,15 +903,17 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
 
        if ( $comments ) {
                echo '<div id="latest-comments" class="activity-block">';
-               echo '<h4>' . __( 'Comments' ) . '</h4>';
+               echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
 
-               echo '<div id="the-comment-list" data-wp-lists="list:comment">';
+               echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
                foreach ( $comments as $comment )
                        _wp_dashboard_recent_comments_row( $comment );
-               echo '</div>';
+               echo '</ul>';
 
-               if ( current_user_can('edit_posts') )
-                       _get_list_table('WP_Comments_List_Table')->views();
+               if ( current_user_can( 'edit_posts' ) ) {
+                       echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>';
+                       _get_list_table( 'WP_Comments_List_Table' )->views();
+               }
 
                wp_comment_reply( -1, false, 'dashboard', false );
                wp_comment_trashnotice();
@@ -816,7 +950,7 @@ function wp_dashboard_rss_output( $widget_id ) {
  * @since 2.5.0
  *
  * @param string $widget_id
- * @param callback $callback
+ * @param callable $callback
  * @param array $check_urls RSS feeds
  * @return bool False on failure. True on success.
  */
@@ -833,7 +967,8 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
                $check_urls = array( $widgets[$widget_id]['url'] );
        }
 
-       $cache_key = 'dash_' . md5( $widget_id );
+       $locale = get_locale();
+       $cache_key = 'dash_' . md5( $widget_id . '_' . $locale );
        if ( false !== ( $output = get_transient( $cache_key ) ) ) {
                echo $output;
                return true;
@@ -855,14 +990,17 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
        return true;
 }
 
-/* Dashboard Widgets Controls */
+//
+// Dashboard Widgets Controls
+//
 
-// Calls widget_control callback
 /**
  * Calls widget control callback.
  *
  * @since 2.5.0
  *
+ * @global array $wp_dashboard_control_callbacks
+ *
  * @param int $widget_control_id Registered Widget ID.
  */
 function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
@@ -934,7 +1072,7 @@ function wp_dashboard_primary() {
                         *
                         * @param string $link The widget's primary link URL.
                         */
-                       'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ),
+                       'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ),
 
                        /**
                         * Filter the primary feed URL for the 'WordPress News' dashboard widget.
@@ -986,7 +1124,15 @@ function wp_dashboard_primary() {
                         * @param string $title Title attribute for the widget's secondary link.
                         */
                        'title'        => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
-                       'items'        => 3,
+
+                       /**
+                        * Filter the number of secondary link items for the 'WordPress News' dashboard widget.
+                        *
+                        * @since 4.4.0
+                        *
+                        * @param string $items How many items to show in the secondary feed.
+                        */
+                       'items'        => apply_filters( 'dashboard_secondary_items', 3 ),
                        'show_summary' => 0,
                        'show_author'  => 0,
                        'show_date'    => 0,
@@ -1019,7 +1165,7 @@ function wp_dashboard_primary() {
  * @param array  $feeds     Array of RSS feeds.
  */
 function wp_dashboard_primary_output( $widget_id, $feeds ) {
-       foreach( $feeds as $type => $args ) {
+       foreach ( $feeds as $type => $args ) {
                $args['type'] = $type;
                echo '<div class="rss-widget">';
                if ( $type === 'plugins' ) {
@@ -1035,6 +1181,9 @@ function wp_dashboard_primary_output( $widget_id, $feeds ) {
  * Display plugins text for the WordPress news widget.
  *
  * @since 2.5.0
+ *
+ * @param string $rss  The RSS feed URL.
+ * @param array  $args Array of arguments for this RSS feed.
  */
 function wp_dashboard_plugins_output( $rss, $args = array() ) {
        // Plugin feeds plus link to install them
@@ -1092,10 +1241,13 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) {
                if ( !isset($items[$item_key]) )
                        continue;
 
-               $title = esc_html( $item->get_title() );
+               $raw_title = $item->get_title();
 
                $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&amp;TB_iframe=true&amp;width=600&amp;height=800';
-               echo "<li class='dashboard-news-plugin'><span>" . __( 'Popular Plugin' ) . ":</span> <a href='$link' class='dashboard-news-plugin-link'>$title</a>&nbsp;<span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span></li>";
+               echo '<li class="dashboard-news-plugin"><span>' . __( 'Popular Plugin' ) . ':</span> ' . esc_html( $raw_title ) .
+                       '&nbsp;<a href="' . $ilink . '" class="thickbox open-plugin-details-modal" aria-label="' .
+                       /* translators: %s: plugin name */
+                       esc_attr( sprintf( __( 'Install %s' ), $raw_title ) ) . '">(' . __( 'Install' ) . ')</a></li>';
 
                $feed->__destruct();
                unset( $feed );
@@ -1112,7 +1264,7 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) {
  * @since 3.0.0
  *
  * @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' ) )
                return true;
@@ -1129,7 +1281,7 @@ function wp_dashboard_quota() {
        $percentused = number_format( $percentused );
 
        ?>
-       <h4 class="mu-storage"><?php _e( 'Storage Space' ); ?></h4>
+       <h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
        <div class="mu-storage">
        <ul>
                <li class="storage-count">
@@ -1139,10 +1291,10 @@ function wp_dashboard_quota() {
                                number_format_i18n( $quota )
                        );
                        printf(
-                               '<a href="%1$s" title="%2$s">%3$s</a>',
+                               '<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
                                esc_url( admin_url( 'upload.php' ) ),
-                               __( 'Manage Uploads' ),
-                               $text
+                               $text,
+                               __( 'Manage Uploads' )
                        ); ?>
                </li><li class="storage-count <?php echo $used_class; ?>">
                        <?php $text = sprintf(
@@ -1152,17 +1304,16 @@ function wp_dashboard_quota() {
                                $percentused
                        );
                        printf(
-                               '<a href="%1$s" title="%2$s" class="musublink">%3$s</a>',
+                               '<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
                                esc_url( admin_url( 'upload.php' ) ),
-                               __( 'Manage Uploads' ),
-                               $text
+                               $text,
+                               __( 'Manage Uploads' )
                        ); ?>
                </li>
        </ul>
        </div>
        <?php
 }
-add_action( 'activity_box_end', 'wp_dashboard_quota' );
 
 // Display Browser Nag Meta Box
 function wp_dashboard_browser_nag() {
@@ -1171,9 +1322,15 @@ function wp_dashboard_browser_nag() {
 
        if ( $response ) {
                if ( $response['insecure'] ) {
-                       $msg = sprintf( __( "It looks like you're using an insecure version of <a href='%s'>%s</a>. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );
+                       /* translators: %s: browser name and link */
+                       $msg = sprintf( __( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ),
+                               sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
+                       );
                } else {
-                       $msg = sprintf( __( "It looks like you're using an old version of <a href='%s'>%s</a>. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );
+                       /* translators: %s: browser name and link */
+                       $msg = sprintf( __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),
+                               sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
+                       );
                }
 
                $browser_nag_class = '';
@@ -1191,7 +1348,7 @@ function wp_dashboard_browser_nag() {
                        $browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
 
                $notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>';
-               $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss">' . __( 'Dismiss' ) . '</a></p>';
+               $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';
                $notice .= '<div class="clear"></div>';
        }
 
@@ -1206,6 +1363,12 @@ function wp_dashboard_browser_nag() {
        echo apply_filters( 'browse-happy-notice', $notice, $response );
 }
 
+/**
+ * @since 3.2.0
+ *
+ * @param array $classes
+ * @return array
+ */
 function dashboard_browser_nag_class( $classes ) {
        $response = wp_check_browser_version();
 
@@ -1220,6 +1383,8 @@ function dashboard_browser_nag_class( $classes ) {
  *
  * @since 3.2.0
  *
+ * @global string $wp_version
+ *
  * @return array|bool False on failure, array of browser data on success.
  */
 function wp_check_browser_version() {
@@ -1244,8 +1409,8 @@ function wp_check_browser_version() {
                /**
                 * Response should be an array with:
                 *  'name' - string - A user friendly browser name
-                *  'version' - string - The most recent version of the browser
-                *  'current_version' - string - The version of the browser the user is using
+                *  'version' - string - The version of the browser the user is using
+                *  'current_version' - string - The most recent version of the browser
                 *  'upgrade' - boolean - Whether the browser needs an upgrade
                 *  'insecure' - boolean - Whether the browser is deemed insecure
                 *  'upgrade_url' - string - The url to visit to upgrade
@@ -1276,12 +1441,12 @@ function wp_dashboard_empty() {}
 function wp_welcome_panel() {
        ?>
        <div class="welcome-panel-content">
-       <h3><?php _e( 'Welcome to WordPress!' ); ?></h3>
+       <h2><?php _e( 'Welcome to WordPress!' ); ?></h2>
        <p class="about-description"><?php _e( 'We&#8217;ve assembled some links to get you started:' ); ?></p>
        <div class="welcome-panel-column-container">
        <div class="welcome-panel-column">
                <?php if ( current_user_can( 'customize' ) ): ?>
-                       <h4><?php _e( 'Get Started' ); ?></h4>
+                       <h3><?php _e( 'Get Started' ); ?></h3>
                        <a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a>
                <?php endif; ?>
                <a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a>
@@ -1290,7 +1455,7 @@ function wp_welcome_panel() {
                <?php endif; ?>
        </div>
        <div class="welcome-panel-column">
-               <h4><?php _e( 'Next Steps' ); ?></h4>
+               <h3><?php _e( 'Next Steps' ); ?></h3>
                <ul>
                <?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
                        <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
@@ -1307,7 +1472,7 @@ function wp_welcome_panel() {
                </ul>
        </div>
        <div class="welcome-panel-column welcome-panel-last">
-               <h4><?php _e( 'More Actions' ); ?></h4>
+               <h3><?php _e( 'More Actions' ); ?></h3>
                <ul>
                <?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?>
                        <li><div class="welcome-icon welcome-widgets-menus"><?php
@@ -1324,7 +1489,7 @@ function wp_welcome_panel() {
                <?php if ( current_user_can( 'manage_options' ) ) : ?>
                        <li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
                <?php endif; ?>
-                       <li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'http://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
+                       <li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li>
                </ul>
        </div>
        </div>