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

WordPress Trac noreply at wordpress.org
Sat Aug 12 15:19:07 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                               |
-------------------------------------------------+-------------------------

Comment (by flixos90):

 [attachment:40180.2.diff] makes a few improvements:

 * It adds support for getting a site by only its path, if the current
 setup is a subdirectory install. Example: `get_site_by( 'path', '/foo/' )`
 * It introduces a new idea of simply passing a URL (domain-path
 combination), which is a lot quicker than passing an array of domain and
 path. Example: `get_site_by( 'url', 'mysite.com/foo/' )`
 * An additional tweak in the beginning of the functions ensures that
 `get_site()` is called as an easy shortcut when only an ID is passed.
 * Further unit tests have been added/adjusted.

 I'm starting to like the `url` argument. Actually, that argument would
 allow us to completely get rid of the requirement of supporting an array,
 which would make the function much simpler. The only thing that people
 might wanna pass in addition is the network ID, but since that only
 applies to multi-network installs, it could as well be an extra third
 parameter, as it is in several other core functions. I will create another
 patch with that proposal.

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


More information about the wp-trac mailing list