[wp-trac] [WordPress Trac] #14511: new function - wp_get_sites($args)

WordPress Trac wp-trac at lists.automattic.com
Sat Sep 25 16:26:16 UTC 2010


#14511: new function - wp_get_sites($args)
-------------------------+--------------------------------------------------
 Reporter:  transom      |       Owner:                 
     Type:  enhancement  |      Status:  new            
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Multisite    |     Version:                 
 Severity:  normal       |    Keywords:  has-patch      
-------------------------+--------------------------------------------------
Description changed by nacin:

Old description:

> With the deprication of get_blog_list (and the dire warnings), we had a
> need for a function to retrieve a list of blogs. At first blush, it
> appears that one could use get_blogs_of_user. It seems to assume that the
> same admin (userid 1) is going to create all sites. If you have multiple
> network_admins, then a search for a single user's sites won't return a
> full list.
>
> So I have adapted the code from wp-admin/ms-sites.php and with a nod to
> wp_list_pages - am submitting wp_get_sites for a future release.
>
> This function accepts an argument list to filter the results, modify the
> order, and limit the range of results. I wrote it with an eye to provide
> an interface consistent with other wp functions, as well as potentially
> replacing the sql query in wp-admin/ms-sites.php.
>
> The initial set of arguments include:
>
>                         'include_id'            ,
> // includes only these sites in the results, comma-delimited
>                         'exclude_id'            ,
> // excludes these sites from the results, comma-delimted
>                         'blogname_like'         ,
> // domain or path is like this value
>                         'ip_like'                       ,
> // Match IP address
>                         'reg_date_since'        ,
> // sites registered since (accepts pretty much any valid date like
> tomorrow, today, 5/12/2009, etc.)
>                         'reg_date_before'       ,
> // sites registered before
>                         'include_user_id'       ,
> // only sites owned by these users, comma-delimited
>                         'exclude_user_id'       ,
> // don't include sites owned by these users, comma-delimited
>                         'include_spam'          => false,
> // Include sites marked as "spam"
>                         'include_deleted'       => false,
> // Include deleted sites
>                         'include_archived'      => false,
> // Include archived sites
>                         'include_mature'        => false,
> // Included blogs marked as mature
>                         'public_only'           => true,
> // Include only blogs marked as public
>                         'sort_column'           => 'registered',// or
> registered, last_updated, blogname, site_id
>                         'order'                         => 'asc',
> // or desc
>                         'limit_results'         ,
> // return this many results
>                         'start'                         ,
> // return results starting with this item
>
> The usual warning are provided. It works for me but I haven't tested it
> completely yet. But I am assuming this could be helpful to others and I
> have no doubt about getting comments back <grin>

New description:

 With the deprication of get_blog_list (and the dire warnings), we had a
 need for a function to retrieve a list of blogs. At first blush, it
 appears that one could use get_blogs_of_user. It seems to assume that the
 same admin (userid 1) is going to create all sites. If you have multiple
 network_admins, then a search for a single user's sites won't return a
 full list.

 So I have adapted the code from wp-admin/ms-sites.php and with a nod to
 wp_list_pages - am submitting wp_get_sites for a future release.

 This function accepts an argument list to filter the results, modify the
 order, and limit the range of results. I wrote it with an eye to provide
 an interface consistent with other wp functions, as well as potentially
 replacing the sql query in wp-admin/ms-sites.php.

 The initial set of arguments include:
 {{{
                         'include_id'            ,
 // includes only these sites in the results, comma-delimited
                         'exclude_id'            ,
 // excludes these sites from the results, comma-delimted
                         'blogname_like'         ,
 // domain or path is like this value
                         'ip_like'                       ,
 // Match IP address
                         'reg_date_since'        ,
 // sites registered since (accepts pretty much any valid date like
 tomorrow, today, 5/12/2009, etc.)
                         'reg_date_before'       ,
 // sites registered before
                         'include_user_id'       ,
 // only sites owned by these users, comma-delimited
                         'exclude_user_id'       ,
 // don't include sites owned by these users, comma-delimited
                         'include_spam'          => false,               //
 Include sites marked as "spam"
                         'include_deleted'       => false,               //
 Include deleted sites
                         'include_archived'      => false,               //
 Include archived sites
                         'include_mature'        => false,               //
 Included blogs marked as mature
                         'public_only'           => true,                //
 Include only blogs marked as public
                         'sort_column'           => 'registered',// or
 registered, last_updated, blogname, site_id
                         'order'                         => 'asc',
 // or desc
                         'limit_results'         ,
 // return this many results
                         'start'                         ,
 // return results starting with this item
 }}}
 The usual warning are provided. It works for me but I haven't tested it
 completely yet. But I am assuming this could be helpful to others and I
 have no doubt about getting comments back <grin>

--

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14511#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list