內容簡介
```html
<ul>
<li>將 Nostr Components 帶入您的 WordPress 網站,通過現代 Web 組件的方式將 Nostr(透過傳遞器傳輸的筆記和其他內容)的功能帶進來。</li>
<li>該外掛提供 Gutenberg 區塊和短代碼,讓您可以將 Nostr 內容無縫地整合到您的文章和頁面中。</li>
</ul>
<h3>功能特點</h3>
<ul>
<li>Gutenberg 區塊:支持 Nostr Zap 按鈕、文章、個人檔案、個人檔案徽章和關注按鈕的現代區塊編輯器集成。</li>
<li>短代碼:支持經典編輯器,使用簡單的短代碼語法。</li>
<li>選擇性加載:僅啟用您需要的組件以獲得最佳性能。</li>
<li>可定制:配置中繼器、主題和組件設置。</li>
<li>安全性:通過 KSES 自定義元素允許列表實現內建安全性。</li>
<li>性能:基於已啟用的組件的有條件資產加載。</li>
</ul>
```
```html
<h3>常見問題</h3>
<details>
<summary>如何將點贊和唧唧按鈕添加到所有文章/頁面中?</summary>
<p>您可以進入外觀 → 主題編輯器(或使用子主題進行更安全的自定義),選擇您的活動主題(或子主題),打開 functions.php,在文件末尾添加以下代碼:</p>
<pre>
// 將短代碼添加到每個文章和頁面的末尾
function add_shortcode_to_content($content) {
// 只在單一文章和頁面(而不是首頁或存檔頁)中添加
if (is_singular(['post', 'page']) && in_the_loop() && is_main_query()) {
$shortcode_1 = do_shortcode('[nostr_like]');
$current_url = esc_url(get_permalink());
$shortcode_2 = do_shortcode('[nostr_zap npub="[YOUR-NPUB-GOES-HERE]" url="' . $current_url . '"]');
$content .= '<div class="nostr-shortcode-wrapper">' . $shortcode_1 . '<br/><br/>' . $shortcode_2 . '</div>';
}
return $content;
}
add_filter('the_content', 'add_shortcode_to_content');
</pre>
<p><strong>重要備註:</strong></p>
<ul>
<li>替換 [YOUR-NPUB-GOES-HERE] 為您的實際 Nostr 公鑰(npub 格式)。</li>
<li>請在修改主題文件時始終使用子主題,以保存在主題更新期間的更改。</li>
<li>這些按鈕只會顯示在單一文章和頁面檢視中,而不會顯示在存檔頁或首頁。</li>
</ul>
</details>
```
外掛標籤
開發者團隊
原文外掛簡介
Nostr Components brings the power of Nostr (Notes and Other Stuff Transmitted by Relays) to your WordPress site through modern web components. This plugin provides Gutenberg blocks and shortcodes that allow you to seamlessly integrate Nostr content into your posts and pages.
Key Features
Gutenberg Blocks: Modern block editor integration for Nostr Zap button, Post, Profile, Profile Badge, Follow Button, Like Button, and Livestream
Shortcodes: Classic editor support with simple shortcode syntax
Selective Loading: Enable only the components you need for optimal performance
Customizable: Configure relays, themes, and component settings
Security: Built-in security with custom element allowlist via KSES
Performance: Conditional asset loading based on enabled components
Available Components
Nostr Zap button: Allows your readers to zap to your posts and pages
Nostr Follow Button: Interactive follow/unfollow buttons for Nostr users
Nostr Post: Display Nostr notes/posts with full content and metadata
Nostr Profile: Show complete Nostr user profiles with bio, stats, and social links
Nostr Profile Badge: Compact profile display perfect for sidebars and footers
Nostr Like Button: Like URLs using Nostr reactions (NIP-25)
Nostr Livestream: Display Nostr livestreams (NIP-53) with video playback and participant information
How It Works
Install and activate the plugin
Go to Settings → Saiy2k Nostr Components to configure
Enable only the components you need
Add blocks in the Gutenberg editor or use shortcodes
Configure relays and theme settings as needed
Example Usage
Gutenberg Blocks:
Simply add the Nostr blocks from the block inserter and configure them in the block settings.
Shortcodes:
[nostr_zap_button pubkey=”npub1abc…” url=””]
[nostr_post eventid=”note1abc…”]
[nostr_profile pubkey=”npub1abc…”]
[nostr_profile_badge pubkey=”npub1abc…”]
[nostr_follow_button pubkey=”npub1abc…”]
[nostr_like_button]
[nostr_livestream naddr=”naddr1abc…”]
Adding Like and Zap Buttons to All Posts/Pages
To automatically add Like and Zap buttons to the end of every post and page:
Go to Appearance → Theme Editor (or use a child theme for safer customization)
Select your active theme (or child theme)
Open functions.php
Add the following code at the end of the file:
// Add shortcode to the end of every post and page
function add_shortcode_to_content($content) {
// Only add in single posts and pages (not homepage or archives)
if (is_singular(['post', 'page']) && in_the_loop() && is_main_query()) {
$shortcode_1 = do_shortcode('[nostr_like_button]');
$current_url = esc_url(get_permalink());
$shortcode_2 = do_shortcode('[nostr_zap_button npub="[YOUR-NPUB-GOES-HERE]" url="' . $current_url . '"]');
$content .= '
' . $shortcode_2 . '
';
}
return $content;
}
add_filter('the_content', 'add_shortcode_to_content');
Important Notes:
* Replace [YOUR-NPUB-GOES-HERE] with your actual Nostr public key (npub format)
* Always use a child theme when modifying theme files to preserve changes during theme updates
* The buttons will only appear on single post and page views, not on archive pages or the homepage
Development
This plugin is developed as part of the Nostr Components project. For development, bug reports, and feature requests, please visit the GitHub repository.
Support
For support, please visit the GitHub repository or create an issue.
Privacy Policy
This plugin does not collect, store, or transmit any personal data. All Nostr data is fetched directly from public relays and displayed locally on your site. If components fetch data client‑side, visitors’ browsers may directly connect to configured relays (exposing their IP and user agent to those relays). Configure trusted relays accordingly.
