gMagicScott / wordpress-plugin_amazing-system

0 stars 1 forks source link

Add extra characters around a standard merge #15

Open gMagicScott opened 10 years ago

gMagicScott commented 10 years ago

From the Facebook group:

How do I pluralize this? [as what="firstname" default="Your"] where I want (Chad's) or (Your). Would this work? [as what="firstname" "'s" default="Your"]

At first, I thought it might be possible to combine two shortcodes like this: [as what="firstname" default="Your" /][block field="Name"]'s[/block], but block checks against a specific value, not a generic "is set".

We could add another attribute to add the extra content when the merge is there.

as

[as prepend="Hi " what="firstname" append="!" default="Hello friend," /]

Output when Name not set:
Hello friend,

Output when Name is set (Chad):
Hi Chad!

The ability to prepend wasn't asked for, but I think prepend and append go well together.