X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/03f2fa83c13c1b532284205fa7efcab9b8b2c41f..d3947bc013df7edd54b46deed8230d2eeafc5ecb:/wp-admin/includes/dashboard.php diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 144fcc04..5a234857 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -130,14 +130,19 @@ function wp_dashboard_setup() { } /** + * Adds a new dashboard widget. * - * @global array $wp_dashboard_control_callbacks + * @since 2.7.0 * - * @param string $widget_id - * @param string $widget_name - * @param callable $callback - * @param callable $control_callback - * @param array $callback_args + * @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(); @@ -169,9 +174,13 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_ } /** + * Outputs controls for the current dashboard widget. + * + * @access private + * @since 2.7.0 * - * @param type $dashboard - * @param type $meta_box + * @param mixed $dashboard + * @param array $meta_box */ function _wp_dashboard_control_callback( $dashboard, $meta_box ) { echo '
'; @@ -259,14 +268,17 @@ function wp_dashboard_right_now() { ?>
  • 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 */ - $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), number_format_i18n( $num_comm->moderated ) ); + $aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n ); ?>
  • + ?>"> $content

    "; + echo "

    $content

    "; } ?> @@ -549,8 +563,9 @@ function wp_dashboard_recent_drafts( $drafts = false ) { $url = get_edit_post_link( $draft->ID ); $title = _draft_or_post_title( $draft->ID ); echo "
  • \n"; - echo '
    ' . esc_html( $title ) . ''; - echo '
    '; + /* translators: %s: post title */ + echo '
    ' . esc_html( $title ) . ''; + echo '
    '; if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) { echo '

    ' . $the_content . '

    '; } @@ -560,17 +575,23 @@ function wp_dashboard_recent_drafts( $drafts = false ) { } /** + * Outputs a row for the Recent Comments widget. + * + * @access private + * @since 2.7.0 + * * @global WP_Comment $comment * - * @param WP_Comment $comment - * @param bool $show_date + * @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'] = clone $comment; - if ( $comment->comment_post_ID > 0 && current_user_can( 'edit_post', $comment->comment_post_ID ) ) { + if ( $comment->comment_post_ID > 0 ) { + $comment_post_title = _draft_or_post_title( $comment->comment_post_ID ); - $comment_post_url = get_edit_post_link( $comment->comment_post_ID ); + $comment_post_url = get_the_permalink( $comment->comment_post_ID ); $comment_post_link = "$comment_post_title"; } else { $comment_post_link = ''; @@ -597,20 +618,20 @@ 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'] = "" . __( 'Approve' ) . ''; - $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; - $actions['edit'] = "". __('Edit') . ''; - $actions['reply'] = '' . __('Reply') . ''; - $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; + $actions['approve'] = "" . __( 'Approve' ) . ''; + $actions['unapprove'] = "" . __( 'Unapprove' ) . ''; + $actions['edit'] = "". __( 'Edit' ) . ''; + $actions['reply'] = '' . __( 'Reply' ) . ''; + $actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . ''; if ( ! EMPTY_TRASH_DAYS ) { - $actions['delete'] = "" . __('Delete Permanently') . ''; + $actions['delete'] = "" . __( 'Delete Permanently' ) . ''; } else { - $actions['trash'] = "" . _x('Trash', 'verb') . ''; + $actions['trash'] = "" . _x( 'Trash', 'verb' ) . ''; } if ( '1' === $comment->comment_approved ) { - $actions['view'] = '' . _x( 'View', 'verb' ) . ''; + $actions['view'] = '' . __( 'View' ) . ''; } /** @@ -638,10 +659,9 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { $actions_string .= "$sep$link"; } } - ?> -
    > +
  • > @@ -649,24 +669,25 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {

    - ' . get_comment_author_link( $comment ) . '', $comment_post_link, - ' ' . __( '[Pending]' ) . '' + '' . __( '[Pending]' ) . '' ); } else { printf( /* translators: 1: comment author, 2: notification if the comment is pending */ __( 'From %1$s %2$s' ), '' . get_comment_author_link( $comment ) . '', - ' ' . __( '[Pending]' ) . '' + '' . __( '[Pending]' ) . '' ); } - ?> + ?>

    - -

    $type", $comment_post_link ); ?>

    +

    + $type", + $comment_post_link, + '' . __( '[Pending]' ) . '' + ); + } else { + printf( + /* translators: 1: type of comment, 2: notification if the comment is pending */ + _x( '%1$s %2$s', 'dashboard' ), + "$type", + '' . __( '[Pending]' ) . '' + ); + } + ?> +

    +

    +
    -
    +
  • %1$s, %2$s %4$s' ); - printf( "
  • $format
  • ", $relative, get_the_time(), $recent_post_link, _draft_or_post_title() ); + $draft_or_post_title = _draft_or_post_title(); + printf( + '
  • %1$s %4$s
  • ', + /* 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 “%s”' ), $draft_or_post_title ) ), + $draft_or_post_title + ); } echo ''; @@ -854,15 +903,17 @@ function wp_dashboard_recent_comments( $total_items = 5 ) { if ( $comments ) { echo '
    '; - echo '

    ' . __( 'Comments' ) . '

    '; + echo '

    ' . __( 'Recent Comments' ) . '

    '; - echo '
    '; + echo '
      '; foreach ( $comments as $comment ) _wp_dashboard_recent_comments_row( $comment ); - echo '
    '; + echo ''; - if ( current_user_can('edit_posts') ) - _get_list_table('WP_Comments_List_Table')->views(); + if ( current_user_can( 'edit_posts' ) ) { + echo '

    ' . __( 'View more comments' ) . '

    '; + _get_list_table( 'WP_Comments_List_Table' )->views(); + } wp_comment_reply( -1, false, 'dashboard', false ); wp_comment_trashnotice(); @@ -1130,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 @@ -1187,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) . '&TB_iframe=true&width=600&height=800'; - echo "
  • " . __( 'Popular Plugin' ) . ": $title (" . __( 'Install' ) . ")
  • "; + echo '
  • ' . __( 'Popular Plugin' ) . ': ' . esc_html( $raw_title ) . + ' (' . __( 'Install' ) . ')
  • '; $feed->__destruct(); unset( $feed ); @@ -1207,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; @@ -1234,10 +1291,10 @@ function wp_dashboard_quota() { number_format_i18n( $quota ) ); printf( - '%3$s', + '%2$s (%3$s)', esc_url( admin_url( 'upload.php' ) ), - __( 'Manage Uploads' ), - $text + $text, + __( 'Manage Uploads' ) ); ?>
  • %3$s', + '%2$s (%3$s)', esc_url( admin_url( 'upload.php' ) ), - __( 'Manage Uploads' ), - $text + $text, + __( 'Manage Uploads' ) ); ?>
  • @@ -1291,7 +1348,7 @@ function wp_dashboard_browser_nag() { $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); $notice .= '

    ' . sprintf( __( 'Update %2$s or learn how to browse happy' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '

    '; - $notice .= '

    ' . __( 'Dismiss' ) . '

    '; + $notice .= '

    ' . __( 'Dismiss' ) . '

    '; $notice .= '
    '; }