Closed iruzevic closed 3 years ago
@iruzevic @dingo-d it may be prudent to skip this for the moment in favour of your own implementation (if you already have one). I may have published that post at exactly the wrong time as core is introducing some better helper functions to do this. See: https://core.trac.wordpress.org/ticket/46599
@pattonwebz tnx I will check this
Thanks for the heads up William :+1:
@dingo-d do we still need this?
I don't think we implemented this. In the plugins, something like this goes in the activate()
method, where you can check the dependencies (including the PHP), but we should look how to implement this in the theme with the suggested fix by William.
but I think that composer will fail if you have an unsupported PHP version. Is that enough?
I am happy to make a PR this week for this based on whatever the latest status is from core (which I expect is still no movement as of yet :( ).
I don't think reliance on composer failing would be sufficient - most people build and deploy to different machines. after_switch_theme
is a good place to perform a PHP version check as it runs only one time when a theme is switched to.
I agree with William, as people can build it, and then they could try to upload it and activate it, and it would fail.
@pattonwebz thanks! I appreciate it 🙂
Did we abandon this for themes/plugins?
In the plugin it's a simple check during the activation hook, something like
if (version_compare((string)PHP_VERSION_ID, '70300', '<')) {
deactivate_plugins(plugin_basename(__FILE__));
$error_message = esc_html__('This plugin requires PHP 7.3 or greater to function.', 'eightshift-boilerplate');
throw PluginActivationFailure::activationMessage($error_message);
}
The same could be done in the themes functions.php
. My guess we could find where the libs are loading first in the request process and put that check there.
Implement this:
https://make.wordpress.org/themes/2019/04/01/core-php-compatibility-changes-in-wordpress-5-2/