Problem with shortcode identification?
-
I’ve written up some shortcodes for our site/blog, and noticed a persistent problem. It seems to be due to an oversight in the shortcode-matching code in WordPress; the shortcodes aren’t being recognized correctly, it seems.
This shortcode can have either be self-closing or contain content.
I’ve replaced it with a simple return of the $content between brackets to identify what was being matched as the shortag’s content (second argument of the short tag function). Page examples below.
<dl> <dt>[team name="person1"]Person1[/team]</dt> <dd>Founder, Coordinator</dd> <dt>[team name="SomePerson" /]</dt> <dd>Artist</dd> (A few more) <dt>[team name="Pookie" /]</dt> <dd>Artist</dd> <dt>[team name="Ray"]Raymund[/team]</dt> <dd>Artist</dd> </dl>The first one in this example will be identified fine. For the second, however, it’s detected as being
</dt>\n<dd>Artist</dd>all the way up toRaymund, where it sees the [/team] tag. Same thing is I replace the XHTML-style self-closing tag with a full [/team] tag without content.I’ve taken a look at line 170 of wp-includes/shortcodes.php, but if I try to make it recognize EITHER the self-closing slash or the close tag, but not both, it ends up returning nothing (I get blank output for the post content; no errors in the log, the rest of the page outputs). The modified code I use is:
return '\[('.$tagregexp.')\b(.*?)(?:(\/\])|(?:(.+?)\[\/\1\]))';Has anyone else encountered this problem? Is there anything I haven’t thought of, here, or is my only option to forego the shorthand and use the full shortcode (or make another one for shorthand)?
And what exactly causes my regex to fail?
Thanks in advance for any help,
— Laogeodritt
The topic ‘Problem with shortcode identification?’ is closed to new replies.