本文整理汇总了PHP中update_blog_details函数的典型用法代码示例。如果您正苦于以下问题:PHP update_blog_details函数的具体用法?PHP update_blog_details怎么用?PHP update_blog_details使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_blog_details函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wpmu_update_blogs_date
/**
* Update the last_updated field for the current blog.
*
* @since MU
*/
function wpmu_update_blogs_date() {
global $wpdb;
update_blog_details( $wpdb->blogid, array('last_updated' => current_time('mysql', true)) );
do_action( 'wpmu_blog_updated', $wpdb->blogid );
}
开发者ID:pauEscarcia,项目名称:AIMM,代码行数:12,代码来源:MS-BLOGS.PHP
示例2: test_get_blogs_of_user
/**
* Test the returned data from get_blogs_of_user()
*/
function test_get_blogs_of_user()
{
$user1_id = $this->factory->user->create(array('role' => 'administrator'));
// Maintain a list of 6 total sites and include the primary network site.
$blog_ids = $this->factory->blog->create_many(5, array('user_id' => $user1_id));
$blog_ids = array_merge(array(1), $blog_ids);
// All sites are new and not marked as spam, archived, or deleted.
$blog_ids_of_user = array_keys(get_blogs_of_user($user1_id));
// User should be a member of the created sites and the network's initial site.
$this->assertEquals($blog_ids, $blog_ids_of_user);
$this->assertTrue(remove_user_from_blog($user1_id, $blog_ids[0]));
$this->assertTrue(remove_user_from_blog($user1_id, $blog_ids[2]));
$this->assertTrue(remove_user_from_blog($user1_id, $blog_ids[4]));
unset($blog_ids[0]);
unset($blog_ids[2]);
unset($blog_ids[4]);
sort($blog_ids);
$blogs_of_user = get_blogs_of_user($user1_id, false);
// The user should still be a member of all remaining sites.
$blog_ids_of_user = array_keys($blogs_of_user);
$this->assertEquals($blog_ids, $blog_ids_of_user);
// Each site retrieved should match the expected structure.
foreach ($blogs_of_user as $blog_id => $blog) {
$this->assertEquals($blog_id, $blog->userblog_id);
$this->assertTrue(isset($blog->userblog_id));
$this->assertTrue(isset($blog->blogname));
$this->assertTrue(isset($blog->domain));
$this->assertTrue(isset($blog->path));
$this->assertTrue(isset($blog->site_id));
$this->assertTrue(isset($blog->siteurl));
$this->assertTrue(isset($blog->archived));
$this->assertTrue(isset($blog->spam));
$this->assertTrue(isset($blog->deleted));
}
// Mark each remaining site as spam, archived, and deleted.
update_blog_details($blog_ids[0], array('spam' => 1));
update_blog_details($blog_ids[1], array('archived' => 1));
update_blog_details($blog_ids[2], array('deleted' => 1));
// Passing true as the second parameter should retrieve ALL sites, even if marked.
$blogs_of_user = get_blogs_of_user($user1_id, true);
$blog_ids_of_user = array_keys($blogs_of_user);
$this->assertEquals($blog_ids, $blog_ids_of_user);
// Check if sites are flagged as expected.
$this->assertEquals(1, $blogs_of_user[$blog_ids[0]]->spam);
$this->assertEquals(1, $blogs_of_user[$blog_ids[1]]->archived);
$this->assertEquals(1, $blogs_of_user[$blog_ids[2]]->deleted);
unset($blog_ids[0]);
unset($blog_ids[1]);
unset($blog_ids[2]);
sort($blog_ids);
// Passing false (the default) as the second parameter should retrieve only good sites.
$blog_ids_of_user = array_keys(get_blogs_of_user($user1_id, false));
$this->assertEquals($blog_ids, $blog_ids_of_user);
}
开发者ID:Benrajalu,项目名称:philRaj,代码行数:57,代码来源:multisite.php
示例3: update
/**
* Update the URL of a site
*
* @synopsis <ID> <NEW_URL> [--force]
*
* @param array $args
* @param array $assoc_args
*/
public function update(array $args = [], array $assoc_args = [])
{
$site_id = (int) $args[0];
$site = get_blog_details($site_id, TRUE);
if (!$site) {
WP_CLI::error("A site with ID {$site_id} does not exist");
}
if (is_main_site($site_id)) {
WP_CLI::error("The given site is the main site of the network. This feature does not support updating the main site URL");
}
$new_url = $args[1];
if (!filter_var($new_url, FILTER_VALIDATE_URL)) {
WP_CLI::error("{$new_url} is not a valid url");
}
/**
* Parse the new URL components
*/
$url_components = parse_url($new_url);
$existing_scheme = parse_url($site->siteurl, PHP_URL_SCHEME);
$scheme = isset($url_components['scheme']) ? $url_components['scheme'] : $existing_scheme;
$host = isset($url_components['host']) ? $url_components['host'] : '';
$path = isset($url_components['path']) ? trailingslashit($url_components['path']) : '/';
// WP core does not accept ports in the URL so we don't too
$site_details = get_object_vars($site);
$site_details['domain'] = $host;
$site_details['path'] = $path;
/**
* Update the site details (goes to the wp_blogs table)
*/
update_blog_details($site_id, $site_details);
// update 'home' and 'siteurl' in the options table
switch_to_blog($site_id);
$existing_home = trailingslashit(get_option('home'));
$new_home = esc_url_raw($scheme . '://' . $host . $path);
$new_home = untrailingslashit($new_home);
// check if the actual 'home' value matches the old site URL
if ($site->domain === parse_url($existing_home, PHP_URL_HOST) && $site->path === parse_url($existing_home, PHP_URL_PATH)) {
update_option('home', $new_home);
}
$existing_site_url = trailingslashit(get_option('siteurl'));
if ($site->domain === parse_url($existing_site_url, PHP_URL_HOST) && $site->path === parse_url($existing_site_url, PHP_URL_PATH)) {
update_option('siteurl', $new_home);
}
/**
* WP core deletes rewrite rules during the URL updating process
*
* @see wp-admin/network/site-info.php
*/
delete_option('rewrite_rules');
restore_current_blog();
$new_home = trailingslashit($new_home);
// append trailing slash for success report to avoid confusion
WP_CLI::success("Update site URL to {$new_home}");
}
开发者ID:inpsyde,项目名称:wp-cli-site-url,代码行数:62,代码来源:SiteUrl.php
示例4: wpmu_update_blogs_date
/**
* Update the last_updated field for the current blog.
*
* @since MU
*/
function wpmu_update_blogs_date()
{
global $wpdb;
update_blog_details($wpdb->blogid, array('last_updated' => current_time('mysql', true)));
/**
* Fires after the blog details are updated.
*
* @since MU
*
* @param int $blog_id Blog ID.
*/
do_action('wpmu_blog_updated', $wpdb->blogid);
}
开发者ID:trinoamez,项目名称:WordpressPlatzi,代码行数:18,代码来源:ms-blogs.php
示例5: stripslashes_deep
}
// rewrite rules can't be flushed during switch to blog
delete_option( 'rewrite_rules' );
// update blogs table
$blog_data = stripslashes_deep( $_POST['blog'] );
$existing_details = get_blog_details( $id, false );
$blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
foreach ( $blog_data_checkboxes as $c ) {
if ( ! in_array( $existing_details->$c, array( 0, 1 ) ) )
$blog_data[ $c ] = $existing_details->$c;
else
$blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0;
}
update_blog_details( $id, $blog_data );
restore_current_blog();
wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-info.php') );
exit;
}
if ( isset($_GET['update']) ) {
$messages = array();
if ( 'updated' == $_GET['update'] )
$messages[] = __('Site info updated.');
}
$title = sprintf( __('Edit Site: %s'), get_blogaddress_by_id($id));
$parent_file = 'sites.php';
$submenu_file = 'sites.php';
开发者ID:realfluid,项目名称:umbaugh,代码行数:31,代码来源:site-info.php
示例6: test_update_blog_details
function test_update_blog_details() {
global $test_action_counter;
$user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
$blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogpath', 'title' => 'Test Title' ) );
$this->assertInternalType( 'int', $blog_id );
$result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => 'my_path/') );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( 'example.com', $blog->domain );
$this->assertEquals( 'my_path/', $blog->path );
$this->assertEquals( '0', $blog->spam );
$result = update_blog_details( $blog_id, array('domain' => 'example2.com','spam' => 1) );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( 'example2.com', $blog->domain );
$this->assertEquals( 'my_path/', $blog->path );
$this->assertEquals( '1', $blog->spam );
$result = update_blog_details( $blog_id );
$this->assertFalse( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( 'example2.com', $blog->domain );
$this->assertEquals( 'my_path/', $blog->path );
$this->assertEquals( '1', $blog->spam );
$test_action_counter = 0;
add_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10, 1 );
$result = update_blog_details( $blog_id, array( 'spam' => 0 ) );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( '0', $blog->spam );
$this->assertEquals( 1, $test_action_counter );
// Same again
$result = update_blog_details( $blog_id, array( 'spam' => 0 ) );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( '0', $blog->spam );
$this->assertEquals( 1, $test_action_counter );
remove_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10, 1 );
add_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10, 1 );
$result = update_blog_details( $blog_id, array( 'spam' => 1 ) );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( '1', $blog->spam );
$this->assertEquals( 2, $test_action_counter );
// Same again
$result = update_blog_details( $blog_id, array( 'spam' => 1 ) );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( '1', $blog->spam );
$this->assertEquals( 2, $test_action_counter );
remove_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10, 1 );
add_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10, 1 );
$result = update_blog_details( $blog_id, array( 'archived' => 1 ) );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( '1', $blog->archived );
$this->assertEquals( 3, $test_action_counter );
// Same again
$result = update_blog_details( $blog_id, array( 'archived' => 1 ) );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( '1', $blog->archived );
$this->assertEquals( 3, $test_action_counter );
remove_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10, 1 );
add_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10, 1 );
$result = update_blog_details( $blog_id, array( 'archived' => 0 ) );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( '0', $blog->archived );
$this->assertEquals( 4, $test_action_counter );
// Same again
$result = update_blog_details( $blog_id, array( 'archived' => 0 ) );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( '0', $blog->archived );
$this->assertEquals( 4, $test_action_counter );
remove_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10, 1 );
add_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10, 1 );
$result = update_blog_details( $blog_id, array( 'deleted' => 1 ) );
$this->assertTrue( $result );
$blog = get_blog_details( $blog_id );
$this->assertEquals( '1', $blog->deleted );
$this->assertEquals( 5, $test_action_counter );
// Same again
$result = update_blog_details( $blog_id, array( 'deleted' => 1 ) );
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:ms.php
示例7: test_update_blog_details_single_directory_path
/**
* When the path for a site is updated with update_blog_details(), the final path
* should have a leading and trailing slash.
*
* @dataProvider data_single_directory_path
*/
public function test_update_blog_details_single_directory_path($path, $expected)
{
update_blog_details(1, array('path' => $path));
$site = get_site(1);
$this->assertEquals($expected, $site->path);
}
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:12,代码来源:updateBlogDetails.php
示例8: test_update_blog_status_unmature_blog_action
function test_update_blog_status_unmature_blog_action()
{
global $test_action_counter;
$test_action_counter = 0;
$blog_id = self::factory()->blog->create();
update_blog_details($blog_id, array('mature' => 1));
add_action('unmature_blog', array($this, '_action_counter_cb'), 10);
update_blog_status($blog_id, 'mature', 0);
$blog = get_blog_details($blog_id);
$this->assertEquals('0', $blog->mature);
$this->assertEquals(1, $test_action_counter);
// The action should fire if the status of 'mature' stays the same.
update_blog_status($blog_id, 'mature', 0);
$blog = get_blog_details($blog_id);
$this->assertEquals('0', $blog->mature);
$this->assertEquals(2, $test_action_counter);
remove_action('unmature_blog', array($this, '_action_counter_cb'), 10);
}
开发者ID:ntwb,项目名称:wordpress-travis,代码行数:18,代码来源:site.php
示例9: test_get_order_by
/**
* @group get_order_by
*/
public function test_get_order_by()
{
if (!is_multisite()) {
return;
}
$old_user = get_current_user_id();
$u = $this->factory->user->create();
$this->set_current_user($u);
$bs = array('foobar' => $this->factory->blog->create(array('title' => 'Foo Bar Blog', 'user_id' => $u, 'path' => '/path' . rand() . time() . '/')), 'barfoo' => $this->factory->blog->create(array('title' => 'Bar foo Blog', 'user_id' => $u, 'path' => '/path' . rand() . time() . '/')));
bp_blogs_record_existing_blogs();
// make the blog public or it won't turn up in generic results
foreach ($bs as $b) {
update_blog_option($b, 'blog_public', '1');
}
// Used to make sure barfoo is older than foobar
$b_time = date_i18n('Y-m-d H:i:s', strtotime('-5 minutes'));
/* Alphabetical */
$blogs = BP_Blogs_Blog::get('alphabetical', false, false, $u);
$blog_ids = wp_list_pluck($blogs['blogs'], 'blog_id');
$this->assertEquals(array($bs['barfoo'], $bs['foobar']), $blog_ids);
/* Newest */
update_blog_details($bs['barfoo'], array('registered' => $b_time));
$blogs = BP_Blogs_Blog::get('newest', false, false, $u);
$blog_ids = wp_list_pluck($blogs['blogs'], 'blog_id');
$this->assertEquals(array($bs['foobar'], $bs['barfoo']), $blog_ids);
/* Active */
bp_blogs_update_blogmeta($bs['barfoo'], 'last_activity', $b_time);
$blogs = BP_Blogs_Blog::get('active', false, false, $u);
$blog_ids = wp_list_pluck($blogs['blogs'], 'blog_id');
$this->assertEquals(array($bs['foobar'], $bs['barfoo']), $blog_ids);
/* Random */
$blogs = BP_Blogs_Blog::get('random', false, false, $u);
$this->assertTrue(2 == count($blogs['blogs']));
$this->set_current_user($old_user);
}
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:38,代码来源:class-bp-blogs-blog.php
示例10: make_primary
/**
* Make this mapping the primary domain, eg. set the homeurl for the site
*
* @return bool|\WP_Error True if we created the old mapping or WP_Error if an error occurred
*/
public function make_primary()
{
// Get current site details to update
$site = $this->get_site();
// Create a new mapping from the old canonical domain
$mapping = self::create($site->blog_id, $site->domain, true);
if (is_wp_error($mapping)) {
return $mapping;
}
// Set the new home and siteurl etc to the current mapping
update_blog_details($site->blog_id, array('domain' => $this->get_domain()));
// These are just a visual update for the site admin
$url = esc_url($this->get_domain());
update_blog_option($site->blog_id, 'home', $url);
update_blog_option($site->blog_id, 'siteurl', $url);
// Remove current mapping
$this->delete();
/**
* Fires after a mapping has set as primary.
*
* @param Mercator\Mapping $mapping The mapping object.
*/
do_action('mercator.mapping.made_primary', $this);
return true;
}
开发者ID:humanmade,项目名称:mercator,代码行数:30,代码来源:class-mapping.php
示例11: _apply_pseudonym
/**
* Applies the student's chosen pseudonym.
*
* This updates the student's user and blog information, then attempts to
* update any references to the old URL, such as those used by media embedded
* into posts on the blog whose URL is being changed.
*
* The inputs for this function will have already been validated by another
* method, so it can be assumed that they are valid.
*
* @param int $user_id the student's user ID
* @param int $blog_id the ID of the student's primary blog
* @param string $new_username the student's new username
*
* @access private
* @since 0.1
*/
private function _apply_pseudonym($user_id, $blog_id, $new_username)
{
global $nxtdb;
// Update the student's username
$nxtdb->update($nxtdb->users, array('user_login' => $new_username), array('ID' => $user_id), array('%s'), array('%d'));
// Deal with the implications of the updated username in multisite
if (ClassBlogs_Utils::is_multisite()) {
ClassBlogs_NXTClass::switch_to_blog($blog_id);
$old_url = trailingslashit(home_url());
// Update the blog URL to reflect their new username
$site = get_current_site();
$new_path = trailingslashit($site->path . $new_username);
$new_url = 'http://' . $site->domain . $new_path;
update_option('siteurl', $new_url);
update_option('home', $new_url);
update_blog_details($blog_id, array('path' => $new_path));
delete_option('rewrite_rules');
// Replace any occurrences of the old URL in the blog's posts
$referring_posts = $nxtdb->get_results("\n\t\t\t\tSELECT ID, post_content FROM {$nxtdb->posts}\n\t\t\t\tWHERE post_content LIKE '%%" . like_escape($old_url) . "%%' ");
foreach ($referring_posts as $post) {
$nxtdb->update($nxtdb->posts, array('post_content' => str_replace($old_url, $new_url, $post->post_content)), array('ID' => $post->ID), array('%s'), array('%d'));
}
ClassBlogs_NXTClass::restore_current_blog();
}
// Flag that the user has changed their username
$changed = $this->get_option('changed_users');
$changed[$new_username] = true;
$this->update_option('changed_users', $changed);
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:46,代码来源:StudentPseudonym.php
示例12: update_blog_details
<?php
update_blog_details(2, array('deleted' => '0'));
开发者ID:Cywaithaka,项目名称:bwawwp,代码行数:3,代码来源:example-10.php
示例13: ust_toolbar_ajax
function ust_toolbar_ajax()
{
if (!current_user_can('manage_sites')) {
die(0);
}
// Just for super admins
$blog_id = (int) @$_POST['blog_id'];
$flag = @$_POST['flag'];
$data = get_blog_details($blog_id);
switch ($flag) {
case "spam":
$data->spam = $data->spam ? 0 : 1;
break;
case "archive":
$data->archived = $data->archived ? 0 : 1;
break;
}
$res = (int) update_blog_details($blog_id, $data);
header('Content-type: application/json');
echo json_encode(array('status' => $res ? 1 : 0));
exit;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:22,代码来源:anti-splog.php
示例14: test_update_blog_details_should_purge_blogmeta_cache
/**
* @group update_blog_details
*/
public function test_update_blog_details_should_purge_blogmeta_cache()
{
if (!is_multisite()) {
return;
}
$u = $this->factory->user->create();
$b1 = $this->factory->blog->create();
bp_blogs_record_blog($b1, $u, true);
// prime cache
bp_blogs_get_blogmeta($b1, 'url');
$this->assertNotEmpty(wp_cache_get($b1, 'blog_meta'));
// updating blog details should purge cache
update_blog_details($b1, array('domain' => 'awesome.com'));
// assert cache is purged
$this->assertEmpty(wp_cache_get($b1, 'blog_meta'));
}
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:19,代码来源:cache.php
示例15: set_domain
/**
* @subcommand set-domain
* @synopsis <domain>
*/
public function set_domain($args, $assoc_args)
{
global $wpdb;
$sites = wp_get_sites();
list($domain) = $args;
$network = wp_get_network($wpdb->siteid);
if (empty($network)) {
return;
}
$old_domain = $network->domain;
if ($old_domain == $domain) {
return;
}
$wpdb->update($wpdb->site, array('domain' => $domain), array('id' => $wpdb->siteid));
update_site_option('siteurl', "http://{$domain}/");
update_site_option('site_name', "{$domain} Sites");
update_site_option('admin_email', "wordpress@{$domain}");
foreach (wp_get_sites() as $site) {
$blog_id = $site['blog_id'];
switch_to_blog($blog_id);
$blog_domain = str_replace($old_domain, $domain, $site['domain']);
$blog_data = array('domain' => $blog_domain, 'siteurl' => 'http://' . $blog_domain, 'path' => '/');
$blog_address = esc_url_raw($blog_data['siteurl']);
if (get_option('siteurl') != $blog_address) {
update_option('siteurl', $blog_address);
}
if (get_option('home') != $blog_address) {
update_option('home', $blog_address);
}
update_blog_details($blog_id, $blog_data);
restore_current_blog();
WP_CLI::line("{$blog_data['domain']} -> {$blog_domain}");
}
if (file_exists(__DIR__ . '/hosts')) {
$hosts = file_get_contents(__DIR__ . '/hosts');
$hosts = preg_replace('/\\s' . preg_quote($old_domain) . '\\s/', " {$domain} ", $hosts);
$hosts = preg_replace('/\\.' . preg_quote($old_domain) . '\\s/', ".{$domain} ", $hosts);
file_put_contents(__DIR__ . '/hosts', $hosts);
}
if (file_exists(__DIR__ . '/server_hosts')) {
$hosts = file_get_contents(__DIR__ . '/server_hosts');
$hosts = preg_replace('/\\s' . preg_quote($old_domain) . '\\s/', " {$domain} ", $hosts);
$hosts = preg_replace('/\\.' . preg_quote($old_domain) . '\\s/', ".{$domain} ", $hosts);
file_put_contents(__DIR__ . '/server_hosts', $hosts);
}
if (file_exists('/etc/hosts')) {
$hosts = file_get_contents('/etc/hosts');
$hosts = preg_replace('/\\s' . preg_quote($old_domain) . '\\s/', " {$domain} ", $hosts);
$hosts = preg_replace('/\\.' . preg_quote($old_domain) . '\\s/', ".{$domain} ", $hosts);
file_put_contents('/etc/hosts', $hosts);
}
WP_CLI::success("{$old_domain} -> {$domain}");
}
开发者ID:amandhare,项目名称:vip-quickstart,代码行数:57,代码来源:pmc-wp-cli.php
注:本文中的update_blog_details函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论