X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/256a3b381f63716209b3527d0a14442ae570c283..refs/tags/wordpress-4.5:/wp-admin/includes/dashboard.php diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index afc76f0d..5a234857 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -12,17 +12,16 @@ * 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; $wp_dashboard_control_callbacks = array(); $screen = get_current_screen(); - $update = false; - $widget_options = get_option( 'dashboard_widget_options' ); - if ( !$widget_options || !is_array($widget_options) ) - $widget_options = array(); - /* Register Widgets and Controls */ $response = wp_check_browser_version(); @@ -48,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( '%1$s %2$s', __( 'Quick Draft' ), __( 'Drafts' ) ); wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); } @@ -56,16 +55,56 @@ function wp_dashboard_setup() { // WordPress News wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress News' ), 'wp_dashboard_primary' ); - // Hook to register new widgets - // Filter widget order if ( is_network_admin() ) { + + /** + * Fires after core widgets for the Network Admin dashboard have been registered. + * + * @since 3.1.0 + */ do_action( 'wp_network_dashboard_setup' ); + + /** + * Filter the list of widgets to load for the Network Admin dashboard. + * + * @since 3.1.0 + * + * @param array $dashboard_widgets An array of dashboard widgets. + */ $dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() ); } elseif ( is_user_admin() ) { + + /** + * Fires after core widgets for the User Admin dashboard have been registered. + * + * @since 3.1.0 + */ do_action( 'wp_user_dashboard_setup' ); + + /** + * Filter the list of widgets to load for the User Admin dashboard. + * + * @since 3.1.0 + * + * @param array $dashboard_widgets An array of dashboard widgets. + */ $dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() ); } else { + + /** + * Fires after core widgets for the admin dashboard have been registered. + * + * @since 2.5.0 + */ do_action( 'wp_dashboard_setup' ); + + /** + * Filter the list of widgets to load for the admin dashboard. + * + * @since 2.5.0 + * + * @param array $dashboard_widgets An array of dashboard widgets. + */ $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() ); } @@ -83,15 +122,28 @@ function wp_dashboard_setup() { exit; } - if ( $update ) - update_option( 'dashboard_widget_options', $widget_options ); - /** This action is documented in wp-admin/edit-form-advanced.php */ - do_action('do_meta_boxes', $screen->id, 'normal', ''); + do_action( 'do_meta_boxes', $screen->id, 'normal', '' ); + /** This action is documented in wp-admin/edit-form-advanced.php */ - do_action('do_meta_boxes', $screen->id, 'side', ''); + 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; @@ -121,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 '
'; + echo ''; wp_dashboard_trigger_widget_control( $meta_box['id'] ); wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' ); echo ''; @@ -145,16 +206,16 @@ function wp_dashboard() { ?>
-
+
id, 'normal', '' ); ?>
-
+
id, 'side', '' ); ?>
-
+
id, 'column3', '' ); ?>
-
+
id, 'column4', '' ); ?>
@@ -165,7 +226,9 @@ function wp_dashboard() { } -/* Dashboard Widgets */ +// +// Dashboard Widgets +// /** * Dashboard widget that displays some basic stats about the site. @@ -175,11 +238,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'); ?>
    @@ -194,73 +252,116 @@ function wp_dashboard_right_now() { $text = _n( '%s Page', '%s Pages', $num_posts->publish ); } $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); - printf( '
  • %2$s
  • ', $post_type, $text ); + $post_type_object = get_post_type_object( $post_type ); + if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) { + printf( '
  • %2$s
  • ', $post_type, $text ); + } else { + printf( '
  • %2$s
  • ', $post_type, $text ); + } + } } // 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 ) ); ?>
  • 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 ) ); - ?> -
  • - 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 ); + ?> +
  • + ' . implode( "\n
  • ", $elements ) . "
  • \n"; } ?>
-

$content

"; + echo "

$content

"; } ?>
@@ -270,6 +371,9 @@ function wp_dashboard_right_now() {

- + + +

- - 'submit_users' ) ); ?> + + + 'submit_users' ) ); ?>

- - 'submit_sites' ) ); ?> + + + 'submit_sites' ) ); ?>

- +
- +

