[wp-hackers] proposal for per-post filters in WP

m at tidakada.com m at tidakada.com
Tue Oct 19 12:49:03 UTC 2004


Expected results:
a) Installing a filter plugin should automatically register the filter in the
list of available text filters.
b) A dropdown of available text filters in the post interface (single or
multi-selection, or a text field, or a list of checkboxes like categories use).
c) Filters would be applied to the content and title (and excerpt?) before
storing them into post_content_filtered and post_title_filtered (title filter
may not be so necessary, but would still cut down on some processing time when
displaying a set of posts).
d) In the future: an admin page to specify options for available text filters.
Since most plugins would not have a lot of options, WordPress could just
aggregate their options in a single options page.

Implementation:
Plugins need an additionnal register_text_filter() call, to add themselves to a
variable that holds the name of each available text filter function. This
variable is only used in the posting interface, and when replying to
getSupportedFilters or whatever this MT API function is called.
Posts have a post_filters text field, with either a simple space-separated list
of functions or a serialized array of them (an array would be future-proof, by
enabling the function to receive additionnal arguments).
When displaying posts, WP would always pick post_content_filtered and
post_filters, and check that it wouldn't apply twice the same text filter (once
when posting with per-post filter, once when displaying with apply_filter) to
the content.
WP needs a way to define sets default text filters to apply: a set of text
filters that would always be applied (we could move wpautop there) but could be
deactivated only in the options, and a set of text filters that would be
choosable when posting (out of which some could be selected by default).


I tried getting that kind of thing running yesterday, but it implies a shitload
of modifications, and isn't as intuitive as current plugins are.
Note that WP should be able to use a text filter even when its associated plugin
is disabled, when 'disabled' actually means 'we won't filter content with this
plugin at display time'. OR WP would need to know that only the per-post filter
functionnality of a plugin is available.
This implies that plugin activation as we know it would change.

I'm requesting some feedback on these ideas...

Alternatively, per-post filters could just plug into wp_filter. The details of
such an implementation escape me at the moment though: I tried but I could only
come up with hacky hacky joy joy crap.

One thing is certain though: we NEED to apply some expensive filters at the
moment we store post content and not when displaying content. It would save a
real lot of processing.

--
Michel Valdrighi
http://zengun.org/weblog/



More information about the hackers mailing list