Confirmation dialog in WordPress
A small window asking to confirm an action before running it.
Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.
This component also comes in
The code in WordPress
<?php
/**
* Plugin Name: Forge, Fenêtre de confirmation
* Description: Une petite fenêtre qui demande de confirmer une action avant de l'exécuter. Ajoute la composition « Fenêtre de confirmation » à l'éditeur de blocs.
* Version: 1.0.0
* Requires at least: 6.6
* Requires PHP: 8.1
* Author: Forge
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: forge-modale-confirmation
*<!-- wp:html -->
<button type="button" class="trigger" data-dialog-open="confirm-dialog">Annuler ma réservation</button>
<!-- /wp:html -->
<!-- wp:html -->
<dialog id="confirm-dialog" aria-labelledby="confirm-title" aria-describedby="confirm-text">
<form method="dialog" class="confirm">
<h2 id="confirm-title">Annuler la réservation du 18 octobre ?</h2>
<p id="confirm-text">Votre table pour quatre personnes sera libérée. Vous pourrez réserver à nouveau à tout moment.</p>
<div class="confirm__actions">
<button type="submit" value="keep" class="confirm__secondary">Garder ma réservation</button>
<button type="submit" value="cancel" class="confirm__primary">Annuler la réservation</button>(() => {
if (!document.querySelector(".trigger")) return;
document.querySelectorAll("[data-dialog-open]").forEach((button) => {
const dialog = document.getElementById(button.dataset.dialogOpen);
button.addEventListener("click", () => dialog.showModal());
});
document.querySelectorAll("dialog").forEach((dialog) => {
dialog.addEventListener("click", (event) => {
if (event.target === dialog) dialog.close();
});
dialog.querySelectorAll("[data-dialog-close]").forEach((button) => {:root {
--modal-bg: #ffffff;
--modal-text: #0f172a;
--modal-muted: #475569;
--modal-line: #cbd5e1;
--modal-accent: #1d4ed8;
--modal-accent-text: #ffffff;
--modal-ring: #1d4ed8;
--demo-modale-confirmation-bg: #f1f5f9;
--demo-modale-confirmation-text: #0f172a;
}
Free component: copy it freely, including for commercial projects.
Other modals components in WordPress
Modals components in WordPress
Age verification
FreeA legal-age check window for a wine shop or brewery, accessible, remembered for the session and with the French Evin law notices.
- Tailwind
- React
- CSS
- WordPress

A search covering the page, with popular suggestions, opened from the navigation bar.
- Tailwind
- React
- CSS
- WordPress

A short form in a window to request a call from an advisor.
- Tailwind
- React
- CSS
- WordPress