Exemplo n.º 1
0
function bp_groupblog_blog_defaults($blog_id)
{
    global $bp, $wp_rewrite;
    // only apply defaults to groupblog blogs
    if (bp_is_groups_component()) {
        switch_to_blog($blog_id);
        // get the site options
        $options = get_site_option('bp_groupblog_blog_defaults_options');
        foreach ((array) $options as $key => $value) {
            update_option($key, $value);
        }
        // override default themes
        if (!empty($options['theme'])) {
            // we want something other than the default theme
            $values = explode("|", $options['theme']);
            switch_theme($values[0], $values[1]);
        }
        // groupblog bonus options
        if (strlen($options['default_cat_name']) > 0) {
            global $wpdb;
            $cat = $options['default_cat_name'];
            $slug = str_replace(' ', '-', strtolower($cat));
            $results = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->terms} SET name = %s, slug = %s  WHERE term_id = 1", $cat, $slug));
        }
        if (strlen($options['default_link_cat']) > 0) {
            global $wpdb;
            $cat = $options['default_link_cat'];
            $slug = str_replace(' ', '-', strtolower($cat));
            $results = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->terms} SET name = %s, slug = %s  WHERE term_id = 2", $cat, $slug));
        }
        if (isset($options['delete_first_post']) && $options['delete_first_post'] == 1) {
            global $wpdb;
            $statement = "UPDATE {$wpdb->posts} SET post_status = 'draft'  WHERE id = 1";
            $results = $wpdb->query($statement);
        }
        if (isset($options['delete_first_comment']) && $options['delete_first_comment'] == 1) {
            wp_delete_comment(1);
        }
        if ($options['delete_blogroll_links'] == 1) {
            wp_delete_link(1);
            //delete Wordpress.com blogroll link
            wp_delete_link(2);
            //delete Wordpress.org blogroll link
        }
        if ($options['redirectblog'] == 2) {
            $blog_page = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_name' => $options['pageslug'], 'post_title' => $options['pagetitle'], 'post_type' => 'page', 'post_content' => __('<p><strong>This page has been created automatically by the BuddyPress GroupBlog plugin.</strong></p><p>Please contact the site admin if you see this message instead of your blog posts. Possible solution: please advise your site admin to create the <a href="http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates">page template</a> needed for the BuddyPress GroupBlog plugin.<p>', 'groupblog'));
            $blog_page_id = wp_insert_post($blog_page);
            if ($blog_page_id) {
                add_post_meta($blog_page_id, '_wp_page_template', 'blog.php');
            }
            add_post_meta($blog_page_id, 'created_by_groupblog_dont_change', '1');
            // Set the Blog Reading Settings to load the template page as front page
            if ($options['deep_group_integration'] == 1) {
                update_option('show_on_front', 'page');
                update_option('page_on_front', $blog_page_id);
            }
        }
        restore_current_blog();
    }
}
Exemplo n.º 2
0
 /**
  * Deletes plugin link from Blogroll
  *
  * @return void
  */
 public static function link_delete()
 {
     require_once ABSPATH . 'wp-admin/includes/bookmark.php';
     $bookmarks = get_bookmarks();
     $link_id = 0;
     foreach ($bookmarks as $bookmark) {
         if ($bookmark->link_url == W3TC_LINK_URL) {
             wp_delete_link($bookmark->link_id);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Delete the bookmark corresponding to this container.
  * Also removes the synch. record of the container and removes all associated instances.
  *
  * @return bool|WP_error
  */
 function delete_wrapped_object()
 {
     if (wp_delete_link($this->container_id)) {
         //Note that there is no need to explicitly delete the synch. record and instances
         //associated with this link - wp_delete_link() will execute the 'delete_link' action,
         //which will be noticed by blcBookmarkManager, which will then delete anything that needs
         //to be deleted.
         //But in case the (undocumented) behaviour of wp_delete_link() changes in a later WP version,
         //add a call to $this->delete() here.
         return true;
     } else {
         $bookmark = $this->get_wrapped_object();
         if (is_null($bookmark)) {
             $link_name = "[nonexistent]";
         } else {
             $link_name = sanitize_bookmark_field('link_name', $bookmark->link_name, $this->container_id, 'display');
         }
         $msg = sprintf(__('Failed to delete blogroll link "%s" (%d)', 'broken-link-checker'), $link_name, $this->container_id);
         return new WP_Error('delete_failed', $msg);
     }
 }
 function process()
 {
     global $wp_rewrite, $wpcc_options;
     $langs = array();
     foreach ($this->langs as $key => $value) {
         if (isset($_POST['wpcco_variant_' . $key])) {
             $langs[] = $key;
         }
     }
     $options = array('wpcc_used_langs' => $langs, 'wpcc_search_conversion' => intval($_POST['wpcco_search_conversion']), 'wpcc_browser_redirect' => intval($_POST['wpcco_browser_redirect']), 'wpcc_use_cookie_variant' => intval($_POST['wpcco_use_cookie_variant']), 'wpcc_use_fullpage_conversion' => isset($_POST['wpcco_use_fullpage_conversion']) ? 1 : 0, 'wpcc_trackback_plugin_author' => isset($_POST['wpcco_trackback_plugin_author']) ? intval($_POST['wpcco_trackback_plugin_author']) : 0, 'wpcc_add_author_link' => isset($_POST['wpcco_add_author_link']) ? 1 : 0, 'wpcc_use_permalink' => intval($_POST['wpcco_use_permalink']), 'wpcc_auto_language_recong' => isset($_POST['wpcco_auto_language_recong']) ? 1 : 0, 'wpcc_no_conversion_tag' => trim($_POST['wpcco_no_conversion_tag'], " \t\n\r\v,|"), 'wpcc_no_conversion_ja' => isset($_POST['wpcco_no_conversion_ja']) ? 1 : 0, 'wpcc_no_conversion_qtag' => isset($_POST['wpcco_no_conversion_qtag']) ? 1 : 0, 'nctip' => trim($_POST['wpcco_no_conversion_tip']));
     foreach ($this->langs as $lang => $value) {
         if (!empty($_POST[$value[1]])) {
             $options[$value[1]] = trim($_POST[$value[1]]);
         }
     }
     if ($this->get_cache_status() == 2 && empty($options['wpcc_browser_redirect']) && empty($options['wpcc_use_cookie_variant'])) {
         $this->uninstall_cache_module();
     }
     if ($options['wpcc_trackback_plugin_author'] == 1) {
         $options['wpcc_trackback_plugin_author'] = $this->trackback();
         if ($options['wpcc_trackback_plugin_author'] == 2) {
             $this->message .= '已成功向<a href="https://oogami.name/project/wpcc/" target="_blank">插件主页</a>发送Trackback。感谢您的支持。<br />';
         } else {
             $this->message .= '向<a href="https://oogami.name/project/wpcc/" target="_blank">插件主页</a>发送Trackback失败,你可以尝试重新提交。<br />';
         }
     }
     if ($options['wpcc_add_author_link'] == 1 && $this->options['wpcc_add_author_link'] == 0) {
         if ($options['wpcc_add_author_link'] = wp_insert_link(array('link_target' => '_blank', 'link_description' => '小野大神的 Blog,关注文明与幻想。', 'link_rss' => 'https://oogami.name/feed/', 'link_name' => '小野大神', 'link_url' => 'https://oogami.name/'))) {
             $this->message .= '已成功添加<a href="https://oogami.name/" target="_blank">插件作者</a>的主页链接。感谢您的支持<br />';
         } else {
             $options['wpcc_add_author_link'] = 0;
             $this->message .= '添加插件作者主页链接失败。请重试。<br />';
         }
     } else {
         if ($options['wpcc_add_author_link'] == 0 && $this->options['wpcc_add_author_link'] != 0) {
             if (wp_delete_link($this->options['wpcc_add_author_link'])) {
                 $this->message .= '已删除插件作者的主页链接。<br />';
             }
         }
     }
     $wpcc_options = $options;
     //因为可能需要刷新rewrite规则, 必须立即更新wpcc_options全局变量
     if ($this->options['wpcc_use_permalink'] != $options['wpcc_use_permalink'] || $this->options['wpcc_use_permalink'] != 0 && $this->options['wpcc_used_langs'] != $options['wpcc_used_langs']) {
         if (!has_filter('rewrite_rules_array', 'wpcc_rewrite_rules')) {
             add_filter('rewrite_rules_array', 'wpcc_rewrite_rules');
         }
         $wp_rewrite->flush_rules();
     }
     update_option('wpcc_options', $options);
     $this->options = $options;
     $this->is_success = true;
     $this->message .= '<br />设置已更新。';
 }
Exemplo n.º 5
0
function wpmu_delete_user($id)
{
    global $wpdb;
    $id = (int) $id;
    $user = new WP_User($id);
    do_action('wpmu_delete_user', $id);
    $blogs = get_blogs_of_user($id);
    if (!empty($blogs)) {
        foreach ($blogs as $blog) {
            switch_to_blog($blog->userblog_id);
            remove_user_from_blog($id, $blog->userblog_id);
            $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
            foreach ((array) $post_ids as $post_id) {
                wp_delete_post($post_id);
            }
            // Clean links
            $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
            if ($link_ids) {
                foreach ($link_ids as $link_id) {
                    wp_delete_link($link_id);
                }
            }
            restore_current_blog();
        }
    }
    $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
    foreach ($meta as $mid) {
        delete_metadata_by_mid('user', $mid);
    }
    $wpdb->delete($wpdb->users, array('ID' => $id));
    clean_user_cache($user);
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
Exemplo n.º 6
0
/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to an User ID, then all posts will
 * be deleted of that user. The action 'delete_user' that is passed the User ID
 * being deleted will be run after the posts are either reassigned or deleted.
 * The user meta will also be deleted that are for that User ID.
 *
 * @since unknown
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function wp_delete_user($id, $reassign = 'novalue') {
	global $wpdb;

	$id = (int) $id;
	$user = new WP_User($id);

	// allow for transaction statement
	do_action('delete_user', $id);

	if ($reassign == 'novalue') {
		$post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id) );

		if ($post_ids) {
			foreach ($post_ids as $post_id)
				wp_delete_post($post_id);
		}

		// Clean links
		$link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) );

		if ( $link_ids ) {
			foreach ( $link_ids as $link_id )
				wp_delete_link($link_id);
		}

	} else {
		$reassign = (int) $reassign;
		$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $id) );
		$wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $id) );
	}

	// FINALLY, delete user

	$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
	$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );

	wp_cache_delete($id, 'users');
	wp_cache_delete($user->user_login, 'userlogins');
	wp_cache_delete($user->user_email, 'useremail');
	wp_cache_delete($user->user_nicename, 'userslugs');

	// allow for commit transaction
	do_action('deleted_user', $id);

	return true;
}
Exemplo n.º 7
0
/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to an User ID, then all posts will
 * be deleted of that user. The action 'delete_user' that is passed the User ID
 * being deleted will be run after the posts are either reassigned or deleted.
 * The user meta will also be deleted that are for that User ID.
 *
 * @since 2.0.0
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function wp_delete_user($id, $reassign = 'novalue')
{
    global $wpdb;
    $id = (int) $id;
    $user = new WP_User($id);
    // allow for transaction statement
    do_action('delete_user', $id);
    if ('novalue' === $reassign || null === $reassign) {
        $post_types_to_delete = array();
        foreach (get_post_types(array(), 'objects') as $post_type) {
            if ($post_type->delete_with_user) {
                $post_types_to_delete[] = $post_type->name;
            } elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) {
                $post_types_to_delete[] = $post_type->name;
            }
        }
        $post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id);
        $post_types_to_delete = implode("', '", $post_types_to_delete);
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_type IN ('{$post_types_to_delete}')", $id));
        if ($post_ids) {
            foreach ($post_ids as $post_id) {
                wp_delete_post($post_id);
            }
        }
        // Clean links
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        if ($link_ids) {
            foreach ($link_ids as $link_id) {
                wp_delete_link($link_id);
            }
        }
    } else {
        $reassign = (int) $reassign;
        $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
    }
    // FINALLY, delete user
    if (is_multisite()) {
        remove_user_from_blog($id, get_current_blog_id());
    } else {
        $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
        foreach ($meta as $mid) {
            delete_metadata_by_mid('user', $mid);
        }
        $wpdb->delete($wpdb->users, array('ID' => $id));
    }
    clean_user_cache($user);
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
Exemplo n.º 8
0
 private static function delete_links($links)
 {
     $saved_links = self::get_ojsimport_links();
     foreach ($links as $url => $id) {
         wp_delete_link($id);
         unset($saved_links[$url]);
     }
     update_option('_ojsimportlinks', $saved_links);
 }
