[wp-hackers] PHP requirement for plugins
James Currie
jamie at wunderdojo.com
Mon May 2 22:56:33 UTC 2016
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
>
More information about the wp-hackers
mailing list