本文整理汇总了PHP中get_blogaddress_by_name函数的典型用法代码示例。如果您正苦于以下问题:PHP get_blogaddress_by_name函数的具体用法?PHP get_blogaddress_by_name怎么用?PHP get_blogaddress_by_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_blogaddress_by_name函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_created_site_details
/**
* Test the cache keys and database tables setup through the creation of a site.
*/
function test_created_site_details()
{
global $wpdb;
$blog_id = self::factory()->blog->create();
$this->assertInternalType('int', $blog_id);
$prefix = $wpdb->get_blog_prefix($blog_id);
// $get_all = false, only retrieve details from the blogs table
$details = get_blog_details($blog_id, false);
// Combine domain and path for a site specific cache key.
$key = md5($details->domain . $details->path);
$this->assertEquals($details, wp_cache_get($blog_id . 'short', 'blog-details'));
// get_id_from_blogname(), see #20950
$this->assertEquals($blog_id, get_id_from_blogname($details->path));
$this->assertEquals($blog_id, wp_cache_get('get_id_from_blogname_' . trim($details->path, '/'), 'blog-details'));
// get_blogaddress_by_name()
$this->assertEquals('http://' . $details->domain . $details->path, get_blogaddress_by_name(trim($details->path, '/')));
// These are empty until get_blog_details() is called with $get_all = true
$this->assertEquals(false, wp_cache_get($blog_id, 'blog-details'));
$this->assertEquals(false, wp_cache_get($key, 'blog-lookup'));
// $get_all = true, populate the full blog-details cache and the blog slug lookup cache
$details = get_blog_details($blog_id, true);
$this->assertEquals($details, wp_cache_get($blog_id, 'blog-details'));
$this->assertEquals($details, wp_cache_get($key, 'blog-lookup'));
// Check existence of each database table for the created site.
foreach ($wpdb->tables('blog', false) as $table) {
$suppress = $wpdb->suppress_errors();
$table_fields = $wpdb->get_results("DESCRIBE {$prefix}{$table};");
$wpdb->suppress_errors($suppress);
// The table should exist.
$this->assertNotEmpty($table_fields);
// And the table should not be empty, unless commentmeta, termmeta, or links.
$result = $wpdb->get_results("SELECT * FROM {$prefix}{$table} LIMIT 1");
if ('commentmeta' == $table || 'termmeta' == $table || 'links' == $table) {
$this->assertEmpty($result);
} else {
$this->assertNotEmpty($result);
}
}
// update the blog count cache to use get_blog_count()
wp_update_network_counts();
$this->assertEquals(2, (int) get_blog_count());
}
示例2: is_user_logged_in
* Fires when the site sign-up form is sent.
*
* @since 3.0.0
*/
do_action( 'preprocess_signup_form' );
if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) )
signup_another_blog($newblogname);
elseif ( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) )
signup_user( $newblogname, $user_email );
elseif ( is_user_logged_in() == false && ( $active_signup == 'blog' ) )
_e( 'Sorry, new registrations are not allowed at this time.' );
else
_e( 'You are logged in already. No need to register again!' );
if ( $newblogname ) {
$newblog = get_blogaddress_by_name( $newblogname );
if ( $active_signup == 'blog' || $active_signup == 'all' )
printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist, but you can create it now!' ) . '</em></p>', $newblog );
else
printf( '<p><em>' . __( 'The site you were looking for, <strong>%s</strong>, does not exist.' ) . '</em></p>', $newblog );
}
break;
}
}
?>
</div>
</div>
<?php
/**
* Fires after the sign-up forms, before wp_footer.
示例3: test_getters
function test_getters(){
global $current_site;
$blog_id = get_current_blog_id();
$blog = get_blog_details( $blog_id );
$this->assertEquals( $blog_id, $blog->blog_id );
$this->assertEquals( $current_site->domain, $blog->domain );
$this->assertEquals( '/', $blog->path );
// Test defaulting to current blog
$this->assertEquals( $blog, get_blog_details() );
$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogname', 'title' => 'Test Title' ) );
$this->assertInternalType( 'int', $blog_id );
$this->assertEquals( 'http://' . DOMAIN_CURRENT_SITE . PATH_CURRENT_SITE . 'test_blogname/', get_blogaddress_by_name('test_blogname') );
$this->assertEquals( $blog_id, get_id_from_blogname('test_blogname') );
}
示例4: tml_display_register
//.........这里部分代码省略.........
<p><?php
_e('But, before you can start using your site, <strong>you must activate it</strong>.', 'theme-my-login');
?>
</p>
<p><?php
printf(__('Check your inbox at <strong>%s</strong> and click the link given.', 'theme-my-login'), $user_email);
?>
</p>
<p><?php
_e('If you do not activate your site within two days, you will have to sign up again.', 'theme-my-login');
?>
</p>
<h2><?php
_e('Still waiting for your email?', 'theme-my-login');
?>
</h2>
<p>
<?php
_e('If you haven’t received your email yet, there are a number of things you can do:', 'theme-my-login');
?>
<ul id="noemail-tips">
<li><p><strong><?php
_e('Wait a little longer. Sometimes delivery of email can be delayed by processes outside of our control.', 'theme-my-login');
?>
</strong></p></li>
<li><p><?php
_e('Check the junk or spam folder of your email client. Sometime emails wind up there by mistake.', 'theme-my-login');
?>
</p></li>
<li><?php
printf(__('Have you entered your email correctly? You have entered %s, if it’s incorrect, you will not receive your email.', 'theme-my-login'), $user_email);
?>
</li>
</ul>
</p>
<?php
do_action('signup_finished');
} else {
_e('Site registration has been disabled.', 'theme-my-login');
}
break;
case 'gimmeanotherblog':
$current_user = wp_get_current_user();
if (!is_user_logged_in()) {
die;
}
$result = wpmu_validate_blog_signup($_POST['blogname'], $_POST['blog_title'], $current_user);
extract($result);
$theme_my_login->errors = $errors;
if ($errors->get_error_code()) {
$this->signup_another_blog($blogname, $blog_title);
break;
}
$public = (int) $_POST['blog_public'];
$meta = apply_filters('signup_create_blog_meta', array('lang_id' => 1, 'public' => $public));
// deprecated
$meta = apply_filters('add_signup_meta', $meta);
wpmu_create_blog($domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid);
?>
<h2><?php
printf(__('The site %s is yours.', 'theme-my-login'), "<a href='http://{$domain}{$path}'>{$blog_title}</a>");
?>
</h2>
<p>
<?php
printf(__('<a href="http://%1$s">http://%2$s</a> is your new site. <a href="%3$s">Log in</a> as “%4$s” using your existing password.', 'theme-my-login'), $domain . $path, $domain . $path, "http://" . $domain . $path . "wp-login.php", $current_user->user_login);
?>
</p>
<?php
do_action('signup_finished');
break;
case 'default':
default:
$user_email = isset($_POST['user_email']) ? $_POST['user_email'] : '';
do_action('preprocess_signup_form');
// populate the form from invites, elsewhere?
if (is_user_logged_in() && ($active_signup == 'all' || $active_signup == 'blog')) {
$this->signup_another_blog($newblogname);
} elseif (is_user_logged_in() == false && ($active_signup == 'all' || $active_signup == 'user')) {
$this->signup_user($newblogname, $user_email);
} elseif (is_user_logged_in() == false && $active_signup == 'blog') {
_e('Sorry, new registrations are not allowed at this time.', 'theme-my-login');
} else {
_e('You are logged in already. No need to register again!', 'theme-my-login');
}
if ($newblogname) {
$newblog = get_blogaddress_by_name($newblogname);
if ($active_signup == 'blog' || $active_signup == 'all') {
printf(__('<p><em>The site you were looking for, <strong>%s</strong> does not exist, but you can create it now!</em></p>', 'theme-my-login'), $newblog);
} else {
printf(__('<p><em>The site you were looking for, <strong>%s</strong>, does not exist.</em></p>', 'theme-my-login'), $newblog);
}
}
break;
}
}
echo '</div>';
do_action('after_signup_form');
}
示例5: bw_display_blog
/**
* Display information about a blog in a particular format
*
*
*/
function bw_display_blog($id, $atts, $content)
{
$bloginfo = bw_get_bloginfo($id);
if ($bloginfo) {
if (is_numeric($id)) {
$url = get_blogaddress_by_id($id);
} else {
$url = get_blogaddress_by_name($id);
}
$blog = $bloginfo->blog_id;
switch_to_blog($blog);
if ($content) {
e(bw_do_shortcode($content));
} else {
alink(null, $url, $bloginfo->blogname);
}
restore_current_blog();
}
}
示例6: get_header
<?php
get_header();
?>
<div id="content">
<?php
global $post;
$weekblog = $post;
$wb_name = get_post_meta($weekblog->ID, '_xtecweekblog-name', true);
$wb_url = get_blogaddress_by_name($wb_name);
$wb_blog_title = get_bloginfo('title');
$wb_description = get_post_meta($weekblog->ID, '_xtecweekblog-description', true);
?>
<div id="box">
<span class="contentboxheadright"></span>
<span class="contentboxheadleft"></span>
<h2 class="contentboxheadfons">Bloc destacat</h2>
<div id="bloc_destacat">
<a href="<?php
echo $wb_url;
?>
" target="_blank" title="<?php
$wb_blog_title;
?>
"><?php
echo get_the_post_thumbnail($weekblog->ID, 'xtecweekblog', array('alt' => 'Accedeix al bloc'));
?>
</a>
<p><?php
示例7: cli_init_blog
private function cli_init_blog($blog)
{
if (is_multisite()) {
if (is_numeric($blog)) {
$blog_address = get_blogaddress_by_id((int) $blog);
} else {
$blog_address = get_blogaddress_by_name($blog);
}
if ($blog_address == 'http://' || strstr($blog_address, 'wordpress.com.wordpress.com')) {
$this->debug_msg(sprintf("the blog_address received from %s looks weird: %s", $blog, $blog_address));
return false;
}
$blog_address = str_replace('http://', '', $blog_address);
$blog_address = preg_replace('#/$#', '', $blog_address);
$blog_id = get_blog_id_from_url($blog_address);
} else {
$blog_id = 1;
}
$home_url = str_replace('http://', '', get_home_url($blog_id));
$home_url = preg_replace('#/$#', '', $home_url);
$this->blog_address = $home_url;
if ($blog_id > 0) {
$this->debug_msg(sprintf("the blog_address we found is %s (%d)", $this->blog_address, $blog_id));
$this->args->blog = $blog_id;
if (function_exists('is_multisite') && is_multisite()) {
switch_to_blog((int) $blog_id);
}
$this->blog_id = (int) $blog_id;
return true;
} else {
$this->debug_msg(sprintf("could not get a blog_id for this address: %s", var_export($blog_id, true)));
die;
}
}
示例8: get_blogaddress_by_name
/** RESTful endpoint for this multisite function.
*
* Get $_REQUEST options for this endpoint:
*
* name (required) blog name retrieve address for
*
* Returns blogaddress or error
*/
public function get_blogaddress_by_name()
{
global $json_api;
extract($_REQUEST);
if (!isset($blogname)) {
$json_api->error(__("You must send the 'blogname' parameter."));
}
$blogaddress = get_blogaddress_by_name($blogname);
return array("blogaddress" => $blogaddress);
}