Exemplo n.º 9
0
     if (is_wp_error($r)) {
         $x = new WP_AJAX_Response(array('what' => 'link-cat', 'id' => $id, 'data' => $r));
         $x->send();
     }
     die('1');
     break;
 case 'delete-link':
     check_ajax_referer("delete-bookmark_{$id}");
     if (!current_user_can('manage_links')) {
         die('-1');
     }
     $link = get_bookmark($id);
     if (!$link || is_wp_error($link)) {
         die('1');
     }
     if (wp_delete_link($id)) {
         die('1');
     } else {
         die('0');
     }
     break;
 case 'delete-meta':
     check_ajax_referer("delete-meta_{$id}");
     if (!($meta = get_post_meta_by_id($id))) {
         die('1');
     }
     if (!current_user_can('edit_post', $meta->post_id)) {
         die('-1');
     }
     if (delete_meta($meta->meta_id)) {
         die('1');
Exemplo n.º 10
0
/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to an User ID, then all posts will
 * be deleted of that user. The action 'delete_user' that is passed the User ID
 * being deleted will be run after the posts are either reassigned or deleted.
 * The user meta will also be deleted that are for that User ID.
 *
 * @since unknown
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function wp_delete_user($id, $reassign = 'novalue')
{
    global $wpdb;
    $id = (int) $id;
    // allow for transaction statement
    do_action('delete_user', $id);
    if ('novalue' === $reassign || null === $reassign) {
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
        if ($post_ids) {
            foreach ($post_ids as $post_id) {
                wp_delete_post($post_id);
            }
        }
        // Clean links
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        if ($link_ids) {
            foreach ($link_ids as $link_id) {
                wp_delete_link($link_id);
            }
        }
    } else {
        $reassign = (int) $reassign;
        $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
    }
    clean_user_cache($id);
    // FINALLY, delete user
    if (!is_multisite()) {
        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
        $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->users} WHERE ID = %d", $id));
    } else {
        $level_key = $wpdb->get_blog_prefix() . 'capabilities';
        // wpmu site admins don't have user_levels
        $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE user_id = {$id} AND meta_key = '{$level_key}'");
    }
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
Exemplo n.º 11
0
/**
 * Ajax handler for deleting a link.
 *
 * @since 3.1.0
 */
function wp_ajax_delete_link()
{
    $id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
    check_ajax_referer("delete-bookmark_{$id}");
    if (!current_user_can('manage_links')) {
        wp_die(-1);
    }
    $link = get_bookmark($id);
    if (!$link || is_wp_error($link)) {
        wp_die(1);
    }
    if (wp_delete_link($id)) {
        wp_die(1);
    } else {
        wp_die(0);
    }
}
Exemplo n.º 12
0
	function set_blog_defaults($blog_id, $user_id)
    {
		global $wp_rewrite, $wpdb, $current_site;
		
		
		
		switch_to_blog($blog_id);
		
		
		
		// get the site options 
		$options = get_site_option('cets_blog_defaults_options');
		
		
		// check for the blogname_flag and if it's 0, then delete the blogname option
		if ($options['blogname_flag'] == 0 && isset($options['blogname'])) {
			unset($options['blogname']);
		}
		
		// check for the blog_public setting and if it's blank, delete it
		if (strlen($options['blog_public']) == 0) {
			unset($options['blog_public']);
			
		}
		
		// bonus options - set these first and then unset each one so they don't clutter the database
		// Add User to Blog
		if ($options['add_user_to_blog'] == 1) {
			if(strlen($options['add_user_to_blog_id']) == 1) {
				add_user_to_blog( $options['add_user_to_blog_id'], $user_id, $options['add_user_to_blog_role'] );
			}
			elseif (strlen($options['add_user_to_blog_id']) > 1) {
				$blogs = explode(',', $options['add_user_to_blog_id']);
				foreach ($blogs as $blog){
					add_user_to_blog( $blog, $user_id, $options['add_user_to_blog_role'] );
				}
				
			}
			
			
		}
		unset($options['add_user_to_blog']);
		unset($options['add_user_to_blog_role']);
		unset($options['add_user_to_blog_id']);
		
		// Delete Links		
		if ($options['delete_blogroll_links'] == 1) {
			wp_delete_link(1); // documentation
			wp_delete_link(2); // wordpress blog
		 	wp_delete_link(3); //delete suggest ideas
    		wp_delete_link(4); //delete support forum
    		wp_delete_link(5); //delete plugins
    		wp_delete_link(6); //delete themes
    		wp_delete_link(7); //delete wp planet
		}
		unset($options['delete_blogroll_links']);
		
		// Default Category Name
		if (strlen($options['default_cat_name']) > 0){
			global $wpdb;
			$cat = $options['default_cat_name'];
			$slug = str_replace(' ', '-', strtolower($cat)); 
			$results = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET name = %s, slug = %s  WHERE term_id = 1", $cat, $slug ) );	
			
		}
		unset($options['default_cat_name']);
		
		// Default Link Category
		if (strlen($options['default_link_cat']) > 0){
			global $wpdb;
			$cat = $options['default_link_cat'];
			$slug = str_replace(' ', '-', strtolower($cat)); 
			$results = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET name = %s, slug = %s  WHERE term_id = 2", $cat, $slug ) );	
			
		}
		unset($options['default_link_cat']);
		
		//Delete First Comment
		if (isset($options['delete_first_comment']) && $options['delete_first_comment'] == 1){
			wp_delete_comment( 1 );
			
		}
		unset($options['delete_first_comment']);
		
		// Close Comments on Hello World
		if (isset($options['close_comments_on_hello_world']) && $options['close_comments_on_hello_world'] == 1){
			global $wpdb;
			$statement = "UPDATE $wpdb->posts SET comment_status = 'closed'  WHERE id = 1";
			
			$results = $wpdb->query( $statement );
			
			
		}
		unset($options['close_comments_on_hello_world']);
		
		// Close Comments on About Page
		if (isset($options['close_comments_on_about_page']) && $options['close_comments_on_about_page'] == 1){
			global $wpdb;
			$statement = "UPDATE $wpdb->posts SET comment_status = 'closed'  WHERE id = 2";
			
			$results = $wpdb->query( $statement );
			
			
		}
		unset($options['close_comments_on_about_page']);
		
		
		// Delete First Post
		if (isset($options['delete_first_post']) && $options['delete_first_post'] == 1){
			global $wpdb;
			$statement = "UPDATE $wpdb->posts SET post_status = 'draft'  WHERE id = 1";
			
			$results = $wpdb->query( $statement );
			
			
		}
		unset($options['delete_first_post']);
		
		// Delete Initial Widgets
		if (isset($options['delete_initial_widgets']) && $options['delete_initial_widgets'] == 1){
			delete_option('sidebars_widgets');
		}
		unset($options['delete_initial_widgets']);
		
		
		// Add Default Links
		if (isset($options['default_links']) && strlen($options['default_links'])){
			
			
			
			$links = explode("|+", $options['default_links']);
			
			foreach ($links as $link) {
				$thislink = explode('=>', $link);
				wp_insert_link(array('link_name' => $thislink[0], 'link_url' => $thislink[1]));
				
			}
			
		}
		unset($options['default_links']);
		
		// Add Default Categories
		if (isset($options['default_categories']) && strlen($options['default_categories'])){
			$cats = explode("|+", $options['default_categories']);
			
			
			foreach ($cats as $cat) {
				$thiscat = explode('=>', $cat);
				// get the id of the parent category
				$parentid = category_exists($thiscat[3]);
				
				$cat_array = array('cat_name'=>$thiscat[0], 'category_description'=>$thiscat[1], 'category_nicename'=> $thiscat[2], 'category_parent' => $parentid );
				
				
				
				wp_insert_category($cat_array, true);			
								
			}
			
		}
		unset($options['default_categories']);
		
		
		// deal with the themes
		if (! empty($options['theme'])) {
			// we want something other than the default theme
			$values= explode("|", $options['theme']);
			switch_theme($values[0], $values[1]);		
			//this is weird, but it would appear there might be a bug with switch theme in that it doesn't switch the current_theme. But if we kill it then the code runs to reset it.
			update_option('current_theme', '');
			
		
		}	
		
		unset($options['theme']);
		
		
		// End Bonus Options - now process all the "normal" options.
		foreach($options as $key => $value) {
			// update all the options (we know they should all be set because this runs after populate_options()
			update_option($key, $value);	
		}
		
		// run through the permalink options here and set the blog to use them
		if ( isset($options['permalink_structure']) || isset($options['category_base']) || isset($options['tag_base']) ) {
				$details = $wpdb->get_results( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = $blog_id");
					if ( isset($options['permalink_structure']) ) {
						$permalink_structure = $options['permalink_structure'];
						if (! empty($permalink_structure) )
							$permalink_structure = preg_replace('#/+#', '/', '/' . $options['permalink_structure']);
						if( constant( 'VHOST' ) == 'no' && $permalink_structure != '' && $current_site->domain.$current_site->path == $details->domain.$details->path ) {
							$permalink_structure = '/blog' . $permalink_structure;
						}
						$wp_rewrite->set_permalink_structure($permalink_structure);
					}
				
					if ( isset($options['category_base']) ) {
						$category_base = $options['category_base'];
						if (! empty($category_base) )
							$category_base = preg_replace('#/+#', '/', '/' . $options['category_base']);
						if( constant( 'VHOST' ) == 'no' && $category_base != '' && $current_site->domain.$current_site->path == $details->domain.$details->path ) {
							$category_base = '/blog' . $category_base;
						}
						$wp_rewrite->set_category_base($category_base);
					}
				
					if ( isset($options['tag_base']) ) {
						$tag_base = $options['tag_base'];
						if (! empty($tag_base) )
							$tag_base = preg_replace('#/+#', '/', '/' . $options['tag_base']);
						if( constant( 'VHOST' ) == 'no' && $tag_base != '' && $current_site->domain.$current_site->path == $details->domain.$details->path ) {
							$tag_base = '/blog' . $tag_base;
						}
						$wp_rewrite->set_tag_base($tag_base);
					}
				}
				
				$permalink_structure = get_option('permalink_structure');
				$category_base = get_option('category_base');
				$tag_base = get_option( 'tag_base' );
				
				if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
					$writable = true;
				else
					$writable = false;
				
				if ($wp_rewrite->using_index_permalinks())
					$usingpi = true;
				else
					$usingpi = false;
				
				$wp_rewrite->flush_rules();
				// shouldn't have to do this - it should happen in the above code. But, maybe forcing it would work?
				update_option('rewrite_rules','');
			
			
		// end permalink mucking about
		
		
		
		
		restore_current_blog();
		
		
    	
    }
Exemplo n.º 13
0
/**
 * Delete a user from the network and remove from all sites.
 *
 * @since 3.0.0
 *
 * @todo Merge with wp_delete_user() ?
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int $id The user ID.
 * @return bool True if the user was deleted, otherwise false.
 */
function wpmu_delete_user($id)
{
    global $wpdb;
    if (!is_numeric($id)) {
        return false;
    }
    $id = (int) $id;
    $user = new WP_User($id);
    if (!$user->exists()) {
        return false;
    }
    // Global super-administrators are protected, and cannot be deleted.
    $_super_admins = get_super_admins();
    if (in_array($user->user_login, $_super_admins, true)) {
        return false;
    }
    /**
     * Fires before a user is deleted from the network.
     *
     * @since MU
     *
     * @param int $id ID of the user about to be deleted from the network.
     */
    do_action('wpmu_delete_user', $id);
    $blogs = get_blogs_of_user($id);
    if (!empty($blogs)) {
        foreach ($blogs as $blog) {
            switch_to_blog($blog->userblog_id);
            remove_user_from_blog($id, $blog->userblog_id);
            $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
            foreach ((array) $post_ids as $post_id) {
                wp_delete_post($post_id);
            }
            // Clean links
            $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
            if ($link_ids) {
                foreach ($link_ids as $link_id) {
                    wp_delete_link($link_id);
                }
            }
            restore_current_blog();
        }
    }
    $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
    foreach ($meta as $mid) {
        delete_metadata_by_mid('user', $mid);
    }
    $wpdb->delete($wpdb->users, array('ID' => $id));
    clean_user_cache($user);
    /** This action is documented in wp-admin/includes/user.php */
    do_action('deleted_user', $id);
    return true;
}
Exemplo n.º 14
0
/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to an User ID, then all posts will
 * be deleted of that user. The action 'delete_user' that is passed the User ID
 * being deleted will be run after the posts are either reassigned or deleted.
 * The user meta will also be deleted that are for that User ID.
 *
 * @since 2.0.0
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function wp_delete_user($id, $reassign = 'novalue')
{
    global $wpdb;
    $id = (int) $id;
    $user = new WP_User($id);
    // allow for transaction statement
    do_action('delete_user', $id);
    if ('novalue' === $reassign || null === $reassign) {
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
        if ($post_ids) {
            foreach ($post_ids as $post_id) {
                wp_delete_post($post_id);
            }
        }
        // Clean links
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        if ($link_ids) {
            foreach ($link_ids as $link_id) {
                wp_delete_link($link_id);
            }
        }
    } else {
        $reassign = (int) $reassign;
        $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
    }
    // FINALLY, delete user
    if (is_multisite()) {
        remove_user_from_blog($id, get_current_blog_id());
    } else {
        $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
        foreach ($meta as $mid) {
            delete_metadata_by_mid('user', $mid);
        }
        $wpdb->delete($wpdb->users, array('ID' => $id));
    }
    clean_user_cache($user);
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
Exemplo n.º 15
0
 function ReciprocalLinkChecker($RecipCheckAddress = '', $recipcheckdelete403 = false)
 {
     global $wpdb;
     if ($RecipCheckAddress != '') {
         $linkquery = "SELECT distinct *, l.link_id as proper_link_id, UNIX_TIMESTAMP(l.link_updated) as link_date ";
         $linkquery .= "FROM " . $this->db_prefix() . "terms t ";
         $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_taxonomy tt ON (t.term_id = tt.term_id) ";
         $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
         $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links l ON (tr.object_id = l.link_id) ";
         $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links_extrainfo le ON (l.link_id = le.link_id) ";
         $linkquery .= "WHERE tt.taxonomy = 'link_category' ";
         $linkquery .= "AND le.link_reciprocal <> '' ";
         $linkquery .= "order by l.link_name ASC";
         $links = $wpdb->get_results($linkquery);
         $output = "<strong>Reciprocal Link Checker Report</strong><br /><br />";
         if ($links) {
             foreach ($links as $link) {
                 $sitecontent = file_get_contents($link->link_reciprocal);
                 $output .= "<a href='" . $link->link_url . "'>" . $link->link_name . "</a>: ";
                 if (strpos($http_response_header[0], "200")) {
                     if (strpos($sitecontent, $RecipCheckAddress) === false) {
                         $output .= "<span style='color: #FF0000'>Not Found</span><br />";
                     } elseif (strpos($sitecontent, $RecipCheckAddress) !== false) {
                         $output .= "<span style='color: #00FF00'>OK</span><br />";
                     }
                 } elseif (strpos($http_response_header[0], "403") && $recipcheckdelete403 == true) {
                     wp_delete_link($link->link_id);
                     $output .= "Error 403: Link Deleted";
                 } else {
                     $output .= "Website Unreachable";
                 }
             }
         } else {
             $output = "There are no links with reciprocal links associated with them.<br />";
         }
         return $output;
     }
 }
Exemplo n.º 16
0
function tp_remove_link()
{
    global $wpdb;
    if ($link_id = get_option('tp_link_id')) {
        wp_delete_link($link_id);
    }
}
function fwp_multidelete_page()
{
    // If this is a POST, validate source and user credentials
    FeedWordPressCompatibility::validate_http_request('feedwordpress_feeds', 'manage_links');
    $link_ids = isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array();
    if (isset($_REQUEST['link_id'])) {
        array_push($link_ids, $_REQUEST['link_id']);
    }
    if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm'] == 'Delete') {
        if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) {
            $actions = $GLOBALS['fwp_post']['link_action'];
        } else {
            $actions = array();
        }
        $do_it = array('hide' => array(), 'nuke' => array(), 'delete' => array());
        foreach ($actions as $link_id => $what) {
            $do_it[$what][] = $link_id;
        }
        $alter = $errs = array();
        if (count($do_it['hide']) > 0) {
            $links = get_bookmarks(array('include' => implode(',', $do_it['hide'])));
            if (is_array($links) && !empty($links)) {
                foreach ($links as $link) {
                    $link->link_visible = 'N';
                    $alter[] = 'hiding link: ' . $link->link_id;
                    wp_update_link((array) $link);
                }
            }
        }
        if (count($do_it['nuke']) > 0) {
            foreach ($do_it['nuke'] as $nuke_id) {
                // Make a list of the items syndicated from this feed...
                $args = array('posts_per_page' => -1, 'numberposts' => 0, 'meta_key' => 'syndication_feed_id', 'meta_value' => $nuke_id);
                $posts = get_posts($args);
                // ... and kill them all
                if (is_array($posts) && !empty($posts)) {
                    foreach ($posts as $p) {
                        $alter[] = 'deleting post: ' . $p->ID;
                        wp_delete_post($p->ID, true);
                    }
                }
                // Then delete the link
                wp_delete_link($nuke_id);
            }
        }
        if (count($do_it['delete']) > 0) {
            $deletem = "(" . implode(', ', $do_it['delete']) . ")";
            foreach ($do_it['delete'] as $del_id) {
                // Make a list of the items syndicated from this feed...
                $args = array('posts_per_page' => -1, 'numberposts' => 0, 'meta_key' => 'syndication_feed_id', 'meta_value' => $del_id);
                $posts = get_posts($args);
                // Make the items syndicated from this feed appear to be locally-authored
                if (is_array($posts) && !empty($posts)) {
                    foreach ($posts as $p) {
                        $alter[] = 'deleting postmeta for post: ' . $p->ID;
                        if (!delete_post_meta($p->ID, 'syndication_feed_id')) {
                            $errs[] = 'Could not delete meta for post: ' . $p->ID;
                        }
                    }
                }
                // Then delete the link
                wp_delete_link($del_id);
            }
        }
        if (count($alter) > 0) {
            echo "<div class=\"updated\">\n";
            if (count($errs) > 0) {
                echo "There were some problems processing your ";
                echo "unsubscribe request. [Errors: " . implode('; ', $errs) . "]";
            } else {
                echo "Your unsubscribe request(s) have been processed.";
            }
            echo "</div>\n";
        }
        return true;
        // Continue on to Syndicated Sites listing
    } else {
        if (count($link_ids) > 0) {
            $targets = get_bookmarks(array('include' => implode(',', $link_ids), 'hide_invisible' => 0));
        } else {
            $targets = array();
        }
        ?>
<form action="admin.php?page=<?php 
        echo FWP_SYNDICATION_PAGE_SLUG;
        ?>
" method="post">
<div class="wrap">
<?php 
        FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds');
        ?>
<input type="hidden" name="action" value="Unsubscribe" />
<input type="hidden" name="confirm" value="Delete" />

<h2>Unsubscribe from Syndicated Links:</h2>
<?php 
        foreach ($targets as $link) {
            $subscribed = 'Y' == strtoupper($link->link_visible);
            $link_url = esc_html($link->link_url);
            $link_name = esc_html($link->link_name);
            $link_description = esc_html($link->link_description);
            $link_rss = esc_html($link->link_rss);
            ?>
<fieldset>
<legend><?php 
            echo $link_name;
            ?>
</legend>
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
<tr><th scope="row" width="20%"><?php 
            _e('Feed URI:');
            ?>
</th>
<td width="80%"><a href="<?php 
            echo $link_rss;
            ?>
"><?php 
            echo $link_rss;
            ?>
</a></td></tr>
<tr><th scope="row" width="20%"><?php 
            _e('Short description:');
            ?>
</th>
<td width="80%"><?php 
            echo $link_description;
            ?>
</span></td></tr>
<tr><th width="20%" scope="row"><?php 
            _e('Homepage:');
            ?>
</th>
<td width="80%"><a href="<?php 
            echo $link_url;
            ?>
"><?php 
            echo $link_url;
            ?>
</a></td></tr>
<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php 
            _e('Options');
            ?>
:</th>
<td width="80%"><ul style="margin:0; padding: 0; list-style: none">
<?php 
            if ($subscribed) {
                ?>
<li><input type="radio" id="hide-<?php 
                echo $link->link_id;
                ?>
"
name="link_action[<?php 
                echo $link->link_id;
                ?>
]" value="hide" checked="checked" />
<label for="hide-<?php 
                echo $link->link_id;
                ?>
">Turn off the subscription for this
syndicated link<br/><span style="font-size:smaller">(Keep the feed information
and all the posts from this feed in the database, but don't syndicate any
new posts from the feed.)</span></label></li>
<?php 
            }
            ?>
<li><input type="radio" id="nuke-<?php 
            echo $link->link_id;
            ?>
"<?php 
            if (!$subscribed) {
                ?>
 checked="checked"<?php 
            }
            ?>
name="link_action[<?php 
            echo $link->link_id;
            ?>
]" value="nuke" />
<label for="nuke-<?php 
            echo $link->link_id;
            ?>
">Delete this syndicated link and all the
posts that were syndicated from it</label></li>
<li><input type="radio" id="delete-<?php 
            echo $link->link_id;
            ?>
"
name="link_action[<?php 
            echo $link->link_id;
            ?>
]" value="delete" />
<label for="delete-<?php 
            echo $link->link_id;
            ?>
">Delete this syndicated link, but
<em>keep</em> posts that were syndicated from it (as if they were authored
locally).</label></li>
<li><input type="radio" id="nothing-<?php 
            echo $link->link_id;
            ?>
"
name="link_action[<?php 
            echo $link->link_id;
            ?>
]" value="nothing" />
<label for="nothing-<?php 
            echo $link->link_id;
            ?>
