diff -r c7c34916027a -r 177826044cd9 wp/wp-admin/includes/dashboard.php
--- a/wp/wp-admin/includes/dashboard.php Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-admin/includes/dashboard.php Mon Oct 14 18:28:13 2019 +0200
@@ -20,38 +20,36 @@
function wp_dashboard_setup() {
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
$wp_dashboard_control_callbacks = array();
- $screen = get_current_screen();
+ $screen = get_current_screen();
/* 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'] ) {
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
- if ( $response['insecure'] )
+ if ( $response['insecure'] ) {
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
- else
+ } else {
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
+ }
+ }
+
+ // PHP Version.
+ $response = wp_check_php_version();
+ if ( $response && isset( $response['is_acceptable'] ) && ! $response['is_acceptable'] && current_user_can( 'update_php' ) ) {
+ add_filter( 'postbox_classes_dashboard_dashboard_php_nag', 'dashboard_php_nag_class' );
+ wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' );
}
// Right Now
- if ( is_blog_admin() && current_user_can('edit_posts') )
+ if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) {
wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
+ }
- if ( is_network_admin() )
+ if ( is_network_admin() ) {
wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
+ }
// Activity Widget
if ( is_blog_admin() ) {
@@ -81,7 +79,7 @@
*
* @since 3.1.0
*
- * @param array $dashboard_widgets An array of dashboard widgets.
+ * @param string[] $dashboard_widgets An array of dashboard widget IDs.
*/
$dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
} elseif ( is_user_admin() ) {
@@ -98,7 +96,7 @@
*
* @since 3.1.0
*
- * @param array $dashboard_widgets An array of dashboard widgets.
+ * @param string[] $dashboard_widgets An array of dashboard widget IDs.
*/
$dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() );
} else {
@@ -115,17 +113,17 @@
*
* @since 2.5.0
*
- * @param array $dashboard_widgets An array of dashboard widgets.
+ * @param string[] $dashboard_widgets An array of dashboard widget IDs.
*/
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
}
foreach ( $dashboard_widgets as $widget_id ) {
- $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " " . __('View all') . ' ';
- wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
+ $name = empty( $wp_registered_widgets[ $widget_id ]['all_link'] ) ? $wp_registered_widgets[ $widget_id ]['name'] : $wp_registered_widgets[ $widget_id ]['name'] . " " . __( 'View all' ) . ' ';
+ wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] );
}
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) {
check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' );
ob_start(); // hack - but the same hack wp-admin/widgets.php uses
wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
@@ -134,10 +132,10 @@
exit;
}
- /** This action is documented in wp-admin/edit-form-advanced.php */
+ /** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'normal', '' );
- /** This action is documented in wp-admin/edit-form-advanced.php */
+ /** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'do_meta_boxes', $screen->id, 'side', '' );
}
@@ -164,18 +162,18 @@
if ( is_null( $callback_args ) ) {
$callback_args = $private_callback_args;
- } else if ( is_array( $callback_args ) ) {
+ } elseif ( 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;
+ $wp_dashboard_control_callbacks[ $widget_id ] = $control_callback;
if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
- list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
+ list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
$widget_name .= ' ' . __( 'Cancel' ) . ' ';
- $callback = '_wp_dashboard_control_callback';
+ $callback = '_wp_dashboard_control_callback';
} else {
- list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
+ list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
$widget_name .= ' ' . __( 'Configure' ) . ' ';
}
}
@@ -183,12 +181,16 @@
$side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
$location = 'normal';
- if ( in_array($widget_id, $side_widgets) )
+ if ( in_array( $widget_id, $side_widgets ) ) {
$location = 'side';
+ }
+
+ $high_priority_widgets = array( 'dashboard_browser_nag', 'dashboard_php_nag' );
$priority = 'core';
- if ( 'dashboard_browser_nag' === $widget_id )
+ if ( in_array( $widget_id, $high_priority_widgets, true ) ) {
$priority = 'high';
+ }
add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args );
}
@@ -206,8 +208,8 @@
echo '
';
}
@@ -217,14 +219,14 @@
* @since 2.5.0
*/
function wp_dashboard() {
- $screen = get_current_screen();
- $columns = absint( $screen->get_columns() );
+ $screen = get_current_screen();
+ $columns = absint( $screen->get_columns() );
$columns_css = '';
if ( $columns ) {
$columns_css = " columns-$columns";
}
-?>
+ ?>
-
+ ?>
publish );
}
- $text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
+ $text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
$post_type_object = get_post_type_object( $post_type );
if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
printf( '%2$s ', $post_type, $text );
} else {
printf( '%2$s ', $post_type, $text );
}
-
}
}
// Comments
@@ -290,15 +291,15 @@
moderated );
/* translators: %s: number of comments in moderation */
- $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
- /* translators: %s: number of comments in moderation */
- $aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
+ $text = sprintf( _n( '%s Comment in moderation', '%s Comments in moderation', $num_comm->moderated ), $moderated_comments_count_i18n );
?>
-
+
$content ";
@@ -384,11 +385,13 @@
$actions = ob_get_clean();
- if ( !empty( $actions ) ) : ?>
+ if ( ! empty( $actions ) ) :
+ ?>
- ' . __( 'Create a New Site' ) . '';
- if ( current_user_can('create_users') )
- $actions['create-user'] = '' . __( 'Create a New User' ) . ' ';
+ if ( current_user_can( 'create_sites' ) ) {
+ $actions['create-site'] = '' . __( 'Create a New Site' ) . ' ';
+ }
+ if ( current_user_can( 'create_users' ) ) {
+ $actions['create-user'] = '' . __( 'Create a New User' ) . ' ';
+ }
$c_users = get_user_count();
$c_blogs = get_blog_count();
@@ -415,12 +420,12 @@
if ( $actions ) {
echo '';
foreach ( $actions as $class => $action ) {
- $actions[ $class ] = "\t$action";
+ $actions[ $class ] = "\t $action";
}
echo implode( " | \n", $actions ) . "\n";
echo ' ';
}
-?>
+ ?>
@@ -432,13 +437,11 @@
* just before the user and site search form fields.
*
* @since MU (3.0.0)
- *
- * @param null $unused
*/
- do_action( 'wpmuadminresult', '' );
+ do_action( 'wpmuadminresult' );
?>
-
-
-post_title = ''; // Remove the auto draft title
}
} else {
- $post = get_default_post_to_edit( 'post' , true);
+ $post = get_default_post_to_edit( 'post', true );
$user_id = get_current_user_id();
// Don't create an option if this is a super admin who does not belong to this site.
- if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) )
+ if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) {
update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
+ }
}
$post_ID = (int) $post->ID;
-?>
+ ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- testing, filing bugs , or contributing on the GitHub repository .' ),
- 'https://make.wordpress.org/test/handbook/call-for-testing/gutenberg-testing/',
- 'https://github.com/WordPress/gutenberg/issues',
- 'https://github.com/WordPress/gutenberg/blob/master/CONTRIBUTING.md'
- );
- ?>
-
-
-
-
-
-
-
-
-
- Learn more about Gutenberg' ),
- __( 'https://wordpress.org/gutenberg/' )
- );
-
- /**
- * Filters the "Learn more" link in the Try Gutenberg panel.
- *
- * It allows hosts or site owners to change the link, to provide extra
- * information about Gutenberg, specific to their service.
- *
- * WARNING: This filter will only exist in the 4.9.x series, it will not be
- * added to WordPress 5.0 and later.
- *
- * @since 4.9.8
- */
- echo apply_filters( 'try_gutenberg_learn_more_link', $learnmore );
- ?>
-
-
-
-
-
-
-
-
-
-
-
- Classic Editor plugin to keep using the current editor until you’re ready to make the switch.' ),
- __( 'https://wordpress.org/plugins/classic-editor' )
- );
- ?>
-
-
-
-
-
-
-
-
-
-