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

PHP get_network函数代码示例

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

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



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

示例1: getsock

function getsock($addr, $port)
{
    $socket = null;
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    if ($socket === false || $socket === null) {
        $error = socket_strerror(socket_last_error());
        $msg = "socket create(TCP) failed";
        echo "ERR: {$msg} '{$error}'\n";
        return null;
    }
    $res = socket_connect($socket, $addr, $port);
    if ($res === false) {
        $error = socket_strerror(socket_last_error());
        $msg = '<center class="alert alert-danger bs-alert-old-docs">CGMiner is not running...If it is not restart after minutes ,please try to reboot.</center>';
        socket_close($socket);
        echo $msg;
        @exec('sudo service cgminer stop ');
        @exec('sudo service cgminer stop ');
        @exec('sudo service cgminer stop ');
        $network = get_network();
        $gateway = $network['gateway_id'];
        @exec('sudo  route add default gw ' . $gateway);
        //sleep(3);
        //@exec('sudo service cgminer start &');
        //showmsg($msg,'?c=home&m=reboot','10000');
        //echo "ERR: $msg '$error'\n";
        //exit;
        return null;
    }
    return $socket;
}
开发者ID:Tiger66639,项目名称:NewRbox,代码行数:31,代码来源:common.inc.php


示例2: global_home_url

 function global_home_url($path = '', $scheme = null)
 {
     if (!is_multinetwork()) {
         return network_home_url($path, $scheme);
     }
     $main_site_id = get_main_network_id();
     $main_site = get_network($main_site_id);
     $orig_scheme = $scheme;
     if (!in_array($scheme, array('http', 'https', 'relative'))) {
         $scheme = is_ssl() && !is_admin() ? 'https' : 'http';
     }
     if ('relative' == $scheme) {
         $url = $main_site->path;
     } else {
         $url = set_url_scheme('http://' . $main_site->domain . $main_site->path, $scheme);
     }
     if ($path && is_string($path)) {
         $url .= ltrim($path, '/');
     }
     /**
      * Filters the global home URL.
      *
      * @since 1.0.0
      *
      * @param string      $url         The complete global home URL including scheme and path.
      * @param string      $path        Path relative to the global home URL. Blank string
      *                                 if no path is specified.
      * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
      *                                 'relative' or null.
      */
     return apply_filters('global_home_url', $url, $path, $orig_scheme);
 }
开发者ID:felixarntz,项目名称:global-admin,代码行数:32,代码来源:link-template.php


示例3: get_network_status

function get_network_status()
{
    //创建
    $tmp = array();
    //获取网络信息
    $content1 = get_network();
    sleep(1);
    $content2 = get_network();
    //开始生成数据
    foreach ($content1 as $key => $row) {
        $len = strpos($row, ' ');
        $device_name = substr($row, 0, $len);
        //获取信息-接口名称
        $tmp[$key]['device_name'] = $device_name;
        //获取信息-网络速度
        preg_match_all('|RX bytes:(.*) \\(.*\\)  TX bytes:(.*) \\(.*\\)|', $content1[$key], $matches1);
        preg_match_all('|RX bytes:(.*) \\(.*\\)  TX bytes:(.*) \\(.*\\)|', $content2[$key], $matches2);
        $rx1 = (int) $matches1[1][0];
        $rx2 = (int) $matches2[1][0];
        $tx1 = (int) $matches1[2][0];
        $tx2 = (int) $matches2[2][0];
        $tmp[$key]['rx_speed'] = $rx2 - $rx1;
        $tmp[$key]['tx_speed'] = $tx2 - $tx1;
        //获取信息-总流量
        $tmp[$key]['rx_total'] = $rx2;
        $tmp[$key]['tx_total'] = $tx2;
        //获取信息-IPv4地址
        preg_match_all('|inet addr:(\\S+)|', $content1[$key], $matches3);
        $tmp[$key]['ipv4'] = isset($matches3[1][0]) ? $matches3[1][0] : null;
    }
    return $tmp;
}
开发者ID:heweida,项目名称:mmonitor,代码行数:32,代码来源:get.php


示例4: work

