Screen options: Improve the "Apply" button

Previously the button was output as a part of the per-page option rendering, inline with that input. While this was appropriate for core's usage, the `screen_settings` filter has allowed plugins to place additional items at the bottom of the panel, which a number take advantage of. This leads to confusing situations where plugins that don't save settings via Ajax either have to add their own button or piggyback onto the existing button, which doesn't make any sense in the flow of additional options. It also hinders core from adding any other options that need to be submitted.

Also, when the screen options panel is open, a submit button there is the primary action at that moment. The "Apply" button also does a full page load, which a primary button indicates better.

fixes #34295. see #22222, #23738.

Built from https://develop.svn.wordpress.org/trunk@35161


git-svn-id: http://core.svn.wordpress.org/trunk@35127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2015-10-14 18:58:25 +00:00
parent f1787056de
commit 6820130e33
6 changed files with 33 additions and 7 deletions

View File

@ -1629,6 +1629,11 @@ form.upgrade .hint {
margin-top: 10px;
}
.metabox-prefs .submit {
margin-top: 1em;
padding: 0;
}
/*------------------------------------------------------------------------------
6.2 - Help Menu
------------------------------------------------------------------------------*/

View File

@ -1629,6 +1629,11 @@ form.upgrade .hint {
margin-top: 10px;
}
.metabox-prefs .submit {
margin-top: 1em;
padding: 0;
}
/*------------------------------------------------------------------------------
6.2 - Help Menu
------------------------------------------------------------------------------*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -993,6 +993,21 @@ final class WP_Screen {
$this->render_per_page_options();
echo $this->_screen_settings;
/**
* Filter whether to show the Screen Options submit button.
*
* @since 4.4.0
*
* @param bool $show_button Whether to show Screen Options submit button.
* Default false.
* @param WP_Screen $this Current WP_Screen instance.
*/
$show_button = apply_filters( 'screen_options_show_submit', false, $this );
if ( $show_button ) {
submit_button( __( 'Apply' ), 'primary', 'screen-options-apply', true );
}
echo $form_end . $wrapper_end;
}
@ -1155,6 +1170,9 @@ final class WP_Screen {
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
}
// This needs a submit button
add_filter( 'screen_options_show_submit', '__return_true' );
?>
<fieldset class="screen-options">
<legend><?php _e( 'Pagination' ); ?></legend>
@ -1163,10 +1181,8 @@ final class WP_Screen {
<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
id="<?php echo esc_attr( $option ); ?>" maxlength="3"
value="<?php echo esc_attr( $per_page ); ?>" />
<?php endif;
echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?>
<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
<?php endif; ?>
<input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
</fieldset>
<?php
}

View File

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