[theme-reviewers] PHP 5.3 In Themes

Chip Bennett chip at chipbennett.net
Tue Mar 5 23:15:05 UTC 2013


But that's not the usual use-case for anonymous functions, is it? Normally
it's more like:

add_action( 'init', function() { /* some stuff here */ } );


And if you're going to use:

$foo = function() { /* some stuff here */ }
add_action( 'init', $foo );


...then what's the point of using an anonymous function?


On Tue, Mar 5, 2013 at 6:06 PM, Peter Baylies <
pbaylies at semperfiwebdesign.com> wrote:

>
> Chip,
>
> Actually, you can remove an anonymous function; you just need a reference
> to it, just as you would with any instance of an object:
>
> $foo = function() { return "Hello!"; };
> add_action( 'the_content', $foo );
> remove_action( 'the_content', $foo );
>
> Cheers,
>
>  -- Peter
>
>
> On Tue, Mar 5, 2013 at 4:28 PM, Chip Bennett <chip at chipbennett.net> wrote:
>
>> 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.
>>
>>
>> On Tue, Mar 5, 2013 at 4:27 PM, Chip Bennett <chip at chipbennett.net>wrote:
>>
>>> 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.
>>>
>>>
>>> On Tue, Mar 5, 2013 at 4:23 PM, Ryan Van Etten <ryanve at gmail.com> wrote:
>>>
>>>> PHP 5.3 supports closures<http://php.net/manual/en/functions.anonymous.php> and
>>>> other features <http://php.net/manual/en/migration53.new-features.php>
>>>> . I want to propose a mechanism for safely allowing PHP 5.3+ themes:
>>>>
>>>> /**
>>>>  * Theme Name: example
>>>>  * Minimum PHP version: 5.3.0
>>>>  * ...
>>>>  */
>>>>
>>>> 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 requirement<http://wordpress.org/about/requirements/>
>>>> .
>>>>
>>>> I'd like to see WP be proactive about encouraging users to use 5.3+.
>>>> The sooner we get the majority<http://stackoverflow.com/questions/8372114/php-version-adoption-stats>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.
>>>>
>>>> @ryanve <http://twitter.com/ryanve>
>>>>
>>>> _______________________________________________
>>>> theme-reviewers mailing list
>>>> theme-reviewers at lists.wordpress.org
>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> theme-reviewers mailing list
>> theme-reviewers at lists.wordpress.org
>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>
>>
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20130305/9f0943f5/attachment.htm>


More information about the theme-reviewers mailing list