">Keep this feed as it is. I changed
my mind.</label></li>
</ul>
</table>
</fieldset>
<?php 
        }
        ?>

<div class="submit">
<input class="delete" type="submit" name="submit" value="<?php 
        _e('Unsubscribe from selected feeds &raquo;');
        ?>
" />
</div>
</div>
<?php 
        return false;
        // Don't continue on to Syndicated Sites listing
    }
}
Exemplo n.º 18
0
/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to an User ID, then all posts will
 * be deleted of that user. The action 'delete_user' that is passed the User ID
 * being deleted will be run after the posts are either reassigned or deleted.
 * The user meta will also be deleted that are for that User ID.
 *
 * @since 2.0.0
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function wp_delete_user($id, $reassign = 'novalue')
{
    global $wpdb;
    $id = (int) $id;
    $user = new WP_User($id);
    if (!$user->exists()) {
        return false;
    }
    // allow for transaction statement
    do_action('delete_user', $id);
    if ('novalue' === $reassign || null === $reassign) {
        $post_types_to_delete = array();
        foreach (get_post_types(array(), 'objects') as $post_type) {
            if ($post_type->delete_with_user) {
                $post_types_to_delete[] = $post_type->name;
            } elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) {
                $post_types_to_delete[] = $post_type->name;
            }
        }
        $post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id);
        $post_types_to_delete = implode("', '", $post_types_to_delete);
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_type IN ('{$post_types_to_delete}')", $id));
        if ($post_ids) {
            foreach ($post_ids as $post_id) {
                wp_delete_post($post_id);
            }
        }
        // Clean links
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        if ($link_ids) {
            foreach ($link_ids as $link_id) {
                wp_delete_link($link_id);
            }
        }
    } else {
        $reassign = (int) $reassign;
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
        $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        if (!empty($post_ids)) {
            foreach ($post_ids as $post_id) {
                clean_post_cache($post_id);
            }
        }
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
        if (!empty($link_ids)) {
            foreach ($link_ids as $link_id) {
                clean_bookmark_cache($link_id);
            }
        }
    }
    // FINALLY, delete user
    if (is_multisite()) {
        remove_user_from_blog($id, get_current_blog_id());
    } else {
        $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
        $group_user = $_POST['users'];
        //print_r($group_user);
        //exit();
        foreach ($meta as $mid) {
            delete_metadata_by_mid('user', $mid);
        }
        $direct = ABSPATH;
        require_once $direct . '/User.php';
        require_once $direct . '/course.php';
        $user_course = new User();
        $course = new Course();
        foreach ($group_user as $gid) {
            $get_lmsid = "select user_lms from wp_users where ID=" . $gid;
            $getlms = $wpdb->get_row($get_lmsid);
            $res = $user_course->delete_user(1, $getlms->user_lms);
        }
        //echo "hiiiiiiiiiii".$id;
        //exit();
        $wpdb->delete($wpdb->users, array('ID' => $id));
    }
    clean_user_cache($user);
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
Exemplo n.º 19
0
/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to a User ID, then all posts will
 * be deleted of that user. The action 'delete_user' that is passed the User ID
 * being deleted will be run after the posts are either reassigned or deleted.
 * The user meta will also be deleted that are for that User ID.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int $id User ID.
 * @param int $reassign Optional. Reassign posts and links to new User ID.
 * @return bool True when finished.
 */
