You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(popup): add close-esc-key parameter to control ESC key behavior
- Add new close-esc-key parameter with boolean control
- Implement JavaScript ESC key prevention logic
- Enhance README with comprehensive opening/closing examples
- Restructure documentation for better usability
- Add acknowledgment of Micromodal.js dependency
- Bump version to 1.1.0
@@ -10,6 +10,8 @@ WordPress plugin that provides shortcode for creating popups.
10
10
11
11
Kntnt Popup is a lightweight, customizable WordPress plugin that provides an easy-to-use shortcode for creating modal popups on your website. With this plugin, you can create popups triggered by various user actions without writing any JavaScript or HTML code.
12
12
13
+
This plugin is built on top of [Micromodal.js](https://micromodal.vercel.app/) by Indrashish Ghosh, a powerful and accessible micro modal library. We extend our sincere gratitude to the Micromodal.js project and its contributors for providing such an excellent foundation for creating accessible modal dialogs.
14
+
13
15
### Key Features:
14
16
15
17
- Simple shortcode implementation with extensive customization options
@@ -36,31 +38,161 @@ The plugin provides a shortcode `[popup]...[/popup]` where the content between t
36
38
Basic usage:
37
39
38
40
```
39
-
[popup show-after-time="5"]Your popup content here. Can include text, images, forms, and even other shortcodes.[/popup]
41
+
[popup modal show-after-time=3 close-button close-outside-click close-esc-key]This is a typical pop-up.[/popup]
42
+
```
43
+
44
+
Here's a sophisticated popup that combines multiple opening triggers and closing methods:
<li>Or by <a data-popup-close>clicking this link</a></li>
61
+
</ul>
62
+
[/popup]
63
+
```
64
+
65
+
This example creates a modal popup that will appear when ANY of the three trigger conditions are met (whichever happens first). Users can then close it using any of the four available methods, providing maximum flexibility and user control.
66
+
67
+
## Triggers
68
+
69
+
Kntnt Popup offers multiple ways to control when and how popups appear and disappear. You can use automatic triggers, manual controls, or combine multiple methods to create the perfect user experience.
70
+
71
+
### Time-based trigger
72
+
73
+
**Delayed display:** Show a popup after a specified number of seconds:
74
+
```
75
+
[popup show-after-time="10"]This popup appears after 10 seconds.[/popup]
76
+
```
77
+
78
+
**Immediate display:** Show a popup as soon as the page loads:
79
+
```
80
+
[popup show-after-time="0"]This popup appears immediately when the page loads.[/popup]
81
+
```
82
+
83
+
### Scroll-based trigger
84
+
85
+
Show a popup when the user has scrolled a certain percentage of the page:
86
+
```
87
+
[popup show-after-scroll="75"]This popup appears when you've scrolled 75% of the page.[/popup]
40
88
```
41
89
42
-
In addition to the automatic triggers (time delay, scroll position, exit intent), you can also launch a popup by clicking any HTML element (like a link or button) on the page.
90
+
### Exit intent trigger
91
+
92
+
Trigger a popup when the user moves their mouse cursor toward the browser's address bar or tab area, indicating they might be about to leave:
93
+
```
94
+
[popup show-on-exit-intent]Wait! Don't leave yet. Check out this special offer![/popup]
95
+
```
43
96
44
-
1.**Define the popup:** First, you must have defined the popup on the same page using the shortcode with a unique ID:
97
+
*Note: Exit intent only works on desktop/laptop devices with a mouse cursor.*
98
+
99
+
### Clickable triggers
100
+
101
+
1.**Define the popup:** First, create a popup with a unique ID:
<p>Get weekly updates delivered to your inbox.</p>
106
+
[/popup]
107
+
```
108
+
109
+
2.**Create trigger elements:** Add the `data-popup-open` attribute to any HTML element to make it open the popup:
110
+
111
+
**Text link:**
112
+
```html
113
+
<ahref="#"data-popup-open="newsletter-signup">Subscribe to our newsletter</a>
47
114
```
48
115
49
-
2.**Create the trigger element (link/button):** Next, add an HTML element where you want your trigger. This element must have the data attribute `data-popup-open` set to the ID of the popup you want to open.
116
+
**Button:**
117
+
```html
118
+
<buttondata-popup-open="newsletter-signup">Sign Up Now</button>
119
+
```
50
120
51
-
**Example using a link:**
121
+
**Image:**
52
122
```html
53
-
<ahref="#"data-popup-open="my-unique-popup">Open My Popup</a>
123
+
<imgsrc="signup-banner.jpg"data-popup-open="newsletter-signup"alt="Click to subscribe">
54
124
```
55
125
56
-
**Example using a button:**
126
+
**Any element:**
57
127
```html
58
-
<buttondata-popup-open="my-unique-popup">Open My Popup</button>
In this example, the popup will appear when the user tries to leave the page, OR after 15 seconds, OR after scrolling 60% of the page - whichever happens first. It will be centered with a width of 600px, have a dark blue overlay, display a close button, prevent background scrolling, and use fade animations.
652
+
In this example, the popup will appear when the user tries to leave the page, OR after 15 seconds, OR after scrolling 60% of the page - whichever happens first. It will be centered with a width of 600px, have a dark blue overlay, display a close button, allow ESC key closing, prevent background scrolling, and use fade animations.
504
653
505
654
### Examples
506
655
@@ -720,6 +869,13 @@ If you are not familiar with Git, please create a new ticket on the plugin's iss
720
869
721
870
## Changelog
722
871
872
+
## 1.1.0 (2025-05-23)
873
+
874
+
- feature: add new `close-esc-key` parameter to control whether ESC key closes the popup
875
+
- enhance: improve documentation with better examples and clearer usage instructions
876
+
- enhance: add acknowledgment of Micromodal.js library
877
+
- improve: reorganize README structure for better navigation
878
+
723
879
## 1.0.2 (2025-05-23)
724
880
725
881
- fix: resolve JavaScript initialization timing issue that prevented popups from working
@@ -730,7 +886,7 @@ If you are not familiar with Git, please create a new ticket on the plugin's iss
0 commit comments