Make WordPress Core

Changeset 52713


Ignore:
Timestamp:
02/11/2022 10:09:35 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Make sure the "Show hidden updates" button is visible and works as expected.

The .toggle( handler, handler ) method signature was deprecated in jQuery 1.8 and removed in jQuery 1.9.

This commit updates the click handler function to work with jQuery 1.9+.

Follow-up to [9441], [9543], [42785], [48323].

Props malinevskiy, Boniu91, SergeyBiryukov.
Merges [52644] to the 5.9 branch.
Fixes #54886.

Location:
branches/5.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/src/wp-admin/update-core.php

    r52203 r52713  
    207207        )
    208208    );
     209
    209210    if ( $dismissed ) {
    210 
    211211        $show_text = esc_js( __( 'Show hidden updates' ) );
    212212        $hide_text = esc_js( __( 'Hide hidden updates' ) );
    213213        ?>
    214     <script type="text/javascript">
    215         jQuery(function( $ ) {
    216             $( 'dismissed-updates' ).show();
    217             $( '#show-dismissed' ).toggle( function() { $( this ).text( '<?php echo $hide_text; ?>' ).attr( 'aria-expanded', 'true' ); }, function() { $( this ).text( '<?php echo $show_text; ?>' ).attr( 'aria-expanded', 'false' ); } );
    218             $( '#show-dismissed' ).click( function() { $( '#dismissed-updates' ).toggle( 'fast' ); } );
    219         });
    220     </script>
     214        <script type="text/javascript">
     215            jQuery( function( $ ) {
     216                $( '#show-dismissed' ).on( 'click', function() {
     217                    var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) );
     218
     219                    if ( isExpanded ) {
     220                        $( this ).text( '<?php echo $show_text; ?>' ).attr( 'aria-expanded', 'false' );
     221                    } else {
     222                        $( this ).text( '<?php echo $hide_text; ?>' ).attr( 'aria-expanded', 'true' );
     223                    }
     224
     225                    $( '#dismissed-updates' ).toggle( 'fast' );
     226                });
     227            });
     228        </script>
    221229        <?php
    222230        echo '<p class="hide-if-no-js"><button type="button" class="button" id="show-dismissed" aria-expanded="false">' . __( 'Show hidden updates' ) . '</button></p>';
Note: See TracChangeset for help on using the changeset viewer.