X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/af50974463450c98503e763a7836a50e260461a9..607b7e02d77e7326161e8ec15639052d2040f745:/wp-admin/includes/dashboard.php diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index bf37176b..e517f956 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( '
'modified', 'order' => 'DESC' ); + + /** + * Filters 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 +562,18 @@ function wp_dashboard_recent_drafts( $drafts = false ) { echo ' ', __( 'Quick Draft' ), __( 'Drafts' ) ); wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); } @@ -61,7 +65,7 @@ function wp_dashboard_setup() { do_action( 'wp_network_dashboard_setup' ); /** - * Filter the list of widgets to load for the Network Admin dashboard. + * Filters the list of widgets to load for the Network Admin dashboard. * * @since 3.1.0 * @@ -78,7 +82,7 @@ function wp_dashboard_setup() { do_action( 'wp_user_dashboard_setup' ); /** - * Filter the list of widgets to load for the User Admin dashboard. + * Filters the list of widgets to load for the User Admin dashboard. * * @since 3.1.0 * @@ -95,7 +99,7 @@ function wp_dashboard_setup() { do_action( 'wp_dashboard_setup' ); /** - * Filter the list of widgets to load for the admin dashboard. + * Filters the list of widgets to load for the admin dashboard. * * @since 2.5.0 * @@ -125,10 +129,33 @@ 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; + $private_callback_args = array( '__widget_basename' => $widget_name ); + + if ( is_null( $callback_args ) ) { + $callback_args = $private_callback_args; + } else if ( is_array( $callback_args ) ) { + $callback_args = array_merge( $callback_args, $private_callback_args ); + } + if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { $wp_dashboard_control_callbacks[$widget_id] = $control_callback; if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) { @@ -154,8 +181,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 '' . _x( 'View all', 'drafts' ) . "
\n"; + echo '' . _x( 'View all', 'drafts' ) . "
\n"; } - echo '' . $the_content . '
'; } @@ -515,20 +582,29 @@ function wp_dashboard_recent_drafts( $drafts = false ) { echo "+
+ +
'; foreach ( $comments as $comment ) _wp_dashboard_recent_comments_row( $comment ); - echo '