[wp-trac] [WordPress Trac] #40511: get_blogs_of_user should return an array of WP_Site objects

WordPress Trac noreply at wordpress.org
Sat Apr 22 11:15:45 UTC 2017


#40511: get_blogs_of_user should return an array of WP_Site objects
--------------------------------+------------------------------
 Reporter:  spacedmonkey        |       Owner:
     Type:  enhancement         |      Status:  new
 Priority:  normal              |   Milestone:  Awaiting Review
Component:  Networks and Sites  |     Version:
 Severity:  normal              |  Resolution:
 Keywords:                      |     Focuses:  multisite
--------------------------------+------------------------------

Comment (by flixos90):

 This was previously considered in #37061 (particularly
 https://core.trac.wordpress.org/ticket/37061#comment:8). While I certainly
 like the idea, I think we should hold off on this change. Adding
 `userblog_id` as a magic property makes sense and addresses most backward-
 compatibility concerns, however two issues remain:

 * `WP_Site` is not available outside of multisite, and I don't like the
 idea of the function having different return types depending on whether
 it's in multisite or not.
 * Something like `$blogs = get_blogs_of_user( $user_id ); $site_data =
 get_object_vars( $blogs[0] ); echo $site_data['userblog_id'];` on a
 returned object works currently, but wouldn't work with a `WP_Site`
 object. It's really annoying that that weird `userblog_id` property exists
 in the first place, but now it's there. I admit this is really nitpicking
 / edge-case, and maybe we can ignore it, but it is something to consider.

 Especially the first point makes me wary of this change. In my opinion
 it's worth revisiting once we possibly decide to make some site
 functionality available on non-multisite (see #37948 for previous thoughts
 on this).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40511#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list