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

Otto otto at ottodestruct.com
Mon Jul 20 13:20:47 UTC 2009

You don't even need to do that. As long as the PHP 5 code doesn't get
executed on the initial include, then it works fine.

It's like this:
 * 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');

function do_plugin_actual_work() {
// a bunch of php 5 only code here

That will run fine. PHP only will throw an error if it actually makes
it to the code. Code is interpreted at the time of execution, not at
the time of inclusion. You can include a file with complete gibberish
inside a function, but until you try to use that function, it won't
stop the program.


On Fri, Jul 17, 2009 at 9:45 PM, Aaron D. Campbell<aaron at xavisys.com> wrote:
> No offense to the PHP 4 users out there, but it's not worth the hassle.
> Chris Jean wrote:
>> In other words, you could create a small base plugin file that contained
>> the plugin meta-data to register the plugin and contained nothing more than
>> the version check as Otto described. If the version check passes, load the
>> necessary code from another file included with the plugin.
>> Chris Jean
> _______________________________________________
> 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