我目前正在寫一個wordpress插件,我遇到了一些問題。 我的功能不會在插件激活時運行...有人可以告訴我問題在哪裏?WordPress的:register_activation_hook不工作
class my_plugin { public $ajaxurl; public $excanvas; public $plugin_path = ''; function __construct() { register_activation_hook(__FILE__,array(&$this, 'install')); } public function wpmon_install() { //Copy my page template to current theme. $plugin_path = getcwd() . DIRECTORY_SEPARATOR . 'wp-content'. DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'wpmon' . DIRECTORY_SEPARATOR; $target_path = get_stylesheet_directory(). DIRECTORY_SEPARATOR; $target_path = str_replace('/',DIRECTORY_SEPARATOR,$target_path); $template_files = glob($plugin_path . 'page_template'.DIRECTORY_SEPARATOR.'*.php'); foreach($template_files as $files) { $basename = basename($files); try{ $target = $target_path . $basename; copy($files , $target); } catch(Exception $e){ $this->log_error($e->getMessage()); } } }
可惜安裝功能不工作... 但當外類中「安裝」這個代碼FUNC工作
我也嘗試過,但仍然沒有好... – Monski