From 3d6fc458346208012beed8bf2833a87f142aadac Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 5 Jul 2016 15:22:29 +0000 Subject: [PATCH] Dashboard: Don't add a "Configure" link to the toggle button. The HTML for the toggle gets appended to the widget name which is later used for the widget title and the screen reader text of the toggle button. Storing the original widget name in the arguments allows us to use the name without the HTML for the screen reader text and doesn't require further changes by plugin developers. Props nicholas_io, swissspidy. Fixes #35021. Built from https://develop.svn.wordpress.org/trunk@37972 git-svn-id: http://core.svn.wordpress.org/trunk@37913 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/dashboard.php | 8 ++++++++ wp-admin/includes/screen.php | 17 +++++++++++++---- wp-admin/includes/template.php | 10 +++++++++- wp-includes/version.php | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 98743939a3..ae40a94636 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -148,6 +148,14 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_ $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'] ) { diff --git a/wp-admin/includes/screen.php b/wp-admin/includes/screen.php index 3c6a5131b9..1e57622003 100644 --- a/wp-admin/includes/screen.php +++ b/wp-admin/includes/screen.php @@ -117,10 +117,19 @@ function meta_box_prefs( $screen ) { // Submit box cannot be hidden if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) continue; - $box_id = $box['id']; - echo '\n"; + + $widget_title = $box['title']; + + if ( isset( $box['args']['__widget_basename'] ) ) { + $widget_title = $box['args']['__widget_basename']; + } + + printf( + '', + esc_attr( $box['id'] ), + checked( in_array( $box['id'], $hidden ), false, false ), + $widget_title + ); } } } diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index cc590e3dfd..ef7621a02d 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1027,8 +1027,16 @@ function do_meta_boxes( $screen, $context, $object ) { $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; echo '
' . "\n"; if ( 'dashboard_browser_nag' != $box['id'] ) { + $widget_title = $box[ 'title' ]; + + if ( is_array( $box[ 'args' ] ) && isset( $box[ 'args' ][ '__widget_basename' ] ) ) { + $widget_title = esc_html( $box[ 'args' ][ '__widget_basename' ] ); + // Do not pass this parameter to the user callback function. + unset( $box[ 'args' ][ '__widget_basename' ] ); + } + echo ''; } diff --git a/wp-includes/version.php b/wp-includes/version.php index d768f8f379..2d677c2fe1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-beta1-37971'; +$wp_version = '4.6-beta1-37972'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.