[wp-hackers] readme.txt: "Requires PHP 5 tag"

Jordi Canals jcanals at alkivia.com
Wed Jul 15 09:59:41 UTC 2009


I set a message on the section INSTALL on readme.txt, as a
requirement. But some users did not read anything before downloading
and installing, so, I manage like this on all my plugins:

On the main plugin file, I have just this:

/**
 * Sets an admin warning regarding required PHP version.
 *
 * @hook action 'admin_notices'
 * @return void
 */
function _ucom_php_warning() {

	$data = get_plugin_data(__FILE__);
	load_plugin_textdomain('akucom', false, basename(dirname(__FILE__)) .'/lang');

	echo '<div class="error"><p><strong>' . __('Warning:', 'akucom') . '</strong> '
		. sprintf(__('The active plugin %s is not compatible with your PHP
version.', 'akucom') .'</p><p>', '&laquo;' . $data['Name'] . ' ' .
$data['Version'] . '&raquo;')
		. sprintf(__('%s is required for this plugin.', 'akucom'), 'PHP-5 ')
. '</p></div>';
}

// Check required PHP version.
if ( version_compare(PHP_VERSION, '5.0.0', '<') ) {
	// Send an armin warning
	add_action('admin_notices', '_ucom_php_warning');
} else {
	include ( 'plugin-filename.php');
}

And all stuff goes into plugin-filename.php. This way users will
receive an admin notice on the dashboard and the plugin does nothing
if activated,

Best regards,

-- 
Jordi Canals [Txanny]
http://alkivia.org


2009/7/15 Lutz Schröer <latz at elektroelch.de>:
> Otto wrote:
>>
>> Don't rely on users, they're invariably idiots. ;)
>>
>> Make your plugin smarter instead.
>>
>> register_activation_hook(__FILE__, 'plugin_activation_check');
>>
>>
>
> My problems aren't those who update through the backend but those who update
> manually (downloading from wp.org, unzipping, uploading to blog).
>
> I think I'm going to check for the PHP version and print a big hint in the
> backend (maybe even in the dashboard), and add a  small hint in the blog and
> only execute PHP4 code, so that the blog will not stop from rendering
> completely.
>
> BTW: I stopped the auto-update by using add_filter('option_update_plugins',
> 'plugin_prevent_upgrade');. Works for me, I will blog this solution soon (or
> you can look it up in the "pagebar" plugin.
>
> lutz
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list