[theme-reviewers] Question about ob_start and ob_get_clean (Vicky Arulsingam)
Otto
otto at ottodestruct.com
Sat Jul 2 04:44:06 UTC 2011
On Fri, Jul 1, 2011 at 11:21 PM, Darren Slatten <darrenslatten at gmail.com> wrote:
> Result: theme's user has no control over wp_head() output--in other words,
> no control over the content that plugins insert into the page's <head>
> section.
I would argue that this is the desired result. Themes shouldn't be
attempting to modify what plugins do.
> Result: theme's user has the ability to filter the output of wp_head()--in
> other words, theme's user can:
The user can do that anyway, and in a much more sane way. If the
plugin is hooked into wp_head, then it's using an action hook to do
it. Modifying the output is simply a matter of removing the plugin's
hook using remove_action and then adding its own hook using
add_action.
Example:
Plugin does this:
add_action('wp_head','plugin');
function plugin() {
// do something
}
Theme wants to override that, so theme does this (presumably in functions.php):
remove_action('wp_head','plugin');
add_action('wp_head','theme');
function theme() {
// do something different, but similar.. perhaps using a modified
copy of the plugin() function
}
> Remove redundant references to jQuery (for example, 2 plugins queue the
> latest versions of jQuery that were available at the time of writing,
> however both plugins will function with one or the other--removing the
> redundant jQuery reference allows pages to load faster).
Plugins should not include jQuery, as it's built into WordPress.
Multiple plugins can wp_enqueue_script('jquery') all day long and only
one jquery script gets put into the header.
Correcting the plugin that is doing this incorrectly is the better alternative.
> Remove plugin author attribution HTML comments (in compliance with GPL, of
> course).
> Remove duplicate rel="canonical" tag (caused by plugins incorporating this
> feature before WP core...and then WP catching up, adding a second
> occurrence).
> Remove WP core scripts (e.g. reply.js and l10n.js) because I've already
> appended them to the end of a global custom .js file.
> Remove favicon references.
remove_action alone, without an alternate function add, would work for
most of these cases.
> Change order of CSS and JS to optimize page load speed and prevent FOUC.
CSS and JS should be using the proper enqueue script/style methods,
avoiding this anyway. Fixing the plugin is preferable.
> If Theme and Plugins all enqueue jQuery properly, then there will *never* be
> duplicate jQuery scripts enqueued.--not true in cases where
> specific/multiple jQuery versions are referenced. Also, wp_enqueue_script is
> @since 2.8, so backwards compatibility can't be ignored.
If a plugin is using an older version of jquery or is maintaining
back-compat all the way to 2.8, then please notify the author of the
plugin that he's doing it wrong. I'd even be inclined to remove such
plugins from the directory, as they're badly out of date.
-Otto
More information about the theme-reviewers
mailing list