本文整理汇总了PHP中get_main_network_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_main_network_id函数的具体用法?PHP get_main_network_id怎么用?PHP get_main_network_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_main_network_id函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: is_main_network
/**
* Determine whether a network is the main network of the Multisite install.
*
* @since 3.7.0
*
* @param int $network_id Optional. Network ID to test. Defaults to current network.
* @return bool True if $network_id is the main network, or if not running Multisite.
*/
function is_main_network($network_id = null)
{
if (!is_multisite()) {
return true;
}
$current_network_id = (int) get_current_site()->id;
if (null === $network_id) {
$network_id = $current_network_id;
}
$network_id = (int) $network_id;
return $network_id === get_main_network_id();
}
开发者ID:hpilevar,项目名称:WordPress,代码行数:20,代码来源:functions.php
示例3: wp_get_main_network
/**
* Get the main network
*
* Uses the same logic as {@see is_main_network}, but returns the network object
* instead.
*
* @return stdClass|null
*/
function wp_get_main_network()
{
global $wpdb;
if (!is_multisite()) {
return null;
}
// Added in 4.3.0
if (function_exists('get_main_network_id')) {
$primary_network_id = get_main_network_id();
// 4.2.0
} else {
// Override
if (defined('PRIMARY_NETWORK_ID')) {
return wp_get_network((int) PRIMARY_NETWORK_ID);
}
// Check cache
$primary_network_id = (int) wp_cache_get('primary_network_id', 'site-options');
if (!empty($primary_network_id)) {
return wp_get_network($primary_network_id);
}
$primary_network_id = (int) $wpdb->get_var("SELECT id FROM {$wpdb->site} ORDER BY id LIMIT 1");
wp_cache_add('primary_network_id', $primary_network_id, 'site-options');
}
return wp_get_network($primary_network_id);
}
开发者ID:tlandn,项目名称:akvo-sites-zz-template,代码行数:33,代码来源:functions-wp-ms-networks.php
示例4: 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
示例5: die
}
die('WordPress Core directory could not be detected.');
}
define('WP_GLOBAL_ADMIN', true);
/** Load WordPress Administration Bootstrap */
require_once _ga_detect_abspath() . '/wp-admin/admin.php';
// This would be it if it was part of Core.
//require_once( dirname( dirname( __FILE__ ) ) . '/admin.php' );
if (!is_multisite()) {
wp_die(__('Multisite support is not enabled.'));
}
if (!is_multinetwork()) {
wp_die(__('Multinetwork support is not enabled.', 'global-admin'));
}
$current_network = get_network();
$main_network_id = get_main_network_id();
$main_network = get_network($main_network_id);
$redirect_global_admin_request = 0 !== strcasecmp($current_network->domain, $main_network->domain) || 0 !== strcasecmp($current_network->path, $main_network->path);
/**
* Filters whether to redirect the request to the Global Admin.
*
* @since 1.0.0
*
* @param bool $redirect_global_admin_request Whether the request should be redirected.
*/
$redirect_global_admin_request = apply_filters('redirect_global_admin_request', $redirect_global_admin_request);
if ($redirect_global_admin_request) {
wp_redirect(global_admin_url());
exit;
}
unset($current_network);
开发者ID:felixarntz,项目名称:global-admin,代码行数:31,代码来源:admin.php
示例6: wp_get_main_network
/**
* Get the main network
*
* Uses the same logic as {@see is_main_network}, but returns the network object
* instead.
*
* @return stdClass|null
*/
function wp_get_main_network()
{
// Bail if not multisite
if (!is_multisite()) {
return null;
}
// Return main network ID
return wp_get_network(get_main_network_id());
}
开发者ID:richardtape,项目名称:wp-multi-network,代码行数:17,代码来源:functions-wp-ms-networks.php
示例7: test_get_main_network_id_filtered
function test_get_main_network_id_filtered()
{
add_filter('get_main_network_id', array($this, '_get_main_network_id'));
$this->assertEquals(3, get_main_network_id());
remove_filter('get_main_network_id', array($this, '_get_main_network_id'));
}
开发者ID:ntwb,项目名称:wordpress-travis,代码行数:6,代码来源:network.php
示例8: page_delete_networks
/**
* Output the delete multiple networks page
*
* @since 2.0.0
*/
private function page_delete_networks()
{
// Get posted networks
$network_id = get_main_network_id();
$all_networks = isset($_POST['all_networks']) ? array_map('absint', $_POST['all_networks']) : array();
// Prevent primary network from being deleted
$all_networks = array_diff($all_networks, array($network_id));
// Query for networks
$networks = get_networks(array('network__in' => $all_networks));
// Bail if no networks
if (empty($networks)) {
wp_die(esc_html__('You have selected an invalid network or networks for deletion', 'wp-multi-network'));
}
// Ensure each network is valid
foreach ($networks as $network) {
if (!get_network($network)) {
wp_die(esc_html__('You have selected an invalid network for deletion.', 'wp-multi-network'));
}
}
// Query for sites in selected networks
$sites = get_sites(array('network__in' => $all_networks));
?>
<div class="wrap">
<h1><?php
esc_html_e('Networks', 'wp-multi-network');
?>
</h1>
<h3><?php
esc_html_e('Delete Multiple Networks', 'wp-multi-network');
?>
</h3>
<form method="post" action="<?php
echo esc_url($this->admin_url());
?>
">
<?php
if (!empty($sites)) {
?>
<div class="error inline">
<h3><?php
esc_html_e('You have selected the following networks for deletion', 'wp-multi-network');
?>
:</h3>
<ul>
<?php
foreach ($networks as $deleted_network) {
?>
<li><input type="hidden" name="deleted_networks[]" value="<?php
echo esc_attr($deleted_network->id);
?>
"><?php
echo esc_html($deleted_network->domain . $deleted_network->path);
?>
</li>
<?php
}
?>
</ul>
<p><?php
// Messaging
wp_should_rescue_orphaned_sites() ? esc_html_e('One or more of these networks has existing sites. Deleting these networks will orphan these sites.', 'wp-multi-network') : esc_html_e('One or more of these networks has existing sites. Deleting these networks will permanently delete these sites.', 'wp-multi-network');
?>
</p>
<p>
<label for="override"><?php
esc_html_e('Please confirm that you still want to delete these networks', 'wp-multi-network');
?>
:</label>
<input type="checkbox" name="override" id="override">
</p>
</div>
<?php
} else {
?>
<div id="message inline">
<h3><?php
esc_html_e('You have selected the following networks for deletion', 'wp-multi-network');
?>
:</h3>
<ul><?php
foreach ($networks as $deleted_network) {
?>
<li><input type="hidden" name="deleted_networks[]" value="<?php
echo esc_attr($deleted_network->id);
?>
"><?php
echo esc_html($deleted_network->domain . $deleted_network->path);
?>
</li><?php
}
?>
//.........这里部分代码省略.........
开发者ID:stuttter,项目名称:wp-multi-network,代码行数:101,代码来源:class-wp-ms-networks-admin.php
示例9: global_step2
function global_step2()
{
$main_network_id = get_main_network_id();
$main_network = get_network($main_network_id);
$hostname = $main_network->domain;
$abspath_fix = str_replace('\\', '/', ABSPATH);
$location_of_wp_config = $abspath_fix;
if (!file_exists(ABSPATH . 'wp-config.php') && file_exists(dirname(ABSPATH) . '/wp-config.php')) {
$location_of_wp_config = dirname($abspath_fix);
}
$location_of_wp_config = trailingslashit($location_of_wp_config);
if ($_POST || !is_multinetwork()) {
?>
<h3><?php
esc_html_e('Enabling the Multinetwork');
?>
</h3>
<p><?php
_e('Complete the following steps to enable the global admin panel for creating multiple networks.');
?>
</p>
<div class="updated inline"><p>
<?php
printf(__('We recommend you back up your existing %s file.', 'global-admin'), '<code>wp-config.php</code>');
?>
</p></div>
<?php
} else {
?>
<p><?php
_e('The original configuration steps are shown here for reference.', 'global-admin');
?>
</p>
<?php
}
?>
<ol>
<li>
<p><?php
printf(__('Add the following to your %1$s file in %2$s <strong>above</strong> the line reading %3$s:', 'global-admin'), '<code>wp-config.php</code>', '<code>' . $location_of_wp_config . '</code>', '<code>/* ' . __('That’s all, stop editing! Happy blogging.', 'global-admin') . ' */</code>');
?>
</p>
<textarea class="code" readonly="readonly" cols="100" rows="2">
define('MULTINETWORK', true);
</textarea>
</li>
</ol>
<?php
if (!is_multinetwork()) {
?>
<p><?php
_e('Once you complete these steps, your multinetwork is enabled and configured.', 'global-admin');
?>
</p>
<?php
}
}
开发者ID:felixarntz,项目名称:global-admin,代码行数:57,代码来源:global.php
注:本文中的get_main_network_id函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论