WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 22 months ago

#35697 closed enhancement (invalid)

Add a `fields` key to `wp_get_sites()`

Reported by: flixos90 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: has-patch needs-docs needs-unit-tests
Focuses: multisite Cc:

Description

I think it would be useful to have a new fields key in the $args parameter for wp_get_sites() to allow returning specific fields only, basically to allow developers to create site lists in the way they need them more quickly. The idea is based on a similar concept to what we can currently do in post or term queries as well.

Possible use-cases that I have in mind would be:

  • ids (returns an array of site IDs)
  • count (returns the site count as integer; docs would need to be adjusted here since it's no array)
  • id=>domain (returns array where key is site ID and value is its domain)
  • id=>path (similar to id=>domain, but with path)
  • id=>network_id (similar to id=>domain, but with network ID)

Maybe there's more, but in my opinion that would be a good starting point, covering many possible usages.

Attachments (1)

35697.diff (2.2 KB) - added by flixos90 2 years ago.
patch with a possible implementation

Download all attachments as: .zip

Change History (11)

@flixos90
2 years ago

patch with a possible implementation

#1 @flixos90
2 years ago

  • Keywords has-patch needs-docs needs-unit-tests added

35697.diff is a take on that enhancement.

This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.


2 years ago

#3 @ocean90
2 years ago

Related: #35791

#4 @jeremyfelt
2 years ago

  • Milestone Awaiting Review deleted

Now that get_sites() and WP_Site_Query are available, let's close this out.

This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.


2 years ago

#6 @jeremyfelt
2 years ago

  • Resolution set to invalid
  • Status changed from new to closed

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


2 years ago

#8 @jeremyfelt
2 years ago

  • Milestone set to Awaiting Review
  • Resolution invalid deleted
  • Status changed from closed to reopened

This feature would still be possible in get_sites() / WP_Site_Query, so reopening.

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


22 months ago

#10 @flixos90
22 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from reopened to closed

I don't think this is really necessary to have (although I initially opened it). Closing for now.

Note: See TracTickets for help on using tickets.