X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/af50974463450c98503e763a7836a50e260461a9..3194d1bb103c2d8db4f44feeced5e58ee2756658:/wp-admin/includes/dashboard.php
diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php
index bf37176b..144fcc04 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;
@@ -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( '%1$s %2$s', __( 'Quick Draft' ), __( 'Drafts' ) );
wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' );
}
@@ -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 callable $callback
+ * @param callable $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 '
'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,9 +540,9 @@ 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 ) {
@@ -515,20 +559,23 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
echo "
\n
";
}
+/**
+ * @global WP_Comment $comment
+ *
+ * @param WP_Comment $comment
+ * @param bool $show_date
+ */
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
- $GLOBALS['comment'] =& $comment;
+ $GLOBALS['comment'] = clone $comment;
- $comment_post_title = strip_tags(get_the_title( $comment->comment_post_ID ));
-
- if ( current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
+ if ( $comment->comment_post_ID > 0 && current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
+ $comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
$comment_post_url = get_edit_post_link( $comment->comment_post_ID );
$comment_post_link = "$comment_post_title";
} else {
- $comment_post_link = $comment_post_title;
+ $comment_post_link = '';
}
- $comment_link = '';
-
$actions_string = '';
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
// Pre-order it: Approve | Reply | Edit | Spam | Trash.
@@ -537,7 +584,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" ) );
@@ -554,10 +602,16 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
$actions['edit'] = "". __('Edit') . '';
$actions['reply'] = '' . __('Reply') . '';
$actions['spam'] = "" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '';
- if ( !EMPTY_TRASH_DAYS )
+
+ if ( ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = "" . __('Delete Permanently') . '';
- else
+ } else {
$actions['trash'] = "" . _x('Trash', 'verb') . '';
+ }
+
+ if ( '1' === $comment->comment_approved ) {
+ $actions['view'] = '';
+ }
/**
* Filter the action links displayed for each comment in the 'Recent Comments'
@@ -565,10 +619,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 );
@@ -587,17 +641,33 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
?>
-
- ' . get_comment_author_link() . '', $comment_post_link.' '.$comment_link, ' ' . __( '[Pending]' ) . '' ); ?> -
++ ' . 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]' ) . '' + ); + } + ?> +
-$type", $comment_post_link." ".$comment_link ); ?>
- +$type", $comment_post_link ); ?>
+ - +' . $args['title'] . '
'; + echo '' . $args['title'] . '
'; echo ''; @@ -710,20 +790,20 @@ 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 = __( '%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 +838,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,7 +854,7 @@ function wp_dashboard_recent_comments( $total_items = 5 ) { if ( $comments ) { echo '' . __( 'Comments' ) . '
'; + echo '' . __( 'Comments' ) . '
'; echo '