How-To: Customize the PHP Version Warning your WordPress users see
Starting with WordPress 5.1, WordPress is posting a warning in the WordPress Dashboard, if the site is using PHP version 5.5 or older. Eventually, WordPress plans to drop support for older PHP versions altogether.
The warning that customers see in the dashboard looks something like this:
https://zdnet1.cbsistatic.com/hub/i/2019/01/15/e1877ed1-7ae1-4f87-a257-1133f3e3bbf9/a0628c1690dbd8eb1927800a1dd68be4/wordpress-outdated-php-version-warning.png
Notice the big blue button that says "Learn more about updating PHP" ? By default, that button will take the user to this page: CloudLinux - Main | New template I do not like the CloudLinux page, since it basically tells users "Hey, it's Ok that you are running a crappy old version of PHP, since we have applied security patches to it." -- while it's true that the old versions of PHP are more secure with their Hardening... WordPress still won't work with these old versions of PHP eventually, so it sends the wrong message. We need to get customers to upgrade to a newer version of PHP, right? This page doesn't help. I found out that web hosting providers can inject their own URL, so that when people click "Learn more about updating PHP", hosting providers can send users directly to their own Knowledge Base article, which might explain how to use the PHP Configuration feature in cPanel to change PHP versions (or on CloudLinux, how to use Select PHP Version). This makes much more sense, right? So, this is how I did it... I hope it helps others to do the same: STEP 1 - Check for mod_env and install via EA4 if necessary: Check to see if you have the mod_env Apache Module enabled. From command line, issue the command "apachectl -M | grep env" and look to see if you have "env_module (shared)" -- if yes, proceed to step 2. If not, you need to install it. Please note that you may see "setenvif_module" but that is NOT the same. You need "env_module" To install mod_env, go to WHM > EasyApache 4 > Apache Modules and search for mod_env. If it is toggled off, then just toggle it ON, click Next and follow the normal steps to provision. STEP 2 - Add the special Apache Environment Variable via Include Editor We need to add the special environment variable that WordPress is looking for, which is called WP_UPDATE_PHP_URL. We'll do this via the Apache Include Editor in WHM: Go to WHM > Service Configuration > Apache Configuration > Include Editor, and under Pre VirtualHost Include > All Versions, simply add this one line:
Obviously, you have to change the example.com URL with your own real link to your KB article. Hit Update, then follow the prompts to restart Apache. That's it. Now, if you open a WP site that is using old PHP and see the warning in the Dashboard, it should take you to your own KB article, when you click the Learn More button. NOTE: If you have servers that are used by Resellers, you might want to link to a generic page. In our case, since we use CloudLinux, I linked to the CloudLinux page that explains
Notice the big blue button that says "Learn more about updating PHP" ? By default, that button will take the user to this page: CloudLinux - Main | New template I do not like the CloudLinux page, since it basically tells users "Hey, it's Ok that you are running a crappy old version of PHP, since we have applied security patches to it." -- while it's true that the old versions of PHP are more secure with their Hardening... WordPress still won't work with these old versions of PHP eventually, so it sends the wrong message. We need to get customers to upgrade to a newer version of PHP, right? This page doesn't help. I found out that web hosting providers can inject their own URL, so that when people click "Learn more about updating PHP", hosting providers can send users directly to their own Knowledge Base article, which might explain how to use the PHP Configuration feature in cPanel to change PHP versions (or on CloudLinux, how to use Select PHP Version). This makes much more sense, right? So, this is how I did it... I hope it helps others to do the same: STEP 1 - Check for mod_env and install via EA4 if necessary: Check to see if you have the mod_env Apache Module enabled. From command line, issue the command "apachectl -M | grep env" and look to see if you have "env_module (shared)" -- if yes, proceed to step 2. If not, you need to install it. Please note that you may see "setenvif_module" but that is NOT the same. You need "env_module" To install mod_env, go to WHM > EasyApache 4 > Apache Modules and search for mod_env. If it is toggled off, then just toggle it ON, click Next and follow the normal steps to provision. STEP 2 - Add the special Apache Environment Variable via Include Editor We need to add the special environment variable that WordPress is looking for, which is called WP_UPDATE_PHP_URL. We'll do this via the Apache Include Editor in WHM: Go to WHM > Service Configuration > Apache Configuration > Include Editor, and under Pre VirtualHost Include > All Versions, simply add this one line:
SetEnv WP_UPDATE_PHP_URL "https://example.com/your-kb-article.php"
Obviously, you have to change the example.com URL with your own real link to your KB article. Hit Update, then follow the prompts to restart Apache. That's it. Now, if you open a WP site that is using old PHP and see the warning in the Dashboard, it should take you to your own KB article, when you click the Learn More button. NOTE: If you have servers that are used by Resellers, you might want to link to a generic page. In our case, since we use CloudLinux, I linked to the CloudLinux page that explains
Please sign in to leave a comment.
Comments
0 comments