wpmu_current_site [ WordPress Function ]
wpmu_current_site ( No parameters )
| Access: |
|
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: get_current_site, wp_get_current_user, wp_set_current_user, current_filter, current_time
Sets current_site object.
Source
<?php
function wpmu_current_site() {
global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain;
if ( empty( $current_site ) )
$current_site = new stdClass;
if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
$current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
$current_site->domain = DOMAIN_CURRENT_SITE;
$current_site->path = $path = PATH_CURRENT_SITE;
if ( defined( 'BLOG_ID_CURRENT_SITE' ) )
$current_site->blog_id = BLOG_ID_CURRENT_SITE;
elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) // deprecated.
$current_site->blog_id = BLOGID_CURRENT_SITE;
if ( DOMAIN_CURRENT_SITE == $domain )
$current_site->cookie_domain = $cookie_domain;
elseif ( substr( $current_site->domain, 0, 4 ) == 'www.' )
$current_site->cookie_domain = substr( $current_site->domain, 4 );
else
$current_site->cookie_domain = $current_site->domain;
wp_load_core_site_options( $current_site->id );
return $current_site;
}
$current_site = wp_cache_get( 'current_site', 'site-options' );
if ( $current_site )
return $current_site;
$sites = $wpdb->get_results( "SELECT * FROM $wpdb->site" ); // usually only one site
if ( 1 == count( $sites ) ) {
$current_site = $sites[0];
wp_load_core_site_options( $current_site->id );
$path = $current_site->path;
$current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) );
$current_site = get_current_site_name( $current_site );
if ( substr( $current_site->domain, 0, 4 ) == 'www.' )
$current_site->cookie_domain = substr( $current_site->domain, 4 );
wp_cache_set( 'current_site', $current_site, 'site-options' );
return $current_site;
}
$path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) );
if ( $domain == $cookie_domain )
$current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $domain, $path ) );
else
$current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE domain IN ( %s, %s ) AND path = %s ORDER BY CHAR_LENGTH( domain ) DESC LIMIT 1", $domain, $cookie_domain, $path ) );
if ( ! $current_site ) {
if ( $domain == $cookie_domain )
$current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $domain ) );
else
$current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain IN ( %s, %s ) AND path = '/' ORDER BY CHAR_LENGTH( domain ) DESC LIMIT 1", $domain, $cookie_domain, $path ) );
}
if ( $current_site ) {
$path = $current_site->path;
$current_site->cookie_domain = $cookie_domain;
return $current_site;
}
if ( is_subdomain_install() ) {
$sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) );
$current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path) );
if ( $current_site ) {
$current_site->cookie_domain = $current_site->domain;
return $current_site;
}
$current_site = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s AND path='/'", $sitedomain) );
}
if ( $current_site || defined( 'WP_INSTALLING' ) ) {
$path = '/';
return $current_site;
}
// Still no dice.
wp_load_translations_early();
if ( 1 == count( $sites ) )
wp_die( sprintf( __( 'That site does not exist. Please try <a href="%s">%s</a>.' ), 'http://' . $sites[0]->domain . $sites[0]->path ) );
else
wp_die( __( 'No site defined on this host. If you are the owner of this site, please check <a href="http://codex.wordpress.org/Debugging_a_WordPress_Network">Debugging a WordPress Network</a> for help.' ) );
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- wpmu_current_site (WordPress Function) - WPSeek.com
WordPress lookup for wpmu_current_site, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme authors.
wpseek.com - WordPress › Support » wpmu_current_site wrong
pileofrogs. Member Posted 3 months ago #. Hi all. I've screwed up my WP install. I'm a unix admin at a community college. I'm installing a WP network for faculty.
wordpress.org - (wpmu_current_site() calls an undefined function) - WordPress Trac
Fatal error: Call to undefined function () in /Users/denis/Sites/wp-trunk/wp- includes/ms-load.php on line 175. found after taking a legacy site and defining ...
core.trac.wordpress.org - #12736 (my-sites.php uses site url instead of home url in visit links ...
ms-load.php function wpmu_current_site()//messes up cookie domains due to the home, site url related faults. ms-settings.php 83: $destination = "http://" .
core.trac.wordpress.org