[wp-trac] [WordPress Trac] #20509: Theme idea - generic.php
WordPress Trac
wp-trac at lists.automattic.com
Wed Apr 25 13:17:21 UTC 2012
#20509: Theme idea - generic.php
--------------------------------------+------------------------------
Reporter: johnjamesjacoby | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Themes | Version:
Severity: normal | Resolution:
Keywords: needs-patch dev-feedback |
--------------------------------------+------------------------------
Comment (by scribu):
`generic-{plugin}.php` would be useful if you wanted to control the
appearance ''around'' a specific plugin. This conflicts with
`register_generic_plugin_file()`, which would do the same thing, like it
or not.
Speaking of which, `register_generic_plugin_file()` seems kind of wrong.
The whole point is that the plugin can't know what a `generic.php`
template should look like.
BuddyPress could still do something like this:
{{{
add_filter( 'template_include', function ( $path )
{
if ( is_generic_request() && 'index.php' == basename( $path ) )
{
// Fall back to plugin.php if there's no generic.php
return plugin_dir_path( __FILE__ ) . '/plugin.php';
}
return $path;
}
}}}
Note that this:
{{{
// From WP Core:
load_template( plugin_dir_path( __FILE__ ) . '/my-template.php' );
}}}
is different than this:
{{{
// From WP Core
load_template( locate_template( 'generic.php' ) );
...
// From Plugin
add_action( 'generic_content', function() {
load_template( plugin_dir_path( __FILE__ ) . '/my-template.php' );
} );
}}}
In the second case, `generic.php` encloses `my-template.php`, making my-
template.php a template part, rather than a whole template, which is what
we want.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20509#comment:27>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list