wordpress 插件初始化 和页面跳转

//在插件初始化(激活插件的时候)的时候执行的函数
//适用于建立数据表,设置一些初始值
register_activation_hook( __FILE__, 'create_ciphp_remal_table' );
function create_ciphp_remal_table()
{
	global $wpdb;
	if(@is_file(ABSPATH.'/wp-admin/upgrade-functions.php'))
	{
		include_once(ABSPATH.'/wp-admin/upgrade-functions.php');
	}
	elseif(@is_file(ABSPATH.'/wp-admin/includes/upgrade.php'))
	{
		include_once(ABSPATH.'/wp-admin/includes/upgrade.php');
	}
	else
	{
		die('We have problem finding your 
'/wp-admin/upgrade-functions.php' and
 '/wp-admin/includes/upgrade.php'');
	}
	$table_charset= '';
	if($wpdb->supports_collation())
	{
		if(!empty($wpdb->charset))
		{
			$table_charset= "DEFAULT CHARACTER SET $wpdb->charset";
		}
		if(!empty($wpdb->collate))
		{
			$table_charset.= " COLLATE $wpdb->collate";
		}
	}
	$sql= "";
	maybe_create_table($wpdb->prefix."user_fav",$sql);
}


wordpress页面跳转函数

wp_redirect(get_bloginfo('url').'/wp-login.php?redirect_to='.get_bloginfo('url').'/member');
//redirect_to参数告诉WP登录超过了跳转到什么页面,默认是wp-admin

PS:如果有发现wordpress分类无故丢失的清空,重启下mysql 可能会解决!

2 评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注