前言介紹
- 這款 WordPress 外掛「URL Params」是 2011-06-25 上架。
- 目前有 9000 個安裝啟用數。
- 上一次更新是 2024-12-17,距離現在已有 137 天。
- 外掛最低要求 WordPress 3.0 以上版本才可以安裝。
- 有 37 人給過評分。
- 論壇上目前有 1 個提問,問題解答率 0%
外掛協作開發者
外掛標籤
url | urlparam | url params | query string | url parameters |
內容簡介
URL Params WordPress 插件允許您訪問 URL 中查詢字符串中的 URL 參數。
這個插件甚至允許您在短代碼中指定一個默認值,如果該參數沒有設置,那麼如果您想說“Hello, FirstName”,而 FirstName 沒有設置,它會說一些像“Hello, Friend!”這樣的話。
要指定備份 URL 參數,請輸入用逗號分隔的多個參數。插件將按順序檢查每個參數,直到找到匹配的參數並返回該參數。如果找不到您列出的任何參數,則將返回默認值。例如,您可以指定[urlparam param="FirstName, First, name" default="Friend" /]以檢查 FirstName,如果未找到,則尋找 First,如果未找到,則尋找 name,如果都不行,則返回“Friend”。
如果該參數是一個日期,您還可以使用 PHP 友好日期格式指定 dateformat 選項,例如[urlparam param="somedate" dateformat="F Js" /]。請注意,PHP 始終返回英文格式的日期,不考慮語言環境設置。
如果您有個性化鏈接(例如來自 Infusionsoft 或 Keap),這很有用,因為它可以讓您使用人的名稱個性化登陸頁面。
您還可以使用此功能根據查詢字符串預填表單字段。例如,如果在 URL 中傳遞了他們的名字,您的登陸頁面可以使用他們的名字問候觀眾並預填寫其名字在表單中。
使用方法
使用可選的“預設值”參數的短代碼 urlparam。例如,[urlparam param="FirstName" /]或[
urlparam param="FirstName" default="Friend"/]。
要使用條件內容,請使用[ifurlparam] [/ifurlparam]。例如,[ifurlparam param="FirstName"]Hey,我認識你,[urlparam param="FirstName"]! [/ifurlparam]會向已知用戶問候,但不會向沒有名稱的用戶顯示任何內容。
如果您想顯示當值不存在時的內容,可以在[ifurlparam]中設置 empty。例如,[ifurlparam param="FirstName" empty="1"]歡迎來到網站,訪客! [/ifurlparam]會向沒有名稱的訪客問候,但不會顯示帶有名稱的訪客。
如果您希望只向其查詢字符串中具有特定值的訪客顯示內容,可以在[ifurlparam]中設置is。例如,[ifurlparam param="FirstName" is="Bob"]嗨,Bob![/ifurlparam]只向具有 FirstName 參數設置為 Bob 的訪客問候。
如果您希望 urlparam 返回 HTML 屬性,例如在預設輸入或隱藏的輸入字段中使用,請傳遞可選的 attr 參數。可以像這樣設置輸入字段的值屬性:或可以像這樣設置圖像標籤的 src 屬性:
如果您希望 urlparam 返回整個 HTML 標記(例如在創建輸入字段時),請傳遞可選的 htmltag 參數。例如,[urlparam htmltag="input" type="text" name="firstname" id="first" attr="value" param="FirstName" default="Bob" /]將產生類似於的內容。
安全性
為了幫助保護您的網站免遭反射式跨網站腳本攻擊,我們使用
原文外掛簡介
The URL Params WordPress Plugin allows you to access URL parameters in the Query String of the URL.
The plugin even allows you to specify a default value in the shortcode if the parameter isn’t set, so if you want to say “Hello, FirstName” and FirstName isn’t set, it could say something like “Hello, Friend!”
To specify a backup url parameter, enter multiple parameters seperated by commas. The plugin will check for each parameter, in order, until a matching one is found and return that. Failing finding any of the parameters you listed, the default will be returned. For example, you can specify [urlparam param="FirstName, First, name" default="Friend" /] to check for FirstName, and if not found, then First, if not found, then name, and if not, then just return “Friend”.
If the parameter is a date, you can also specify the dateformat option using a PHP friendly date format, for example [urlparam param="somedate" dateformat="F Js" /]. Note that PHP only returns dates formatted in English regardless of locale settings.
This is great if you have personalized links, like from Infusionsoft or Keap, as it lets you personalize a landing page with a persons name.
You can also use this to pre-fill out form fields for folks based on the querystring. For example, if their first name is passed in the URL, your landing page can greet the viewer by name and pre-fill their name on a form.
Usage
Use the shortcode urlparam with the optional parameter of “default”. For example [urlparam param="FirstName" /] or [urlparam param="FirstName" default="Friend"/].
For conditional content use [ifurlparam][/ifurlparam]. For example, [ifurlparam param="FirstName"]Hey, I know you, [urlparam param="FirstName"]![/ifurlparam] would greet known visitors, but display nothing to users without a FirstName in the query string.
If you want to show content when a value does NOT exist, you can set empty in [ifurlparam]. For example [ifurlparam param="FirstName" empty="1"]Welcome to the site, visitor![/ifurlparam] would greet visitors without a FirstName in the query string, but display nothing for visitors with FirstName in the query string.
If you want to show content only to visitors with a specific value in their query string, you can set is in [ifurlparam]. For example, [ifurlparam param="FirstName" is="Bob"]Hi, Bob![/ifurlparam], would only greet visitors with the FirstName param set to Bob.
If you want to have urlparam return an HTML attribute, for example to use in pre-setting the value of input or hidden input fields, pass in the optional attr parameter. You might set a value attribute for an input field like so: or you might set a src attribute for an image tag like so:
If you want urlparam to return an entire HTML tag, for example in creating an input field, pass in the optional htmltag parameter. For example, [urlparam htmltag="input" type="text" name="firstname" id="first" attr="value" param="FirstName" default="Bob" /] will produce something like
Security
To help protect your site against Reflected Cross Site Scripting, we sanitize output with esc_html() which prevents any HTML tags from being passed in and displayed. This would prevent someone from passing in javascript, for example, and having it execute on your site.
Starting in the WordPress 4.2.3 security auto-update, you can no longer include shortcodes in HTML attributes. Previous to this WordPress update, you could set a field value like this: . Now you have to set it like this: or [urlparam htmltag="input" type="text" name="firstname" attr="value" param="FirstName" /]. If you are still using this shortcode the old way, unfortunately, WordPress simply won’t process the shortcode and will return the full shortcode text unprocessed.
To prevent unprivileged users (like Contributors) from using this shortcode to have privileged users (like Admins) accidentally execute arbitrary javascript via HTML attributes (like onclick, onmouseover, etc), html tags and attributes are sanitized.
If you do need have a need to set certain sanitized tags or attributes, at your own risk, you can manually allow these from the URL Params options page under Settings.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「URL Params」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
1.6 | 1.7 | 1.8 | 2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | trunk | 2.5-review |
延伸相關外掛(你可能也想知道)
暫無相關外掛推薦。