Skip to content

Commit 00b4633

Browse files
committed
churn: fixes
1 parent 47a40c1 commit 00b4633

File tree

2 files changed

+123
-112
lines changed

2 files changed

+123
-112
lines changed

README.md

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Kntnt Popup
2+
23
[![License: GPL v2+](https://img.shields.io/badge/License-GPLv2+-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
34
[![Requires PHP: 8.2+](https://img.shields.io/badge/PHP-8.2+-blue.svg)](https://php.net)
45
[![Requires WordPress: 6.8+](https://img.shields.io/badge/WordPress-6.8+-blue.svg)](https://wordpress.org)
@@ -10,6 +11,7 @@ WordPress plugin that provides shortcode for creating popups.
1011
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.
1112

1213
### Key Features:
14+
1315
- Simple shortcode implementation with extensive customization options
1416
- Multiple trigger options: exit intent, time delay, scroll position
1517
- Customizable animations for opening and closing
@@ -21,21 +23,45 @@ Kntnt Popup is a lightweight, customizable WordPress plugin that provides an eas
2123
- Built with modern PHP and JavaScript practices
2224

2325
## Installation
26+
2427
1. [Download the plugin zip archive.](https://github.com/Kntnt/kntnt-popup/releases/latest/download/kntnt-popup.zip)
2528
2. Go to WordPress admin panel → Plugins → Add New.
2629
3. Click "Upload Plugin" and select the downloaded zip archive.
2730
4. Activate the plugin.
2831

2932
## Usage
33+
3034
The plugin provides a shortcode `[popup]...[/popup]` where the content between the opening and closing tags will be displayed in the popup. This content is processed normally, meaning you can include text, images, HTML, and even other shortcodes inside the popup.
3135

3236
Basic usage:
37+
3338
```
34-
[popup show-after-time="5"]
35-
Your popup content here. Can include text, images, forms, and even other shortcodes.
36-
[/popup]
39+
[popup show-after-time="5"]Your popup content here. Can include text, images, forms, and even other shortcodes.[/popup]
3740
```
3841

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.
43+
44+
1. **Define the popup:** First, you must have defined the popup on the same page using the shortcode with a unique ID:
45+
```
46+
[popup id="my-unique-popup"]Popup content…[/popup]
47+
```
48+
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.
50+
51+
**Example using a link:**
52+
```html
53+
<a href="#" data-popup-open="my-unique-popup">Open My Popup</a>
54+
```
55+
56+
**Example using a button:**
57+
```html
58+
<button data-popup-open="my-unique-popup">Open My Popup</button>
59+
```
60+
61+
When a user clicks the element with `data-popup-open`, the plugin's JavaScript will automatically open the corresponding popup.
62+
63+
*Important:* Both the popup shortcode and the HTML element with `data-popup-open` must exist on the same page.
64+
3965
## Parameters
4066

4167
The shortcode accepts various parameters to customize the popup's behavior and appearance. Parameters can be used in three different ways:
@@ -61,6 +87,7 @@ Controls whether the popup shows when the user moves their cursor to leave the p
6187
*Default value:* `false`
6288

6389
*Examples:*
90+
6491
* `[popup shown-on-exit-intent="true"]`: Triggers popup when user attempts to leave the page
6592
* `[popup shown-on-exit-intent]`: Same as above since flag value is `true`
6693
* `[popup]`: Won't trigger popup when user attempts to leave the page since default value is `false`
@@ -78,6 +105,7 @@ Controls whether the popup shows after a specified number of seconds.
78105
*Note:* This parameter expects a numeric value without units, representing seconds.
79106

80107
*Examples:*
108+
81109
* `[popup show-after-time="5"]`: Triggers popup after 5 seconds
82110
* `[popup show-after-time]`: Triggers popup after 30 seconds (flag value)
83111
* `[popup]`: Won't trigger popup based on time since default value is `false`
@@ -95,6 +123,7 @@ Controls whether the popup shows after the user has scrolled a certain percentag
95123
*Note:* This parameter expects a numeric value without units, representing percentage (0-100).
96124

97125
*Examples:*
126+
98127
* `[popup show-after-scroll="50"]`: Triggers popup after scrolling 50% of the page
99128
* `[popup show-after-scroll]`: Triggers popup after scrolling 80% of the page (flag value)
100129
* `[popup]`: Won't trigger popup based on scrolling since default value is `false`
@@ -112,6 +141,7 @@ Sets a custom ID attribute for the popup's wrapper div.
112141
*Default value:* Automatically generated ID
113142

114143
*Examples:*
144+
115145
* `[popup id="newsletter-popup"]`: Sets the popup ID to "newsletter-popup"
116146
* `[popup]`: Assigns an automatically generated ID
117147

@@ -126,6 +156,7 @@ Adds custom CSS classes to the popup element.
126156
*Default value:* None (no additional classes)
127157

128158
*Examples:*
159+
129160
* `[popup class="custom-theme large-popup"]`: Adds "custom-theme" and "large-popup" classes
130161
* `[popup]`: No additional CSS classes
131162

@@ -140,6 +171,7 @@ Adds inline CSS for the overlay element.
140171
*Default value:* None (no inline styles)
141172

142173
*Examples:*
174+
143175
* `[popup style-overlay="backdrop-filter: blur(5px);"]`: Adds a blur effect to the overlay
144176
* `[popup]`: No additional inline styles for the overlay
145177

@@ -154,6 +186,7 @@ Adds inline CSS for the dialog element.
154186
*Default value:* None (no inline styles)
155187

156188
*Examples:*
189+
157190
* `[popup style-dialog="box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);"]`: Adds shadow
158191
* `[popup]`: No additional inline styles for the dialog
159192

@@ -168,6 +201,7 @@ Adds inline CSS for the close button element.
168201
*Default value:* None (no inline styles)
169202

170203
*Examples:*
204+
171205
* `[popup style-close-button="font-size: 24px; color: #ff0000;"]`: Creates a larger, red close button
172206
* `[popup style-close-button="background-color: #333; border-radius: 50%; color: white;"]`: Creates a dark circular close button
173207
* `[popup]`: No additional inline styles for the close button
@@ -183,10 +217,11 @@ Adds inline CSS for the popup content area.
183217
*Default value:* None (no inline styles)
184218

185219
*Examples:*
220+
186221
* `[popup style-content="color: #333; font-size: 16px;"]`: Styles text in the popup content
187222
* `[popup style-content="background-color: #f9f9f9; padding: 10px;"]`: Adds background and padding to content area
188223
* `[popup]`: No additional inline styles for the content area
189-
224+
190225
### Layout and Positioning Parameters
191226

192227
#### `position`
@@ -200,6 +235,7 @@ Determines the popup position on the screen.
200235
*Default value:* `center`
201236

202237
*Examples:*
238+
203239
* `[popup position="top"]`: Positions the popup at the top center
204240
* `[popup position="bottom-right"]`: Positions the popup at the bottom right
205241
* `[popup]`: Centers the popup (default position)
@@ -217,6 +253,7 @@ Sets the desired width of the popup.
217253
*Default value:* `clamp(300px, 90vw, 800px)`
218254

219255
*Examples:*
256+
220257
* `[popup width="500px"]`: Sets popup width to 500 pixels
221258
* `[popup width="50%"]`: Sets popup width to 50% of viewport width
222259
* `[popup]`: Uses the default responsive width
@@ -232,6 +269,7 @@ Sets the maximum height of the popup before scrolling is activated.
232269
*Default value:* `95vh`
233270

234271
*Examples:*
272+
235273
* `[popup max-height="80vh"]`: Sets maximum height to 80% of viewport height
236274
* `[popup max-height="600px"]`: Sets maximum height to 600 pixels
237275
* `[popup]`: Uses the default maximum height (95% of viewport)
@@ -247,6 +285,7 @@ Sets the internal padding of the popup.
247285
*Default value:* `clamp(20px, calc(5.2vw - 20px), 160px)`
248286

249287
*Examples:*
288+
250289
* `[popup padding="30px"]`: Sets padding to 30 pixels on all sides
251290
* `[popup padding="20px 40px"]`: Sets vertical padding to 20px and horizontal to 40px
252291
* `[popup]`: Uses the default responsive padding
@@ -262,6 +301,7 @@ Sets the color of the overlay behind the popup.
262301
*Default value:* `rgba(0,0,0,80%)`
263302

264303
*Examples:*
304+
265305
* `[popup overlay-color="rgba(0,0,50,70%)"]`: Sets a semi-transparent dark blue overlay
266306
* `[popup overlay-color="#000000cc"]`: Sets a semi-transparent black overlay
267307
* `[popup]`: Uses the default semi-transparent black overlay
@@ -279,6 +319,7 @@ Displays a close button with the specified character.
279319
*Default value:* `false`
280320

281321
*Examples:*
322+
282323
* `[popup close-button="×"]`: Shows a close button with the × character
283324
* `[popup close-button]`: Shows a close button with the default ✖ character
284325
* `[popup]`: No close button is displayed
@@ -294,6 +335,7 @@ Determines whether clicking outside the popup area closes it.
294335
*Default value:* `false`
295336

296337
*Examples:*
338+
297339
* `[popup close-outside-click="true"]`: Clicking outside the popup closes it
298340
* `[popup close-outside-click]`: Same as above (using flag value)
299341
* `[popup]`: Clicking outside doesn't close the popup
@@ -309,6 +351,7 @@ Controls whether the popup behaves as a modal dialog.
309351
*Default value:* `false`
310352

311353
*Examples:*
354+
312355
* `[popup modal="true"]`: Creates a modal popup (focus trapped, background scrolling prevented, overlay added)
313356
* `[popup modal]`: Same as above (using flag value)
314357
* `[popup]`: Creates a non-modal popup (focus not trapped, background scrolling not prevented, overlay not added)
@@ -326,12 +369,14 @@ Controls how long before the popup can appear again after being closed.
326369
*Note:* This parameter is converted to seconds internally. For example, "30s" becomes 30 seconds, "2h" becomes 7,200 seconds, etc.
327370

328371
*Examples:*
372+
329373
* `[popup reappear-delay="4h"]`: Popup won't reappear for 4 hours after being closed
330374
* `[popup reappear-delay="30s"]`: Popup won't reappear for 30 seconds after being closed
331375
* `[popup reappear-delay]`: Popup won't reappear for 1 day after being closed (flag value)
332376
* `[popup]`: Popup can reappear immediately after being closed
333377

334378
Time values can use these units:
379+
335380
- No unit or `s`: seconds (e.g., `30` or `30s`)
336381
- `m`: minutes (e.g., `5m`)
337382
- `h`: hours (e.g., `2h`)
@@ -350,6 +395,7 @@ Sets the animation used when the popup appears.
350395
*Default value:* `false` (no animation)
351396

352397
*Examples:*
398+
353399
* `[popup open-animation="fade-in"]`: Popup fades in when appearing
354400
* `[popup open-animation="slide-in-top"]`: Popup slides in from the top
355401
* `[popup open-animation]`: Uses the tada animation (flag value)
@@ -368,6 +414,7 @@ Sets the animation used when the popup closes.
368414
*Default value:* `false` (no animation)
369415

370416
*Examples:*
417+
371418
* `[popup close-animation="fade-out-top"]`: Popup fades out toward the top when closing
372419
* `[popup close-animation="slide-out-bottom"]`: Popup slides out to the bottom
373420
* `[popup close-animation]`: Popup fades out (flag value)
@@ -388,6 +435,7 @@ Overrides the default duration of the open animation.
388435
*Note:* This parameter expects a numeric value representing milliseconds.
389436

390437
*Examples:*
438+
391439
* `[popup open-animation="fade-in" open-animation-duration="500"]`: Fade in animation lasts 500ms
392440
* `[popup open-animation="slide-in-top"]`: Uses the default duration for slide-in-top
393441

@@ -404,6 +452,7 @@ Overrides the default duration of the close animation.
404452
*Note:* This parameter expects a numeric value representing milliseconds.
405453

406454
*Examples:*
455+
407456
* `[popup close-animation="fade-out" close-animation-duration="300"]`: Fade out animation lasts 300ms
408457
* `[popup close-animation="slide-out-bottom"]`: Uses the default duration for slide-out-bottom
409458

@@ -420,6 +469,7 @@ Sets the ARIA label for the popup element.
420469
*Default value:* `"Popup"` (localized if translations are available)
421470

422471
*Examples:*
472+
423473
* `[popup aria-label-popup="Newsletter Signup"]`: Sets a custom ARIA label
424474
* `[popup]`: Uses the default "Popup" label (translated if available)
425475

@@ -434,6 +484,7 @@ Sets the ARIA label for the close button.
434484
*Default value:* `"Close popup"` (localized if translations are available)
435485

436486
*Examples:*
487+
437488
* `[popup aria-label-close="Dismiss newsletter"]`: Sets a custom ARIA label for close button
438489
* `[popup]`: Uses the default "Close popup" label (translated if available)
439490

@@ -454,6 +505,7 @@ In this example, the popup will appear when the user tries to leave the page, OR
454505
### Examples
455506

456507
Show a popup after 5 seconds with a close button:
508+
457509
```
458510
[popup show-after-time="5" close-button]
459511
<h2>Welcome to our site!</h2>
@@ -462,6 +514,7 @@ Show a popup after 5 seconds with a close button:
462514
```
463515

464516
Show a popup on exit intent with custom width and position:
517+
465518
```
466519
[popup shown-on-exit-intent width="400px" position="top"]
467520
<h2>Wait before you go!</h2>
@@ -470,6 +523,7 @@ Show a popup on exit intent with custom width and position:
470523
```
471524

472525
Show a popup after scrolling 50% with fade-in animation:
526+
473527
```
474528
[popup show-after-scroll="50" open-animation="fade-in" close-outside-click]
475529
<h2>You're halfway there!</h2>
@@ -478,6 +532,7 @@ Show a popup after scrolling 50% with fade-in animation:
478532
```
479533

480534
Show a popup containing a contact form (using Contact Form 7 shortcode as an example):
535+
481536
```
482537
[popup show-after-time="10" close-button position="center" width="600px"]
483538
<h2>Contact Us!</h2>
@@ -493,7 +548,9 @@ The plugin provides a few hooks for developers to customize the popup behavior:
493548
### WordPress Filters:
494549

495550
#### `kntnt-popup-shortcode-atts`
551+
496552
Modifies shortcode attributes before they're processed.
553+
497554
```php
498555
add_filter('kntnt-popup-shortcode-atts', function($attributes) {
499556
// Modify attributes based on conditions
@@ -505,7 +562,9 @@ add_filter('kntnt-popup-shortcode-atts', function($attributes) {
505562
```
506563

507564
#### `kntnt-popup-content`
565+
508566
Filters the popup content before it's displayed.
567+
509568
```php
510569
add_filter('kntnt-popup-content', function($content, $popup_id) {
511570
// Personalize content for logged-in users
@@ -518,7 +577,9 @@ add_filter('kntnt-popup-content', function($content, $popup_id) {
518577
```
519578

520579
#### `kntnt-popup-armed`
580+
521581
Determines whether a popup should be shown at all.
582+
522583
```php
523584
add_filter('kntnt-popup-armed', function($armed) {
524585
// Disable popups for administrators
@@ -534,7 +595,9 @@ add_filter('kntnt-popup-armed', function($armed) {
534595
```
535596

536597
#### `kntnt-popup-shortcode`
598+
537599
Filters the entire popup HTML output.
600+
538601
```php
539602
add_filter('kntnt-popup-shortcode', function($output, $atts, $content) {
540603
// Modify the final HTML
@@ -549,22 +612,26 @@ add_filter('kntnt-popup-shortcode', function($output, $atts, $content) {
549612
Event listeners should be added before the popup is initialized:
550613
551614
#### `kntnt_popup:before_open`
615+
552616
Triggered before a popup is opened.
617+
553618
```javascript
554-
document.addEventListener('kntnt_popup:before_open', function(event) {
619+
document.addEventListener('kntnt_popup:before_open', function (event) {
555620
// Pause videos when popup opens
556-
document.querySelectorAll('video').forEach(function(video) {
621+
document.querySelectorAll('video').forEach(function (video) {
557622
video.pause();
558623
});
559624
});
560625
```
561626
562627
#### `kntnt_popup:after_close`
628+
563629
Triggered after a popup is closed.
630+
564631
```javascript
565-
document.addEventListener('kntnt_popup:after_close', function(event) {
632+
document.addEventListener('kntnt_popup:after_close', function (event) {
566633
// Resume background content after popup closes
567-
document.querySelectorAll('.background-video').forEach(function(video) {
634+
document.querySelectorAll('.background-video').forEach(function (video) {
568635
video.play();
569636
});
570637
});
@@ -638,18 +705,23 @@ Now you have the necessary JavaScript file in place, and the plugin should funct
638705
## Questions & Answers
639706

640707
### How can I get help?
708+
641709
If you have questions about the plugin and cannot find an answer here, start by looking at issues and pull requests on our GitHub repository. If you still cannot find the answer, feel free to ask in the plugin's issue tracker on GitHub.
642710
643711
### How can I report a bug?
712+
644713
If you have found a potential bug, please report it on the plugin's issue tracker on GitHub.
645714

646715
### How can I contribute?
716+
647717
Contributions to the code or documentation are much appreciated.
648718
If you are familiar with Git, please do a pull request.
649719
If you are not familiar with Git, please create a new ticket on the plugin's issue tracker on GitHub.
650720
651721
## Changelog
722+
652723
### 1.0.0 (2025-04-19)
724+
653725
- Initial release
654726
- Added shortcode functionality with comprehensive parameter options
655727
- Implemented multiple trigger mechanisms (exit intent, time delay, scroll position)

0 commit comments

Comments
 (0)