?? sorry about being so obscure, it’s hard sometimes to know what level of understanding people possess.
There’s always the Codex, for example, using filters is explained in the Plugin API. Regexp is not limited to WP, so a general Internet search should turn up some explanations.
More specifically, the best source for me is the core source code itself. The source for smilies_init() explains a lot. You can see how the similes are defined. I don’t know what the hexcodes mean, I assume they are character codes for a smiley font. It doesn’t really matter, you’re not inventing new smiley images, only new smiley text that will be substituted for the same hexcode or image reference.
The comment at line 3165 explains why we need to krsort()
the definition array.
The final part with the foreach loop is hard to follow, but the only thing important is how the regexp pattern for whitespaces (contained in $spaces
) plays an important part in building the regexp for finding smiley text. You can see how $spaces
is defined in wp_spaces_regexp() and how the ‘wp_spaces_regexp’ filter is applied. This is where you could define brackets as “whitespace”. Of course, understanding regexp is crucial. Even if you do understand regexp, it’s often difficult to imagine what any particular regexp actually does. There are several online tools that let you fiddle with regexp to see exactly how any particular regexp is applied. For example regexr.com
Happy learning!