X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/48ab98cb1779cf2088c1351ac3dd3d0da6fb31d3..d3947bc013df7edd54b46deed8230d2eeafc5ecb:/wp-admin/includes/dashboard.php?ds=sidebyside
diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php
index 2a5e74be..5a234857 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,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 '
'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 '';
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 '';
+ /* translators: %s: post title */
+ echo '';
if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
echo '
' . $the_content . '
';
}
@@ -515,20 +574,29 @@ 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_title = strip_tags(get_the_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 = "$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 +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'] = "" . __( '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'] = '';
+ }
/**
* 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 .= "$sep$link";
}
}
-
?>
-
'; foreach ( $comments as $comment ) _wp_dashboard_recent_comments_row( $comment ); - echo '