<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
I would agree with everything Chip is saying here with exception to the using only core-included versions of jQuery, or any other script for that matter. I can easily designate the version by first deregistering the included jquery and then registering the newer version. As long as it's registered as 'jquery' and not something like 'jquery.new'. This way when a plugin enqueues jquery (the right way) they will get the newer version and there still will only be one version included....something like the following:<div><br></div><div>wp_deregister_script( 'jquery' );</div><div>wp_register_script( 'jquery', '/path/to/new/jquery.js', false, '1.6.2' );</div><div><br></div><div>now whenever a theme or plugin uses the standard wp_enqueue_script( 'jquery' ); they will get the specified version above....not the included "core" version.</div><div><br></div><div>This is example btw is available right on the codex -> <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">http://codex.wordpress.org/Function_Reference/wp_enqueue_script</a><br><br><div><hr id="stopSpelling">Date: Sat, 2 Jul 2011 07:46:40 -0500<br>From: chip@chipbennett.net<br>To: theme-reviewers@lists.wordpress.org<br>Subject: Re: [theme-reviewers] Question about ob_start and ob_get_clean        (Vicky Arulsingam)<br><br>Actually, I rarely use passive-aggression. If I think you're full of crap, I just say so. I'm going to ignore the condescending flame-bait, and address only the germane parts of your email below.<div><br></div><div>
Saying that output buffering is required in order to remove content hooked into wp_head is simply untrue. Anything hooked in via wp_head can just as easily be unhooked. Every add_action() can be undone with a remove_action(). Every wp_enqueue_style() or wp_enqueue_script() can be undone with a wp_dequeue_style() or wp_dequeue_script().</div>
<div><br></div><div>Core WordPress functionality provides everything necessary for adding/removing styles, scripts, and/or meta tags hooked into wp_head, for rearranging their order of output, and for editing their content.</div>
<div><br></div><div>By using output buffering to accomplish the same thing, you're adding needless complexity and processing, for zero gain. End users can do all of those things using core functionality and files. All you're doing is adding a hook layer on top of an existing hook layer. You've basically rewritten the functionality of wp_print_scripts and wp_print_styles. Congratulations!*</div>
<div><br></div><div>As for your real-world examples:</div><div><ul><li>The front end of a site should never enqueue multiple versions of the same jQuery script. That's just asking for conflicts. IMHO**, Themes and Plugins should only ever be using the core-bundled version of any given jQuery script (including jQuery itself), because <i>other Themes and Plugins will rightfully assume that the core-bundled version is the version available for their use</i>, so if another Theme or Plugin enqueues a different version, they can cause potential breakage.<br>
<br></li><li>If developers are hooking in HTML-comment attribution via wp_head, then those attributions can be un-hooked via wp_head just as easily. Also, just FYI: there are no "GPL compliance" issues with HTML-comment attribution.<br>
<br></li><li>Duplicate rel=canonical links hooked in via wp_head can be unhooked via wp_head just as easily.<br><br></li><li>Removing core scripts such as comment-reply.js and l10n.js, that are added via filter, can just as easily be removed via filter. Also: doing something like this is not the jurisdiction of a publicly released Theme.<br>
<br></li><li>Favicon links that are hooked in via wp_head can just as easily be unhooked via wp_head. (Are you noticing a pattern here?*)<br><br></li><li>Scripts and styles that are enqueued can all be rearranged however one prefers, using nothing other than functionality available in core. The Hooks API provides a convenient <i>prioritization</i> method.</li>
</ul></div><div><br></div><div>As for your rebuttals:</div><div><ul><li>If a Plugin developer is that obtuse, then sure. But such Plugin developers are the exception, not the rule. And even so, the existence of such Plugin developers does not refute the fact that correcting such behavior in the Plugin itself is far more efficient and effective than making end users correct the behavior themselves. And in this case, there is nothing subjective about the "right way". Scripts and styles (and anything else custom-added to the document head) should be hooked in via wp_head, at an appropriate hook within wp_head.<br>
<br></li><li>Again: Themes should not be outputting multiple versions of the same jQuery script. Doing so is just asking for problems.<br><br></li><li>Any end user still using WordPress 2.8 has enough other problems and issues to worry about. Such a user either needs to update to the latest version, or else be responsible for any such problems/issues incurred by choosing to use out-of-date software.</li>
</ul></div><div>Chip</div><div><br></div><div>* Note: that's <i>sarcasm</i>, not passive-aggression</div><div><br></div><div>** Note: this statement is my opinion only.</div><div><br><div class="ecxgmail_quote">On Fri, Jul 1, 2011 at 11:21 PM, Darren Slatten <span dir="ltr"><<a href="mailto:darrenslatten@gmail.com">darrenslatten@gmail.com</a>></span> wrote:<blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex">
<b style="color:rgb(153, 0, 0)"><u>Without</u> output buffering:</b><br>
<br><head><br> <meta charset="<?php bloginfo( 'charset' ); ?>" /><br> <title><?php wp_title( '|', true, 'right' ); ?></title><br> <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /><br>
<?php<br> <b style="color:rgb(153, 0, 0)">wp_head();</b><br> ?><br></head><br><br><b>Result:</b> 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.</blockquote>
<blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex"><br><br><b style="color:rgb(51, 51, 255)"><u>With</u> output buffering:</b><br><br><head><br> <meta charset="<?php bloginfo( 'charset' ); ?>" /><br>
<title><?php wp_title( '|', true, 'right' ); ?></title><br>
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /><br> <?php<br><i><span style="color:rgb(0, 153, 0)"> // Start output buffering.</span></i><br>
<b style="color:rgb(51, 51, 255)">ob_start();</b><br><br><i><span style="color:rgb(0, 153, 0)"> // Any plugins that use the wp_head hook to insert meta tags, CSS, </span><br style="color:rgb(0, 153, 0)">
<span style="color:rgb(0, 153, 0)"> // scripts, etc. will still function as intended, the only difference here </span><br style="color:rgb(0, 153, 0)"><span style="color:rgb(0, 153, 0)"> // is that they'll print to the output buffer instead of echoing directly </span><br style="color:rgb(0, 153, 0)">
<span style="color:rgb(0, 153, 0)"> // to the output stream.</span></i><br> <b style="color:rgb(51, 51, 255)">wp_head();</b><br><br><i><span style="color:rgb(0, 153, 0)"> // Stop the output buffering and store the buffer content (as a string) </span><br style="color:rgb(0, 153, 0)">
<span style="color:rgb(0, 153, 0)"> // in $my_wp_head_content.</span></i><br> <b><span style="color:rgb(51, 51, 255)">$my_wp_head_content = ob_get_clean();</span></b><br><br><i style="color:rgb(0, 153, 0)"> // If a filter has been defined by the theme's user, run our buffer <br>
// content through it and echo it. If no filter is defined, just echo the <br> // content like usual (in other words, execute wp_head default behavior).</i><br> <b><span style="color:rgb(51, 51, 255)">echo apply_filters( 'my_custom_wp_head_filter', $my_wp_head_content );</span></b><br>
?><br></head><br><br><b>Result:</b> theme's user has the ability to filter the output of wp_head()--in
other words, theme's user can:<br><ul><li>Add or remove meta tags, CSS, scripts, etc.</li><li>Rearrange the order of meta tags, CSS, scripts, etc.</li><li>Edit the content of meta tags, CSS, scripts, etc.</li></ul></blockquote>
<blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex">Real examples of things I've personally used this functionality to accomplish on my own sites:<br>
<ul><li>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).</li>
<li>Remove plugin author attribution HTML comments (in compliance with GPL, of course).</li><li>Remove duplicate rel="canonical" tag (caused by plugins incorporating this feature before WP core...and then WP catching up, adding a second occurrence).</li>
<li>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.</li><li>Remove favicon references.</li><li>Change order of CSS and JS to optimize page load speed and prevent FOUC.</li>
</ul><br>Please note that my real examples rebut the following arguments:<br><ul><li><i><b>Notify the plugin author or submit patches</b></i>--not a solution in cases where plugin author has intentionally inserted a 4-line HTML comment into my <head> section, essentially advertising his/her website. More generally, not a solution for cases where "the right way" is subjective.</li>
<li><i><b>If Theme and Plugins all enqueue jQuery properly, then there will *never* be duplicate jQuery scripts enqueued.</b></i>--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.<br>
</li></ul><br><br>Okay, I'm done. Fire away.<br><br><br><br><br><br><br><br><br><div class="ecxgmail_quote"><div><div></div><div class="h5">On Fri, Jul 1, 2011 at 1:10 AM, Andrew Nacin <span dir="ltr"><<a href="mailto:wp@andrewnacin.com">wp@andrewnacin.com</a>></span> wrote:<br>
</div></div><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5"><div>On Thu, Jun 30, 2011 at 1:58 AM, Gmail <span dir="ltr"><<a href="mailto:darrenslatten@gmail.com">darrenslatten@gmail.com</a>></span> wrote:<br>
</div><div class="ecxgmail_quote"><div><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex">
The illogical responses from you and Chip lead me to believe that I must not be explaining this adequately. I will return to this topic in a few days, when I have my computer up and running again, and I can insert code examples for clarity. Currently, I'm trying to respond via iPhone, and it's not doing this issue any justice. I'll be back.<br>
</blockquote><div><br></div></div><div>It's Otto and Chip. Responses don't get more logical.</div><div><br></div><div>If you're going to apologize for not explaining things adequately, backhanded remarks like that aren't necessary.</div>
<div><br></div><div>I agree with them. You're doing it wrong. And approaching it wrong, too. We're all quite approachable, but that comes with the caveat of doing so the right way.</div></div>
<br></div></div><div class="ecxim">_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a><br>
<a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
<br></div></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br>-Darren Slatten<br><br>
</font><br>_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a><br>
<a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________
theme-reviewers mailing list
theme-reviewers@lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers</div></div>                                            </div></body>
</html>