[wp-hackers] custom_post_type and custom taxonomy naming

Lox lox.dev at knc.nc
Mon Aug 23 01:56:09 UTC 2010


2010/8/23 Andrew Nacin <wp at andrewnacin.com>

> I'm not sure why it should. We introduced get_template_part() in order to
> DRY up code. single.php has its own code that isn't used elsewhere; same
> with page.php.
>
> If you want to override page.php, you can do so, on a number of different
> hooks or via a child theme. get_template_part() was not designed for plugin
> overrides as much as child theme overrides.
>

Ok let me explain and use an example.

I have made, for a website, a quiz plugin. I *need* a page to hold it, so it
can be moved, ordered, added to a nav menu, title can be managed using the
page form etc. I can't use a shortcode to let the user put the quiz on the
page he likes, because page content can be parsed many times per page
request (like if u use Otto's SFC plugin) So, in my plugin settings page,
the user selects, from a dropdown, the page to use as the quiz's page
holder.

As long as it is for a specific web site, I can use a theme template adding
my template tag (or a do_action witch I prefer) to display the quiz: that
will reflect the site specific theme and it is ok.

But what happens if I make such plugin public? I will make a copy of the
2010 whole page.php to a template folder of my plugin. So out of the box,
the quiz will use a template based on 2010, and if the user uses a different
theme, the bundled page.php template won't fit. So what? I must give
instruction to tell the user how to make its own template for the quizz, and
thus have to maintain two page.php (his and the quiz's) whereas there is
only one line that changes .... That is tedious ...

Now if page.php was using get_template_part(), I could simply hook into
get_template_part_{$slug} to use a bundled template part. So, my plugin will
feets in user's theme out of the box (as long as his theme reflect the
template layout of 2010 theme witch is the way to do)

Cheers

-- 
Lox
lox.dev at knc.nc


More information about the wp-hackers mailing list