X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f..53f4633144ed68c8b8fb5861f992b5489894a940:/wp-admin/includes/dashboard.php diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 2a5e74be..49fcdd92 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -12,6 +12,10 @@ * 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; @@ -125,6 +129,16 @@ function wp_dashboard_setup() { do_action( 'do_meta_boxes', $screen->id, 'side', '' ); } +/** + * + * @global array $wp_dashboard_control_callbacks + * + * @param string $widget_id + * @param string $widget_name + * @param callback $callback + * @param callback $control_callback + * @param array $callback_args + */ 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 +168,13 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_ add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args ); } +/** + * + * @param type $dashboard + * @param type $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 ''; @@ -235,8 +254,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 ) ); ?>
  • " method="get">

    - + + 'submit_users' ) ); ?>

    - + + 'submit_sites' ) ); ?>

    @@ -411,11 +435,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 +507,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 ) { @@ -515,10 +547,16 @@ function wp_dashboard_recent_drafts( $drafts = false ) { echo "\n"; } +/** + * @global object $comment + * + * @param object $comment + * @param bool $show_date + */ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { $GLOBALS['comment'] =& $comment; - $comment_post_title = strip_tags(get_the_title( $comment->comment_post_ID )); + $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 ); @@ -593,7 +631,7 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { comment_type || 'comment' == $comment->comment_type ) : ?> -
    +

    ' . get_comment_author_link() . '', $comment_post_link.' '.$comment_link, ' ' . __( '[Pending]' ) . '' ); ?> @@ -613,7 +651,7 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { } $type = esc_html( $type ); ?> -
    +

    $type", $comment_post_link." ".$comment_link ); ?>

    @@ -689,6 +727,15 @@ 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() ) { @@ -715,15 +762,12 @@ function wp_dashboard_recent_posts( $args ) { $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 = __( '%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() ); - } + // 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(); + + /* translators: 1: relative date, 2: time, 3: post edit link or permalink, 4: post title */ + $format = __( '%1$s, %2$s %4$s' ); + printf( "
  • $format
  • ", $relative, get_the_time(), $recent_post_link, _draft_or_post_title() ); } echo ''; @@ -758,6 +802,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; @@ -833,7 +880,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; @@ -863,6 +911,8 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar * * @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 ) { @@ -967,7 +1017,7 @@ function wp_dashboard_primary() { * * @param string $link The widget's secondary link URL. */ - 'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ), + 'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ), /** * Filter the secondary feed URL for the 'WordPress News' dashboard widget. @@ -976,7 +1026,7 @@ function wp_dashboard_primary() { * * @param string $url The widget's secondary feed URL. */ - 'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ), + 'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ), /** * Filter the secondary link title for the 'WordPress News' dashboard widget. @@ -1111,7 +1161,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' ) ) @@ -1162,7 +1212,6 @@ function wp_dashboard_quota() {
  • ' . __( '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' ) ); ?>