Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global $name_or_url;
- global $begin_wrap;
- global $end_wrap;
- // determine whether using vhosts or not for both functions to use
- $vhosts = (defined( "VHOST" ) && constant( "VHOST" ) == 'yes' );
- function echoArrayBlogList($arrayName, $name_sort) {
- global $wpdb;
- global $name_or_url;
- global $begin_wrap;
- global $end_wrap;
- global $vhosts;
- $intArrayCount = 0;
- $bid = '';
- // if blog name requested, then get it
- if ($name_or_url == "name") {
- $blogs = array();
- $i = 1;
- foreach ($arrayName as $blog) {
- $blogname = get_blog_option( $blog['blog_id'], "blogname");
- $blogs[$i] = array('key' => strtolower($blogname), // give it a key to sort by
- 'blog_name' => $blogname,
- 'blog_id' => $blog['blog_id'],
- 'domain' => $blog['domain']);
- $i++;
- }
- // now sort if requested
- if($name_sort) {
- asort($blogs);
- }
- // replace array
- $arrayName = $blogs;
- }
- foreach ($arrayName as $blog) {
- // get blog url depending on vhost or not-vhost installtion
- if( $vhosts )
- $tmp_domain = $blog['domain'];
- else
- $tmp_domain = get_blog_option( $blog['blog_id'], "siteurl");
- if ($name_or_url == "name") {
- $tmp_display = $blog['blog_name'];
- } else {
- $tmp_display = $tmp_domain;
- }
- // get blog url depending on vhost or not-vhost installtion
- if( $vhosts )
- echo $begin_wrap . "<a href='http://" . $tmp_domain . $blog['path'] . "'>" . $tmp_display . "</a>" . $end_wrap;
- else
- echo $begin_wrap . "<a href='" . $tmp_domain . "'>" . $tmp_display . "</a>" . $end_wrap;
- }
- }
- function list_all_wpmu_blogs($tmp_limit, $tmp_name_or_url, $tmp_begin_wrap, $tmp_end_wrap, $tmp_order,$filter = 'a') {
- global $wpdb;
- global $name_or_url;
- global $begin_wrap;
- global $end_wrap;
- global $vhosts;
- if ($tmp_limit != "") {
- $limit = "LIMIT " . $tmp_limit;
- }
- if ($tmp_name_or_url == "" || $tmp_name_or_url == "name") {
- $name_or_url = "name";
- // did user request sort by blog_name
- $name_sort = ($tmp_order == "blog_name");
- } else {
- $name_or_url = "url";
- $name_sort = false;
- }
- if (tmp_begin_wrap == "" || tmp_end_wrap == "" ) {
- $begin_wrap = "<p>";
- $end_wrap = "</p>";
- } else {
- $begin_wrap = $tmp_begin_wrap;
- $end_wrap = $tmp_end_wrap;
- }
- if ($tmp_order == "" || $tmp_order == "updated") {
- $order = "ORDER BY last_updated DESC";
- } else if ($tmp_order == "first_created") {
- $order = "ORDER BY blog_id ASC";
- } else if ($tmp_order == "last_created") {
- $order = "ORDER BY blog_id DESC";
- } else if ($tmp_order == "domain") {
- $order = "ORDER BY domain ASC";
- }
- // if vhosts retrieve all the data from global table in one query
- if($vhosts) {
- $extra = "domain, path, ";
- }
- $where = '';
- if ($filter) {
- $where = "AND UPPER(blog_name) LIKE '".strtoupper($filter)."%' ";
- }
- $blog_list = $wpdb->get_results( "SELECT " . $extra . "blog_id, last_updated FROM " . $wpdb->blogs. " WHERE public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted ='0'" . $where . $order . " " . $limit . "", ARRAY_A );
- if (count($blog_list) < 2 ){ // we don't want to display the admin blog so we return this even if there is one blog
- echo "<p>This are currently no active blogs</p>";
- } else {
- echoArrayBlogList($blog_list, $name_sort);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement