[wp-trac] [WordPress Trac] #18561: Better Way to Insert Things Below Individual Posts
WordPress Trac
wp-trac at lists.automattic.com
Thu Sep 1 17:48:36 UTC 2011
#18561: Better Way to Insert Things Below Individual Posts
-------------------------+------------------------------
Reporter: jane | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.2.1
Severity: minor | Resolution:
Keywords: |
-------------------------+------------------------------
Comment (by greenshady):
My idea would be to allow themes to register support for "post hooks".
Then, a plugin could check if a theme supports this before deciding to
filter `the_content`. This solution would offer backwards compatibility
with old hooks in themes that are already doing this and offer a lot of
flexibility for theme authors in terms of where they'd want to place these
hooks in their themes.
A theme would register support for this like so:
{{{
add_theme_support( 'post-hooks', array( 'before' =>
'before_post_hookname', 'after' => 'after_post_hookname' ) );
}}}
`before` and `after` should have some defaults (e.g., `before_post`,
`after_post`) so that we could start standardizing on this method.
Allowing them to be custom would offer some backwards compatibility for
themes with existing hooks.
A theme would use this like so in their theme templates:
{{{
do_action( 'before_post' );
Post stuff
do_action( 'after_post' );
}}}
A plugin's use:
{{{
if ( current_theme_supports( 'post-hooks' ) ) {
$post_hooks = get_theme_support( 'post-hooks' );
add_action( $post_hooks[0]['after'], 'some_function' );
} else {
add_filter( 'the_content', 'some_function' );
}
}}}
That's my idea anyway. There's not going to be a solution that'll work
for everyone without all themes adding the code in.
I think a lot of other theme devs are in the same boat as me. We
absolutely hate that plugins hook everything to `the_content` because it
ruins our designs. We'll settle on any standard.
There can be some control over whatever solution is decided upon though.
The theme review team will take strides in getting themes up to par. That
will at least offer some standardization with themes on the repository.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18561#comment:48>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list