[WordPress] 外掛分享: Page Guard

WordPress 外掛 Page Guard 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Page Guard」是 2017-03-20 上架。
  • 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
  • 上一次更新是 2022-08-22,距離現在已有 1284 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 4.7 以上版本才可以安裝。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

fculross |

外掛標籤

url | post | query string | conditional title | conditional output |

內容簡介

Page Guard使用單個URL參數或POST變量作為提供令牌的手段,以保護放置此插件shortcode的任何頁面。當令牌缺失或不匹配預期值時,可以輸出替換內容 - 如果收到的令牌與預期值匹配,則可以向訪問者顯示受控內容。

對於此版本,附加的shortcode屬性“title”還允許條件性地更改頁面標題,但前提是在瀏覽器中啟用了JAVASCRIPT(如果JavaScript被關閉,則不起作用!)

要使用的shortcode是“pageguard” - 其屬性為:

tokenparam(必需) -> 包含令牌URL param的字符串值 - 例如“mytoken”<br />
eq(可選) -> 包含tokenparam的預期值的字符串值 - 例如'x34ggj45b'<br />
ne(可選) -> 對於“eq”,但在使用時,shortcode將在未匹配令牌時輸出內容<br />
absent(可選) -> 當absent =“1”時,shortcode將在檢測到缺少令牌時輸出內容<br />
title(可選) -> 包含父shortcode條件符合時應用的頁面標題的字符串 <br />

語法示例:

顯示匹配令牌的區塊 -
[pageguard param="token" eq="download"]
找到匹配令牌時要輸出的文本
[/pageguard]

顯示非匹配區塊+更改標題
[pageguard tokenparam="token" ne="download" title="Downloads - invalid token"]
當令牌不匹配時輸出錯誤文本
[/pageguard]

顯示找不到令牌的內容+更改標題
[pageguard tokenparam="token" absent="1" title="Downloads - missing token"]
當令牌缺失時輸出錯誤文本
[/pageguard]

使用方法

典型的使用情況可能是控制對下載頁面的訪問。假設您在網站上使用PayPal“立即購買”按鈕,該按鈕允許訪問者支付電子書或音頻錄音等項目。在您的PayPal帳戶中設置按鈕時,您指定返回頁面上的URL,訪問者在支付後返回該頁面。在此返回頁面上,您添加了訪問者可以使用的鏈接以下載其購買內容 - 但是,您不希望任何未付款的訪問者也有權訪問頁面上的下載鏈接!如果您還希望頁面標題反映任何錯誤條件,則可以使用“title”屬性來執行此操作(請注意,此功能取決於JavaScript在用戶的瀏覽器中啟用 - 它被禁用,“title”無效)。

在您設置了PayPal按鈕時,將參數添加到返回URL的末尾(使用任何名稱和值):

"http://your.wordpress.site/download/?dltoken=x34ggj45b"

接下來,將要處理的情況的pageguard shortcode添加到您的WordPress返回頁面中 -

[pageguard param="token" eq="x34ggj45b" title="Title for matched token"]
找到匹配令牌時要輸出的文字
[/pageguard]

[pageguard tokenparam="token" ne="x34ggj45b" title="Title for failed match"]
當令牌不匹配時輸出錯誤文本
[/pageguard]

[pageguard tokenparam="token" absent="1" title="Title for missing token"]
當令牌缺失時輸出錯誤文本
[/pageguard]

這將在Page Guard檢測到匹配令牌時正確顯示頁面的主要內容。如果令牌不正確或缺失,還可以提供額外的錯誤內容。

原文外掛簡介

Page Guard uses a single URL parameter or POST variable as a means of providing a token to guard access to any page on which this plugin’s shortcode is placed. Output of alternative content can be made to occur when the token is missing or fails to match what is expected – if the token received matches the expected one, the controlled content can be revealed to the visitor.
For this version, an additional shortcode attribute “title” also allows the page title to be changed conditionally PROVIDED JAVASCRIPT IS ENABLED IN THE BROWSER (it has no effect if JavaScript is turned off!)
The shortcode to use is ‘pageguard’ – its attributes are:
tokenparam (required) -> a string value containing the name of the token URL param - e.g. 'mytoken'
eq (optional) -> a string value containing the expected value of the tokenparam - e.g. 'x34ggj45b'
ne (optional) -> as for "eq" but when used, shortcode will output content on non matching token
absent (optional) -> when absent="1", shortcode will output content on detection of missing token
title (optional) -> a string containing a page title to apply when the parent shortcode's criteria are met

Syntax examples:
show block on matching token -
[pageguard param="token" eq="download"]
Text to be output on matching token found
[/pageguard]

show block on non match + change title
[pageguard tokenparam="token" ne="download" title="Downloads - invalid token"]
Error text for output when token fails to match
[/pageguard]

show this on no token found + change title
[pageguard tokenparam="token" absent="1" title="Downloads - missing token"]
Error text for output when token is missing
[/pageguard]

Usage
A typical use scenario might be to control access to a downloads page. Suppose you have a PayPal “Buy Now” button on your site which allows visitors to make a payment for say, an eBook or audio recording. When setting up the button in your PayPal account you specify a URL on your site to which the visitor is returned after they’ve made payment. On this return page you’ve added a link the visitor can use to download their purchase – however, you don’t want any non paying visitors to have access to the download link(s) on the page! If you also want the page title to reflect any error conditions, you an use the “title” attribute to do this (please be aware however that this functionality depends on JavaScript being enable in the user’s browser – it disabled, “title” has no effect.)
Add a parameter to the end of the return URL (using any name and value you want) when you set up your button in PayPal e.g.
"http://your.wordpress.site/download/?dltoken=x34ggj45b"

Next, add pageguard short codes for the cases you intend to handle to your return page in WordPress –
[pageguard param="token" eq="x34ggj45b" title="Title for matched token"]
Text to be output on matching token found
[/pageguard]

[pageguard tokenparam="token" ne="x34ggj45b" title="Title for failed match"]
Error text for output when token fails to match
[/pageguard]

[pageguard tokenparam="token" absent="1" title="Title for missing token"]
Error text for output when token is missing
[/pageguard]

This will correctly display the main content for the page when Page Guard detects a matching token. It also provides for the possibility of providing different error content for the page in the event of the token being incorrect or missing.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Page Guard」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 1.1 |

延伸相關外掛(你可能也想知道)

暫無相關外掛推薦。

文章
Filter
Mastodon