You write a plugin which requires PHP 5.1. Someone tries to install it on a server with PHP 4. How do you deal with that in a safe and user-friendly manner?
Leave a Reply
You must be logged in to post a comment.
You write a plugin which requires PHP 5.1. Someone tries to install it on a server with PHP 4. How do you deal with that in a safe and user-friendly manner?
You must be logged in to post a comment.
This function and activation hook prevents the plugin from activating and allows you to check for both a minimum PHP and WordPress version.
I’m not sure since which WP version this happened, but in 3.5 the plugin actually fails to activate and the error message is shown to the user in the admin, which is neat.
The error message is not translated, though. In order to do that youâd have to load your translation files right before the
exit
call.You could activate it and show an error message:
It’s also probably possible to deactivate it programmatically, before the return statement…
I know this is an older question, but for those searching for a good solution, Gary Pendergast had a good route to go that covers a few of the bases mentioned in the other answers (see his post here, I’ve updated the code below to check the PHP version, but you can use it for virtually any check):
I’ve also saved the code above in a gist.