WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 7 months ago

#25344 closed enhancement (invalid)

Introduce *_network_meta() functions

Reported by: jeremyfelt Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Multisite Keywords:
Focuses: Cc:

Description

The get_metadata(), update_metadata(), delete_metadata(), and add_metadata() functions are abstracted well enough for posts, comments, and users that adding in wrappers for network meta is pretty straight forward.

The attached patch introduces get_network_meta(), update_network_meta(), delete_network_meta(), and add_network_meta().

A few caveats:

  • The table we're pulling from is sitemeta, which is a bummer. While the functions are named *_network_meta(), we still end up passing site as a parameter to the wrapped function. As it stands, any filters available would still need to use site rather than network. There's a chance we can work around this with some logic on the underlying functions, but I didn't go that far yet.
  • Certain network meta likely has more consequence when removed. It may be worth protecting a few of the meta keys so that they are validated properly and are not deleted. See next point.
  • This may or may not belong as part of an overall Network strategy that includes better structure around what a WP_Network object looks like and requires. That thought probably belongs somewhere else. :)

Attachments (1)

25344.diff (2.7 KB) - added by jeremyfelt 7 months ago.

Download all attachments as: .zip

Change History (3)

jeremyfelt7 months ago

comment:1 follow-up: nacin7 months ago

sitemeta isn't really a meta table for key/value pairs, but is the network equivalent to "options". Indeed, sitemeta is currently handled by get/add/update/delete_site_option(). What's the purpose of these when we already have a more options-like API?

comment:2 in reply to: ↑ 1 jeremyfelt7 months ago

  • Keywords has-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Replying to nacin:

sitemeta isn't really a meta table for key/value pairs, but is the network equivalent to "options". Indeed, sitemeta is currently handled by get/add/update/delete_site_option(). What's the purpose of these when we already have a more options-like API?

Well, when you put it that way... :) Chalk this one up to losing my mind when wrapping it around historical naming.

Note: See TracTickets for help on using tickets.