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

Protected Posts Logout Button

外掛說明

This plugin simply adds a logout button to the content of any password protected post. Sometimes clients want a password protected page to share information with privileged individuals and the default 10 days for the cookie to expire is too long for their liking. So I wrote a little plugin to do this with AJAX and set the cookie to expire immediately, well actually 10 days in the past.

  • Works logged in or out as a WordPress user.
  • Uses the same functionality WordPress uses to set post cookies.
  • Has a simple settings page to make everything easier.
  • Allows you to alert user they have logged out.

螢幕擷圖

  • Admin Screen for simple settings
  • Optional alert
  • Button added to the content

安裝方式

  1. Upload pplb_logout_button.zip to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Customize your settings.
  4. Confirm it is working & you’re done!

常見問題集

The logout button shows up, but nothing happens when clicked, what’s wrong?

Does your theme have <?php wp_head(); ?> and <?php wp_footer(); ?> installed correctly? This plugin uses some javascript that gets embedded automatically in the header or footer, and requires it to work properly.

This button is so ugly?! What can I do?

Well, this button is setup to be no intrusive on your theme, so it adapts to the styles that come with you theme.

That being said, you can style the button as you wish using a css class you define on the settings page, or add your themes button class.

I get more than one button on my page when I am logged in to a protected post, what gives?

Well that logout button gets added to the function the_content() but only when the function in_the_loop() returns true (as of version 1.2).
if your theme is using apply_filters('the_content', $some_str); it is possible it will show up more than once.

使用者評論

2021 年 1 月 7 日
Thank you for this excellent plugin. It does what it says on the tin perfectly!
2016 年 9 月 3 日 2 則留言
Works well, but expiry doesnt work. Any idea? I've set the expiry 300 Seconds but it doesnt log out.
閱讀全部 12 則使用者評論

參與者及開發者

以下人員參與了開源軟體〈Protected Posts Logout Button〉的開發相關工作。

參與者

將〈Protected Posts Logout Button〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

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

變更記錄

1.4.6

  • Fixed vulnerabilities in option saving function, not allowing unescaped user input and checking user role

1.4.5

  • Tested with WordPress 6.1.1
  • Added nonce verification for updating options.

1.4.4

  • Tested with WordPress 5.2.2
  • Added option for positioning button after content.

1.4.3

  • Tested with WordPress 5.1.1
  • Added support for multisite by adding COOKIE_DOMAIN to the logout function. Thanks to @rcreactor, @gahapati, and @gserafini

1.4.2

  • Tested with WordPress 5.0.3
  • Added filters pplb_button_text & pplb_button_html for manipulating text and HTML button output.

1.4.1

  • Added an option for changing the button text
  • re added the function pplb_logout_button to fix potential PHP errors

1.4.0

  • Refactored code into a class
  • Moved the options page to a template
  • Tested with version 4.4.2

1.3.2.1

  • Moving javascript to footers
  • Checking to see if logout cookie option is numeric

1.3.2

  • Added a optional debug to the send response to the console.log function ( only for debugging use should not be used in production. )
  • Added a check to see the message is not of type “undefined”
  • Added an option to the options page for turning on or off debug.
  • Tested with version 4.0!

1.3.1

  • Added the ability to change the default WordPress postpass cookie in the admin area.
  • Cleaned up some logic and php code.

1.3

  • Added conditional logic to the allow admin to disable the automatic filter.
  • Added a shortcode to allow users to place the button inside posts and a php function to place it in template files or hook it.

1.2

Added conditional logic to the filter to only add the button inside of the loop.

1.1

Fixed a bug with javascript enqueue that was causing a 404 file not found for logout.js.

1.0

Original Release: uses wp_enqueue_scripts and ajax to logout password protected posts by setting the cookie to expire immediately.