Administration: Convert H5 usage in Screen Options to use fieldsets and legends.

These H5 (heading level 5) don't allow for a good headings hierarchy and shouldn't be headings in the first place. Each group of options has now its own fieldset and legend.
In `render_screen_options()`, introduce two new "render" methods: `render_meta_boxes_preferences()` and `render_list_table_columns_preferences()` for consistency with already existing render methods and cleaner code.

Props joedolson, afercia.
Fixes #33646.
Built from https://develop.svn.wordpress.org/trunk@34991


git-svn-id: http://core.svn.wordpress.org/trunk@34956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrea Fercia 2015-10-09 18:05:24 +00:00
parent 681573e80a
commit 42b33e1645
10 changed files with 165 additions and 109 deletions

View File

@ -1570,10 +1570,17 @@ form.upgrade .hint {
background-position: bottom left; background-position: bottom left;
} }
#screen-options-wrap h5, #screen-options-wrap h5, /* Back-compat for old plugins */
#screen-options-wrap legend,
#contextual-help-wrap h5 { #contextual-help-wrap h5 {
margin: 8px 0; margin: 0;
font-size: 13px; padding: 8px 0;
font-size: 13px;
font-weight: 600;
}
.ie8 #screen-options-wrap legend {
color: inherit;
} }
.metabox-prefs label { .metabox-prefs label {
@ -1582,27 +1589,30 @@ form.upgrade .hint {
line-height: 30px; line-height: 30px;
} }
.metabox-prefs label input[type=checkbox] { #number-of-columns {
margin-top: -4px; display: inline-block;
vertical-align: middle;
line-height: 30px;
}
.metabox-prefs input[type=checkbox] {
margin-top: 0;
margin-left: 6px; margin-left: 6px;
} }
.metabox-prefs label input { .metabox-prefs label input,
margin: 0 2px 0 5px; .metabox-prefs label input[type=checkbox] {
margin: -4px 0 0 5px;
} }
.metabox-prefs .columns-prefs label input { .metabox-prefs .columns-prefs label input {
margin: 0 2px; margin: -1px 0 0 2px;
} }
.metabox-prefs label a { .metabox-prefs label a {
display: none; display: none;
} }
.metabox-prefs .screen-options {
padding-top: 10px;
}
.metabox-prefs .screen-options input, .metabox-prefs .screen-options input,
.metabox-prefs .screen-options label { .metabox-prefs .screen-options label {
margin-top: 0; margin-top: 0;
@ -1619,6 +1629,10 @@ form.upgrade .hint {
padding-left: 0; padding-left: 0;
} }
.screen-options + .screen-options {
margin-top: 10px;
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
6.2 - Help Menu 6.2 - Help Menu
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -1900,7 +1914,7 @@ html.wp-toolbar {
} }
.columns-prefs label { .columns-prefs label {
padding: 0 5px; padding: 0 0 0 10px;
} }
/* @todo: what is this doing here */ /* @todo: what is this doing here */

View File

@ -1570,10 +1570,17 @@ form.upgrade .hint {
background-position: bottom left; background-position: bottom left;
} }
#screen-options-wrap h5, #screen-options-wrap h5, /* Back-compat for old plugins */
#screen-options-wrap legend,
#contextual-help-wrap h5 { #contextual-help-wrap h5 {
margin: 8px 0; margin: 0;
font-size: 13px; padding: 8px 0;
font-size: 13px;
font-weight: 600;
}
.ie8 #screen-options-wrap legend {
color: inherit;
} }
.metabox-prefs label { .metabox-prefs label {
@ -1582,27 +1589,30 @@ form.upgrade .hint {
line-height: 30px; line-height: 30px;
} }
.metabox-prefs label input[type=checkbox] { #number-of-columns {
margin-top: -4px; display: inline-block;
vertical-align: middle;
line-height: 30px;
}
.metabox-prefs input[type=checkbox] {
margin-top: 0;
margin-right: 6px; margin-right: 6px;
} }
.metabox-prefs label input { .metabox-prefs label input,
margin: 0 5px 0 2px; .metabox-prefs label input[type=checkbox] {
margin: -4px 5px 0 0;
} }
.metabox-prefs .columns-prefs label input { .metabox-prefs .columns-prefs label input {
margin: 0 2px; margin: -1px 2px 0 0;
} }
.metabox-prefs label a { .metabox-prefs label a {
display: none; display: none;
} }
.metabox-prefs .screen-options {
padding-top: 10px;
}
.metabox-prefs .screen-options input, .metabox-prefs .screen-options input,
.metabox-prefs .screen-options label { .metabox-prefs .screen-options label {
margin-top: 0; margin-top: 0;
@ -1619,6 +1629,10 @@ form.upgrade .hint {
padding-right: 0; padding-right: 0;
} }
.screen-options + .screen-options {
margin-top: 10px;
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
6.2 - Help Menu 6.2 - Help Menu
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -1900,7 +1914,7 @@ html.wp-toolbar {
} }
.columns-prefs label { .columns-prefs label {
padding: 0 5px; padding: 0 10px 0 0;
} }
/* @todo: what is this doing here */ /* @todo: what is this doing here */

View File

@ -349,7 +349,7 @@
display: none; display: none;
background: #fff; background: #fff;
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
padding: 4px 15px 0; padding: 4px 15px 15px;
} }
.wp-customizer .metabox-prefs label { .wp-customizer .metabox-prefs label {

File diff suppressed because one or more lines are too long

View File

@ -349,7 +349,7 @@
display: none; display: none;
background: #fff; background: #fff;
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
padding: 4px 15px 0; padding: 4px 15px 15px;
} }
.wp-customizer .metabox-prefs label { .wp-customizer .metabox-prefs label {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -918,9 +918,9 @@ final class WP_Screen {
$this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n"; $this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
break; break;
case 'post' : case 'post' :
$expand = '<div class="editor-expand hidden"><label for="editor-expand-toggle">'; $expand = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">';
$expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />'; $expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
$expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></div>'; $expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>';
$this->_screen_settings = $expand; $this->_screen_settings = $expand;
break; break;
default: default:
@ -969,110 +969,137 @@ final class WP_Screen {
*/ */
public function render_screen_options( $options = array() ) { public function render_screen_options( $options = array() ) {
global $wp_meta_boxes; global $wp_meta_boxes;
$options = wp_parse_args( $options, array( $options = wp_parse_args( $options, array(
'wrap' => true, 'wrap' => true,
) ); ) );
$columns = get_column_headers( $this ); $wrapper_start = $wrapper_end = $form_start = $form_end = '';
$hidden = get_hidden_columns( $this );
?> // Output optional wrapper.
<?php if ( $options['wrap'] ) : ?> if ( $options['wrap'] ) {
<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>"> $wrapper_start = '<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="' . esc_attr__( 'Screen Options Tab' ) . '">';
<?php endif; ?> $wrapper_end = '</div>';
<form id="adv-settings" method="post"> }
<?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?>
<h5><?php _e( 'Show on screen' ); ?></h5>
<?php
endif;
if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?> // Don't output the form and nonce for the widgets accessibility mode links.
<div class="metabox-prefs"> if ( 'widgets' !== $this->base ) {
<?php $form_start = "\n<form id='adv-settings' method='post'>\n";
meta_box_prefs( $this ); $form_end = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n</form>\n";
}
if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) { echo $wrapper_start . $form_start;
if ( isset( $_GET['welcome'] ) ) {
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
} else {
$welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) )
$welcome_checked = false;
}
echo '<label for="wp_welcome_panel-hide">';
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
}
?>
<br class="clear" />
</div>
<?php endif;
if ( $columns ) :
if ( ! empty( $columns['_title'] ) ) : ?>
<h5><?php echo $columns['_title']; ?></h5>
<?php endif; ?>
<div class="metabox-prefs">
<?php
$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname');
foreach ( $columns as $column => $title ) {
// Can't hide these for they are special
if ( in_array( $column, $special ) )
continue;
if ( empty( $title ) )
continue;
if ( 'comments' == $column )
$title = __( 'Comments' );
$id = "$column-hide";
echo '<label for="' . $id . '">';
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />';
echo "$title</label>\n";
}
?>
<br class="clear" />
</div>
<?php endif;
$this->render_meta_boxes_preferences();
$this->render_list_table_columns_preferences();
$this->render_screen_layout(); $this->render_screen_layout();
$this->render_per_page_options(); $this->render_per_page_options();
echo $this->_screen_settings; echo $this->_screen_settings;
?> echo $form_end . $wrapper_end;
<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div> }
</form>
<?php if ( $options['wrap'] ) : ?> /**
</div> * Render the meta boxes preferences.
*
* @since 4.4.0
*/
public function render_meta_boxes_preferences() {
global $wp_meta_boxes;
if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?>
<fieldset class="metabox-prefs">
<legend><?php _e( 'Boxes' ); ?></legend>
<?php
meta_box_prefs( $this );
if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
if ( isset( $_GET['welcome'] ) ) {
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
} else {
$welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) )
$welcome_checked = false;
}
echo '<label for="wp_welcome_panel-hide">';
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
}
?>
</fieldset>
<?php endif; <?php endif;
} }
/**
* Render the list table columns preferences.
*
* @since 4.4.0
*/
public function render_list_table_columns_preferences() {
$columns = get_column_headers( $this );
$hidden = get_hidden_columns( $this );
if ( $columns ) {
$legend = ! empty( $columns['_title'] ) ? $columns['_title'] : __( 'Columns' );
?>
<fieldset class="metabox-prefs">
<legend><?php echo $legend; ?></legend>
<?php
$special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' );
foreach ( $columns as $column => $title ) {
// Can't hide these for they are special
if ( in_array( $column, $special ) ) {
continue;
}
if ( empty( $title ) ) {
continue;
}
if ( 'comments' == $column ) {
$title = __( 'Comments' );
}
$id = "$column-hide";
echo '<label>';
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" value="' . $column . '"' . checked( ! in_array( $column, $hidden ), true, false ) . ' />';
echo "$title</label>\n";
}
?>
</fieldset>
<?php
}
}
/** /**
* Render the option for number of columns on the page * Render the option for number of columns on the page
* *
* @since 3.3.0 * @since 3.3.0
*/ */
public function render_screen_layout() { public function render_screen_layout() {
if ( ! $this->get_option('layout_columns') ) if ( ! $this->get_option( 'layout_columns' ) ) {
return; return;
}
$screen_layout_columns = $this->get_columns(); $screen_layout_columns = $this->get_columns();
$num = $this->get_option( 'layout_columns', 'max' ); $num = $this->get_option( 'layout_columns', 'max' );
?> ?>
<h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5> <fieldset class='columns-prefs'>
<div class='columns-prefs'><?php <legend class="screen-layout"><?php _e( 'Layout' ); ?></legend><?php
_e('Number of Columns:');
for ( $i = 1; $i <= $num; ++$i ): for ( $i = 1; $i <= $num; ++$i ):
?> ?>
<label class="columns-prefs-<?php echo $i; ?>"> <label class="columns-prefs-<?php echo $i; ?>">
<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>' <input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
<?php checked( $screen_layout_columns, $i ); ?> /> <?php checked( $screen_layout_columns, $i ); ?> />
<?php echo esc_html( $i ); ?> <?php printf( _n( '%s column', '%s columns', $i ), number_format_i18n( $i ) ); ?>
</label> </label>
<?php <?php
endfor; ?> endfor; ?>
</div> </fieldset>
<?php <?php
} }
@ -1119,12 +1146,13 @@ final class WP_Screen {
// Back compat // Back compat
if ( isset( $this->post_type ) ) { if ( isset( $this->post_type ) ) {
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ /** This filter is documented in wp-admin/includes/post.php */
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type ); $per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
} }
?> ?>
<div class="screen-options"> <fieldset class="screen-options">
<legend><?php _e( 'Pagination' ); ?></legend>
<?php if ( $per_page_label ) : ?> <?php if ( $per_page_label ) : ?>
<label for="<?php echo esc_attr( $option ); ?>"><?php echo $per_page_label; ?></label> <label for="<?php echo esc_attr( $option ); ?>"><?php echo $per_page_label; ?></label>
<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]" <input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
@ -1134,7 +1162,7 @@ final class WP_Screen {
echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?> echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?>
<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" /> <input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
</div> </fieldset>
<?php <?php
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-34990'; $wp_version = '4.4-alpha-34991';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.