MF Modal Button
Add a button to open a modal window
by Mario Flores · github.com/umlouco/mfmodalwindow · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/umlouco/mfmodalwindow/archive/refs/heads/main.zipMF Modal Button is a lightweight WordPress plugin that provides shortcodes for opening content inside a modal window.
It supports two use cases:
- Rendering inline WordPress content inside a modal
- Loading an external page inside an iframe modal
The plugin uses Bootstrap styling for layout and ships its own vanilla JavaScript modal controller, so it does not require jQuery.
Included assets
The plugin enqueues:
css/bootstrap.min.csscss/mfmodal.cssjs/mfmodal.js
The custom stylesheet adds:
- link-style defaults for the open trigger and close control
- modal/backdrop stacking fixes so the content stays above the overlay
- basic iframe sizing for iframe-based modals
Shortcodes
mf_modal
Use this shortcode when the modal content is provided directly inside the shortcode body.
Example:
[mf_modal label="Privacy policy" title="Privacy Policy"]
<p>This site processes personal data according to the privacy policy.</p>
[/mf_modal]
Supported attributes:
label: text shown on the trigger element. Default:Opentitle: optional modal heading shown in the header. Default: emptybutton_class: CSS classes applied to the trigger button. Default:mf-modal-triggermodal_width: Bootstrap modal dialog size class such asmodal-lg. Default:modal-lgclose_class: CSS classes applied to the close button. Default:mf-modal-close
Behavior:
- The trigger opens the modal using the plugin's vanilla JavaScript controller
- If
titleis set, the plugin renders anh4in the modal header - The close control displays only the
×symbol by default - Nested shortcodes inside the modal body are processed with
do_shortcode()
mf_modal_iframe
Use this shortcode when the modal should load an external or internal URL in an iframe.
Example:
[mf_modal_iframe label="Privacy policy" title="Privacy Policy" url="https://example.com/privacy-policy/"]
Supported attributes:
url: URL loaded into the iframe when the modal opens. Default: emptylabel: text shown on the trigger element. Default:Opentitle: optional modal heading shown in the header. Default: emptybutton_class: CSS classes applied to the trigger button. Default:mf-modal-triggermodal_width: Bootstrap modal dialog size class such asmodal-lg. Default:modal-lgclose_class: CSS classes applied to the close button. Default:mf-modal-closemodalid: optional unique identifier for the modal instance. Default: generated withuniqid()
Behavior:
- The iframe
srcis set only when the modal is shown - The iframe
srcis cleared when the modal is hidden - This avoids leaving remote content active after the modal closes
Default styling
By default, the plugin styles the trigger and close control like plain text links rather than solid Bootstrap buttons.
Defaults:
- Open trigger:
mf-modal-trigger - Close control:
mf-modal-close
You can override either with shortcode attributes if the theme needs different classes.
Example:
[mf_modal label="Open terms" button_class="btn btn-link" close_class="btn btn-link" title="Terms"]
Content here.
[/mf_modal]
Files
mfmodal.php: registers assets and shortcodesviews/modal.php: template for inline modal contentviews/modaliframe.php: template for iframe modal contentcss/mfmodal.css: plugin-specific modal styling adjustments
Notes
- The plugin does not require jQuery for modal interaction
- The modal header title is optional
- The plugin generates unique modal IDs automatically unless
modalidis passed tomf_modal_iframe