Skip to:
Content

bbPress.org

Changeset 7189


Ignore:
Timestamp:
02/18/2021 05:17:16 AM (8 weeks ago)
Author:
johnjamesjacoby
Message:

Users: Improve UX of form-user-passwords.php template part.

This change makes sure that the "Generate Password" UI is hidden by default if the browser has JavaScript enabled, and that the traditional UI is visible if JavaScript is not enabled.

It also includes the following related improvements:

  • Introduce bbp_doing_script_debug() and bbp_doing_autosave() helpers, and use them where needed
  • Introduce bbp_asset_version() and bbp_get_asset_version() to bust asset cache when debugging
  • Update forum-user-passwords.php template part to swap out body class and add missing element ID
  • Update password form styling in bbpress.css default theme compat CSS

In branches/2.6 for 2.6.7. See #3421.

Location:
branches/2.6/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/src/includes/admin/classes/class-bbp-admin.php

    r7089 r7189  
    816816        // RTL and/or minified
    817817        $suffix  = is_rtl() ? '-rtl' : '';
    818         $suffix .= defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     818        $suffix .= bbp_doing_script_debug() ? '' : '.min';
    819819
    820820        // Get the version to use for JS
    821         $version = bbp_get_version();
     821        $version = bbp_get_asset_version();
    822822
    823823        // Register admin CSS with dashicons dependency
     
    860860
    861861        // Minified
    862         $suffix  = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     862        $suffix  = bbp_doing_script_debug() ? '' : '.min';
    863863
    864864        // Get the version to use for JS
    865         $version = bbp_get_version();
     865        $version = bbp_get_asset_version();
    866866
    867867        // Header JS
  • branches/2.6/src/includes/admin/forums.php

    r7085 r7189  
    296296
    297297        // Bail if doing an autosave
    298         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
     298        if ( bbp_doing_autosave() ) {
    299299            return $forum_id;
    300300        }
  • branches/2.6/src/includes/admin/replies.php

    r6850 r7189  
    390390
    391391        // Bail if doing an autosave
    392         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
     392        if ( bbp_doing_autosave() ) {
    393393            return $reply_id;
    394394        }
  • branches/2.6/src/includes/admin/topics.php

    r6850 r7189  
    509509
    510510        // Bail if doing an autosave
    511         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
     511        if ( bbp_doing_autosave() ) {
    512512            return $topic_id;
    513513        }
  • branches/2.6/src/includes/common/template.php

    r7077 r7189  
    968968function bbp_body_class( $wp_classes, $custom_classes = false ) {
    969969
    970     $bbp_classes = array();
     970    // Default classes
     971    $bbp_classes = array( 'no-js' );
    971972
    972973    /** Archives **************************************************************/
  • branches/2.6/src/includes/core/functions.php

    r6930 r7189  
    3333
    3434/**
     35 * Output the bbPress asset version
     36 *
     37 * @since 2.6.7 bbPress (r7188)
     38 */
     39function bbp_asset_version() {
     40    echo bbp_get_asset_version();
     41}
     42    /**
     43     * Return the bbPress asset version
     44     *
     45     * @since 2.6.7 bbPress (r7188)
     46     *
     47     * @retrun string The bbPress asset version
     48     */
     49    function bbp_get_asset_version() {
     50        return bbp_doing_script_debug()
     51            ? (string) time()
     52            : bbp_get_version();
     53    }
     54
     55/**
    3556 * Output the bbPress database version
    3657 *
     
    656677    exit();
    657678}
     679
     680/** Global Helpers ************************************************************/
     681
     682/**
     683 * Return if debugging scripts or not
     684 *
     685 * @since 2.6.7 (r7188)
     686 *
     687 * @return bool True if debugging scripts. False if not debugging scripts.
     688 */
     689function bbp_doing_script_debug() {
     690    return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
     691}
     692
     693/**
     694 * Return if auto-saving or not
     695 *
     696 * @since 2.6.7 (r7188)
     697 *
     698 * @return bool True if mid auto-save. False if not mid auto-save.
     699 */
     700function bbp_doing_autosave() {
     701    return defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE;
     702}
  • branches/2.6/src/includes/core/template-functions.php

    r7077 r7189  
    141141
    142142    // Are we debugging?
    143     $script_debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
     143    $script_debug = bbp_doing_script_debug();
    144144
    145145    // Debugging, so prefer unminified files
     
    218218        // Make sure there is always a version
    219219        if ( empty( $ver ) ) {
    220             $ver = bbp_get_version();
     220            $ver = bbp_get_asset_version();
    221221        }
    222222
     
    262262        // Make sure there is always a version
    263263        if ( empty( $ver ) ) {
    264             $ver = bbp_get_version();
     264            $ver = bbp_get_asset_version();
    265265        }
    266266
  • branches/2.6/src/templates/default/bbpress-functions.php

    r6984 r7189  
    4747            'id'      => 'default',
    4848            'name'    => 'bbPress Default',
    49             'version' => bbp_get_version(),
     49            'version' => bbp_get_asset_version(),
    5050            'dir'     => trailingslashit( bbpress()->themes_dir . 'default' ),
    5151            'url'     => trailingslashit( bbpress()->themes_url . 'default' ),
  • branches/2.6/src/templates/default/bbpress/form-user-passwords.php

    r6558 r7189  
    1313// Filters the display of the password fields
    1414if ( apply_filters( 'show_password_fields', true, bbpress()->displayed_user ) ) : ?>
     15
     16<script type="text/javascript">
     17    document.body.className = document.body.className.replace( 'no-js', 'js' );
     18</script>
    1519
    1620<div id="password" class="user-pass1-wrap">
     
    4549<div class="pw-weak">
    4650    <label for="pw_weak"><?php esc_html_e( 'Confirm', 'bbpress' ); ?></label>
    47     <input type="checkbox" name="pw_weak" class="pw-checkbox checkbox" />
     51    <input type="checkbox" name="pw_weak" id="pw_weak" class="pw-checkbox checkbox" />
    4852    <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
    4953</div>
  • branches/2.6/src/templates/default/css/bbpress.css

    r7034 r7189  
    1010
    1111.hidden,
     12.no-js .hide-if-no-js,
    1213.js .hide-if-js {
    1314    display: none;
     
    734735/* Try to prevent untall selects & text boxes */
    735736#bbpress-forums fieldset.bbp-form select,
    736 #bbpress-forums fieldset.bbp-form input[type="text"] {
     737#bbpress-forums fieldset.bbp-form input[type="text"],
     738#bbpress-forums fieldset.bbp-form input[type="password"] {
    737739    min-height: 28px;
    738740    height: 28px;
     
    971973#bbpress-forums #bbp-your-profile fieldset fieldset.password {
    972974    width: 60%;
    973     display: inline;
     975    margin-left: 20%;
     976    margin-top: 10px;
    974977}
    975978
     
    10421045}
    10431046
    1044 #bbpress-forums #password#pass1.bad,
     1047#bbpress-forums #password #pass1.bad,
    10451048#bbpress-forums #password #pass1-text.bad {
    10461049    border-color: #f78b53;
Note: See TracChangeset for help on using the changeset viewer.