[WordPress] 外掛分享: Hide This

首頁外掛目錄 › Hide This
WordPress 外掛 Hide This 的封面圖片
3,000+
安裝啟用
★★★★★
5/5 分(49 則評價)
2948 天前
最後更新
問題解決
WordPress 3.0+ v1.1.3 上架:2013-10-12

內容簡介

Hide This 提供 [hide] 短碼,讓你可以隱藏文章和頁面的某些內容。你可以輕鬆管理隱藏內容的包含和排除方式,分為三個層次:絕對、群組和能力,以及指定用戶。

也許你的文章的某些部分還不應該發佈?或者你想向特定的群體或使用者展示內容的某些特定部分,比如登錄的使用者或你的客戶?這個外掛可能是你需要的解決方案。

非常重要的一點是,包含在短碼中的內容甚至不會作為 HTML 印出來,它真的是完全隱藏的。有許多偉大的外掛可以通過 CSS 和 JavaScript 隱藏內容,但這不是這個插件的情況。如果你希望你的內容不可見,但仍以 HTML 印出,你應該試試其中一個。

基本用法:

[hide]Lorem ipsum dolor sit amet.[/hide]

這個例子將隱藏該內容以適用於所有網站訪客。但是你可以通過使用屬性來做更具體的指定。

可接受的屬性:

- for:(可選)用於隱藏內容的規則。你可以使用絕對規則(all、none、[!]logged)、按角色和能力劃分的規則([!]{role}、[!]{role}:[!]{capability}、:[!]{capability})以及按特定用戶劃分的規則(userid:[!]{ID}、useremail:[!]{email}、username:[!]{username})。
- exclude:(可選)用於向特定訪客展示隱藏內容的規則。與 for 一樣,你可以使用絕對規則(all、none、[!]logged)、按角色和能力劃分的規則([!]{role}、[!]{role}:[!]{capability}、:[!]{capability})以及按特定用戶劃分的規則(userid:[!]{ID}、useremail:[!]{email}、username:[!]{username})。
- test:(可選)用於調試的目的。你所期望的輸出類型。接受 content 和 empty。輸出在測試結果上會顯示一條訊息,所以請明智使用。

一些有用的示例:

- 對所有訪客隱藏你的內容:

[hide]Lorem ipsum dolor sit amet.[/hide]

- 對所有訪客隱藏你的內容,除了特定的使用者:

[hide for="all" exclude="username:foo"]Lorem ipsum dolor sit amet.[/hide]

- 對所有未登錄的訪客隱藏你的內容:

[hide for="!logged"]Lorem ipsum dolor sit amet.[/hide]

- 對所有已登錄的訪客隱藏你的內容:

[hide for="logged"]Lorem ipsum dolor sit amet.[/hide]

- 對所有已登錄的訪客隱藏你的內容,除了特定的使用者:

[hide for="logged" exclude="username:foo"]Lorem ipsum dolor sit amet.[/hide]

- 隱藏你的內容對於某些特定角色:

[hide for="contributor"]Lorem ipsum dolor sit amet.[/hide]

- 隱藏你的內容對於兩個特定角色:

[hide for="editor, contributor"]Lorem ipsum dolor sit amet.[/hide]

- 對所有訪客隱藏你的內容,除了某個特定角色:

[hide for="!administrator"]Lorem ipsum dolor sit amet.[/hide]
[hide for="all" exclude="administrator"]Lorem ipsum dolor sit amet.[/hide]

- 對所有訪客隱藏你的內容,除了兩個特定角色:

[hide for="!administrator, !editor"]Lorem ipsum dolor sit amet.[/hide]
[hide for="all" exclude="administrator, editor"]Lorem ipsum dolor sit amet.[/hide]

隱藏你的內容對於使用哪些特定用戶,可以在屬性中使用「userid」、「useremail」和「username」。

注意,這裡的 Markdown 原始碼中可能使用了一些 HTML 標籤,請務必保留這些原始標籤。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.1.3) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Hide This」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Hide This provides a [hide] shortcode that lets you hide some parts of the content from your posts and pages. You can easily manage inclusions and exclusions for hidden content in three levels: absolute, groups and capabilities, and specific user.
Maybe some part of your post should not be published yet? Or maybe you want to show some specific parts of your content to a certain group or users, let’s say your logged in users or your clients? This plugin may be the solution you need.
It’s very important to note that the content wrapped within the shortcode won’t even be printed as HTML. It will be really, really hidden. There are a lot of great plugins that hide the content via CSS and Javascript, but this is not the case. If you want your content to not be visible, but still printed as HTML, you should try one of those.
Basic usage:
[hide]Lorem ipsum dolor sit amet.[/hide]

This example will hide that content for all the site visitors. But you can be more specific by using attributes.
Accepted attributes:

for: (optional) your rules to hide content. You can use absolute rules (all, none, [!]logged), rules by roles and capabilities ([!]{role}, [!]{role}:[!]{capability}, :[!]{capability}), and rules by specific user (userid:[!]{ID}, useremail:[!]{email}, username:[!]{username}).
exclude: (optional) your rules to show the hidden content to some specific visitor/s. As in for, you can use absolute rules (all, none, [!]logged), rules by roles and capabilities ([!]{role}, [!]{role}:[!]{capability}, :[!]{capability}), and rules by specific user (userid:[!]{ID}, useremail:[!]{email}, username:[!]{username}).
test: (optional) for debugging purposes. The kind of output you expect. Accepts content and empty. Use it wisely, because it prints a message with the result of the test.

Some useful examples:
Hide your content to all visitors:
[hide]Lorem ipsum dolor sit amet.[/hide]

Hide your content to all visitors, except for a specific user:
[hide for="all" exclude="username:foo"]Lorem ipsum dolor sit amet.[/hide]

Hide your content to all non-logged visitors:
[hide for="!logged"]Lorem ipsum dolor sit amet.[/hide]

Hide your content to all logged in visitors:
[hide for="logged"]Lorem ipsum dolor sit amet.[/hide]

Hide your content to all logged in visitors, except for a specific user:
[hide for="logged" exclude="username:foo"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for some specific role:
[hide for="contributor"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for two specific roles:
[hide for="editor, contributor"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for all visitors except for a specific role:
[hide for="!administrator"]Lorem ipsum dolor sit amet.[/hide]
[hide for="all" exclude="administrator"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for all visitors except for two specific roles:
[hide for="!administrator, !editor"]Lorem ipsum dolor sit amet.[/hide]
[hide for="all" exclude="administrator, editor"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for users with a specific role and a specific capability:
[hide for="some_role:do_a_barrel_roll"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for users with a specific role, not having a specific capability:
[hide for="some_role:!do_a_barrel_roll"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for users with a specific capability:
[hide for=":do_a_barrel_roll"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for a specific user by user name:
[hide for="username:foo"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for a specific user by user ID:
[hide for="userid:42"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for a specific user by user email:
[hide for="useremail:[email protected]"]Lorem ipsum dolor sit amet.[/hide]

Hide your content for everyone except for a specific user by user name:
[hide for="username:!foo"]Lorem ipsum dolor sit amet.[/hide]

You should get the idea by now. Notice how you can use ! to deny values such as login status, roles, capabilities and user values.
Extending
This plugin offers hooks for filters, so you can modify its functionality or add your own.

hide_this_attributes: Modify the attributes that the shortcode receives.
hide_this_content: Modify the full content that the shortcode prints.
hide_this_hide_rules: Modify rules for hiding content.
hide_this_show_rules: Modify rules for showing content.

Contribute
You can make suggestions and submit your own modifications to this plugin on Github.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon