前言介紹
- 這款 WordPress 外掛「Private Page Forbidden」是 2009-09-27 上架。
- 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
- 上一次更新是 2009-09-28,距離現在已有 5696 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 2.7 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
403 | access-control |
內容簡介
這個外掛是由 Shepherd Interactive 開發的,旨在造福社群。沒有提供支援。如有任何問題,請在支援論壇發佈。
停用 404.php 模板,改為提供 403 Forbidden 錯誤,並設定 $wp_query->is_403,如果存在 403.php,則載入它。
提供一個過濾器 forbidden_redirect,如果過濾後的值不是空值,使用者訪問被禁止的頁面時會被重新導向;預設值為 ""(不重新導向)。
與一個過濾器一同使用,該過濾器可以選擇性地禁止私人文章,這樣該頁面將不會顯示在導覽中,也不會包含在 XML 網站地圖中。
function my_filter_private_posts($posts){ if(is_singular() && $posts[0]->post_status == 'private' && # 現在可選擇根據使用者進行允許/不允許: in_array($_SERVER['REQUEST_URI'], (array)@$_SESSION['allowed_private_uris'])) ){ header('Cache-Control: private'); # 防止代理伺服器將此私人頁面快取 $posts[0]->post_status = 'publish'; } return $posts; } add_filter('posts_results', 'my_filter_private_posts');
原文外掛簡介
This plugin is developed at Shepherd Interactive
for the benefit of the community. No support is available. Please post any questions to the support forum.
Instead of serving a 404 Not Found error with the 404.php template, send a 403 Forbidden error and set $wp_query->is_403 and load 403.php if it exists.
Provides a filter forbidden_redirect which if results in a non-empty filtered value will result in the user being redirected if attempting to visit a forbidden page; the default value is "" (no redirect).
Useful with a filter which selectively prevents a private post from being forbidden, so that the page will not show up in the navigation and won’t be included in XML Sitemaps, for example.
function my_filter_private_posts($posts){ if(is_singular() && $posts[0]->post_status == 'private' && #Now optionally allow/disallow based on user session: in_array($_SERVER['REQUEST_URI'], (array)@$_SESSION['allowed_private_uris'])) ){ header('Cache-Control: private'); #Prevent proxies from caching this private page $posts[0]->post_status = 'publish'; } return $posts; } add_filter('posts_results', 'my_filter_private_posts');
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Private Page Forbidden」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Custom Error Pages 》WordPress 內建自訂 404 頁面支援所有主題。但是其他常見錯誤如 401 和 403 呢?你只能看到 Web Server 提供的平庸錯誤頁面。, 使用此外掛,你可以輕鬆建立任...。
F4 Error Pages 》有時候 WordPress 預設的錯誤頁面處理功能不夠,因為它只顯示簡單的文字,或者您必須建立包含 (更多) 靜態內容的自訂 404 模板。, F4 Error Pages 允許您將任...。