function wp_delete_user($id, $reassign = null)
{
    global $wpdb;
    if (!is_numeric($id)) {
        return false;
    }
    $id = (int) $id;
    $user = new WP_User($id);
    if (!$user->exists()) {
        return false;
    }
    // Normalize $reassign to null or a user ID. 'novalue' was an older default.
    if ('novalue' === $reassign) {
        $reassign = null;
    } elseif (null !== $reassign) {
        $reassign = (int) $reassign;
    }
    /**
     * Fires immediately before a user is deleted from the database.
     *
     * @since 2.0.0
     *
     * @param int      $id       ID of the user to delete.
     * @param int|null $reassign ID of the user to reassign posts and links to.
     *                           Default null, for no reassignment.
     */
    do_action('delete_user', $id, $reassign);
    if (null === $reassign) {
        $post_types_to_delete = array();
        foreach (get_post_types(array(), 'objects') as $post_type) {
            if ($post_type->delete_with_user) {
                $post_types_to_delete[] = $post_type->name;
            } elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) {
                $post_types_to_delete[] = $post_type->name;
            }
        }
        /**
         * Filter the list of post types to delete with a user.
         *
         * @since 3.4.0
         *
         * @param array $post_types_to_delete Post types to delete.
         * @param int   $id                   User ID.
         */
        $post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id);
        $post_types_to_delete = implode("', '", $post_types_to_delete);
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_type IN ('{$post_types_to_delete}')", $id));
        if ($post_ids) {
            foreach ($post_ids as $post_id) {
                wp_delete_post($post_id);
            }
        }
        // Clean links
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        if ($link_ids) {
            foreach ($link_ids as $link_id) {
                wp_delete_link($link_id);
            }
        }
    } else {
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
        $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        if (!empty($post_ids)) {
            foreach ($post_ids as $post_id) {
                clean_post_cache($post_id);
            }
        }
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
        if (!empty($link_ids)) {
            foreach ($link_ids as $link_id) {
                clean_bookmark_cache($link_id);
            }
        }
    }
    // FINALLY, delete user
    if (is_multisite()) {
        remove_user_from_blog($id, get_current_blog_id());
    } else {
        $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
        foreach ($meta as $mid) {
            delete_metadata_by_mid('user', $mid);
        }
        $wpdb->delete($wpdb->users, array('ID' => $id));
    }
    clean_user_cache($user);
    /**
     * Fires immediately after a user is deleted from the database.
     *
     * @since 2.9.0
     *
     * @param int      $id       ID of the deleted user.
     * @param int|null $reassign ID of the user to reassign posts and links to.
     *                           Default null, for no reassignment.
     */
    do_action('deleted_user', $id, $reassign);
    return true;
}
Exemplo n.º 20
0
function wpmu_delete_user($id)
{
    global $wpdb;
    $id = (int) $id;
    $user = new WP_User($id);
    if (!$user->exists()) {
        return false;
    }
    /**
     * Fires before a user is deleted from the network.
     *
     * @since MU
     *
     * @param int $id ID of the user about to be deleted from the network.
     */
    do_action('wpmu_delete_user', $id);
    $blogs = get_blogs_of_user($id);
    if (!empty($blogs)) {
        foreach ($blogs as $blog) {
            switch_to_blog($blog->userblog_id);
            remove_user_from_blog($id, $blog->userblog_id);
            $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
            foreach ((array) $post_ids as $post_id) {
                wp_delete_post($post_id);
            }
            // Clean links
            $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
            if ($link_ids) {
                foreach ($link_ids as $link_id) {
                    wp_delete_link($link_id);
                }
            }
            restore_current_blog();
        }
    }
    $meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
    foreach ($meta as $mid) {
        delete_metadata_by_mid('user', $mid);
    }
    $wpdb->delete($wpdb->users, array('ID' => $id));
    clean_user_cache($user);
    /**
     * Fires after the user is deleted from the network.
     *
     * @since 2.8.0
     *
     * @param int $id ID of the user that was deleted from the network.
     */
    do_action('deleted_user', $id);
    return true;
}
Exemplo n.º 21
0
function wpmu_delete_user( $id ) {
	global $wpdb;

	$id = (int) $id;

	do_action( 'wpmu_delete_user', $id );

	$blogs = get_blogs_of_user( $id );

	if ( ! empty( $blogs ) ) {
		foreach ( $blogs as $blog ) {
			switch_to_blog( $blog->userblog_id );
			remove_user_from_blog( $id, $blog->userblog_id );

			$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
			foreach ( (array) $post_ids as $post_id ) {
				wp_delete_post( $post_id );
			}

			// Clean links
			$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );

			if ( $link_ids ) {
				foreach ( $link_ids as $link_id )
					wp_delete_link( $link_id );
			}

			restore_current_blog();
		}
	}

	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->users WHERE ID = %d", $id ) );
	$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id ) );

	clean_user_cache( $id );

	// allow for commit transaction
	do_action( 'deleted_user', $id );

	return true;
}
Exemplo n.º 22
0
 protected function rollback_bookmarks($bookmarks)
 {
     $success = true;
     foreach ($bookmarks as $bookmark_url => $bookmark) {
         if ($bookmark == 'new') {
             $_bookmark = $this->get_bookmark_by_url($bookmark_url);
             wp_delete_link($_bookmark->link_id);
         } else {
             if ($this->import_bookmark($bookmark) === false) {
                 $success = false;
             }
         }
     }
     return $success;
 }
