Putting the discussion here in case anyone finds it of interest...
Currently wysiwyg fields have the filters wp_kses_post
(potentially) and wpautop
(always) applied before saving to the database. This means that the field content has <p>
and </p>
tags, which are added by TinyMCE, saved into the database field itself. This is unlike standard post content wysiwyg fields, which have <p>
and </p>
tags stripped before being saved to the database, and then added again on output by the the_content
filter.
The fact that DCF doesn't apply the_content
to wysiwyg output means that shortcodes aren't converted. Additionally, if the_content
is applied to the output, shortcode are converted but oembeds are not. This is because the oembed regexp looks for an oembed URL directly preceded by a carriage return, whereas the field output contains lines that start with <p>
tags, e.g. <p>http://www.youtube.com/...
The idea is to strip <p>
and </p>
tags when saving the field and to apply the_content
to the output, which will automatically enabled shortcodes and oembeds. This would also enable the use of things like the Gravity Forms button which is also displayed alongside the Add Media button with the media_buttons
setting in wysiwyg_options
.
[As a side note, the "Add Media" button above wysiwyg fields works as expected as it just adds the HTML tags for that image.]
the_content
applies the following filters as far as I can see...
wptexturize
- http://codex.wordpress.org/Function_Reference/wptexturize
convert_smilies
- http://codex.wordpress.org/Function_Reference/convert_smilies
convert_chars
- http://codex.wordpress.org/Function_Reference/convert_chars
wpautop
- http://codex.wordpress.org/Function_Reference/wpautop
shortcode_unautop
- http://wpseek.com/shortcode_unautop/
prepend_attachment
- http://wpseek.com/prepend_attachment/
capital_P_dangit
- http://codex.wordpress.org/Function_Reference/capital_P_dangit
do_shortcode
- http://codex.wordpress.org/Function_Reference/do_shortcode
... and also does the oembeds.
It looks like the_content
therefore doesn't do much of significance in terms of backwards compatibility, although there will of course be other plugins which hook into that filter to do extra filtering.
The main question seems to be whether this should be default behaviour, or whether this behaviour should have to be turned on explicitly. The fact that the_content
doesn't do a great deal, and the built-in post content field has this applied by default, would argue for it to be default behaviour. I suppose there may be cases of unexpected behaviour when used with other plugins, but if the plugin currently doesn't convert shortcodes or oembed URLs, then those won't be included in anyone's existing DCF wysiwyg content fields anyway. I would argue the same is likely to be true of other plugins in the vast majority of cases.
The database fields for wysiwyg content will have <p>
and </p>
tags in them. When the_content is applied to fields like this, these tags are processed without any issue, so there are no conflicts with existing stored fields as far as I can see.
Therefore, my conclusion would be to strip <p>
and </p>
tags when saving wysiwyg fields and apply the_content
to the output. Any other opinions?