[wp-hackers] PHP requirement for plugins
Abdussamad
abdussamad at postbox.work
Tue May 3 09:02:45 UTC 2016
Hi,
WordPress.org maintains stats about the PHP versions people are using.
It's worth a look:
https://wordpress.org/about/stats/
The data is current. The page is updated based on data from active WP
installations.
Regards,
Abdussamad
On 05/03/2016 01:29 PM, Chloé Desoutter wrote:
> Hello,
>
> I don't mean to troll but why as plug-in/theme developers should we
> consider supporting obsolete, unmaintained versions of PHP that will suffer
> from huge security flaws?
>
> This grasping to past versions, broadest compatibility, etc. hinders with
> providing secure, reliable code.
>
> We should be the ones pushing hosters and hoster customers towards newer,
> better supported code versions.
>
> That said, your version test code needs to be the first called by your
> plug-in and to refrain from using newer syntactic elements that would cause
> parse errors.
>
> Yours sincerely,
>
> 2016-05-03 0:56 GMT+02:00 James Currie <jamie at wunderdojo.com>:
>
>> Nothing I'm aware of. This is what I use:
>>
>> public static function check_php_version() {
>> $plugin_name = PLUGIN_NAME;
>> $php_min_version = MIN_PHP_VERSION;
>> $php_min_version_formatted = MIN_PHP_VERSION_FORMATTED;
>>
>> if ( ! ( PHP_VERSION_ID ) || version_compare( PHP_VERSION_ID,
>> $php_min_version, '<' )) {
>> wp_die( sprintf( __( 'PHP version %1$s or greater is
>> required to use this version of the %2$s plugin!', 'text-domain' ),
>> "<strong>{$php_min_version_formatted}</strong>", $plugin_name ) );
>> }
>>
>> }
>>
>> The constants it references look like:
>>
>> const MIN_PHP_VERSION = '50300';
>> const MIN_PHP_VERSION_FORMATTED = '5.3.0';
>>
>> *Jamie Currie*
>> ------------------
>> CEO, wunderdojo
>> 949-734-0758
>> Located in sunny Southern California
>> GMT / UTC - 7 hours
>>
>> On Mon, May 2, 2016 at 3:05 PM, J.D. Grimes <jdg at codesymphony.co> wrote:
>>
>>> Hi Stephen,
>>>
>>> I don't know if there is a "best practice" implementation of this out
>>> there or not. There is nothing like this in WordPress core, and probably
>>> never will be. You might want to take a look at
>>> https://core.trac.wordpress.org/ticket/26909 and the related tickets for
>>> a better understanding of why.
>>>
>>> - J.D.
>>>
>>>> On May 2, 2016, at 5:52 PM, Stephen Rider <wp-hackers at striderweb.com>
>>> wrote:
>>>>
>>>> Hi all —
>>>>
>>>> Is there a standardized method in WordPress to declare that a plugin or
>>> theme requires a certain version of PHP? I’ve started coding my plugins
>> to
>>> require PHP 5.4.
>>>>
>>>> I know I can write code that does something like check for the right
>> PHP
>>> version and deactivate the plugin if it’s not met; but is there anything
>>> like this already within WP? It would be great if we could just add a
>> line
>>> to the Readme.txt or the plugin Headers.
>>>>
>>>> --
>>>> Stephen Rider
>>>>
>>>> wp-hackers at striderweb.com
>>>> http://striderweb.com/nerdaphernalia
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list