Advertisement
Viruthagiri

Untitled

Feb 11th, 2012
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global $name_or_url;
  2. global $begin_wrap;
  3. global $end_wrap;
  4. // determine whether using vhosts or not for both functions to use
  5. $vhosts = (defined( "VHOST" ) && constant( "VHOST" ) == 'yes' );
  6.  
  7. function echoArrayBlogList($arrayName, $name_sort) {
  8.     global $wpdb;
  9.     global $name_or_url;
  10.     global $begin_wrap;
  11.     global $end_wrap;
  12.     global $vhosts;
  13.    
  14.     $intArrayCount = 0;
  15.     $bid = '';
  16.     // if blog name requested, then get it
  17.     if ($name_or_url == "name") {
  18.         $blogs = array();
  19.         $i = 1;
  20.         foreach ($arrayName as $blog) {
  21.             $blogname = get_blog_option( $blog['blog_id'], "blogname");
  22.             $blogs[$i] = array('key' => strtolower($blogname), // give it a key to sort by
  23.                                             'blog_name' => $blogname,
  24.                                             'blog_id' => $blog['blog_id'],
  25.                                             'domain' => $blog['domain']);
  26.             $i++;
  27.         }
  28.         // now sort if requested
  29.         if($name_sort) {
  30.             asort($blogs);
  31.         }
  32.         // replace array
  33.         $arrayName = $blogs;
  34.     }
  35.     foreach ($arrayName as $blog) {
  36.         // get blog url depending on vhost or not-vhost installtion
  37.         if( $vhosts )
  38.             $tmp_domain = $blog['domain'];
  39.         else
  40.             $tmp_domain = get_blog_option( $blog['blog_id'], "siteurl");
  41.         if ($name_or_url == "name") {
  42.             $tmp_display = $blog['blog_name'];
  43.         } else {
  44.             $tmp_display = $tmp_domain;
  45.         }
  46.         // get blog url depending on vhost or not-vhost installtion
  47.         if( $vhosts )
  48.             echo $begin_wrap . "<a href='http://" . $tmp_domain . $blog['path'] . "'>" . $tmp_display . "</a>" . $end_wrap;
  49.         else
  50.             echo $begin_wrap . "<a href='" . $tmp_domain . "'>" . $tmp_display . "</a>" . $end_wrap;
  51.     }
  52. }
  53.  
  54. function list_all_wpmu_blogs($tmp_limit, $tmp_name_or_url, $tmp_begin_wrap, $tmp_end_wrap, $tmp_order,$filter = 'a') {
  55.     global $wpdb;
  56.     global $name_or_url;
  57.     global $begin_wrap;
  58.     global $end_wrap;
  59.     global $vhosts;
  60.    
  61.  
  62.     if ($tmp_limit != "") {
  63.         $limit = "LIMIT " . $tmp_limit;
  64.     }
  65.     if ($tmp_name_or_url == "" || $tmp_name_or_url == "name") {
  66.         $name_or_url = "name";
  67.             // did user request sort by blog_name
  68.         $name_sort = ($tmp_order == "blog_name");
  69.     } else {
  70.         $name_or_url = "url";
  71.         $name_sort = false;
  72.     }
  73.     if (tmp_begin_wrap == "" || tmp_end_wrap == "" ) {
  74.         $begin_wrap = "<p>";
  75.         $end_wrap = "</p>";
  76.     } else {
  77.         $begin_wrap = $tmp_begin_wrap;
  78.         $end_wrap = $tmp_end_wrap;
  79.     }
  80.     if ($tmp_order == "" || $tmp_order == "updated") {
  81.         $order = "ORDER BY  last_updated DESC";
  82.     } else if ($tmp_order == "first_created") {
  83.         $order = "ORDER BY  blog_id ASC";
  84.     } else if ($tmp_order == "last_created") {
  85.         $order = "ORDER BY  blog_id DESC";
  86.     } else if ($tmp_order == "domain") {
  87.         $order = "ORDER BY  domain ASC";
  88.     }
  89.     // if vhosts retrieve all the data from global table in one query
  90.     if($vhosts) {
  91.         $extra = "domain, path, ";
  92.     }
  93.     $where = '';
  94.     if ($filter) {
  95.                 $where = "AND UPPER(blog_name) LIKE '".strtoupper($filter)."%' ";
  96.     }
  97.     $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 );
  98.     if (count($blog_list) < 2 ){ // we don't want to display the admin blog so we return this even if there is one blog
  99.         echo "<p>This are currently no active blogs</p>";
  100.     } else {
  101.         echoArrayBlogList($blog_list, $name_sort);
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement