(wordpress)如何在插件激活时在插件中运行一个函数

时间:2012-05-17 02:15:38

标签: php wordpress

我已经使用了register_activation_hook,但它没有用。

<?php
  /*
  * Plugin Name: practice
  * Plugin URI: http://ramguiao.tk
  * Description: practice
  * Version: 1.0
  * Author: Ram Guiao
  * Author URI: http://ramguiao.tk 
  */

 register_activation_hook(_FILE_,"showMessage");

 function showMessage(){
     echo "activated";
 }

&GT;

谢谢!

1 个答案:

答案 0 :(得分:3)

变化:

register_activation_hook(_FILE_,"showMessage");

要:

register_activation_hook(__FILE__,"showMessage");