• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP install_blog函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中install_blog函数的典型用法代码示例。如果您正苦于以下问题:PHP install_blog函数的具体用法?PHP install_blog怎么用?PHP install_blog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了install_blog函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: jquery_install_site

function jquery_install_site($site, $user)
{
    $sites = jquery_sites();
    $details = $sites[$site];
    if (strpos($site, '/')) {
        list($domain, $path) = explode('/', $site, 2);
        $path = '/' . trim($path, '/') . '/';
    } else {
        $domain = $site;
        $path = '/';
    }
    $default_options = jquery_default_site_options();
    $default_options['admin_email'] = $user->user_email;
    if (1 !== $details['blog_id']) {
        $blog_id = insert_blog(JQUERY_STAGING_PREFIX . $domain, $path, 1);
        if ($blog_id != $details['blog_id']) {
            wp_die("Something went very wrong when trying to install {$domain} as site {$blog_id}-{$details['blog_id']}. Find nacin.");
        }
        switch_to_blog($blog_id);
        install_blog($blog_id, $details['options']['blogname']);
        add_user_to_blog($blog_id, $user->ID, 'administrator');
    }
    $options = array_merge($default_options, $details['options']);
    foreach ($options as $option => $value) {
        update_option($option, $value);
    }
    delete_option('rewrite_rules');
    restore_current_blog();
}
开发者ID:hryniu555,项目名称:jquery-wp-content,代码行数:29,代码来源:install.php


示例2: jquery_install_remaining_sites

function jquery_install_remaining_sites($user)
{
    $domains = jquery_domains();
    $default_options = jquery_default_site_options();
    $default_options['admin_email'] = $user->user_email;
    foreach ($domains as $domain => $details) {
        if (1 !== $details['blog_id']) {
            $blog_id = insert_blog(JQUERY_STAGING_PREFIX . $domain, '/', 1);
            if ($blog_id != $details['blog_id']) {
                wp_die("Something went very wrong when trying to install {$domain} as site {$blog_id}-{$details['blog_id']}. Find nacin.");
            }
            switch_to_blog($blog_id);
            install_blog($blog_id, $details['options']['blogname']);
            add_user_to_blog($blog_id, $user->ID, 'administrator');
        }
        $options = array_merge($default_options, $details['options']);
        foreach ($options as $option => $value) {
            update_option($option, $value);
        }
        // Work around a superficial bug in install_blog(), fixed in WP r21172.
        $home = untrailingslashit(get_option('home'));
        $siteurl = untrailingslashit(get_option('siteurl'));
        update_option('home', 'http://example.com');
        // Please just don't ask.
        update_option('siteurl', 'http://example.com');
        update_option('home', $home);
        update_option('siteurl', $siteurl);
        flush_rewrite_rules();
        restore_current_blog();
    }
}
开发者ID:ravasthi,项目名称:web-base-template,代码行数:31,代码来源:install.php


示例3: wpmu_create_blog

/**
 * Create a site.
 *
 * This function runs when a user self-registers a new site as well
 * as when a Super Admin creates a new site. Hook to 'wpmu_new_blog'
 * for events that should affect all new sites.
 *
 * On subdirectory installs, $domain is the same as the main site's
 * domain, and the path is the subdirectory name (eg 'example.com'
 * and '/blog1/'). On subdomain installs, $domain is the new subdomain +
 * root domain (eg 'blog1.example.com'), and $path is '/'.
 *
 * @since MU
 * @uses domain_exists()
 * @uses insert_blog()
 * @uses wp_install_defaults()
 * @uses add_user_to_blog()
 *
 * @param string $domain The new site's domain.
 * @param string $path The new site's path.
 * @param string $title The new site's title.
 * @param int $user_id The user ID of the new site's admin.
 * @param array $meta Optional. Used to set initial site options.
 * @param int $site_id Optional. Only relevant on multi-network installs.
 * @return mixed Returns WP_Error object on failure, int $blog_id on success
 */
