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

オープン 初心者向け
#122 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
92/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, jquery
領域
frontend

調査の方向性

assets/js/src/welcome-notice.js を開いてください。dismiss リクエストは 61–65 行目あたりで構築され、インストールボタンは 48 行目あたりで無効化されています。success: hideAndRemoveNotice を $.post のデータオブジェクトから移動し、.done( hideAndRemoveNotice ) でアタッチしてください。次に installBtn.attr( 'disabled', true ) を .prop( 'disabled', true ) に切り替えます。確認するには、SCRIPT_DEBUG を有効にしてウェルカム通知を読み込み、それを閉じ、リクエストが成功した後にのみ通知が消えること、および Install & Activate Otter Blocks をクリックしたときに jQuery Migrate が警告しなくなったことを確認してください。

索引モデルが issue の本文から書いたものです。

説明

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 );.

主要言語
PHP
スター
0
フォーク
0
平均マージ
1時間 2分
マージ済み PR(30日)
5

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Codeinwp/fork のほかの issue

Codeinwp/fork の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。