Make WordPress Core

Changeset 57615


Ignore:
Timestamp:
02/13/2024 12:05:00 PM (3 months ago)
Author:
costdev
Message:

Plugins: Only set card button status on plugin install pages.

Previously, the setCardButtonStatus() JS function was called when a card had the ID 'plugin-information-footer'. However, the card will only exist on plugin install pages. This caused a failure when updating plugins from the plugin row on plugins.php due to an undefined $card variable.

This adds a guard to ensure that the current page is one of the plugin install pages, preventing the error and allowing plugin updates from the plugins.php rows to work as expected.

Follow-up to [57545].

Props Presskopp, huzaifaalmesbah, krupajnanda, hellofromTonya, krupalpanchal, costdev.
Fixes #60521.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/updates.js

    r57545 r57615  
    479479        var $updateRow, $card, $message, message,
    480480            $adminBarUpdates = $( '#wp-admin-bar-updates' ),
    481             buttonText = __( 'Updating...' );
     481            buttonText = __( 'Updating...' ),
     482            isPluginInstall = 'plugin-install' === pagenow || 'plugin-install-network' === pagenow;
    482483
    483484        args = _.extend( {
     
    494495                $updateRow.find( '.plugin-title strong' ).text()
    495496            );
    496         } else if ( 'plugin-install' === pagenow || 'plugin-install-network' === pagenow ) {
     497        } else if ( isPluginInstall ) {
    497498            $card    = $( '.plugin-card-' + args.slug + ', #plugin-information-footer' );
    498499            $message = $card.find( '.update-now' ).addClass( 'updating-message' );
     
    519520        $document.trigger( 'wp-plugin-updating', args );
    520521
    521         if ( 'plugin-information-footer' === $card.attr('id' ) ) {
     522        if ( isPluginInstall && 'plugin-information-footer' === $card.attr( 'id' ) ) {
    522523            wp.updates.setCardButtonStatus(
    523524                {
Note: See TracChangeset for help on using the changeset viewer.