wp plugin -4

plugin激活

插件激活时,plugin activation function将会被触发。register_activation_hook()。主要用于设置默认options、检测版本兼容等。

register_activation_hook( $file, $function );

$file - (string) (required) — Path to the primary plugin file

$function - (string) (required) — The function to be executed when the plugin is activated

例如:

< ?php

register_activation_hook( __FILE__, ‘boj_install’ );

function boj_install() {

If ( version_compare( get_bloginfo( ‘version’ ), ‘3.1’, ‘ < ’ ) ) {

deactivate_plugins( basename( __FILE__ ) ); // Deactivate our plugin

}

}

? >

 

posted on 2012-12-03 13:06  kalintw  阅读(105)  评论(0)    收藏  举报

导航