我想创建一个新注册用户有自己网站的网站。新网站必须有我的模板的内容和一些选项激活。我正在使用Customizer,这很好。
我还没有更改默认Customizer的初始选项。所以我考虑在每次用户注册时,用注册数据(子域名、用户名等)自动复制我的模板。
我认为NS clone有一个附加组件,但我不确定。此外,我更喜欢手动操作。
有人知道怎么做吗?
我想创建一个新注册用户有自己网站的网站。新网站必须有我的模板的内容和一些选项激活。我正在使用Customizer,这很好。
我还没有更改默认Customizer的初始选项。所以我考虑在每次用户注册时,用注册数据(子域名、用户名等)自动复制我的模板。
我认为NS clone有一个附加组件,但我不确定。此外,我更喜欢手动操作。
有人知道怎么做吗?
最后,我将使用Multisite Cloner. 这不受支持,但工作正常。
我自动化了https://wordpress.org/plugins/blog-copier/ 来解决这个问题。如果您只想手动执行,请使用此插件,否则,这是我的自动版本:
include "BlogCopierExtended.php";
add_action("wpmu_activate_blog", "blog_copy",15,3);
function blog_copy($blog_id)
{
// first I save the options I want to preserve
$customer_name = get_blog_option($blog_id, "customer_name");
// get the customized class
$blog_copier = new BlogCopierExtended();
// the default blog, from where to copy the data from
$default_blog = get_id_from_blogname( "default" );
// copy this
$copy_now = $blog_copier->copy_blog_to_existing($blog_id, "", "", $default_blog, true);
// now we save the values back
update_blog_option($blog_id, "customer_name", $customer_name);
}
博客复制器扩展类是这样的if (class_exists(\'BlogCopier\')) {
class BlogCopierExtended extends BlogCopier
{
public function copy_blog_to_existing($blog_id, $domain, $title, $from_blog_id = 0, $copy_files = true)
{
global $wpdb, $current_site, $base;
$email = get_blog_option($from_blog_id, \'admin_email\');
$user_id = email_exists(sanitize_email($email));
if (!$user_id) {
// Use current user instead
$user_id = get_current_user_id();
}
// The user id of the user that will become the blog admin of the new blog.
$user_id = apply_filters(\'copy_blog_user_id\', $user_id, $from_blog_id);
if (is_subdomain_install()) {
$newdomain = $domain . "." . $current_site->domain;
$path = $base;
}
else {
$newdomain = $current_site->domain;
$path = trailingslashit($base) . trailingslashit($domain);
}
// The new domain that will be created for the destination blog.
$newdomain = apply_filters(\'copy_blog_domain\', $newdomain, $domain);
// The new path that will be created for the destination blog.
$path = apply_filters(\'copy_blog_path\', $path, $domain);
$wpdb->hide_errors();
// $to_blog_id = get_current_blog_id();
$to_blog_id = $blog_id;
$wpdb->show_errors();
if (!is_wp_error($to_blog_id)) {
$dashboard_blog = get_dashboard_blog();
if (!is_super_admin() && get_user_option(\'primary_blog\', $user_id) == $dashboard_blog->blog_id) update_user_option($user_id, \'primary_blog\', $to_blog_id, true);
// now copy
if ($from_blog_id) {
$this->copy_blog_data($from_blog_id, $to_blog_id);
if ($copy_files) {
$this->copy_blog_files($from_blog_id, $to_blog_id);
$this->replace_content_urls($from_blog_id, $to_blog_id);
}
$msg = sprintf(__(\'Copied: %s in %s seconds\', $this->_domain) , \'<a href="http://\' . $newdomain . \'" target="_blank">\' . $title . \'</a>\', number_format_i18n(timer_stop()));
// do_action( \'log\', __( \'Copy Complete!\', $this->_domain ), $this->_domain, $msg );
// do_action( \'copy_blog_complete\', $from_blog_id, $to_blog_id );
}
}
else {
$msg = $to_blog_id->get_error_message();
}
return $msg;
}
}
}
应该这样做Intro: 我正在初步规划WordPress多站点开发环境,我所在的机构将在该环境中构建我们客户的网站。我们目前正在构建一个“香草”主题,并计划将其用作基础主题。该计划包括为每个客户端创建一个新的子主题,并使用该子主题创建客户端主题,保持普通主题不受自定义代码和覆盖的影响。我们的客户来自同一行业,因此,他们在其网站上共享相同的要求和功能。使用多站点设置有助于将所有内容保持在一个位置,并根据网站的设计进行区分。The question: 我不能清楚地想到的是一个将所有内容组织到版本控制和跨不同环境的解决方