function work($scope, $username, $repository, $developer)
{
	// Get some basic data
	$network		= get_network($username, $repository);
	$collaborators	= get_collaborators($username, $repository);

	if ($network === false || $collaborators === false)
	{
		echo "Error: failed to retrieve network or collaborators\n";
		return 1;
	}

	switch ($scope)
	{
		case 'collaborators':
			$remotes = array_intersect_key($network, $collaborators);
		break;

		case 'organisation':
			$remotes = array_intersect_key($network, get_organisation_members($username));
		break;

		case 'contributors':
			$remotes = array_intersect_key($network, get_contributors($username, $repository));
		break;

		case 'network':
			$remotes = $network;
		break;

		default:
			show_usage();
	}

	if (file_exists('.git'))
	{
		add_remote($username, $repository, isset($collaborators[$developer]));
	}
	else
	{
		clone_repository($username, $repository, isset($collaborators[$developer]));
	}

	// Add private security repository for developers
	if ($username == 'phpbb' && $repository == 'phpbb3' && isset($collaborators[$developer]))
	{
		run("git remote add $username-security " . get_repository_url($username, "$repository-security", true));
	}

	// Skip blessed repository.
	unset($remotes[$username]);

	foreach ($remotes as $remote)
	{
		add_remote($remote['username'], $remote['repository'], $remote['username'] == $developer);
	}

	run('git remote update');
}
开发者ID:naderman,项目名称:phpbb-orchestra,代码行数:59,代码来源:setup_github_network.php


示例5: get_dashboard_blog

/**
 * Get the "dashboard blog", the blog where users without a blog edit their profile data.
 * Dashboard blog functionality was removed in WordPress 3.1, replaced by the user admin.
 *
 * @since MU
 * @deprecated 3.1.0 Use get_site()
 * @see get_site()
 *
 * @return WP_Site Current site object.
 */
function get_dashboard_blog()
{
    _deprecated_function(__FUNCTION__, '3.1.0');
    if ($blog = get_site_option('dashboard_blog')) {
        return get_site($blog);
    }
    return get_site(get_network()->site_id);
}
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:18,代码来源:ms-deprecated.php


