diff -r 490d5cc509ed -r cf61fcea0001 wp/wp-admin/includes/dashboard.php --- a/wp/wp-admin/includes/dashboard.php Tue Jun 09 11:14:17 2015 +0000 +++ b/wp/wp-admin/includes/dashboard.php Mon Oct 14 17:39:30 2019 +0200 @@ -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; @@ -20,6 +24,18 @@ /* Register Widgets and Controls */ + // Try Gutenberg + + // If Gutenberg isn't activated, only show the panel to users who can install and activate it. + $plugins = get_plugins(); + if ( is_plugin_inactive( 'gutenberg/gutenberg.php' ) && ! current_user_can( 'install_plugins' ) ) { + remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' ); + } + // If Gutenberg is activated, only show it to users who can use it. + if ( is_plugin_active( 'gutenberg/gutenberg.php' ) && ! current_user_can( 'edit_posts' ) ) { + remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' ); + } + $response = wp_check_browser_version(); if ( $response && $response['upgrade'] ) { @@ -43,13 +59,13 @@ } // QuickPress Widget - if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) { - $quick_draft_title = sprintf( '
@@ -389,21 +450,21 @@ ', __( 'Quick Draft' ), __( 'Drafts' ) ); + if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { + $quick_draft_title = sprintf( ' ', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) ); wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); } - // WordPress News - wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress News' ), 'wp_dashboard_primary' ); + // WordPress Events and News + wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' ); if ( is_network_admin() ) { @@ -61,7 +77,7 @@ 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 +94,7 @@ 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 +111,7 @@ 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 +141,33 @@ 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 +193,17 @@ 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 '- 'submit_sites' ) ); ?> + 'submit_sites' ) ); ?>
ID ); // Save post_ID } @@ -479,6 +546,8 @@ * 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 ) { @@ -490,6 +559,16 @@ 'orderby' => '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; @@ -498,17 +577,18 @@ echo '' . _x( 'View all', 'drafts' ) . "
\n"; + echo '' . __( 'View all drafts' ) . "
\n"; } - echo '' . $the_content . '
'; } @@ -517,20 +597,29 @@ echo "+
+ +
' . __( 'No activity yet!' ) . '
'; echo '{$msg}
"; - $browsehappy = 'http://browsehappy.com/'; - $locale = get_locale(); + $browsehappy = 'https://browsehappy.com/'; + $locale = get_user_locale(); if ( 'en_US' !== $locale ) $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 .= ' '; + $notice .= ' '; $notice .= ''; } /** - * Filter the notice output for the 'Browse Happy' nag meta box. + * Filters the notice output for the 'Browse Happy' nag meta box. * * @since 3.2.0 * @@ -1214,6 +1492,12 @@ 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(); @@ -1237,26 +1521,33 @@ $key = md5( $_SERVER['HTTP_USER_AGENT'] ); if ( false === ($response = get_site_transient('browser_' . $key) ) ) { - global $wp_version; + // include an unmodified $wp_version + include( ABSPATH . WPINC . '/version.php' ); + $url = 'http://api.wordpress.org/core/browse-happy/1.1/'; $options = array( - 'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ), - 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() + 'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ), + 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) ); - $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', $options ); + if ( wp_http_supports( array( 'ssl' ) ) ) { + $url = set_url_scheme( $url, 'https' ); + } + + $response = wp_remote_post( $url, $options ); if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) return false; /** * 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 + * 'platform' - string - A user-friendly platform name, if it can be determined + * 'name' - string - A user-friendly browser name + * '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 + * 'update_url' - string - The url to visit to upgrade * 'img_src' - string - An image representing the browser * 'img_src_ssl' - string - An image (over SSL) representing the browser */ @@ -1284,21 +1575,22 @@ function wp_welcome_panel() { ?>
'; foreach ( $comments as $comment ) _wp_dashboard_recent_comments_row( $comment ); - echo '