welcome-notice.js: the dismiss callback is sent as POST data, and `attr( 'disabled', true )` warns on WordPress 7.2

Offen Anfängerfreundlich
#122 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
1/5
Geschätzter Aufwand
Unter einer Stunde
Anfängerfreundlichkeit
92/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
javascript, jquery
Bereich
frontend

Rechercherichtung

Öffne assets/js/src/welcome-notice.js: Die Dismiss-Anfrage wird um die Zeilen 61–65 herum aufgebaut, und der Install-Button wird um Zeile 48 herum deaktiviert. Verschiebe success: hideAndRemoveNotice aus dem $.post-Datenobjekt und hänge es mit .done( hideAndRemoveNotice ) an, dann ändere installBtn.attr( 'disabled', true ) zu .prop( 'disabled', true ). Zur Überprüfung lade den Willkommenshinweis mit aktiviertem SCRIPT_DEBUG und schließe ihn, wobei du prüfst, dass der Hinweis erst verschwindet, nachdem die Anfrage erfolgreich war, und dass jQuery Migrate nicht mehr warnt, wenn auf Install & Activate Otter Blocks geklickt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

What's wrong

Two small problems in assets/js/src/welcome-notice.js. Neither breaks the notice today.

  1. Dismiss. Lines 61–65:

    $.post( ajaxUrl, {
    	nonce,
    	action: 'fork_dismiss_welcome_notice',
    	success: hideAndRemoveNotice,
    } );
    

    success is inside the data object, not passed as a callback. When jQuery serializes data it calls any function it finds, so hideAndRemoveNotice() runs immediately when the request is built, and the request carries an empty success= field. As a result, the notice disappears even if the dismissal is not saved (for example after an expired nonce), and then comes back on the next page load. Found by reading the code.

  2. Disabled button. Line 48, installBtn.attr( 'disabled', true );. With SCRIPT_DEBUG on, WordPress 7.2's jQuery Migrate 3.6 logs JQMIGRATE: Boolean attribute 'disabled' is not set to its lowercased name when Install & Activate Otter Blocks is clicked. Seen on 7.2-RC2; the install still completes. WordPress plans to move to jQuery 4 in 7.3.

Suggested fix
$.post( ajaxUrl, { nonce, action: 'fork_dismiss_welcome_notice' } ).done( hideAndRemoveNotice );

and installBtn.prop( 'disabled', true );.

Vorherrschende Sprache
PHP
Sterne
0
Forks
0
Ø Merge
1 Std. 2 Min.
Gemergte PRs (30 T.)
5

Entwicklungsumgebung

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Codeinwp/fork

Alle Issues in Codeinwp/fork

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.