Exemplo n.º 23
0
 */
/** Load WordPress Administration Bootstrap */
require_once 'admin.php';
if (!current_user_can('manage_links')) {
    wp_die(__('You do not have sufficient permissions to edit the links for this site.'));
}
$wp_list_table = _get_list_table('WP_Links_List_Table');
// Handle bulk deletes
$doaction = $wp_list_table->current_action();
if ($doaction && isset($_REQUEST['linkcheck'])) {
    check_admin_referer('bulk-bookmarks');
    if ('delete' == $doaction) {
        $bulklinks = (array) $_REQUEST['linkcheck'];
        foreach ($bulklinks as $link_id) {
            $link_id = (int) $link_id;
            wp_delete_link($link_id);
        }
        wp_redirect(add_query_arg('deleted', count($bulklinks), admin_url('link-manager.php')));
        exit;
    }
} elseif (!empty($_GET['_wp_http_referer'])) {
    wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
    exit;
}
$wp_list_table->prepare_items();
$title = __('Links');
$this_file = $parent_file = 'link-manager.php';
add_contextual_help($current_screen, '<p>' . sprintf(__('You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.'), 'widgets.php') . '</p>' . '<p>' . __('Links may be separated into categories; these are different than the categories used on your posts.') . '</p>' . '<p>' . __('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.') . '</p>' . '<p>' . __('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.') . '</p>' . '<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="http://codex.wordpress.org/Links_Screen" target="_blank">Documentation on Managing Links</a>') . '</p>' . '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>');
include_once './admin-header.php';
if (!current_user_can('manage_links')) {
    wp_die(__("You do not have sufficient permissions to edit the links for this site."));
Exemplo n.º 24
0
 function ReciprocalLinkChecker($RecipCheckAddress = '', $recipcheckdelete403 = false, $check_type = 'reciprocal')
 {
     global $wpdb;
     set_time_limit(0);
     if ($RecipCheckAddress != '') {
         $linkquery = "SELECT distinct *, l.link_id as proper_link_id, UNIX_TIMESTAMP(l.link_updated) as link_date ";
         $linkquery .= "FROM " . $this->db_prefix() . "terms t ";
         $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_taxonomy tt ON (t.term_id = tt.term_id) ";
         $linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
         $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links l ON (tr.object_id = l.link_id) ";
         $linkquery .= "LEFT JOIN " . $this->db_prefix() . "links_extrainfo le ON (l.link_id = le.link_id) ";
         $linkquery .= "WHERE tt.taxonomy = 'link_category' ";
         if ('reciprocal' == $check_type) {
             $linkquery .= "AND le.link_reciprocal <> '' ";
         } elseif ('broken' == $check_type) {
             $linkquery .= "AND l.link_url <> '' ";
         }
         $linkquery .= "order by l.link_name ASC";
         $links = $wpdb->get_results($linkquery);
         if ('reciprocal' == $check_type) {
             echo "<strong>" . __('Reciprocal Link Checker Report', 'link-library') . "</strong><br /><br />";
         } elseif ('broken' == $check_type) {
             echo "<strong>" . __('Broken Link Checker Report', 'link-library') . "</strong><br /><br />";
         }
         if ($links) {
             foreach ($links as $link) {
                 global $my_link_library_plugin;
                 if ('reciprocal' == $check_type) {
                     $reciprocal_result = $my_link_library_plugin->CheckReciprocalLink($RecipCheckAddress, $link->link_reciprocal);
                 } elseif ('broken' == $check_type) {
                     $reciprocal_result = $my_link_library_plugin->CheckReciprocalLink($RecipCheckAddress, $link->link_url);
                 }
                 echo '<a href="' . $link->link_url . '">' . $link->link_name . '</a>: ';
                 if ('reciprocal' == $check_type && $reciprocal_result == 'exists_notfound') {
                     echo '<span style="color: #FF0000">' . __('Not Found', 'link-library') . '</span><br />';
                 } elseif ('reciprocal' == $check_type && $reciprocal_result == 'exists_found') {
                     echo '<span style="color: #00FF00">' . __('OK', 'link-library') . '</span><br />';
                 } elseif ('broken' == $check_type && strpos($reciprocal_result, 'exists') !== false) {
                     echo '<span style="color: #00FF00">' . __('Link valid', 'link-library') . '</span><br />';
                 } elseif ($reciprocal_result == 'error_403' && $recipcheckdelete403 == true) {
                     wp_delete_link($link->link_id);
                     echo '<span style="color: #FF0000">' . __('Error 403: Link Deleted', 'link-library') . '</span><br />';
                 } elseif ($reciprocal_result == 'error_403' && $recipcheckdelete403 == false) {
                     echo '<span style="color: #FF0000">' . __('Error 403', 'link-library') . '</span><br />';
                 } elseif ($reciprocal_result == 'unreachable') {
                     echo '<span style="color: #FF0000">' . __('Website Unreachable', 'link-library') . '</span><br />';
                 }
             }
         } else {
             echo __('There are no links with reciprocal links associated with them', 'link-library') . ".<br />";
         }
     }
 }