不仅仅是一个答案,一项关于这件事的研究
Excel问题我们需要一个数组,Excel可以提供CSV解决方案:How to extract data from csv file in php? <此处未实施相关问题;所有人的共同点是:no definitive procedure has been recorded in this Stack。
测试代码基于OneTrickPony第一个问题
只能运行once。我不知道有什么更好的方法我是not sure如果admin_init
是运行此功能的最佳位置尚未测量,但此代码does not runs fast (本样本中有3个站点)有一个awful CSS bug 运行代码后在管理中。禁用挂钩并重新加载页面后,一切正常,所有站点都已创建。(!?)
/* Enable the hook, refresh the dashboard, <WAIT>, disable again */
// add_action(\'admin_init\',\'wpse_54647_testing_code\');
function wpse_54647_testing_code()
{
$site = get_current_site();
$meta = array(
\'blogdescription\' => \'blog description\'
, \'users_can_register\' => 1
);
$sites_array = array(
array(
\'title\' => \'site 1\'
, \'domain\' => \'site1\'
, \'user\' => \'site1\'
, \'pass\' => \'pass1\'
, \'email\' => \'[email protected]\'
)
, array(
\'title\' => \'site 2\'
, \'domain\' => \'site2\'
, \'user\' => \'site2\'
, \'pass\' => \'pass2\'
, \'email\' => \'[email protected]\'
)
, array(
\'title\' => \'site 3\'
, \'domain\' => \'site3\'
, \'user\' => \'site3\'
, \'pass\' => \'pass3\'
, \'email\' => \'[email protected]\'
)
);
for( $i = 0; $i < count($sites_array); $i++ )
{
$user = wp_insert_user( array (
\'user_login\' => $sites_array[$i][\'user\']
, \'user_pass\' => $sites_array[$i][\'pass\']
, \'user_email\' => $sites_array[$i][\'email\']
) );
$blog_id = wpmu_create_blog(
$sites_array[$i][\'domain\'] . \'.\' . $site->domain
, \'/\'
, $site_titles[$i][\'title\']
, $user
, $meta
, $site->id
);
}
}