[WordPress] 外掛分享: Private Page Forbidden

首頁外掛目錄 › Private Page Forbidden
全新外掛
安裝啟用
尚無評分
6014 天前
最後更新
問題解決
WordPress 2.7+ v0.2 上架:2009-09-27

內容簡介

這個外掛是由 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');

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.2) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Private Page Forbidden」→ 直接安裝(推薦)

原文外掛簡介

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');

延伸相關外掛

文章
Filter
Apply Filters
Mastodon