示例6: test_get_id_from_blogname_invalid_slug

 public function test_get_id_from_blogname_invalid_slug()
 {
     global $current_site;
     $original_network = $current_site;
     $current_site = get_network(self::$network_ids['wordpress.org/']);
     $result = get_id_from_blogname('bar');
     $current_site = $original_network;
     $this->assertEquals(null, $result);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:9,代码来源:getIdFromBlogname.php


示例7: get_perc

function get_perc()
{
    $info = array();
    $info['net_info'] = get_network();
    $info['cpu_info'] = get_cpu();
    $info['disk_info'] = get_disk();
    $info['mem_info'] = get_mem();
    return $info;
}
开发者ID:rchennuri,项目名称:circleci-demo-app,代码行数:9,代码来源:lib.php


示例8: get_id_from_blogname

/**
 * Retrieves a sites ID given its (subdomain or directory) slug.
 *
 * @since MU
 * @since 4.7.0 Converted to use get_sites().
 *
 * @param string $slug A site's slug.
 * @return int|null The site ID, or null if no site is found for the given slug.
 */
function get_id_from_blogname($slug)
{
    $current_network = get_network();
    $slug = trim($slug, '/');
    if (is_subdomain_install()) {
        $domain = $slug . '.' . preg_replace('|^www\\.|', '', $current_network->domain);
        $path = $current_network->path;
    } else {
        $domain = $current_network->domain;
        $path = $current_network->path . $slug . '/';
    }
    $site_ids = get_sites(array('number' => 1, 'fields' => 'ids', 'domain' => $domain, 'path' => $path));
    if (empty($site_ids)) {
        return null;
    }
    return array_shift($site_ids);
}
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:26,代码来源:ms-blogs.php


示例9: create

 /**
  * Add a Network
  *
  * <domain>
  * : Domain for network
  *
  * <path>
  * : Path for network
  *
  * [--site_name=<site_name>]
  * : Name of new network
  *
  * [--clone_network=<clone_network>]
  * : ID of network to clone
  *
  * [--options_to_clone=<options_to_clone>]
  * : Options to clone to new network
  *
  */
 public function create($args, $assoc_args)
 {
     list($domain, $path) = $args;
     $assoc_args = wp_parse_args($assoc_args, array('site_name' => false, 'clone_network' => false, 'options_to_clone' => false));
     $clone_network = $assoc_args['clone_network'];
     $options_to_clone = false;
     if (!empty($clone_network) && !get_network($clone_network)) {
         WP_CLI::error(sprintf(__("Clone network %s doesn't exist.", 'wp-multi-network'), $clone_network));
         if (!empty($assoc_args['options_to_clone'])) {
             $options_to_clone = explode(",", $assoc_args['options_to_clone']);
         }
     }
     // Add the network
     $network_id = add_network(array('domain' => $domain, 'path' => $path, 'site_name' => $assoc_args['site_name'], 'user_id' => get_current_user_id(), 'clone_network' => $clone_network, 'options_to_clone' => $options_to_clone));
     if (is_wp_error($network_id)) {
         WP_CLI::error($network_id);
     }
     WP_CLI::success(sprintf(__('Created network %d.', 'wp-multi-network'), $network_id));
 }
开发者ID:stuttter,项目名称:wp-multi-network,代码行数:38,代码来源:class-wp-ms-networks-cli.php


示例10: ms_cookie_constants

/**
 * Defines Multisite cookie constants.
 *
 * @since 3.0.0
 */
function ms_cookie_constants()
{
    $current_network = get_network();
    /**
     * @since 1.2.0
     */
    if (!defined('COOKIEPATH')) {
        define('COOKIEPATH', $current_network->path);
    }
    /**
     * @since 1.5.0
     */
    if (!defined('SITECOOKIEPATH')) {
        define('SITECOOKIEPATH', $current_network->path);
    }
    /**
     * @since 2.6.0
     */
    if (!defined('ADMIN_COOKIE_PATH')) {
        if (!is_subdomain_install() || trim(parse_url(get_option('siteurl'), PHP_URL_PATH), '/')) {
            define('ADMIN_COOKIE_PATH', SITECOOKIEPATH);
        } else {
            define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
        }
    }
    /**
     * @since 2.0.0
     */
    if (!defined('COOKIE_DOMAIN') && is_subdomain_install()) {
        if (!empty($current_network->cookie_domain)) {
            define('COOKIE_DOMAIN', '.' . $current_network->cookie_domain);
        } else {
            define('COOKIE_DOMAIN', '.' . $current_network->domain);
        }
    }
}
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:41,代码来源:ms-default-constants.php


示例11: get_current_network_id

/**
 * Retrieves the current network ID.
 *
 * @since 4.6.0
 *
 * @return int The ID of the current network.
 */
function get_current_network_id()
{
    if (!is_multisite()) {
        return 1;
    }
    $current_network = get_network();
    if (!isset($current_network->id)) {
        return get_main_network_id();
    }
    return absint($current_network->id);
}
开发者ID:johnpbloch,项目名称:wordpress,代码行数:18,代码来源:load.php


示例12: switch

 switch ($_GET['action']) {
     case 'deleteblog':
         if (!current_user_can('delete_sites')) {
             wp_die(__('Sorry, you are not allowed to access this page.'), '', array('response' => 403));
         }
         $updated_action = 'not_deleted';
         if ($id != '0' && $id != get_network()->site_id && current_user_can('delete_site', $id)) {
             wpmu_delete_blog($id, true);
             $updated_action = 'delete';
         }
         break;
     case 'allblogs':
         if ((isset($_POST['action']) || isset($_POST['action2'])) && isset($_POST['allblogs'])) {
             $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
             foreach ((array) $_POST['allblogs'] as $key => $val) {
                 if ($val != '0' && $val != get_network()->site_id) {
                     switch ($doaction) {
                         case 'delete':
                             if (!current_user_can('delete_site', $val)) {
                                 wp_die(__('Sorry, you are not allowed to delete the site.'));
                             }
                             $updated_action = 'all_delete';
                             wpmu_delete_blog($val, true);
                             break;
                         case 'spam':
                         case 'notspam':
                             $updated_action = 'spam' === $doaction ? 'all_spam' : 'all_notspam';
                             update_blog_status($val, 'spam', 'spam' === $doaction ? '1' : '0');
                             break;
                     }
                 } else {
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:31,代码来源:sites.php


示例13: confirm_delete_users

         $parent_file = 'users.php';
         require_once ABSPATH . 'wp-admin/admin-header.php';
         echo '<div class="wrap">';
         confirm_delete_users($_POST['allusers']);
         echo '</div>';
         require_once ABSPATH . 'wp-admin/admin-footer.php';
         exit;
     case 'spam':
         $user = get_userdata($user_id);
         if (is_super_admin($user->ID)) {
             wp_die(sprintf(__('Warning! User cannot be modified. The user %s is a network administrator.'), esc_html($user->user_login)));
         }
         $userfunction = 'all_spam';
         $blogs = get_blogs_of_user($user_id, true);
         foreach ((array) $blogs as $details) {
             if ($details->userblog_id != get_network()->site_id) {
                 // main blog not a spam !
                 update_blog_status($details->userblog_id, 'spam', '1');
             }
         }
         update_user_status($user_id, 'spam', '1');
         break;
     case 'notspam':
         $userfunction = 'all_notspam';
         $blogs = get_blogs_of_user($user_id, true);
         foreach ((array) $blogs as $details) {
             update_blog_status($details->userblog_id, 'spam', '0');
         }
         update_user_status($user_id, 'spam', '0');
         break;
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:31,代码来源:users.php


示例14: wp_get_network

/**
 * Retrieve an object containing information about the requested network.
 *
 * @since 3.9.0
 *
 * @internal In 4.6.0, converted to use get_network()
 *
 * @param object|int $network The network's database row or ID.
 * @return WP_Network|false Object containing network information if found, false if not.
 */
function wp_get_network($network)
{
    $network = get_network($network);
    if (null === $network) {
        return false;
    }
    return $network;
}
开发者ID:Garth619,项目名称:Femi9,代码行数:18,代码来源:ms-load.php


示例15: Chart

		    label: "Used RAM"
                }
            ];
            // pie chart options
            var dohOptions = {
                 segmentShowStroke : false,
                 animateScale : true
            }
            // get pie chart canvas
            var memory= document.getElementById("memory").getContext("2d");
            // draw pie chart
            new Chart(memory).Pie(dohData, dohOptions);
</script>
<script>
<?php 
$net_info = get_network();
$netTX = $net_info['tx'];
$netRX = $net_info['rx'];
$netEr = $net_info['ex'];
$netDr = $net_info['dx'];
?>
var netOptions = {
	animateRotate : true,
	scaleShowLabelBackdrop : true
	}
var netData = [
    {
        value: <?php 
print $netRX;
?>
,
开发者ID:aws-joe,项目名称:solano-labs-docker,代码行数:31,代码来源:index.php


示例16: set_current_screen

 * @global int       $total_update_count
 * @global string    $parent_file
 */
global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow, $update_title, $total_update_count, $parent_file;
// Catch plugins that include admin-header.php before admin.php completes.
if (empty($current_screen)) {
    set_current_screen();
}
get_admin_page_title();
$title = esc_html(strip_tags($title));
if (is_network_admin()) {
    /* translators: Network admin screen title. 1: Network name */
    $admin_title = sprintf(__('Network Admin: %s'), esc_html(get_network()->site_name));
} elseif (is_user_admin()) {
    /* translators: User dashboard screen title. 1: Network name */
    $admin_title = sprintf(__('User Dashboard: %s'), esc_html(get_network()->site_name));
} else {
    $admin_title = get_bloginfo('name');
}
if ($admin_title == $title) {
    /* translators: Admin screen title. 1: Admin screen name */
    $admin_title = sprintf(__('%1$s &#8212; WordPress'), $title);
} else {
    /* translators: Admin screen title. 1: Admin screen name, 2: Network or site name */
    $admin_title = sprintf(__('%1$s &lsaquo; %2$s &#8212; WordPress'), $title, $admin_title);
}
/**
 * Filters the title tag content for an admin page.
 *
 * @since 3.1.0
 *
开发者ID:johnpbloch,项目名称:wordpress,代码行数:31,代码来源:admin-header.php


示例17: do_register

function do_register()
{
    $network = get_network();
    switch ($_GET['status']) {
        case 'check':
            $user_or_code = get_user();
            if (!$user_or_code) {
                $user_or_code = get_code();
            }
            if (!$user_or_code) {
                echo 'available';
            } else {
                echo 'taken';
            }
            return;
        case 'new_code':
            $sql = 'INSERT INTO ' . db_table('codes') . ' (network_id, username, password, valid_from, created, ' . access_control_fields() . ') ' . 'VALUES (' . $network['id'] . ',\'' . $_GET['user'] . '\',\'' . $_GET['pass'] . '\', now(), now(), ' . access_control_values($network, 'defcode') . ')';
            $resource = 'codes';
            break;
        case 'new_user':
            $sql = 'INSERT INTO ' . db_table('users') . ' (network_id, username, password, valid_from, created, ' . access_control_fields() . ') ' . 'VALUES (' . $network['id'] . ',\'' . $_GET['user'] . '\',\'' . $_GET['pass'] . '\', now(), now(), ' . access_control_values($network, 'defuser') . ')';
            $resource = 'users';
            break;
    }
    db_query($sql, false);
    $id = db_lastid();
    if ($id) {
        $input = $_POST;
        if (!$input) {
            $input = file_get_contents("php://input");
        }
        $lines = preg_split("/\n+/", $input);
        $attrs = array();
        foreach ($lines as $line) {
            $p = preg_split('/[=: ]+/', $line, 2);
            if ($p[0] && $p[1]) {
                $attrs[$p[0]] = $p[1];
            }
        }
        save_attributes($id, $resource, $attrs);
    }
}
开发者ID:ynezz,项目名称:coova-chilli,代码行数:42,代码来源:http-aaa-example.php


示例18: fopen

print "Writing Netmask cache...\n";
$fd = fopen("mapper-cache.txt", "w");
foreach ($interfaces as $key => $int) {
    if (isset($int['netmask'])) {
        fputs($fd, $key . "\t" . $int['netmask'] . "\n");
        $count++;
    }
}
fclose($fd);
print "Wrote {$count} cache entries.\n";
# SNMP netmask => .1.3.6.1.2.1.4.20.1.3.10.1.1.254
# SNMP interface index => .1.3.6.1.2.1.4.20.1.2.10.1.1.254
$count = 0;
foreach ($interfaces as $key => $int) {
    if (isset($int['netmask'])) {
        $network = get_network($int['ip'], $int['netmask']) . "/" . get_cidr($int['netmask']);
        $interfaces[$key]['network'] = $network;
        $networks[$network][] = $key;
        $count++;
    } else {
        print $int['ip'] . "\n";
    }
}
print "Assembled {$count} different network/netmask pairs\n";
$link_config = "";
$node_config = "";
$nodes_seen = array();
$count = 0;
$linkid = 0;
$lannodeid = 0;
foreach ($networks as $network => $members) {
开发者ID:jiangxilong,项目名称:network-weathermap,代码行数:31,代码来源:cacti-mapper.php


示例19: _e

		<tr class="form-field form-required">
			<th scope="row"><label for="site-address"><?php 
_e('Site Address (URL)');
?>
</label></th>
			<td>
			<?php 
if (is_subdomain_install()) {
    ?>
				<input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off"/><span class="no-break">.<?php 
    echo preg_replace('|^www\\.|', '', get_network()->domain);
    ?>
</span>
			<?php 
} else {
    echo get_network()->domain . get_network()->path;
    ?>
<input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc"  autocapitalize="none" autocorrect="off" />
			<?php 
}
echo '<p class="description" id="site-address-desc">' . __('Only lowercase letters (a-z), numbers, and hyphens are allowed.') . '</p>';
?>
			</td>
		</tr>
		<tr class="form-field form-required">
			<th scope="row"><label for="site-title"><?php 
_e('Site Title');
?>
</label></th>
			<td><input name="blog[title]" type="text" class="regular-text" id="site-title" /></td>
		</tr>
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:31,代码来源:site-new.php


示例20: wp_install_defaults

    /**
     * Creates the initial content for a newly-installed site.
     *
     * Adds the default "Uncategorized" category, the first post (with comment),
     * first page, and default widgets for default theme for the current version.
     *
     * @since 2.1.0
     *
     * @global wpdb       $wpdb
     * @global WP_Rewrite $wp_rewrite
     * @global string     $table_prefix
     *
     * @param int $user_id User ID.
     */
    function wp_install_defaults($user_id)
    {
        global $wpdb, $wp_rewrite, $table_prefix;
        // Default category
        $cat_name = __('Uncategorized');
        /* translators: Default category slug */
        $cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
        if (global_terms_enabled()) {
            $cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug));
            if ($cat_id == null) {
                $wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)));
                $cat_id = $wpdb->insert_id;
            }
            update_option('default_category', $cat_id);
        } else {
            $cat_id = 1;
        }
        $wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0));
        $wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
        $cat_tt_id = $wpdb->insert_id;
        // First post
        $now = current_time('mysql');
        $now_gmt = current_time('mysql', 1);
        $first_post_guid = get_option('home') . '/?p=1';
        if (is_multisite()) {
            $first_post = get_site_option('first_post');
            if (!$first_post) {
                /* translators: %s: site link */
                $first_post = __('Welcome to %s. This is your first post. Edit or delete it, then start blogging!');
            }
            $first_post = sprintf($first_post, sprintf('<a href="%s">%s</a>', esc_url(network_home_url()), get_network()->site_name));
            // Back-compat for pre-4.4
            $first_post = str_replace('SITE_URL', esc_url(network_home_url()), $first_post);
            $first_post = str_replace('SITE_NAME', get_network()->site_name, $first_post);
        } else {
            $first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start writing!');
        }
        $wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_post, 'post_excerpt' => '', 'post_title' => __('Hello world!'), 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'comment_count' => 1, 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
        $wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1));
        // Default comment
        $first_comment_author = __('A WordPress Commenter');
        $first_comment_email = '[email protected]';
        $first_comment_url = 'https://wordpress.org/';
        $first_comment = __('Hi, this is a comment.
To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.');
        if (is_multisite()) {
            $first_comment_author = get_site_option('first_comment_author', $first_comment_author);
            $first_comment_email = get_site_option('first_comment_email', $first_comment_email);
            $first_comment_url = get_site_option('first_comment_url', network_home_url());
            $first_comment = get_site_option('first_comment', $first_comment);
        }
        $wpdb->insert($wpdb->comments, array('comment_post_ID' => 1, 'comment_author' => $first_comment_author, 'comment_author_email' => $first_comment_email, 'comment_author_url' => $first_comment_url, 'comment_date' => $now, 'comment_date_gmt' => $now_gmt, 'comment_content' => $first_comment));
        // First Page
        $first_page = sprintf(__("This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:\n\n<blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>\n\n...or something like this:\n\n<blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>\n\nAs a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!"), admin_url());
        if (is_multisite()) {
            $first_page = get_site_option('first_page', $first_page);
        }
        $first_post_guid = get_option('home') . '/?page_id=2';
        $wpdb->insert($wpdb->posts, array('post_author' => $user_id, 'post_date' => $now, 'post_date_gmt' => $now_gmt, 'post_content' => $first_page, 'post_excerpt' => '', 'comment_status' => 'closed', 'post_title' => __('Sample Page'), 'post_name' => __('sample-page'), 'post_modified' => $now, 'post_modified_gmt' => $now_gmt, 'guid' => $first_post_guid, 'post_type' => 'page', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => ''));
        $wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default'));
        // Set up default widgets for default theme.
        update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1));
        update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
        update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1));
        update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1));
        update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1));
        update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1));
        update_option('sidebars_widgets', array('wp_inactive_widgets' => array(), 'sidebar-1' => array(0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2'), 'sidebar-2' => array(), 'sidebar-3' => array(), 'array_version' => 3));
        if (!is_multisite()) {
            update_user_meta($user_id, 'show_welcome_panel', 1);
        } elseif (!is_super_admin($user_id) && !metadata_exists('user', $user_id, 'show_welcome_panel')) {
            update_user_meta($user_id, 'show_welcome_panel', 2);
        }
        if (is_multisite()) {
            // Flush rules to pick up the new page.
            $wp_rewrite->init();
            $wp_rewrite->flush_rules();
            $user = new WP_User($user_id);
            $wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email'));
            // Remove all perms except for the login user.
            $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level'));
            $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities'));
            // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
            if (!is_super_admin($user_id) && $user_id != 1) {
                $wpdb->delete($wpdb->usermeta, array('user_id' => $user_id, 'meta_key' => $wpdb->base_prefix . '1_capabilities'));
//.........这里部分代码省略.........
开发者ID:johnpbloch,项目名称:wordpress,代码行数:101,代码来源:upgrade.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_network_css函数代码示例发布时间:2022-05-15
下一篇:
PHP get_nectar_theme_options函数代码示例发布时间: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