本文整理汇总了PHP中update_blog_status函数的典型用法代码示例。如果您正苦于以下问题:PHP update_blog_status函数的具体用法?PHP update_blog_status怎么用?PHP update_blog_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_blog_status函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: cfgp_install
function cfgp_install()
{
/* Make domain a subdomain to example.com so there's
* no possible way to navigate to it from admin or
* front-end */
$domain = CFGP_SITE_DOMAIN;
$path = '/';
if (!domain_exists($domain, $path, $site)) {
$new_blog_id = create_empty_blog($domain, $path, 'CF Global Posts Blog', CFGP_SITE_ID);
/* Make the blog private */
update_blog_status($new_blog_id, 'public', 0);
} else {
error_log('Domain Already Exists');
}
}
开发者ID:bigdawggi,项目名称:wp-cf-global-posts,代码行数:15,代码来源:cf-global-posts.php
示例2: add_new_blog_field
/**
* Add new option when registering a site (back and front end)
*
* URI: http://stackoverflow.com/a/10372861/1287812
*/
public function add_new_blog_field($blog_id, $user_id, $domain, $path, $site_id, $meta)
{
$new_field_value = '';
# Site added in the back end
if (!empty($_POST['blog']['input_site_cat'])) {
switch_to_blog($blog_id);
$cat_id = $_POST['blog']['input_site_cat'];
# TODO: if Sign-up is to be enabled, change this to a method
$val = B5F_Multisite_Categories::get_instance()->do_mature_to_name($cat_id);
update_blog_option($blog_id, 'site_category', $val);
update_blog_status($blog_id, 'mature', $cat_id);
get_blog_status($blog_id, 'mature');
restore_current_blog();
} elseif (!empty($meta['input_site_cat'])) {
$new_field_value = $meta['input_site_cat'];
update_option('site_category', $new_field_value);
}
}
开发者ID:andy218,项目名称:multisite-site-category,代码行数:23,代码来源:class-sites-categories-signup.php
示例3: check_admin_referer
break;
case 'unmatureblog':
check_admin_referer('unmatureblog');
if (!current_user_can('manage_sites')) {
wp_die(__('You do not have permission to access this page.'));
}
update_blog_status($id, 'mature', '0');
wp_safe_redirect(add_query_arg(array('updated' => 'true', 'action' => 'unmature'), wp_get_referer()));
exit;
break;
case 'matureblog':
check_admin_referer('matureblog');
if (!current_user_can('manage_sites')) {
wp_die(__('You do not have permission to access this page.'));
}
update_blog_status($id, 'mature', '1');
wp_safe_redirect(add_query_arg(array('updated' => 'true', 'action' => 'mature'), wp_get_referer()));
exit;
break;
// Common
// Common
case 'confirm':
check_admin_referer('confirm');
if (!headers_sent()) {
nocache_headers();
header('Content-Type: text/html; charset=utf-8');
}
if ($current_site->blog_id == $id) {
wp_die(__('You are not allowed to change the current site.'));
}
?>
开发者ID:jawandsingh,项目名称:wordpress_with_sql_azure,代码行数:31,代码来源:sites.php
示例4: update_archived
/**
* Update the 'archived' status of a particular blog.
*
* @since MU
*
* @param int $id The blog id
* @param string $archived The new status
* @return string $archived
*/
function update_archived($id, $archived)
{
update_blog_status($id, 'archived', $archived);
return $archived;
}
开发者ID:trinoamez,项目名称:WordpressPlatzi,代码行数:14,代码来源:ms-blogs.php
示例5: update_blog_public
/**
* Update this blog's 'public' setting in the global blogs table.
*
* Public blogs have a setting of 1, private blogs are 0.
*
* @since MU
*
* @param int $old_value
* @param int $value The new public value
*/
function update_blog_public($old_value, $value)
{
update_blog_status(get_current_blog_id(), 'public', (int) $value);
}
开发者ID:Jitsufreak,项目名称:PJ,代码行数:14,代码来源:ms-functions.php
示例6: do_action
* Fires before a network site is deactivated.
*
* @since MU
*
* @param string $id The ID of the site being deactivated.
*/
do_action('deactivate_blog', $id);
update_blog_status($id, 'deleted', '1');
break;
case 'unspamblog':
case 'spamblog':
update_blog_status($id, 'spam', 'spamblog' === $_GET['action'] ? '1' : '0');
break;
case 'unmatureblog':
case 'matureblog':
update_blog_status($id, 'mature', 'matureblog' === $_GET['action'] ? '1' : '0');
break;
}
if (empty($updated_action) && array_key_exists($_GET['action'], $manage_actions)) {
$updated_action = $_GET['action'];
}
if (!empty($updated_action)) {
wp_safe_redirect(add_query_arg(array('updated' => $updated_action), wp_get_referer()));
exit;
}
}
$msg = '';
if (isset($_GET['updated'])) {
switch ($_GET['updated']) {
case 'all_notspam':
$msg = __('Sites removed from spam.');
开发者ID:s4mobile,项目名称:WordPressTech,代码行数:31,代码来源:sites.php
示例7: wpmu_delete_blog
/**
* Delete a site.
*
* @since 3.0.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $blog_id Site ID.
* @param bool $drop True if site's database tables should be dropped. Default is false.
*/
function wpmu_delete_blog($blog_id, $drop = false)
{
global $wpdb;
$switch = false;
if (get_current_blog_id() != $blog_id) {
$switch = true;
switch_to_blog($blog_id);
}
$blog = get_blog_details($blog_id);
/**
* Fires before a site is deleted.
*
* @since MU
*
* @param int $blog_id The site ID.
* @param bool $drop True if site's table should be dropped. Default is false.
*/
do_action('delete_blog', $blog_id, $drop);
$users = get_users(array('blog_id' => $blog_id, 'fields' => 'ids'));
// Remove users from this blog.
if (!empty($users)) {
foreach ($users as $user_id) {
remove_user_from_blog($user_id, $blog_id);
}
}
update_blog_status($blog_id, 'deleted', 1);
$current_site = get_current_site();
// If a full blog object is not available, do not destroy anything.
if ($drop && !$blog) {
$drop = false;
}
// Don't destroy the initial, main, or root blog.
if ($drop && (1 == $blog_id || is_main_site($blog_id) || $blog->path == $current_site->path && $blog->domain == $current_site->domain)) {
$drop = false;
}
$upload_path = trim(get_option('upload_path'));
// If ms_files_rewriting is enabled and upload_path is empty, wp_upload_dir is not reliable.
if ($drop && get_site_option('ms_files_rewriting') && empty($upload_path)) {
$drop = false;
}
if ($drop) {
$uploads = wp_get_upload_dir();
$tables = $wpdb->tables('blog');
/**
* Filters the tables to drop when the site is deleted.
*
* @since MU
*
* @param array $tables The site tables to be dropped.
* @param int $blog_id The ID of the site to drop tables for.
*/
$drop_tables = apply_filters('wpmu_drop_tables', $tables, $blog_id);
foreach ((array) $drop_tables as $table) {
$wpdb->query("DROP TABLE IF EXISTS `{$table}`");
}
$wpdb->delete($wpdb->blogs, array('blog_id' => $blog_id));
/**
* Filters the upload base directory to delete when the site is deleted.
*
* @since MU
*
* @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir()
* @param int $blog_id The site ID.
*/
$dir = apply_filters('wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id);
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
$top_dir = $dir;
$stack = array($dir);
$index = 0;
while ($index < count($stack)) {
// Get indexed directory from stack
$dir = $stack[$index];
$dh = @opendir($dir);
if ($dh) {
while (($file = @readdir($dh)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
if (@is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
} elseif (@is_file($dir . DIRECTORY_SEPARATOR . $file)) {
@unlink($dir . DIRECTORY_SEPARATOR . $file);
}
}
@closedir($dh);
}
$index++;
}
$stack = array_reverse($stack);
// Last added dirs are deepest
//.........这里部分代码省略.........
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:101,代码来源:ms.php
示例8: bp_core_process_spammer_status
/**
* Process a spammed or unspammed user.
*
* This function is called from three places:
*
* - in bp_settings_action_capabilities() (from the front-end)
* - by bp_core_mark_user_spam_admin() (from wp-admin)
* - bp_core_mark_user_ham_admin() (from wp-admin)
*
* @since 1.6.0
*
* @param int $user_id The ID of the user being spammed/hammed.
* @param string $status 'spam' if being marked as spam, 'ham' otherwise.
* @param bool $do_wp_cleanup True to force the cleanup of WordPress content
* and status, otherwise false. Generally, this should
* only be false if WordPress is expected to have
* performed this cleanup independently, as when hooked
* to 'make_spam_user'.
* @return bool True on success, false on failure.
*/
function bp_core_process_spammer_status($user_id, $status, $do_wp_cleanup = true)
{
global $wpdb;
// Bail if no user ID.
if (empty($user_id)) {
return;
}
// Bail if user ID is super admin.
if (is_super_admin($user_id)) {
return;
}
// Get the functions file.
if (is_multisite()) {
require_once ABSPATH . 'wp-admin/includes/ms.php';
}
$is_spam = 'spam' == $status;
// Only you can prevent infinite loops.
remove_action('make_spam_user', 'bp_core_mark_user_spam_admin');
remove_action('make_ham_user', 'bp_core_mark_user_ham_admin');
// Force the cleanup of WordPress content and status for multisite configs.
if ($do_wp_cleanup) {
// Get the blogs for the user.
$blogs = get_blogs_of_user($user_id, true);
foreach ((array) array_values($blogs) as $details) {
// Do not mark the main or current root blog as spam.
if (1 == $details->userblog_id || bp_get_root_blog_id() == $details->userblog_id) {
continue;
}
// Update the blog status.
update_blog_status($details->userblog_id, 'spam', $is_spam);
}
// Finally, mark this user as a spammer.
if (is_multisite()) {
update_user_status($user_id, 'spam', $is_spam);
}
}
// Update the user status.
$wpdb->update($wpdb->users, array('user_status' => $is_spam), array('ID' => $user_id));
// Clean user cache.
clean_user_cache($user_id);
if (!is_multisite()) {
// Call multisite actions in single site mode for good measure.
if (true === $is_spam) {
/**
* Fires at end of processing spammer in Dashboard if not multisite and user is spam.
*
* @since 1.5.0
*
* @param int $value user ID.
*/
do_action('make_spam_user', $user_id);
} else {
/**
* Fires at end of processing spammer in Dashboard if not multisite and user is not spam.
*
* @since 1.5.0
*
* @param int $value user ID.
*/
do_action('make_ham_user', $user_id);
}
}
// Hide this user's activity.
if (true === $is_spam && bp_is_active('activity')) {
bp_activity_hide_user_activity($user_id);
}
// We need a special hook for is_spam so that components can delete data at spam time.
if (true === $is_spam) {
/**
* Fires at the end of the process spammer process if the user is spam.
*
* @since 1.5.0
*
* @param int $value Displayed user ID.
*/
do_action('bp_make_spam_user', $user_id);
} else {
/**
* Fires at the end of the process spammer process if the user is not spam.
*
//.........这里部分代码省略.........
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:101,代码来源:bp-members-functions.php
示例9: bp_core_process_spammer_status
/**
* Process a spammed or unspammed user.
*
* This function is called from three places:
*
* - in bp_settings_action_capabilities() (from the front-end)
* - by bp_core_mark_user_spam_admin() (from wp-admin)
* - bp_core_mark_user_ham_admin() (from wp-admin)
*
* @since BuddyPress (1.6.0)
*
* @param int $user_id The ID of the user being spammed/hammed.
* @param string $status 'spam' if being marked as spam, 'ham' otherwise.
* @param bool $do_wp_cleanup True to force the cleanup of WordPress content
* and status, otherwise false. Generally, this should only be false if
* WordPress is expected to have performed this cleanup independently,
* as when hooked to 'make_spam_user'.
* @return bool True on success, false on failure.
*/
function bp_core_process_spammer_status($user_id, $status, $do_wp_cleanup = true)
{
global $wpdb;
// Bail if no user ID
if (empty($user_id)) {
return;
}
// Bail if user ID is super admin
if (is_super_admin($user_id)) {
return;
}
// Get the functions file
if (is_multisite()) {
require_once ABSPATH . 'wp-admin/includes/ms.php';
}
$is_spam = 'spam' == $status;
// Only you can prevent infinite loops
remove_action('make_spam_user', 'bp_core_mark_user_spam_admin');
remove_action('make_ham_user', 'bp_core_mark_user_ham_admin');
// Determine if we are on an admin page
$is_admin = is_admin();
if ($is_admin && !defined('DOING_AJAX')) {
$is_admin = (bool) (buddypress()->members->admin->user_page !== get_current_screen()->id);
}
// When marking as spam in the Dashboard, these actions are handled by WordPress
if ($do_wp_cleanup) {
// Get the blogs for the user
$blogs = get_blogs_of_user($user_id, true);
foreach ((array) array_values($blogs) as $details) {
// Do not mark the main or current root blog as spam
if (1 == $details->userblog_id || bp_get_root_blog_id() == $details->userblog_id) {
continue;
}
// Update the blog status
update_blog_status($details->userblog_id, 'spam', $is_spam);
}
// Finally, mark this user as a spammer
if (is_multisite()) {
update_user_status($user_id, 'spam', $is_spam);
}
// Always set single site status
$wpdb->update($wpdb->users, array('user_status' => $is_spam), array('ID' => $user_id));
// Call multisite actions in single site mode for good measure
if (!is_multisite()) {
$wp_action = true === $is_spam ? 'make_spam_user' : 'make_ham_user';
do_action($wp_action, bp_displayed_user_id());
}
}
// Hide this user's activity
if (true === $is_spam && bp_is_active('activity')) {
bp_activity_hide_user_activity($user_id);
}
// We need a special hook for is_spam so that components can delete data at spam time
$bp_action = true === $is_spam ? 'bp_make_spam_user' : 'bp_make_ham_user';
do_action($bp_action, $user_id);
// Allow plugins to do neat things
do_action('bp_core_process_spammer_status', $user_id, $is_spam);
// Put things back how we found them
add_action('make_spam_user', 'bp_core_mark_user_spam_admin');
add_action('make_ham_user', 'bp_core_mark_user_ham_admin');
return true;
}
开发者ID:eresyyl,项目名称:mk,代码行数:81,代码来源:bp-members-functions.php
示例10: noindex
/**
* Display a noindex meta tag if required by the blog configuration.
*
* If a blog is marked as not being public then the noindex meta tag will be
* output to tell web robots not to index the page content. Add this to the wp_head action.
* Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
*
* @see wp_no_robots
*
* @since 2.1.0
*/
function noindex()
{
$public = get_option('blog_public');
if (is_multisite()) {
// Compare local and global and override with the local setting if they
// don't match.
global $current_blog;
if ('' != $public && $public != $current_blog->public) {
update_blog_status(get_current_blog_id(), 'public', $public);
$current_blog->public = $public;
}
}
// If the blog is not public, tell robots to go away.
if ('0' == $public) {
wp_no_robots();
}
}
开发者ID:jcsilkey,项目名称:CodeReviewSecurityRepo,代码行数:28,代码来源:general-template.php
示例11: wpmu_create_blog
function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1)
{
$domain = preg_replace("/\\s+/", '', sanitize_user($domain, true));
if (constant('VHOST') == 'yes') {
$domain = str_replace('@', '', $domain);
}
$title = strip_tags($title);
$user_id = (int) $user_id;
if (empty($path)) {
$path = '/';
}
// Check if the domain has been used already. We should return an error message.
if (domain_exists($domain, $path, $site_id)) {
return new WP_Error('blog_taken', __('Blog already exists.'));
}
if (!defined("WP_INSTALLING")) {
define("WP_INSTALLING", true);
}
if (!($blog_id = insert_blog($domain, $path, $site_id))) {
return new WP_Error('insert_blog', __('Could not create blog.'));
}
switch_to_blog($blog_id);
install_blog($blog_id, $title);
install_blog_defaults($blog_id, $user_id);
add_user_to_blog($blog_id, $user_id, 'administrator');
if (is_array($meta)) {
foreach ($meta as $key => $value) {
if ($key == 'public' || $key == 'archived' || $key == 'mature' || $key == 'spam' || $key == 'deleted' || $key == 'lang_id') {
update_blog_status($blog_id, $key, $value);
} else {
update_option($key, $value);
}
}
}
add_option('WPLANG', get_site_option('WPLANG'));
update_option('blog_public', $meta['public']);
if (get_usermeta($user_id, 'primary_blog') == 1) {
update_usermeta($user_id, 'primary_blog', $blog_id);
}
restore_current_blog();
do_action('wpmu_new_blog', $blog_id, $user_id);
return $blog_id;
}
开发者ID:alx,项目名称:blogsfera,代码行数:43,代码来源:wpmu-functions.php
示例12: wangguard_delete_user_and_blogs
function wangguard_delete_user_and_blogs($userid)
{
global $wpdb;
if (function_exists("get_blogs_of_user") && function_exists("update_blog_status") && method_exists($wpdb, 'get_blog_prefix')) {
$blogs = get_blogs_of_user($userid, true);
if (is_array($blogs)) {
foreach ((array) $blogs as $key => $details) {
$isMainBlog = false;
if (isset($current_site)) {
$isMainBlog = $details->userblog_id != $current_site->blog_id;
// main blog not a spam !
} elseif (defined("BP_ROOT_BLOG")) {
$isMainBlog = 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id;
} else {
$isMainBlog = $details->userblog_id == 1;
}
$userIsAuthor = false;
if (!$isMainBlog) {
//Only works on WP 3+
$blog_prefix = $wpdb->get_blog_prefix($details->userblog_id);
$authorcaps = $wpdb->get_var(sprintf("SELECT meta_value as caps FROM {$wpdb->users} u, {$wpdb->usermeta} um WHERE u.ID = %d and u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities'", $userid));
$caps = maybe_unserialize($authorcaps);
$userIsAuthor = isset($caps['administrator']);
}
//Update blog to spam if the user is the author and its not the main blog
if (!$isMainBlog && $userIsAuthor) {
@update_blog_status($details->userblog_id, 'spam', '1');
//remove blog from queue
$table_name = $wpdb->base_prefix . "wangguardreportqueue";
$wpdb->query($wpdb->prepare("delete from {$table_name} where blog_id = '%d'", $details->userblog_id));
}
}
}
}
if (wangguard_is_multisite()) {
if (function_exists('bp_core_mark_user_spam_admin')) {
@(include_once ABSPATH . 'wp-admin/includes/ms.php');
bp_core_mark_user_spam_admin($userid);
wpmu_delete_user($userid);
} else {
@(include_once ABSPATH . 'wp-admin/includes/ms.php');
wpmu_delete_user($userid);
}
} else {
if (function_exists('wp_delete_user') && function_exists('bp_core_mark_user_spam_admin')) {
@(include_once ABSPATH . 'wp-admin/includes/user.php');
bp_core_mark_user_spam_admin($userid);
wp_delete_user($userid);
} else {
@(include_once ABSPATH . 'wp-admin/includes/user.php');
wp_delete_user($userid);
}
}
}
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:54,代码来源:wangguard-admin.php
示例13: update_options
function update_options()
{
global $wpdb, $current_site, $wp_version;
if (!isset($_POST['tags_blog_enabled']) || !$_POST['tags_blog_enabled']) {
if (isset($_POST['tags_blog_enabled']) && $this->get('tags_blog_enabled') != $_POST['tags_blog_enabled']) {
$this->update('tags_blog_enabled', 0, true);
}
wp_redirect(esc_url_raw(add_query_arg(array('updated' => '1'))));
exit;
}
$this->update('tags_blog_enabled', 1);
if ((isset($_POST['tags_blog']) || isset($_POST['tags_blog_main_blog'])) && isset($_POST['tags_blog_public'])) {
if (isset($_POST['tags_blog_main_blog']) && 1 == $_POST['tags_blog_main_blog']) {
if ($current_site->blog_id) {
$id = $current_site->blog_id;
} else {
$id = $wpdb->get_var("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = '{$current_site->domain}' AND path = '{$current_site->path}'");
}
if ($id) {
$this->update('tags_blog_id', $id);
$this->update('tags_blog_main_blog', 1);
} else {
$this->update('tags_blog_main_blog', 0);
}
} else {
$this->update('tags_blog_main_blog', 0);
$aggregate_blog = sanitize_title($_POST['tags_blog']);
$this->update('tags_blog', $aggregate_blog);
if (constant('VHOST') == 'yes') {
$domain = $aggregate_blog . '.' . $current_site->domain;
$path = $current_site->path;
} else {
$domain = $current_site->domain;
$path = trailingslashit($current_site->path . $aggregate_blog);
}
$aggregate_blog_id = $wpdb->get_var("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = '{$domain}' AND path = '{$path}'");
if ($aggregate_blog_id) {
$this->update('tags_blog_id', $aggregate_blog_id);
} else {
$wpdb->hide_errors();
$id = wpmu_create_blog($domain, $path, __('Network Posts', 'wds-multisite-aggregate'), get_current_user_id(), array('public' => $_POST['tags_blog_public']), $current_site->id);
$this->update('tags_blog_id', $id);
$wpdb->show_errors();
}
}
$aggregate_blog_public = (int) $_POST['tags_blog_public'];
$this->update('tags_blog_public', $aggregate_blog_public);
update_blog_option($aggregate_blog_id, 'blog_public', $aggregate_blog_public);
update_blog_status($aggregate_blog_id, 'public', $aggregate_blog_public);
}
$options_as_integers = array('tags_max_posts');
foreach ($options_as_integers as $option_key) {
if ($set = $this->make_integer_from_request($option_key)) {
$this->update($option_key, $set);
}
}
$options_as_integers_maybe_set = array('tags_blog_thumbs', 'tags_blog_pages', 'populate_all_blogs');
foreach ($options_as_integers_maybe_set as $option_key) {
$set = $this->make_integer_from_request($option_key);
if ($set != $this->get($option_key)) {
$this->update($option_key, $set);
}
}
if (($set = $this->make_integer_from_request('tags_blog_pub_check')) && $set != $this->get('tags_blog_pub_check')) {
$set = $aggregate_blog_public == 0 ? $set : 0;
$this->update('tags_blog_pub_check', $set);
}
if (isset($_POST['tags_blog_postmeta']) && '' != $_POST['tags_blog_postmeta']) {
$meta_keys = explode("\n", strip_tags(stripslashes($_POST['tags_blog_postmeta'])));
$this->update('tags_blog_postmeta', array_map('trim', $meta_keys));
} else {
$this->update('tags_blog_postmeta', '');
}
$blogs_to_import = $this->comma_delimited_to_array_from_request('blogs_to_import');
$this->update('blogs_to_import', $blogs_to_import);
// force write if changes saved
$this->update(true);
wp_redirect(esc_url_raw(add_query_arg(array('updated' => '1'))));
exit;
}
开发者ID:clovepod,项目名称:WDS-Multisite-Aggregate,代码行数:80,代码来源:WDS_Multisite_Aggregate_Options.php
示例14: testArchivedSite
/**
* Tests deletion of index when a blog is marked as archived
* @group 392
* @link https://github.com/10up/ElasticPress/issues/392
*/
public function testArchivedSite()
{
$index_count = ep_count_indexes();
$count_indexes = $index_count['total_indexes'];
$last_blog_id = $index_count['last_blog_id_with_index'];
update_blog_status($last_blog_id, 'archived', '1');
$post_delete_count = ep_count_indexes();
$post_count_indexes = $post_delete_count['total_indexes'];
$this->assertNotEquals($count_indexes, $post_count_indexes);
}
开发者ID:10up,项目名称:elasticpress,代码行数:15,代码来源:test-multisite.php
示例15: bp_core_action_set_spammer_status
/**
* When a site admin selects "Mark as Spammer/Not Spammer" from the admin menu
* this action will fire and mark or unmark the user and their blogs as spam.
* Must be a site admin for this function to run.
*
* @package BuddyPress Core
* @param int $user_id Optional user ID to mark as spam
* @global object $wpdb Global WordPress Database object
*/
function bp_core_action_set_spammer_status($user_id = 0)
{
global $wpdb;
// Only super admins can currently spam users
if (!is_super_admin() || bp_is_my_profile()) {
return;
}
// Use displayed user if it's not yourself
if (empty($user_id) && bp_is_user()) {
$user_id = bp_displayed_user_id();
}
// Bail if no user ID
if (empty($user_id)) {
return;
}
// Bail if user ID is super admin
if (is_super_admin($user_id)) {
return;
}
if (bp_is_current_component('admin') && in_array(bp_current_action(), array('mark-spammer', 'unmark-spammer'))) {
// Check the nonce
check_admin_referer('mark-unmark-spammer');
// Get the functions file
if (is_multisite()) {
require ABSPATH . 'wp-admin/includes/ms.php';
}
// To spam or not to spam
$is_spam = bp_is_current_action('mark-spammer') ? 1 : 0;
// Get the blogs for the user
$blogs = get_blogs_of_user($user_id, true);
foreach ((array) $blogs as $key => $details) {
// Do not mark the main or current root blog as spam
if (1 == $details->userblog_id || bp_get_root_blog_id() == $details->userblog_id) {
continue;
}
// Update the blog status
update_blog_status($details->userblog_id, 'spam', $is_spam);
}
// Finally, mark this user as a spammer
if (is_multisite()) {
update_user_status($user_id, 'spam', $is_spam);
}
// Always set single site status
$wpdb->update($wpdb->users, array('user_status' => $is_spam), array('ID' => $user_id));
// Add feedback message
if ($is_spam) {
bp_core_add_message(__('User marked as spammer. Spam users are visible only to site admins.', 'buddypress'));
} else {
bp_core_add_message(__('User removed as spammer.', 'buddypress'));
}
// Hide this user's activity
if ($is_spam && bp_is_active('activity')) {
bp_activity_hide_user_activity($user_id);
}
// We need a special hook for is_spam so that components can delete data at spam time
$bp_action = $is_spam ? 'bp_make_spam_user' : 'bp_make_ham_user';
do_action($bp_action, bp_displayed_user_id());
// Call multisite actions in single site mode for good measure
if (!is_multisite()) {
$wp_action = $is_spam ? 'make_spam_user' : 'make_ham_user';
do_action($wp_action, bp_displayed_user_id());
}
// Allow plugins to do neat things
do_action('bp_core_action_set_spammer_status', bp_displayed_user_id(), $is_spam);
// Redirect back to where we came from
bp_core_redirect(wp_get_referer());
}
}
开发者ID:hornetalcala,项目名称:trunk,代码行数:77,代码来源:bp-members-actions.php
示例16: update_site_status
private function update_site_status($ids, $pref, $value)
{
if ($pref == 'archived' && $value == 1) {
$action = 'archived';
} else {
if ($pref == 'archived' && $value == 0) {
$action = 'unarchived';
} else {
if ($pref == 'deleted' && $value == 1) {
$action = 'deactivated';
} else {
if ($pref == 'deleted' && $value == 0) {
$action = 'activated';
} else {
if ($pref == 'spam' && $value == 1) {
$action = 'marked as spam';
} else {
if ($pref == 'spam' && $value == 0) {
$action = 'removed from spam';
}
}
}
}
}
}
foreach ($ids as $site_id) {
$site = $this->fetcher->get_check($site_id);
if (is_main_site($site->blog_id)) {
WP_CLI::warning("You are not allowed to change the main site.");
continue;
}
$old_value = get_blog_status($site->blog_id, $pref);
if ($value == $old_value) {
WP_CLI::warning("Site {$site->blog_id} already {$action}.");
continue;
}
update_blog_status($site->blog_id, $pref, $value);
WP_CLI::success("Site {$site->blog_id} {$action}.");
}
}
开发者ID:Jaace,项目名称:wp-cli,代码行数:40,代码来源:site.php
示例17: wpmu_delete_blog
/**
* Delete a blog
*
* @since 3.0.0
*
* @param int $blog_id Blog ID
* @param bool $drop True if blog's table should be dropped. Default is false.
* @return void
*/
function wpmu_delete_blog($blog_id, $drop = false)
{
global $wpdb;
$switch = false;
if ($blog_id != $wpdb->blogid) {
$switch = true;
switch_to_blog($blog_id);
}
$blog_prefix = $wpdb->get_blog_prefix($blog_id);
do_action('delete_blog', $blog_id, $drop);
$users = get_users_of_blog($blog_id);
// Remove users from this blog.
if (!empty($users)) {
foreach ($users as $user) {
remove_user_from_blog($user->user_id, $blog_id);
}
}
update_blog_status($blog_id, 'deleted', 1);
if ($drop) {
if (substr($blog_prefix, -1) == '_') {
$blog_prefix = substr($blog_prefix, 0, -1) . '\\_';
}
$drop_tables = $wpdb->get_results("SHOW TABLES LIKE '{$blog_prefix}%'", ARRAY_A);
$drop_tables = apply_filters('wpmu_drop_tables', $drop_tables);
reset($drop_tables);
foreach ((array) $drop_tables as $drop_table) {
$wpdb->query("DROP TABLE IF EXISTS " . current($drop_table) . "");
}
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->blogs} WHERE blog_id = %d", $blog_id));
$dir = apply_filters('wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id);
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
$top_dir = $dir;
$stack = array($dir);
$index = 0;
while ($index < count($stack)) {
# Get indexed directory from stack
$dir = $stack[$index];
$dh = @opendir($dir);
if ($dh) {
while (($file = @readdir($dh)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
if (@is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
} else {
if (@is_file($dir . DIRECTORY_SEPARATOR . $file)) {
@unlink($dir . DIRECTORY_SEPARATOR . $file);
}
}
}
}
$index++;
}
$stack = array_reverse($stack);
// Last added dirs are deepest
foreach ((array) $stack as $dir) {
if ($dir != $top_dir) {
@rmdir($dir);
}
}
}
$wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key = '{$blog_prefix}autosave_draft_ids'");
$blogs = get_site_option('blog_list');
if (is_array($blogs)) {
foreach ($blogs as $n => $blog) {
if ($blog['blog_id'] == $blog_id) {
unset($blogs[$n]);
}
}
update_site_option('blog_list', $blogs);
}
if ($switch === true) {
restore_current_blog();
}
}
开发者ID:owaismeo,项目名称:wordpress-10,代码行数:85,代码来源:ms.php
示例18: update_blog_status
<?php
update_blog_status(get_current_blog_id(), 'deleted', '1');
开发者ID:Cywaithaka,项目名称:bwawwp,代码行数:3,代码来源:example-12.php
示例19: wpmu_delete_blog
/**
* Delete a blog
*
* @since 3.0.0
*
* @param int $blog_id Blog ID
* @param bool $drop True if blog's table should be dropped. Default is false.
* @return void
*/
function wpmu_delete_blog($blog_id, $drop = false)
{
global $wpdb, $current_site;
$switch = false;
if (get_current_blog_id() != $blog_id) {
$switch = true;
switch_to_blog($blog_id);
}
$blog = get_blog_details($blog_id);
do_action('delete_blog', $blog_id, $drop);
$users = get_users(array('blog_id' => $blog_id, 'fields' => 'ids'));
// Remove users from this blog.
if (!empty($users)) {
foreach ($users as $user_id) {
remove_user_from_blog($user_id, $blog_id);
}
}
update_blog_status($blog_id, 'deleted', 1);
// Don't destroy the initial, main, or root blog.
if ($drop && (1 == $blog_id || is_main_site($blog_id) || $blog->path == $current_site->path && $blog->domain == $current_site->domain)) {
$drop = false;
}
if ($drop) {
$drop_tables = apply_filters('wpmu_drop_tables', $wpdb->tables('blog'));
foreach ((array) $drop_tables as $table) {
$wpdb->query("DROP TABLE IF EXISTS `{$table}`");
}
$wpdb->delete($wpdb->blogs, array('blog_id' => $blog_id));
$uploads = wp_upload_dir();
$dir = apply_filters('wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id);
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
$top_dir = $dir;
$stack = array($dir);
$index = 0;
while ($index < count($stack)) {
# Get indexed directory from stack
$dir = $stack[$index];
$dh = @opendir($dir);
if ($dh) {
while (($file = @readdir($dh)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
if (@is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
} else {
if (@is_file($dir . DIRECTORY_SEPARATOR . $file)) {
@unlink($dir . DIRECTORY_SEPARATOR . $file);
}
}
}
@closedir($dh);
}
$index++;
}
$stack = array_reverse($stack);
// Last added dirs are deepest
foreach ((array) $stack as $dir) {
if ($dir != $top_dir) {
@rmdir($dir);
}
}
clean_blog_cache($blog);
}
if ($switch) {
restore_current_blog();
}
}
开发者ID:rodrigosantanati,项目名称:WordPress,代码行数:77,代码来源:ms.php
示例20: set_spammer_status
/**
* set spammeer status
*
* @param <int|array> $user_ids member ids
* @param <bool> $is_spam mark spammer (true) or unmark (false)
* @param <callback> $end_callback function
|
请发表评论