[wp-trac] Re: [WordPress Trac] #3794: Generate post_title based on
post_content
WordPress Trac
wp-trac at lists.automattic.com
Wed Feb 21 07:43:14 GMT 2007
#3794: Generate post_title based on post_content
--------------------------+-------------------------------------------------
Reporter: Justinsomnia | Owner: markjaquith
Type: enhancement | Status: assigned
Priority: normal | Milestone: 2.2
Component: General | Version: 2.1
Severity: normal | Resolution:
Keywords: has-patch |
--------------------------+-------------------------------------------------
Comment (by Justinsomnia):
majelbstoat, I do like your idea of more configurable auto-generated
titles.
In that spirit, I dug a little deeper into filters (I hadn't written any
plugins using them) so I didn't know well enough what I could or could not
do with them. My hunch, that the save_pre filters are atomic and thus one
value (the content) can not affect another (the title), turned out to be
true. Actually given the order of the filters I could store the content as
a global variable or an instance variable, but this depends heavily on the
order of the filters.
So I set out to add the filter (actually two) that I've always wanted, one
that has access to all attributes of a post and differentiates between
publishing and just saving. I called these filters {{{post_publish_pre}}}
and {{{post_save_pre}}} respectively, they happen very early on in the
{{{wp_insert_post()}}} method because of the use of {{{extract()}}} early
on, and they pass the entire {{{$postarr}}} array along to the filter
function.
See attachment:ticket:3794:post.php.diff for the diff and
attachment:ticket:3794:title-auto-generation.php as a proof of concept
plugin that implements the {{{generate_title_from_content()}}} function
from my previous diff using these new filters.
--
Ticket URL: <http://trac.wordpress.org/ticket/3794#comment:17>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list