説明
WordPress は、他の人が投稿を編集していることを標準で知らせてくれます。投稿タイトルの下に出る「編集中です」の通知です。しかしこの通知は警告にすぎません。2人目の編集者が「更新」や「公開」をクリックするのを止めることはなく、保存も止まりません。2人が同じ投稿をほぼ同時に編集すると、最後に保存した人が相手の変更を黙って上書きしてしまい、WordPress 本体にはそれを防ぐ仕組みがありません。
ETBS Edit Conflict Guard は、この通知に加えて投稿単位の実効性のある排他ロックを追加します。あるユーザーが投稿を開いて編集している間、他のすべてのユーザーの保存をブロックし、その理由をはっきりと伝えます。
動作の仕組み
- 投稿の編集画面を開くと、その投稿のロックの取得を試みます (先に開いた人がロックを取得します)。
- 編集画面を開いている間、ロックは WordPress 標準の Heartbeat API によって自動的に延長されます。
- Clicking Save Draft, Update, or Publish (Classic Editor or Block Editor) checks the lock. If someone else (including another edit screen of the same account) holds it, the save is blocked and a modal explains why.
- The lock is released when you leave the edit screen, or when Heartbeat stops (for example the tab is closed) and the lock’s expiration time passes. A Classic Editor save also releases it, because the screen reloads. A Block Editor save keeps it, because you keep editing in the same tab.
- Autosaves neither take nor release the lock, and the lock never blocks them.
- ブロックは、旧エディターの投稿保存とブロックエディターの REST 経由の保存の両方について、サーバー側でも実施されます。そのため JavaScript が無効な場合や通信が不安定な場合でも、ロックは有効なままです。
- In the Classic Editor, WordPress’s own “currently editing” dialog no longer offers “Take over” while this plugin holds the lock for another account, because taking over would not move this plugin’s lock. The dialog says who is protecting the post instead.
All post types that have an admin UI are covered by default (attachments are excluded); any of them can be excluded from the Settings screen. The lock check runs at the moment Save/Update/Publish is clicked. Opening the edit screen shows nothing extra, except a notice when the same account already has the post open in another edit screen.
設定
設定 > Edit Conflict Guard で次の項目を変更できます。
- ロックの有効期限 (秒)。
- ロックの対象から除外する投稿タイプ。
- ロック中の投稿のゴミ箱への移動もブロックするかどうか (初期状態はオフ。オンにすると、ロックを取得している本人の別タブからでも、ロック中の投稿のゴミ箱への移動はすべてブロックされます。完全削除は対象外です)。
- 現在ロック中のすべての投稿を表示する一覧表。管理者向けに、行ごとの「強制解除」ボタンが付きます。
既知の制限
Edit Conflict Guard は意図的に厳格な作りになっており、その結果として、あらかじめ知っておいたほうがよい癖がいくつかあります。
- ブロックエディターのゴミ箱通知。 「ゴミ箱へ移動」がブロックされると、サーバーは正しく拒否します (投稿は公開状態のまま) が、ブロックエディター自体は「ゴミ箱へ移動しました」という成功通知を一瞬表示することがあります。これはロックの失敗ではなく、WordPress 本体の表示先行の挙動です。投稿一覧を再読み込みすれば、実際には移動していないことを確認できます。
- 一括でのゴミ箱移動。 ゴミ箱ブロックが有効なとき、投稿一覧からの一括「ゴミ箱へ移動」の対象にロック中の投稿が含まれていると、その投稿で処理が止まり、後続の投稿は未処理のまま残ります。
- 完全削除はゴミ箱ブロックの対象外です。 ゴミ箱ブロックが対象にするのはゴミ箱への移動だけです。ゴミ箱を経由せずに完全削除する操作 (たとえばカスタム投稿タイプに対する XML-RPC の
wp.deletePostは、WordPress 本体がゴミ箱に入れず直接削除します) は、投稿がロック中でもブロックされません。 - マルチサイトには対応していません。 ロックはマルチサイトのネットワーク内の他のサイトを認識せず、サイト間で共有されることもありません。
- Locks apply to the holder too. By design, even the account that holds the lock is blocked from saving the same post from a second tab, window or device. This is deliberate, not a bug. The plugin can tell the lock is held by the same account, but a matching account does not prove it is the same person (accounts are sometimes shared), so both are treated the same way. The message says “the same account” for that reason.
- Autosave is not blocked. WordPress core usually keeps an autosave away from the post itself by storing it as a separate, per-user revision. Two cases are different: a draft’s own author autosaving that draft, and one account having the same draft open in two tabs. There, the autosave writes to the draft directly, so it can overwrite what someone else saved — including while this plugin’s lock is held by another user. WordPress 7.0 and later narrows this by checking WordPress’s own edit lock first; earlier versions do not check it at all. The notice shown when a second tab opens asks you not to keep editing there, which avoids the two-tab case.
- Block Editor “Take over” button. WordPress’s own “Take over” button in the Block Editor cannot be removed by a plugin. Taking over moves WordPress’s lock but not this plugin’s, so saving stays blocked until the other editor closes their screen or an administrator force-releases the lock.
- Saves made without WP_ADMIN defined are not blocked. WP-Cron, WP-CLI, XML-RPC and front-end code that calls
wp_update_post()directly are let through, because they cannot show a message and would otherwise fail on visitors’ screens. Note thatadmin-post.phpandadmin-ajax.phpdefineWP_ADMINthemselves, so a front-end form that posts to either one is still blocked while the sender is logged in. A save made by a logged-out visitor is let through even there, because a logged-out request is exempt as well. Saves through the REST API and the admin screens (including Quick Edit and bulk edit) are still checked.
スクリーンショット







