我目前正在编写一个 wordpress 插件,但遇到了一些问题。我的功能在插件激活后无法运行...有人可以告诉我问题出在哪里吗?
类 my_plugin {
公共$ajaxurl;
公共 $excanvas;
公共 $plugin_path = '';
函数 __construct()
{
register_activation_hook(__FILE__,array(&$this, 'install'));
}
公共函数 wpmon_install()
{
//将我的页面模板复制到当前主题。
$plugin_path = getcwd() 。目录分隔符。'wp-内容'。目录分隔符。'插件' 。目录分隔符。'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 作为 $files)
{
$basename = basename($files);
尝试{
$target = $target_path 。$基本名称;
复制($文件,$目标);
}
捕获(异常 $e){
$this->log_error($e->getMessage());
}
}
}
但不幸的是,安装功能不起作用......但是当在课堂外时,“安装”功能内的这段代码正在工作