Z – Test shortcode urlparam

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, to check for FirstName, and if not found, then First, if not found, then name, and if not, then just return “Friend”
[ urlparam param="FirstName, First, name" default="Friend" /]
Output: Friend

If the parameter is a date, you can also specify the dateformat option using a PHP friendly date format
[ urlparam param="oggi" dateformat="F Js" default="03-01-2022" / ]
Output: 03-01-2022

Use the shortcode urlparam with the optional parameter of “default”.
[ urlparam param="FirstName" / ] or [ urlparam param="FirstName" default="Friend"/ ].
Output: Friend.

Conditional Use

For conditional content use [ ifurlparam ][ /ifurlparam ]. For example
[ ifurlparam param="FirstName"]Hey, I know you, [ urlparam param="FirstName" ]![ /ifurlparam ]
Output: (Test it)

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 ]
Output: Welcome to the site, visitor!

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 back 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: <input name="firstname" type="text" />or you might set a src attribute for an image tag like so: <img />
If you want urlparam to return back 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 <input id="first" name="firstname" type="text" value="Bob" />

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:
<input name="firstname" type="text" value="[ urlparam param='FirstName' ]" / >.

Now you have to set it like this:
<input name="firstname" type="text" /> or [ urlparam htmltag="input" type="text" name="firstname" attr="value" param="FirstName" / ].