[wp-hackers] readme.txt: "Requires PHP 5 tag"
scribu
scribu at gmail.com
Fri Jul 17 21:15:52 UTC 2009
On Sat, Jul 18, 2009 at 12:11 AM, Geoffrey Sneddon <
foolistbar at googlemail.com> wrote:
>
> /**
>> * plugin_activation_check()
>> *
>> * Replace "plugin" with the name of your plugin
>> */
>> function plugin_activation_check(){
>> if (version_compare(PHP_VERSION, '5.0.0', '<')) {
>> deactivate_plugins(basename(__FILE__)); // Deactivate
>> ourself
>> wp_die("Sorry, but you can't run this plugin, it requires
>> PHP 5 or higher.");
>> }
>> }
>> register_activation_hook(__FILE__, 'plugin_activation_check');
>>
>
> But if you use PHP 5 only syntax, you'll have a fatal error thrown and thus
> that code will never be executed.
>
Supporting PHP4 is a huge pita. Having said that,
You could place the code with PHP5 syntax in a separate file and include it
only after you've done the above check.
--
http://scribu.net
More information about the wp-hackers
mailing list