Skip to content

Releases: wpsharks/wp-php-rv

WP PHP RV 150422

23 Apr 06:04
Compare
Choose a tag to compare
PSR 1,2,4 compat.

WP PHP RV v141007

07 Oct 01:53
Compare
Choose a tag to compare
  • Adding the ability to require specific PHP extensions too. See: #1 for details.

Can I Test for Required PHP Extensions Too?

Yes, $GLOBALS['wp_php_rv'] can be either a string with a required version, or an array with both a required version and a nested array of required PHP extensions. The easiest way to show how this works is by example (as seen below). Note that your array of required PHP extensions must be compatible with PHP's extension_loaded() function.

<?php
$GLOBALS['wp_php_rv']['rv'] = '5.3';
$GLOBALS['wp_php_rv']['re'] = array('curl', 'mbstring');

if(require(dirname(__FILE__).'/wp-php-rv.php')) // `TRUE` if running PHP vX.x+ w/ all required extensions.
    require dirname(__FILE__).'/my-plugin-code.php'; // It's OK to load your plugin.
else wp_php_rv_notice('My Plugin'); // Dashboard notice mentions your software specifically.

Note: with this technique, the dashboard notice may vary depending on the scenario. If only the required PHP version is missing, the dashboard notice will mention this only. If the required PHP version is satisified, but the PHP installation is missing one or more required PHP extensions, only those required extensions will be mentioned to a site owner. If neither can be satisfied (i.e. the required version of PHP is missing, AND one or more required PHP extensions are missing too), the dashboard notice will mention both the required version of PHP, and include a list of the required PHP extensions they are missing. It's quite dynamic! ~ Also, when/if missing PHP extensions are listed for a site owner, they're automatically linked up, leading a site owner to the relevant section of the manual at PHP.net.

WP PHP RV v141005

05 Oct 02:16
Compare
Choose a tag to compare
  • Improved dashboard notice.
  • Added a LICENSE.txt file (GPL v2+).
  • Improved docBlocks in wp-php-rv.php.

Improved Dashboard Notice...

2014-10-04_17-56-09

NEW: If you omit the $software_name argument to wp_php_rv_notice(), a default value is used instead. The default value is ucwords('[calling file basedir]'); e.g. if /my-plugin/stub.php calls wp-php-rv.php, the default $software_name automatically becomes My Plugin. Nice!