インストール
- プラグインのファイルを
/wp-content/plugins/etbs-edit-conflict-guardディレクトリにアップロードするか、WordPress のプラグイン画面から直接インストールします。 - WordPress の「プラグイン」画面からプラグインを有効化します。
- 設定 > Edit Conflict Guard を開き、ロックの有効期限、対象から除外する投稿タイプ、ゴミ箱への移動をロック対象にするかどうかを確認します。
FAQ
-
WordPress が標準で表示する「他のユーザーが編集中です」の通知とは何が違うのですか ?
-
That built-in notice is informational only; it does not stop a second user from saving. This plugin adds an actual block: if someone else holds the lock, clicking Save/Update/Publish is refused and the user sees a modal explaining why (in Quick Edit the same reason appears inline instead), rather than silently overwriting the other person’s changes.
-
ロックが残ったままのようです。どうすれば解除できますか ?
-
ロックを取得しているユーザーの編集画面から Heartbeat が届かないまま有効期限 (設定 > Edit Conflict Guard で指定) が過ぎると、ロックは自動的に解除されます。保存せずにブラウザーのタブを閉じた場合などです。すぐに解除したい場合は、管理者が設定 > Edit Conflict Guard を開き、「現在ロック中の投稿」の表でその投稿の行にある「強制解除」ボタンを使ってください。
-
このプラグインはマルチサイトで動作しますか ?
-
現時点では対応していません。ロックはサイト単位で、マルチサイトのネットワーク内で他のサイトのロックを認識することはありません。
-
ゴミ箱への移動をブロックしたのに、画面には「ゴミ箱へ移動しました」と表示されました。失敗したのでしょうか ?
-
いいえ、投稿は移動していません。これはブロックエディターでのみ起こります。WordPress 本体はサーバーからの応答が届く前に成功の通知を表示しますが、サーバー側ではすでにリクエストを拒否しています。投稿一覧を再読み込みすると、投稿が元の状態のままであることを確認できます。
-
ロックを取得している本人が、自分でロックに引っかかることはありますか ?
-
Yes, deliberately. If the same account opens the same post in a second tab, window or device, the second one is blocked from saving just like any other user would be. The plugin can tell the two belong to the same account, but that does not prove it is the same person, so it applies the same rule to everyone. Close the other edit screen and save again.
評価
このプラグインにはレビューがありません。
貢献者と開発者
変更履歴
1.2.1
- Fixed: in the Block Editor, anything entered in meta boxes (SEO fields, custom fields and other classic-style panels added by plugins) was not saved, and no error was shown. This happened on every save of a post type this plugin protects, and started in 1.2.0. The title and content were saved normally. Please re-enter anything that was lost.
1.2.0
- Fixed: an autosave no longer releases the lock, which left the post unprotected without any sign.
- Fixed: saving in the Block Editor no longer leaves the post unprotected for the rest of the editing session.
- Fixed: the Classic Editor’s autosave no longer fails silently while you hold the lock.
- Fixed: the Block Editor’s autosave no longer reports success without saving anything.
- Fixed: saves made where no message can be shown (WP-Cron, WP-CLI, XML-RPC, requests from logged-out visitors, and front-end code calling wp_update_post() directly) are no longer stopped with an error screen.
- Fixed: the predecessor plugin (EditLock) is now detected even when its folder has been renamed.
- Changed: when a second tab of the same account blocks a save, the message now says so and what to do. It also appears when the second tab opens.
- Changed: the save-blocked dialog is reworded and has an accessible name.
- Fixed: in the Classic Editor, “Publish” on a draft now actually publishes it. It used to save the post as a draft while reporting that the post had been updated.
- Fixed: Quick Edit now shows the reason when a save is blocked, instead of leaving the spinner running.
- Changed: the Classic Editor’s “Take over” button is hidden while another account holds this plugin’s lock.
- Changed: lock ownership is now determined more strictly.
1.1.1
- 日本語翻訳を同梱しました。translate.wordpress.org から配信される翻訳が利用できる場合は、そちらが優先されます。
1.1.0
- プラグイン名を ETBS Edit Conflict Guard に変更しました。
- 画面上のすべての文字列を英語にし、翻訳は同梱ファイルではなく translate.wordpress.org で扱うようにしました。
- 同梱していた更新チェッカー (plugin-update-checker) を削除しました。
- ダッシュボードウィジェットを削除しました。
- プラグイン一覧の行から支援のリンクを削除しました。
- 設定画面のインラインのスクリプトとスタイルを、読み込み用のアセットファイルに移しました。
- 旧版と同時にインストールしても致命的なエラーにならないように、このプラグインの PHP クラス名と定数名を変更しました。設定のキーとロックテーブルは変更していないため、既存の設定はそのまま引き継がれます。
- ロックテーブルと後片付け用のタスクが失われている場合、自動的に復元するようにしました。
1.0.3
- 修正: プラグインを削除しても、設定した内容 (ロックの有効期限、対象から除外する投稿タイプ) が消えないようにしました。削除されるのは、このプラグイン自身の一時的なロックデータと、後片付け用の定期実行イベントだけです。
1.0.2
- 「Requires at least」 (WordPress の最低バージョン) の宣言を削除しました。このプラグインが使用する API について、検証済みの最低バージョンが存在しないためです。
1.0.1
- 宣言している「Requires PHP」を8.3から7.4に下げました。
- プラグイン一覧の行と設定画面のフッターに、「カスタマイズのご依頼」・支援のリンクを追加しました。
1.0.0
- 初回リリース。
