How can I prevent a plugin from updating unless it’s minimum PHP version is met?

I have a plugin distributed on WordPress.org that is fairly popular. I have to drop support for PHP 5.2and I’d like to at least drop support for PHP 5.2, but if I could make the minimum PHP 5.4, late static bindings and useful closures, would be great.

Before you say PHP7, keep in mind that plugin only has 100,000+ sites running it. For all WordPress sites, 10% fo sites are on PHP 5.3 or below. I am not risking breaking 10k sites.

We will be adding a PHP minimum version header, but this does not, on a programatic level, do anything yet.

I am looking for the right pattern to consistently short-circuit updates of my plugin unless the PHP version requirement is set. Does anyone have a bullet-proof way of doing this?

3 s
3

At this time, this is not possible. Not without the PHP minimum version header being implemented.

When that is done, then it will be possible. Until then, you cannot DIY through plugin code alone.

In theory, you could release an update that would block future updates for that one plugin if the PHP version wasn’t met, but even then that would not prevent your plugin from receiving updates when it was not active. So, can’t be done because plugin updates are done by WordPress, not by the plugins themselves.

Leave a Comment