I currently writing a wordpress plugin, and i encountered some problem. my function does not run upon plugin activation... can somebody tell me where is the proble?
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());
}
}
}
but unfortunately the install function not working... but when outside class this code inside 'install' func is working