function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1)
{
    $domain = preg_replace('/\\s+/', '', sanitize_user($domain, true));
    if (is_subdomain_install()) {
        $domain = str_replace('@', '', $domain);
    }
    $title = strip_tags($title);
    $user_id = (int) $user_id;
    if (empty($path)) {
        $path = '/';
    }
    // Check if the domain has been used already. We should return an error message.
    if (domain_exists($domain, $path, $site_id)) {
        return new WP_Error('blog_taken', __('Site already exists.'));
    }
    if (!defined('WP_INSTALLING')) {
        define('WP_INSTALLING', true);
    }
    if (!($blog_id = insert_blog($domain, $path, $site_id))) {
        return new WP_Error('insert_blog', __('Could not create site.'));
    }
    switch_to_blog($blog_id);
    install_blog($blog_id, $title);
    wp_install_defaults($user_id);
    add_user_to_blog($blog_id, $user_id, 'administrator');
    if (is_array($meta)) {
        foreach ($meta as $key => $value) {
            if ($key == 'public' || $key == 'archived' || $key == 'mature' || $key == 'spam' || $key == 'deleted' || $key == 'lang_id') {
                update_blog_status($blog_id, $key, $value);
            } else {
                update_option($key, $value);
            }
        }
    }
    add_option('WPLANG', get_site_option('WPLANG'));
    update_option('blog_public', (int) $meta['public']);
    if (!is_super_admin() && !get_user_meta($user_id, 'primary_blog', true)) {
        update_user_meta($user_id, 'primary_blog', $blog_id);
    }
    restore_current_blog();
    do_action('wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta);
    return $blog_id;
}
开发者ID:nhemsley,项目名称:wordpress,代码行数:69,代码来源:ms-functions.php


示例4: create_empty_blog

/**
 * Create an empty blog.
 *
 * @since MU 1.0
 * @deprecated 4.4.0
 *
 * @param string $domain       The new blog's domain.
 * @param string $path         The new blog's path.
 * @param string $weblog_title The new blog's title.
 * @param int    $site_id      Optional. Defaults to 1.
 * @return string|int The ID of the newly created blog
 */
function create_empty_blog($domain, $path, $weblog_title, $site_id = 1)
{
    _deprecated_function(__FUNCTION__, '4.4.0');
    if (empty($path)) {
        $path = '/';
    }
    // Check if the domain has been used already. We should return an error message.
    if (domain_exists($domain, $path, $site_id)) {
        return __('<strong>ERROR</strong>: Site URL already taken.');
    }
    // Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
    // Need to get blog_id from wp_blogs, and create new table names.
    // Must restore table names at the end of function.
    if (!($blog_id = insert_blog($domain, $path, $site_id))) {
        return __('<strong>ERROR</strong>: problem creating site entry.');
    }
    switch_to_blog($blog_id);
    install_blog($blog_id);
    restore_current_blog();
    return $blog_id;
}
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:33,代码来源:ms-deprecated.php


示例5: wpmu_create_blog

/**
 * Create a site.
 *
 * This function runs when a user self-registers a new site as well
 * as when a Super Admin creates a new site. Hook to 'wpmu_new_blog'
 * for events that should affect all new sites.
 *
 * On subdirectory installs, $domain is the same as the main site's
 * domain, and the path is the subdirectory name (eg 'example.com'
 * and '/blog1/'). On subdomain installs, $domain is the new subdomain +
 * root domain (eg 'blog1.example.com'), and $path is '/'.
 *
 * @since MU
 *
 * @param string $domain  The new site's domain.
 * @param string $path    The new site's path.
 * @param string $title   The new site's title.
 * @param int    $user_id The user ID of the new site's admin.
 * @param array  $meta    Optional. Used to set initial site options.
 * @param int    $site_id Optional. Only relevant on multi-network installs.
 * @return int|WP_Error Returns WP_Error object on failure, int $blog_id on success
 */
function wpmu_create_blog($domain, $path, $title, $user_id, $meta = array(), $site_id = 1)
{
    $defaults = array('public' => 0);
    $meta = wp_parse_args($meta, $defaults);
    $domain = preg_replace('/\\s+/', '', sanitize_user($domain, true));
    if (is_subdomain_install()) {
        $domain = str_replace('@', '', $domain);
    }
    $title = strip_tags($title);
    $user_id = (int) $user_id;
    if (empty($path)) {
        $path = '/';
    }
    // Check if the domain has been used already. We should return an error message.
    if (domain_exists($domain, $path, $site_id)) {
        return new WP_Error('blog_taken', __('Sorry, that site already exists!'));
    }
    if (!wp_installing()) {
        wp_installing(true);
    }
    if (!($blog_id = insert_blog($domain, $path, $site_id))) {
        return new WP_Error('insert_blog', __('Could not create site.'));
    }
    switch_to_blog($blog_id);
    install_blog($blog_id, $title);
    wp_install_defaults($user_id);
    add_user_to_blog($blog_id, $user_id, 'administrator');
    foreach ($meta as $key => $value) {
        if (in_array($key, array('public', 'archived', 'mature', 'spam', 'deleted', 'lang_id'))) {
            update_blog_status($blog_id, $key, $value);
        } else {
            update_option($key, $value);
        }
    }
    add_option('WPLANG', get_site_option('WPLANG'));
    update_option('blog_public', (int) $meta['public']);
    if (!is_super_admin($user_id) && !get_user_meta($user_id, 'primary_blog', true)) {
        update_user_meta($user_id, 'primary_blog', $blog_id);
    }
    restore_current_blog();
    /**
     * Fires immediately after a new site is created.
     *
     * @since MU
     *
     * @param int    $blog_id Blog ID.
     * @param int    $user_id User ID.
     * @param string $domain  Site domain.
     * @param string $path    Site path.
     * @param int    $site_id Site ID. Only relevant on multi-network installs.
     * @param array  $meta    Meta data. Used to set initial site options.
     */
    do_action('wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta);
    return $blog_id;
}
开发者ID:Jitsufreak,项目名称:PJ,代码行数:77,代码来源:ms-functions.php



注:本文中的install_blog函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP install_check_requirements函数代码示例发布时间:2022-05-15
下一篇:
PHP install_already_done_error函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap