這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

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:foo@mail.com"]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.

安裝方式

  1. Unzip hide-this.zip and upload the hide-this folder to your /wp-content/plugins/ directory.
  2. Activate the plugin through the “Plugins” menu in WordPress.
  3. Start using the [hide] shortcode to hide the content you want.

常見問題集

Installation Instructions
  1. Unzip hide-this.zip and upload the hide-this folder to your /wp-content/plugins/ directory.
  2. Activate the plugin through the “Plugins” menu in WordPress.
  3. Start using the [hide] shortcode to hide the content you want.

使用者評論

2019 年 7 月 29 日
I've been using this for a couple of years, now on a number of sites. And, it works fine in WordPress 5. In fact, I'm currently using it on a site I'm developing in WordPress 5.2.2 using the OceanWP template and Elementor page builder. At first, I used Hide This, but then switched to another solution because I thought HT to be a bit limited for certain options. One specific problem I was having with HT was trying to get the ! (not) operator to function as expected. I later came back to HT because I considered it to be "less bad" than the other soution I had begun using. However, once I really got into HT (again) I discovered the "for all" (with exceptions) option. Now, I use the following syntax for everything: [hide for="all" exclude=(my list of exceptions, that is, the list of roles I WANT to be able to view the content)]. Now, THAT is powerful yet extremely flexible. This thing meets ALL my needs. Don't be afraid to give it a try...I think you'll be glad you did.
2019 年 3 月 23 日
Straightforward. If you ever need to hide some page contents, this is for you. I use it often when I play with different ways of displaying information. No need to delete the original version, just hide it while working on new approaches.
閱讀全部 49 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈Hide This〉的開發相關工作。

參與者

將 Hide This 外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

1.1.3

  • Fix: A bug was causing contents always showing for all users when applying negations to roles.

1.1.2

  • Fix: Multiple role assignation wasn’t working in some scenarios.

1.1.1

  • Improvement: Parsing shortcodes into [hide] and [hidethis].

1.1

  • Object oriented code.
  • New filter hooks.

1.0

First release!