4 lines of code, in 1 Plugin, distributed to thousands of users<div><br></div><div>vs</div><div><br></div><div>4 lines of code, in thousands of Themes, to fix one Plugin</div><div><br></div><div>Besides: WordPress *already* provides the "basic functionality for advanced users to take advantage of".</div>
<div><br></div><div>Chip<br><div><br><div class="gmail_quote">On Wed, Jun 29, 2011 at 4:39 PM, Gmail <span dir="ltr"><<a href="mailto:darrenslatten@gmail.com">darrenslatten@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Adding output buffering and a custom filter to wp_head and wp_footer requires...what, 4 extra lines of code? I'm having a very difficult time understanding why "contact the plugin author and ask them to change their code" would be the best approach.<br>
<br>
Also, I'm not suggesting a hard-coded fix for specific plugins--I'm only suggesting that a theme provides that basic functionality for advanced users to take advantage of. This would require adding custom code to functions.php.<br>
<br>
So...4 lines of code to give advanced users control of plugin output...or contact every plugin author and ask them to update their code?<br>
<br>
-Darren Slatten<br>
<div><div></div><div class="h5"><br>
On Jun 29, 2011, at 4:18 PM, Simon Prosser <<a href="mailto:pross@pross.org.uk">pross@pross.org.uk</a>> wrote:<br>
<br>
> Surely the contact form should ONLY be loading it js and css in pages<br>
> and posts that have comments enabled, if not, thats poor coding for<br>
> the plugin, and rather than coding a theme around the plugin, you<br>
> should perhaps be hassling the author to change said plugin to use<br>
> some logic in wp_head.<br>
><br>
> On 29 June 2011 22:13, Gmail <<a href="mailto:darrenslatten@gmail.com">darrenslatten@gmail.com</a>> wrote:<br>
>> So...a better approach would be what? Rewrite all plugins that don't follow<br>
>> best practices?<br>
>> That still wouldn't address issues like client-side load order (e.g. to<br>
>> optimize page load times).<br>
>> A real example where wp_head filtering is useful is in conjunction with the<br>
>> Contact Form 7 plugin. By default, enabling that plugin would insert a CSS<br>
>> file and script into the head of every page. With a custom filter and a<br>
>> conditional statement, I can make sure only the contact form page loads<br>
>> those resources.<br>
>> In many cases, this can also be achieved "more elegantly" by removing hooked<br>
>> functions, but filtering the output buffer (i.e., working with regex) is<br>
>> much faster/easier than digging through plugins, searching for the custom<br>
>> function code that hooked into wp_head.<br>
>> -Darren Slatten<br>
>> On Jun 29, 2011, at 1:44 PM, Chip Bennett <<a href="mailto:chip@chipbennett.net">chip@chipbennett.net</a>> wrote:<br>
>><br>
>> I think you have that approach exactly backwards. Plugins should be looking<br>
>> after themselves, by hooking properly into appropriate hooks. Theme and<br>
>> Plugins should mostly stay out of one another's way.<br>
>> If Theme and Plugins all enqueue jQuery properly, then there will *never* be<br>
>> duplicate jQuery scripts enqueued.<br>
>> Chip<br>
>> On Wed, Jun 29, 2011 at 11:45 AM, Gmail <<a href="mailto:darrenslatten@gmail.com">darrenslatten@gmail.com</a>> wrote:<br>
>>><br>
>>> I use output buffering on wp_head() and wp_footer(), in order to give my<br>
>>> theme complete control over them. Since most plugins hook onto these, they<br>
>>> can become cluttered with scripts and CSS file links. By using OB and a<br>
>>> custom filter, I can do things like (1) remove duplicate jQuery scripts, and<br>
>>> (2) optimize the order that CSS and scripts are loaded in. Essentially this<br>
>>> gives my theme the final say in what resources are loaded into the page,<br>
>>> allowing me to "clean up after" plugins.<br>
>>><br>
>>> -Darren Slatten<br>
>>><br>
>>> On Jun 29, 2011, at 10:12 AM, Vicky Arulsingam<br>
>>> <<a href="mailto:vicky.arulsingam@gmail.com">vicky.arulsingam@gmail.com</a>> wrote:<br>
>>><br>
>>>> I've asked the theme author to explain the usage. If there's a valid<br>
>>>> use for it then it should be allowed but I haven't a clue how.<br>
>>>><br>
>>>> On 6/29/11, Ryan Hellyer <<a href="mailto:ryan@pixopoint.com">ryan@pixopoint.com</a>> wrote:<br>
>>>>> There are many reasons to use output buffering (ob_start etc), but<br>
>>>>> they would rarely be used within a theme. I've seen themes which use<br>
>>>>> buffering as a way to dynamically minify the markup, but that's a<br>
>>>>> horrid way to do it - much better incorporated within a caching plugin<br>
>>>>> IMO.<br>
>>>>><br>
>>>>> There may be a practical use for output buffer in a theme, but I'm<br>
>>>>> darned if I can think of a good example. I wouldn't want to see it<br>
>>>>> banned outright, as someone may come up with a cunning use for it that<br>
>>>>> none of us have thought of.<br>
>>>>><br>
>>>>> Perhaps the theme check plugin could check for output buffering<br>
>>>>> functions and leave a request for the theme developer to provide a<br>
>>>>> reason for using it? That way they'll know it's non-standard and<br>
>>>>> provide a reason (good or bad) for the theme reviewers to read. Could<br>
>>>>> potentially save a little to and fro'ing in the future. Just an idea.<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>
>>>><br>
>>>><br>
>>>> --<br>
>>>> -----<br>
>>>> Vicky Arulsingam<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>
>>> 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>
>> _______________________________________________<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>
>> _______________________________________________<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>
>><br>
><br>
><br>
><br>
> --<br>
> My Blog: <a href="http://www.pross.org.uk/" target="_blank">http://www.pross.org.uk/</a><br>
> Plugins : <a href="http://www.pross.org.uk/plugins/" target="_blank">http://www.pross.org.uk/plugins/</a><br>
> Themes: <a href="http://wordpress.org/extend/themes/profile/pross" target="_blank">http://wordpress.org/extend/themes/profile/pross</a><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>
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>
</div></div></blockquote></div><br></div></div>