[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:27:43 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 Otto42):
Replying to [comment:43 helenyhou]:
> Does this mean that plugin authors have to anticipate or provide options
for what the theme is calling their template part(s), though?
Not at all. But if there was a standard naming scheme, then theme authors
would likely use it to be compatible.
> What if it should be attached to a completely different template part
depending on context?
A plugin could provide an option to do that, if it was desired. That sorta
depends on what the plugin does.
> I don't mean to just fire off questions and perhaps sound belligerent or
defensive on teh internetz, because I don't mean it that way at all. I'm
clearly having a hard time figuring out how that would work, but I'm
genuinely interested/curious and want to understand better. I figure you
know way better than I do and I guess you can never account for what
everybody might do. I do still agree that it's better to use something
that's already there...
What I'm thinking is that if there was a standard way to name things, much
like the template hierarchy, then theme authors could choose to use it.
Plugin authors could use that to hook into specific places in the theme.
This doesn't have to be limited to the content and the loop and such. The
idea can expand beyond that.
For example, what if the concept of a "menu" because a part? Theme authors
could call get_template_part('menu') and have a menu.php file that output
their menu. Maybe this would be as simple as a call to wp_page_menu or
maybe it could be complex. Depends on the theme.
But if they were calling this function, then a plugin could hook into
get_template_part_menu or get_template_part_menu_after to put things
before or after the menu area on the page.
The idea of template parts, as a whole, allows the theme author to break
the page down into specific "areas" and have the output for each of them
separated. This allows child themes to easily override whole areas of the
page without affecting the rest of it. It also allows themes to define
these named areas with fallbacks, so I could say
get_template_part('menu','page_slug') for example (replace 'page_slug'
with whatever gets the current page slug), and then be able to define
menu-slug.php for having individual menus for different pages.
get_template_part already does this.
So it makes sense, if you're giving theme authors a way to divide their
theme into areas, to allow plugins to hook in before and after those areas
to produce content. Simple as that, really. If we let theme authors divide
the page into named chunks, then give them a standard for naming those
chunks, then we can have known names.
If themes don't use those area names, then you have the same situation as
now. Themes have to be modified by the end user to include calls to
functions in plugins, or whatever. This is unchanged. But the goal is to
make it so plugins can try to hook into those standard named areas, and
then if the theme supports them, it "just works".
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18561#comment:45>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list