infinum / eightshift-boilerplate

This repository contains all the tools you need to start building a modern WordPress theme, using all the latest front end development tools.
https://eightshift.com
MIT License
543 stars 69 forks source link

Php version check #138

Closed iruzevic closed 3 years ago

iruzevic commented 5 years ago

Implement this:

https://make.wordpress.org/themes/2019/04/01/core-php-compatibility-changes-in-wordpress-5-2/

pattonwebz commented 5 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

iruzevic commented 5 years ago

@pattonwebz tnx I will check this

dingo-d commented 5 years ago

Thanks for the heads up William :+1:

iruzevic commented 4 years ago

@dingo-d do we still need this?

dingo-d commented 4 years ago

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.

iruzevic commented 4 years ago

but I think that composer will fail if you have an unsupported PHP version. Is that enough?

pattonwebz commented 4 years ago

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.

dingo-d commented 4 years ago

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 🙂

dingo-d commented 3 years ago

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.