內容簡介
**總結:**
GetTerms 外掛可協助您在 WordPress 網站中實現 Cookie 同意管理並直接嵌入法律政策。它連接到您的 GetTerms 帳戶,提供符合法規的自動更新文件和完全可配置的 Cookie 同意橫幅。
**問題與答案:**
1. GetTerms 外掛的功能有哪些?
- 連接到您的 GetTerms Compliance Pack 使用唯一的 token。
- 在整個網站或透過手動整合上嵌入 Cookie 同意小工具。
- 使用短代碼展示實時更新的法律文件(隱私政策、條款、服務協議等)。
- 支援多種語言用於小工具和政策。
2. 如何設置使用 GetTerms 外掛?
- 移動至 WordPress 管理選單中的 GetTerms。
- 輸入您的 GetTerms token 並保存您的設定。
3. 如何嵌入 Cookie 同意小工具?
- 在外掛設定中啟用自動嵌入選項,以在 <head> 標籤中插入同意小工具。
- 您也可以透過提供的腳本標籤進行手動嵌入,適用於進階用途或多語言配置。
- 為確保適當的同意執行,盡可能早地在 head 部分嵌入腳本。
- 如果您手動在您的 head 部分包含其他腳本,建議手動將 GetTerms 腳本嵌入至所有其他腳本之上,並且不使用自動嵌入。
4. 如何使用短代碼?
- 使用以下短代碼展示您的政策文件:[getterms_privacy_en]、[getterms_terms_en]、[getterms_aup_en],以及其他語言和政策在外掛設定中列出的項目。
5. WordPress 如何載入樣式和腳本?
- 註冊 + 排隊和輸出。
6. 外掛如何使用這些 hook?
- 對於 Cookie 同意小工具,您可以選擇自動嵌入或手動嵌入。
- 對於管理頁面和設定,外掛僅在我們的設定頁面上使用 admin_enqueue_scripts 加載其管理捆綁包,以保持 wp-admin 的輕量級運行。
7. 解決問題和最佳實踐是什麼?
- 總是在同意腳本執行後載入第三方追蹤腳本。
- 如果必須硬編碼標籤,將 GetTerms 腳本置於 head 部分之上。
- 永遠不要 echo &l..等。
外掛標籤
開發者團隊
② 後台搜尋「GetTerms Cookie Consent & Policies」→ 直接安裝(推薦)
原文外掛簡介
The GetTerms plugin helps you implement cookie consent management and embed legal policies directly into your WordPress site. It connects with your GetTerms account to provide compliant, auto-updating documents and a fully configurable cookie consent banner.
Features
Connect to your GetTerms Compliance Pack using a unique token.
Embed the Cookie Consent Widget site-wide or via manual integration.
Shortcodes to display live-updated legal documents (Privacy Policy, Terms, AUP, etc.).
Support for multiple languages for both widget and policies.
Usage
Setting Up
Navigate to GetTerms in the WordPress admin menu.
Enter your GetTerms token and save your settings.
Embedding the Cookie Consent Widget
Enable the auto-embed option in plugin settings to insert the consent widget in the <head> tag.
You can also embed manually with the provided script tag for advanced use cases or multilingual configurations.
To ensure proper consent enforcement, embed the script as early as possible in the head section.
If you have manually included other scripts in your <head> the recommendation is to manually embed the GetTerms script above all other scripts, and not use auto-embed
Using Shortcodes
Use the following shortcodes to display your policy documents:
[getterms_privacy_en], [getterms_terms_en], [getterms_aup_en]
[getterms_privacy_fr], [getterms_terms_fr], [getterms_aup_fr]
Additional languages and policies are listed in the plugin settings.
How wp_head and wp_enqueue_script work
WordPress loads styles and scripts in two steps:
1) Registration + enqueue (what you do in PHP)
– You register a script/style and enqueue it using WordPress functions.
– Common hooks:
– wp_enqueue_scripts (front end): enqueue scripts/styles for the theme and plugins.
– admin_enqueue_scripts (wp-admin): enqueue for specific admin screens.
– login_enqueue_scripts (login screen): enqueue for wp-login.php.
2) Output (what WordPress prints into the page)
– WordPress prints the enqueued styles and scripts into the HTML at the proper places, using theme hooks:
– wp_head: prints styles and any head scripts (e.g., those with $in_footer = false).
– wp_footer: prints scripts that were enqueued for the footer (those with $in_footer = true).
In practice, you should enqueue on the correct action, and let WordPress output them on wp_head/wp_footer. Example:
Register and enqueue a script
function myplugin_enqueue_assets() {
wp_register_script(
‘myplugin-frontend’,
plugins_url(‘dist/myplugin.js’, FILE),
array(‘jquery’),
‘1.0.0’,
true // load in footer
);
wp_enqueue_script(‘myplugin-frontend’);
}
add_action(‘wp_enqueue_scripts’, ‘myplugin_enqueue_assets’);
What gets printed where
Because $in_footer = true, the script tag is printed near the end of the page when the theme calls wp_footer().
If $in_footer = false (default), it will be printed in the
How this plugin uses these hooks
– For the Cookie Consent Widget, you can choose between:
– Auto-embed: The plugin hooks into wp_head very early to print the consent script as high as possible in the
– Manual embed: You paste the provided
