
內容簡介
總結:Emberly Popups 是一個輕量級的 WordPress 函數,可以創建可訪問、可定制的彈出視窗。
問題與答案:
1. Emberly Popups 提供哪些功能?
- 自動延遲後自動打開
- 透過cookie或基於session的控制僅向用戶顯示一次
- 透過間隔控制彈出視窗出現的頻率
- 支持在彈出內容中使用shortcodes
- 可調整彈出視窗的寬度和填充
- 具有ARIA角色和屬性的可訪問HTML結構
2. 如何進行調試(debugging)?
- 使用debug參數啟用指定彈出視窗的冗長日誌記錄,以便精確瞭解何時加載、打開、設置cookie或鎖定滾動。
3. 如何調用(calling)彈出視窗?
- 必須通過PHP函數來調用,並建議使用PHP 8+進行調用,這樣可以具體指定要使用的屬性。
4. 如何觸發(trigger)彈出視窗?
- 可以使用auto_open參數自動打開彈出視窗。
- 若要點擊後打開,可以在頁面上的任何地方添加一個觸發元素,並使用em-popup-trigger-id屬性。這個值應匹配您在emberly_popup()調用中為彈出視窗分配的ID。
外掛標籤
開發者團隊
原文外掛簡介
Emberly Popups is a simple PHP function that generates ARIA‑compliant modal popups. Great for newsletters, surveys, announcements, or any call‑to‑action:
Auto‑open after a configurable delay
Cookie‑ or session‑based “show once” control
Repeat interval (milliseconds) between popups
Shortcode support inside popup content
Adjustable width and padding
Accessible markup with proper ARIA roles
Usage
PHP 8+ (named arguments)
“`php
emberly_popup(
title : ‘Welcome!’,
content : ‘
Thanks for visiting our site. Don’t miss our latest offers!
‘,
id : ‘welcome-popup’,
width : ’50rem’,
padding : ‘3rem’,
echo : true,
output_shortcodes: true,
auto_open : true,
delay : 2000,
show_once : false,
persistence_method: ‘session’,
show_interval_ms : 1800000 // 30 minutes
);
PHP 7 & earlier (ordered arguments)
```php
emberly_popup(
'', // $title
'
Thanks for visiting our site. Don't miss our latest offers!
',
'category-survey-popup', // $id
'50rem', // $width
'3rem', // $padding
true, // $echo
true, // $output_shortcodes
true, // $auto_open
2000, // $delay
false, // $show_once
'session', // $persistence_method
1800000 // $show_interval_ms
);
Manual triggers
Anywhere in your markup, add:
html
Open Welcome Popup
The em-popup-trigger-id value must match the $id you set in emberly_popup().
Parameters
Parameter
Type
Default
Description
title
string
”
Popup heading text.
content
string
”
HTML for the popup’s body.
id
string
”
Unique popup identifier (required for cookies/sessions & triggers).
width
string
’60rem’
CSS max-width for the popup container.
padding
string
‘3rem’
Inner padding inside the popup.
echo
bool
true
Echo the markup immediately (false to return as string).
output_shortcodes
bool
false
Process WordPress shortcodes in content.
auto_open
bool
false
Automatically open after delay ms.
delay
int
0
Milliseconds to wait before auto-open.
show_once
bool
false
If true, shows only once per session/cookie period.
persistence_method
string
‘cookie’
Where to store “shown” flag: ‘cookie’ or ‘session’.
show_interval_ms
int
0
Minimum interval (ms) before showing again. 0 disables repeats.
debug
bool
false
Log internal events to browser console (load, open, cookies, scroll lock).
Debugging
Add debug: true (PHP 8+) or append true as the 13th argument (PHP 7) to enable console logging:
`php
// PHP 8+ example
emberly_popup(
title : ‘Debug Popup’,
content: ‘
Debugging is on!
‘,
id : ‘debug-popup’,
debug : true
);
`
