Make WordPress Core

Changeset 35161


Ignore:
Timestamp:
10/14/2015 06:57:16 PM (10 years ago)
Author:
helen
Message:

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.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/common.css

    r35158 r35161  
    16281628.screen-options + .screen-options {
    16291629    margin-top: 10px;
     1630}
     1631
     1632.metabox-prefs .submit {
     1633    margin-top: 1em;
     1634    padding: 0;
    16301635}
    16311636
  • trunk/src/wp-admin/includes/class-wp-screen.php

    r35010 r35161  
    994994        echo $this->_screen_settings;
    995995
     996        /**
     997         * Filter whether to show the Screen Options submit button.
     998         *
     999         * @since 4.4.0
     1000         *
     1001         * @param bool      $show_button Whether to show Screen Options submit button.
     1002         *                               Default false.
     1003         * @param WP_Screen $this        Current WP_Screen instance.
     1004         */
     1005        $show_button = apply_filters( 'screen_options_show_submit', false, $this );
     1006
     1007        if ( $show_button ) {
     1008            submit_button( __( 'Apply' ), 'primary', 'screen-options-apply', true );
     1009        }
     1010
    9961011        echo $form_end . $wrapper_end;
    9971012    }
     
    11561171        }
    11571172
     1173        // This needs a submit button
     1174        add_filter( 'screen_options_show_submit', '__return_true' );
     1175
    11581176        ?>
    11591177        <fieldset class="screen-options">
     
    11641182                    id="<?php echo esc_attr( $option ); ?>" maxlength="3"
    11651183                    value="<?php echo esc_attr( $per_page ); ?>" />
    1166             <?php endif;
    1167 
    1168             echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?>
    1169             <input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
     1184            <?php endif; ?>
     1185                <input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $option ); ?>" />
    11701186        </fieldset>
    11711187        <?php
Note: See TracChangeset for help on using the changeset viewer.