[wp-trac] [WordPress Trac] #40180: Introduce `get_site_by()` function for multisite

WordPress Trac noreply at wordpress.org
Sun Oct 1 21:49:45 UTC 2017


#40180: Introduce `get_site_by()` function for multisite
-------------------------------------------------+-------------------------
 Reporter:  flixos90                             |       Owner:  flixos90
     Type:  enhancement                          |      Status:  assigned
 Priority:  normal                               |   Milestone:  4.9
Component:  Networks and Sites                   |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch dev-feedback has-unit-     |     Focuses:  multisite
  tests ms-roadmap needs-dev-note                |
-------------------------------------------------+-------------------------

Comment (by jeremyfelt):

 Replying to [comment:28 flixos90]:
 > As far as putting `null` goes, I agree that this test can be removed.
 While it would still work because it just calls `get_site()`, trying to
 get a site by a specific ID, which the function name implies, and then
 passing `null` doesn't make sense. Should we actually catch that behavior
 and return `null` in such a case?

 That's tough. We probably aren't consistent in core with how much
 protection we offer. The function signature implies through documentation
 that `string|int` is expected, which I'd expect to be enough. We could do
 something similar to `get_term_by()` and check for a string length greater
 than 0 if `slug`, `domain`, `path`, or `url` and for a positive `int` if
 `id`.

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


More information about the wp-trac mailing list