@@ -382,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 ) { @@ -393,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; @@ -401,17 +554,18 @@ function wp_dashboard_recent_drafts( $drafts = false ) { echo '

'; if ( count( $drafts ) > 3 ) { - echo '

' . _x( 'View all', 'drafts' ) . "

\n"; + echo '

' . _x( 'View all', 'drafts' ) . "

\n"; } - echo '

' . __( 'Drafts' ) . "

\n
    "; + echo '

    ' . __( 'Drafts' ) . "

    \n
      "; $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 "
    • \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 . '

      '; } @@ -420,23 +574,39 @@ function wp_dashboard_recent_drafts( $drafts = false ) { echo "
    \n
"; } +/** + * 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_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_link = '#'; + if ( $comment->comment_post_ID > 0 ) { + + $comment_post_title = _draft_or_post_title( $comment->comment_post_ID ); + $comment_post_url = get_the_permalink( $comment->comment_post_ID ); + $comment_post_link = "$comment_post_title"; + } else { + $comment_post_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' => '', 'edit' => '', 'spam' => '', - 'trash' => '', 'delete' => '' + 'trash' => '', 'delete' => '', + 'view' => '', ); $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); @@ -448,16 +618,33 @@ 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' ) . ''; - if ( !EMPTY_TRASH_DAYS ) - $actions['delete'] = "" . __('Delete Permanently') . ''; - else - $actions['trash'] = "" . _x('Trash', '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' ) . ''; + } else { + $actions['trash'] = "" . _x( 'Trash', 'verb' ) . ''; + } + if ( '1' === $comment->comment_approved ) { + $actions['view'] = '' . __( 'View' ) . ''; + } + + /** + * 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 WP_Comment $comment The comment object. + */ $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); $i = 0; @@ -472,45 +659,84 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { $actions_string .= "$sep$link"; } } - ?> -
comment_ID) ) ); ?>> - comment_type || 'comment' == $comment->comment_type ) : ?> +
  • > -
    -

    - ' . get_comment_author_link() . '', $comment_post_link.' '.$comment_link, ' ' . __( '[Pending]' ) . '' ); ?> -

    + comment_type || 'comment' == $comment->comment_type ) : ?> + +
    +

    + ' . get_comment_author_link( $comment ) . '', + $comment_post_link, + '' . __( '[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]' ) . '' + ); + } + ?> +

    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 ); ?> -
    - -

    $type", $comment_post_link." ".$comment_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]' ) . '' + ); + } + ?> +

    +

    -

    +

    +

    +
    -
    +
  • '; $future_posts = wp_dashboard_recent_posts( array( - 'display' => 2, 'max' => 5, 'status' => 'future', 'order' => 'ASC', @@ -531,7 +756,6 @@ function wp_dashboard_site_activity() { 'id' => 'future-posts', ) ); $recent_posts = wp_dashboard_recent_posts( array( - 'display' => 2, 'max' => 5, 'status' => 'publish', 'order' => 'DESC', @@ -559,8 +783,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. @@ -576,23 +799,28 @@ 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', ); + + /** + * 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 '
    '; - if ( $posts->post_count > $args['display'] ) { - echo '' . sprintf( __( 'See %s more…'), $posts->post_count - intval( $args['display'] ) ) . ''; - } - - echo '

    ' . $args['title'] . '

    '; + echo '

    ' . $args['title'] . '

    '; echo '
      '; - $i = 0; $today = date( 'Y-m-d', current_time( 'timestamp' ) ); $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) ); @@ -604,23 +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 ); } - $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++; + // 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( + '
    • %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 '
    '; @@ -644,11 +876,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, @@ -658,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; @@ -669,19 +901,19 @@ function wp_dashboard_recent_comments( $total_items = 5 ) { $comments_query['number'] = $total_items * 10; } - - 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(); @@ -718,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. */ @@ -735,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; @@ -747,8 +980,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) @@ -757,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 ) { @@ -800,7 +1036,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) ) { @@ -826,9 +1063,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', __( 'https://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, @@ -836,10 +1097,42 @@ 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, + + /** + * 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, @@ -872,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 '
    '; if ( $type === 'plugins' ) { @@ -888,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 @@ -900,13 +1196,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 ) { @@ -947,16 +1241,16 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) { if ( !isset($items[$item_key]) ) continue; - $title = esc_html( $item->get_title() ); - - $description = esc_html( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) ); + $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' ) . ': ' . esc_html( $raw_title ) . + ' (' . __( 'Install' ) . ')
    • '; - echo "
    • $label: $title (" . __( 'Install' ) . ")
    • "; - - $$feed->__destruct(); - unset( $$feed ); + $feed->__destruct(); + unset( $feed ); } echo '
    '; @@ -969,8 +1263,8 @@ 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' ) ) return true; @@ -987,7 +1281,7 @@ function wp_dashboard_quota() { $percentused = number_format( $percentused ); ?> -

    +

    • @@ -997,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' ) ); ?>
    %s. 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( '%s', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) + ); } else { - $msg = sprintf( __( "It looks like you're using an old version of %s. 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( '%s', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) + ); } $browser_nag_class = ''; @@ -1049,13 +1348,27 @@ 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 .= '
    '; } + /** + * 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 ); } +/** + * @since 3.2.0 + * + * @param array $classes + * @return array + */ function dashboard_browser_nag_class( $classes ) { $response = wp_check_browser_version(); @@ -1070,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() { @@ -1094,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 @@ -1126,19 +1441,21 @@ function wp_dashboard_empty() {} function wp_welcome_panel() { ?>
    -

    +

    -

    - + +

    + + true ) ) ) > 1 ) ) : ?>

    change your theme completely' ), admin_url( 'themes.php' ) ); ?>

    -

    +

    • ' . __( 'Edit your front page' ) . '', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?>
    • @@ -1155,11 +1472,24 @@ function wp_welcome_panel() {
    -

    +

    ', 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' ) ); ?>
  • + +
  • ' . __( 'Learn more about getting started' ) . '', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?>