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
This commit is contained in:
parent
b55493e3e6
commit
3d6fc45834
|
@ -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'] ) {
|
||||
|
|
|
@ -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 '<label for="' . $box_id . '-hide">';
|
||||
echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />';
|
||||
echo "{$box['title']}</label>\n";
|
||||
|
||||
$widget_title = $box['title'];
|
||||
|
||||
if ( isset( $box['args']['__widget_basename'] ) ) {
|
||||
$widget_title = $box['args']['__widget_basename'];
|
||||
}
|
||||
|
||||
printf(
|
||||
'<label for="%1$s-hide"><input class="hide-postbox-tog" name="%1$s-hide" type="checkbox" id="%1$s-hide" value="%1$s" %2$s />%3$s</label>',
|
||||
esc_attr( $box['id'] ),
|
||||
checked( in_array( $box['id'], $hidden ), false, false ),
|
||||
$widget_title
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1027,8 +1027,16 @@ function do_meta_boxes( $screen, $context, $object ) {
|
|||
$hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
|
||||
echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\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 '<button type="button" class="handlediv button-link" aria-expanded="true">';
|
||||
echo '<span class="screen-reader-text">' . sprintf( __( 'Toggle panel: %s' ), $box['title'] ) . '</span>';
|
||||
echo '<span class="screen-reader-text">' . sprintf( __( 'Toggle panel: %s' ), $widget_title ) . '</span>';
|
||||
echo '<span class="toggle-indicator" aria-hidden="true"></span>';
|
||||
echo '</button>';
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue