<div dir="ltr">But that's not the usual use-case for anonymous functions, is it? Normally it's more like:<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div style>add_action( 'init', function() { /* some stuff here */ } );</div>
</blockquote><div><br></div><div style>And if you're going to use:</div><div style><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div style>$foo = function() { /* some stuff here */ }</div>
<div style>add_action( 'init', $foo );</div></blockquote><div style><br></div><div style>...then what's the point of using an anonymous function?</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Mar 5, 2013 at 6:06 PM, Peter Baylies <span dir="ltr"><<a href="mailto:pbaylies@semperfiwebdesign.com" target="_blank">pbaylies@semperfiwebdesign.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br></div><div>Chip,</div><div><br></div><div>Actually, you can remove an anonymous function; you just need a reference to it, just as you would with any instance of an object:</div><div><br></div><div><div>$foo = function() { return "Hello!"; };</div>
<div>add_action( 'the_content', $foo );</div><div>remove_action( 'the_content', $foo );</div></div><div><br></div><div>Cheers,</div><div><br></div><div> -- Peter</div><div class="HOEnZb"><div class="h5"><br>
<br><div class="gmail_quote">On Tue, Mar 5, 2013 at 4:28 PM, Chip Bennett <span dir="ltr"><<a href="mailto:chip@chipbennett.net" target="_blank">chip@chipbennett.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Also: I would argue against the use of anonymous functions. They are inherently Child-Theme unfriendly when used for callbacks, because they cannot be overridden with corresponding remove_action() or remove_filter() calls.</div>
<div><div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 5, 2013 at 4:27 PM, Chip Bennett <span dir="ltr"><<a href="mailto:chip@chipbennett.net" target="_blank">chip@chipbennett.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">My initial reaction here is that Themes should support the current core WordPress minimum requirements, which would mean that Themes that implement features beyond the minimum requirements would, at a minimum, need to ensure graceful degradation.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Tue, Mar 5, 2013 at 4:23 PM, Ryan Van Etten <span dir="ltr"><<a href="mailto:ryanve@gmail.com" target="_blank">ryanve@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<div dir="ltr"><span style="font-family:arial,helvetica,sans-serif">PHP 5.3 supports </span><a href="http://php.net/manual/en/functions.anonymous.php" style="font-family:arial,helvetica,sans-serif" target="_blank">closures</a><span style="font-family:arial,helvetica,sans-serif"> and other </span><a href="http://php.net/manual/en/migration53.new-features.php" style="font-family:arial,helvetica,sans-serif" target="_blank">features</a><span style="font-family:arial,helvetica,sans-serif">. </span>I want to propose a mechanism for safely allowing PHP 5.3+ themes:<div>
<br><div><font face="courier new, monospace">/**</font></div><div><font face="courier new, monospace"> * Theme Name: example</font></div><div><font face="courier new, monospace"> * Minimum PHP version: 5.3.0</font></div>
<div><font face="courier new, monospace"> * ...</font></div><div><font face="courier new, monospace"> */</font></div><div><br></div><div><font face="arial, helvetica, sans-serif">With this info, the theme installation page could prevent users from installing 5.3 themes on 5.2 servers. The "Activate" link could be replaced with an alert that tells the user that the theme needs a higher PHP version. If unspecified, it'd default to the WP <a href="http://wordpress.org/about/requirements/" target="_blank">requirement</a>. </font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I'd like to see WP be proactive about encouraging users to use 5.3+. The sooner we get the <a href="http://stackoverflow.com/questions/8372114/php-version-adoption-stats" target="_blank">majority</a> on 5.3, the better it will be for the core too. The same technique could be used for plugins, and it is future-proof to 5.4 etc.</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><div><div><a href="http://twitter.com/ryanve" target="_blank">@ryanve</a></div>
</div></div></div></div>
<br></div></div>_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org" target="_blank">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>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org" target="_blank">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></div><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>