本文整理汇总了PHP中get_current_site函数的典型用法代码示例。如果您正苦于以下问题:PHP get_current_site函数的具体用法?PHP get_current_site怎么用?PHP get_current_site使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_current_site函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Check that legacy data exists before doing anything
*
* @return void
*/
public static function load()
{
// Exit early if there is no option holding the DB version
if (false === get_site_option('wp_stream_db')) {
return;
}
global $wpdb;
// If there are no legacy tables found, then attempt to clear all legacy data and exit early
if (null === $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->base_prefix}stream'")) {
self::drop_legacy_data(false);
return;
}
self::$site_id = is_multisite() ? get_current_site()->id : 1;
self::$blog_id = get_current_blog_id();
$since = WP_Stream::$api->get_plan_retention_max_date();
self::$record_count = $wpdb->get_var($wpdb->prepare("\n\t\t\t\tSELECT COUNT(*)\n\t\t\t\tFROM {$wpdb->base_prefix}stream AS s, {$wpdb->base_prefix}stream_context AS sc\n\t\t\t\tWHERE s.site_id = %d\n\t\t\t\t\tAND s.blog_id = %d\n\t\t\t\t\tAND s.type = 'stream'\n\t\t\t\t\tAND s.created > %s\n\t\t\t\t\tAND sc.record_id = s.ID\n\t\t\t\t", self::$site_id, self::$blog_id, $since));
// If there are no legacy records for this site/blog, then attempt to clear all legacy data and exit early
if (0 === self::$record_count) {
self::drop_legacy_data();
return;
}
self::$limit = apply_filters('wp_stream_migrate_chunk_size', 100);
add_action('admin_notices', array(__CLASS__, 'migrate_notice'), 9);
add_action('wp_ajax_wp_stream_migrate_action', array(__CLASS__, 'process_migrate_action'));
}
示例2: primary
/**
* In a multisite, returns the id of the primary site in the network.
* Otherwise, returns the same value as get_current_blog_id()
* @return integer
*/
static function primary()
{
if (is_multisite()) {
return get_current_site()->blog_id;
}
return get_current_blog_id();
}
示例3: render
function render()
{
$this->open_section_box($this->id, __("Create New Site", "ns-cloner"), false, __("Create Site", "ns-cloner"));
?>
<label for="target_title"><?php
_e("Give the Target site a Title", "ns-cloner");
?>
</label>
<input type="text" name="target_title" placeholder="New Site H1"/>
<label for="target_name"><?php
_e("Give the Target site a URL (or \"Name\" in WP terminology)", "ns-cloner");
?>
</label>
<?php
if (is_subdomain_install()) {
?>
<input type="text" name="target_name" />.<?php
echo preg_replace('|^www\\.|', '', get_current_site()->domain);
?>
<?php
} else {
?>
<?php
echo get_current_site()->domain . get_current_site()->path;
?>
<input type="text" name="target_name" />
<?php
}
?>
<?php
$this->close_section_box();
}
示例4: log
public function log($connector, $message, $args, $object_id, $contexts, $user_id = null)
{
global $wpdb;
if (is_null($user_id)) {
$user_id = get_current_user_id();
}
require_once MAINWP_WP_STREAM_INC_DIR . 'class-wp-stream-author.php';
$user = new WP_User($user_id);
$roles = get_option($wpdb->get_blog_prefix() . 'user_roles');
if (!isset($args['author_meta'])) {
$args['author_meta'] = array('user_email' => $user->user_email, 'display_name' => defined('WP_CLI') && empty($user->display_name) ? 'WP-CLI' : $user->display_name, 'user_login' => $user->user_login, 'user_role_label' => !empty($user->roles) ? $roles[$user->roles[0]]['name'] : null, 'agent' => MainWP_WP_Stream_Author::get_current_agent());
if (defined('WP_CLI') && function_exists('posix_getuid')) {
$uid = posix_getuid();
$user_info = posix_getpwuid($uid);
$args['author_meta']['system_user_id'] = $uid;
$args['author_meta']['system_user_name'] = $user_info['name'];
}
}
// Remove meta with null values from being logged
$meta = array_filter($args, function ($var) {
return !is_null($var);
});
$recordarr = array('object_id' => $object_id, 'site_id' => is_multisite() ? get_current_site()->id : 1, 'blog_id' => apply_filters('blog_id_logged', is_network_admin() ? 0 : get_current_blog_id()), 'author' => $user_id, 'author_role' => !empty($user->roles) ? $user->roles[0] : null, 'created' => current_time('mysql', 1), 'summary' => vsprintf($message, $args), 'parent' => self::$instance->prev_record, 'connector' => $connector, 'contexts' => $contexts, 'meta' => $meta, 'ip' => mainwp_wp_stream_filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP));
$record_id = MainWP_WP_Stream_DB::get_instance()->insert($recordarr);
return $record_id;
}
示例5: setup_constants
protected function setup_constants()
{
$domain = strtoupper($this->args['domain']);
// JUST IN CASE
defined($domain . '_TEXTDOMAIN') or define($domain . '_TEXTDOMAIN', $this->args['domain']);
defined($domain . '_ENABLE_MULTIROOTBLOG') or define($domain . '_ENABLE_MULTIROOTBLOG', FALSE);
if (!defined($domain . '_ROOT_BLOG')) {
// root blog is the main site on this network
if (is_multisite() && !constant($domain . '_ENABLE_MULTIROOTBLOG')) {
$current_site = get_current_site();
// root blogs for multi-network
if (defined($domain . '_SITE_ROOT_BLOG_' . $current_site->id)) {
$root_blog_id = constant($domain . '_SITE_ROOT_BLOG_' . $current_site->id);
} else {
$root_blog_id = $current_site->blog_id;
}
// root blog is every site on this network
} else {
if (is_multisite() && constant($domain . '_ENABLE_MULTIROOTBLOG')) {
$root_blog_id = $this->current_blog;
// root blog is the only blog on this network
} else {
if (!is_multisite()) {
$root_blog_id = 1;
}
}
}
define($domain . '_ROOT_BLOG', $root_blog_id);
}
}
示例6: 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_blog_details()
* @see get_blog_details()
*
* @return int Current site ID.
*/
function get_dashboard_blog()
{
_deprecated_function(__FUNCTION__, '3.1.0');
if ($blog = get_site_option('dashboard_blog')) {
return get_blog_details($blog);
}
return get_blog_details(get_current_site()->blog_id);
}
示例7: override_base_var
function override_base_var()
{
global $base;
if (!is_multisite()) {
return;
}
$base = get_current_site()->path;
}
示例8: list_
/**
* ## OPTIONS
*
* [<network>]
* : Network ID (defaults to current network, use `--url=...`)
*
* [--format=<format>]
* : Format to display as (table, json, csv, count)
*
* @subcommand list
*/
public function list_($args, $assoc_args)
{
$id = empty($args[0]) ? get_current_site()->id : absint($args[0]);
$mappings = Network_Mapping::get_by_network($id);
if (empty($mappings)) {
return;
}
$this->display($mappings, $assoc_args);
}
示例9: comicpress_profile_members_only
function comicpress_profile_members_only()
{
global $profileuser, $errormsg;
$comicpress_is_member = get_user_meta($profileuser->ID, 'comicpress-is-member', true);
if (empty($comicpress_is_member)) {
$comicpress_is_member = 0;
}
$site_name = get_option('blogname');
if (is_multisite()) {
$current_site = get_current_site();
if (!isset($current_site->site_name)) {
$site_name = ucfirst($current_site->domain);
} else {
$site_name = $current_site->site_name;
}
}
?>
<div style="border: solid 1px #aaa; background: #eee; padding: 0 10px 10px;">
<h3><?php
_e('Member of', 'comicpress');
?>
<?php
echo $site_name;
?>
</h3>
<table class="form-table">
<tr>
<th><label for="Memberflag"><?php
_e('Member?', 'comicpress');
?>
</label></th>
<td>
<?php
if (current_user_can('edit_users') || is_super_admin()) {
?>
<input id="comicpress-is-member" name="comicpress-is-member" type="checkbox" value="1" <?php
checked(true, $comicpress_is_member);
?>
/>
<?php
} else {
if ($comicpress_is_member) {
echo 'Is Member';
} else {
echo 'Not a Member';
}
}
?>
</td>
</tr>
</table>
</div>
<br />
<br />
<?php
}
示例10: __construct
/**
* The Constructor function adds the function that pushes published posts to the list, as well as registers the widget.
*/
function __construct()
{
load_plugin_textdomain('hrpn', false, dirname(plugin_basename(__FILE__)) . '/languages');
add_action('publish_post', array($this, 'Add_Post_To_H1_Recent_Posts_From_Network'));
add_action('widgets_init', array($this, 'Register_H1_Recent_Posts_From_Network_Widget'));
$first_post = get_site_option('first_post');
$first_post = str_replace("SITE_URL", esc_url(network_home_url()), $first_post);
$first_post = str_replace("SITE_NAME", get_current_site()->site_name, $first_post);
$this->first_post = $first_post;
}
开发者ID:ZeelandFamily,项目名称:h1-recent-posts-from-network,代码行数:13,代码来源:HerculesRecentPostsfromNetwork.php
示例11: subdomain_body_class
function subdomain_body_class($classes)
{
global $subdomain;
$site = get_current_site()->domain;
$url = get_bloginfo('url');
$sub = preg_replace('@http://@i', '', $url);
$sub = preg_replace('@' . $site . '@i', '', $sub);
$sub = preg_replace('@\\.@i', '', $sub);
$classes[] = 'site-' . $sub;
$subdomain = $sub;
return $classes;
}
示例12: ra_bp_multinetwork_meta_key_filter
function ra_bp_multinetwork_meta_key_filter($key)
{
global $wpdb;
static $user_meta_keys = array('last_activity' => false, 'bp_new_mention_count' => false, 'bp_favorite_activities' => false, 'bp_latest_update' => false, 'total_friend_count' => false, 'total_group_count' => false, 'notification_groups_group_updated' => false, 'notification_groups_membership_request' => false, 'notification_membership_request_completed' => false, 'notification_groups_admin_promotion' => false, 'notification_groups_invite' => false, 'notification_messages_new_message' => false, 'notification_messages_new_notice' => false, 'closed_notices' => false, 'profile_last_updated' => false, 'notification_activity_new_mention' => false, 'notification_activity_new_reply' => false);
if ($wpdb->siteid < 2 || !isset($user_meta_keys[$key])) {
return $key;
}
if (!$user_meta_keys[$key]) {
$current_site = get_current_site();
$user_meta_keys[$key] = $wpdb->get_blog_prefix($current_site->blog_id) . $key;
}
return $user_meta_keys[$key];
}
示例13: comicpress_hosted_on
function comicpress_hosted_on()
{
if (is_multisite()) {
$current_site = get_current_site();
if (!isset($current_site->site_name)) {
$site_name = ucfirst($current_site->domain);
} else {
$site_name = $current_site->site_name;
}
$output = "<span class=\"footer-pipe\">|</span> ";
$output .= __('Hosted on', 'comicpress') . ' <a href="http://' . $current_site->domain . $current_site->path . '">' . $site_name . '</a> ';
return apply_filters('comicpress_hosted_on', $output);
}
}
示例14: resetCronSetup
/**
* Resets `crons_setup` and clears WP-Cron schedules.
*
* @since 151220 Fixing bug with Auto-Cache Engine cron disappearing in some scenarios
*
* @note This MUST happen upon uninstall and deactivation due to buggy WP_Cron behavior. Events with a custom schedule will disappear when plugin is not active (see http://bit.ly/1lGdr78).
*/
public function resetCronSetup()
{
if (is_multisite()) {
// Main site CRON jobs.
switch_to_blog(get_current_site()->blog_id);
wp_clear_scheduled_hook('_cron_' . GLOBAL_NS . '_cleanup');
restore_current_blog();
// Restore current blog.
} else {
// Standard WP installation.
wp_clear_scheduled_hook('_cron_' . GLOBAL_NS . '_cleanup');
}
$this->updateOptions(['crons_setup' => $this->default_options['crons_setup'], 'crons_setup_on_namespace' => $this->default_options['crons_setup_on_namespace'], 'crons_setup_with_cache_cleanup_schedule' => $this->default_options['crons_setup_with_cache_cleanup_schedule'], 'crons_setup_on_wp_with_schedules' => $this->default_options['crons_setup_on_wp_with_schedules']]);
}
示例15: bu_navigation_sandbox_init
/**
* Add a bu-navigation site if this plugin is being tested by lettuce.
* This sets up for the "User is warned when leaving changes" scenario
*/
function bu_navigation_sandbox_init($response, $coverage, $users)
{
if (in_array('plugin-bu-navigation', $coverage)) {
$network = get_current_site();
$domain = $network->domain;
$admin_id = get_current_user_id();
$options = array('users' => array('site_admin' => array($users['site_admin']), 'contributor' => array($users['contributor'])), 'network_id' => $network->id);
// Public site, no ACL
$path = '/bu-navigation/';
$title = 'BU Navigation';
$site_id = bu_create_site($domain, $path, $title, $admin_id, $options);
bu_navigation_sandbox_setup_site($response, $site_id, 'bu-navigation');
}
}