[wp-trac] [WordPress Trac] #30302: Network sites taxonomy
WordPress Trac
noreply at wordpress.org
Fri Mar 31 11:25:11 UTC 2017
#30302: Network sites taxonomy
--------------------------------+-------------------------
Reporter: aurovrata | Owner:
Type: feature request | Status: closed
Priority: normal | Milestone:
Component: Networks and Sites | Version: 4.0
Severity: normal | Resolution: maybelater
Keywords: close | Focuses: multisite
--------------------------------+-------------------------
Comment (by Biont):
Hello everyone.
I am currently developing such a plugin and I from my experience with it,
I do not think it can be done in a satisfying way without touching the
core.
The ideal solution would be create all 4 taxonomy tables into the network
scope (by using a "site_" prefix or something) and then treat Sites (and
possibly Users) as just another ''object_type''.
This '''almost''' works. However, the current state of the Taxonomy API
hampers this in several ways:
* Table names are hardcoded to use a single site context
* Caching is hardcoded to use a single site context
The only way to get it working is to wrap most calls to the Taxonomy API
with code that edits the ''"$wpdb->term_*"'' tables, and
disables/invalidates all caching that might take place.
The alternative would be to copy&paste most of the API to use different
cache keys and tables.
So neither of these options is actually feasible. I took the "smoke and
mirrors"-approach of modifying global state, because it lets me use the
existing API and is somewhat future-proof, but I am not happy at all with
it.
What I am getting at: I do not think that waiting for a feature plugin is
going to help much. It will not a good solution.
It would be rather simple to pull of if a few changes could be made:
* Make ''WP_Taxonomy'' and ''WP_Term'' network aware. So when registering
a taxonomy, you could pass a ''"network"=>true'' argument and thus
register a taxonomy in network scope.
* Make WP_Term_Query, WP_Tax_Query, etc. aware of network taxonomies and
terms. (This will probably extend to some utility functions as well, see
below) Make them use different tables and cache keys depending on the
context.
One pitfall is the ''global $wp_taxonomies'' and the issue of name
collisions. There might be a network "category" as well as a blog
"category". As soon as custom taxonomies come in, ''taxonomy_exists()'',
''get_taxonomy()'' etc. will need be distinguish between contexts and the
intention of the call will probably need to be clear as well (eg. by
passing a "network" parameter). Alternatively, we could introduce
''network_taxonomy_*()'' functions. Those would draw from a different pool
of taxonomies and would setup queries to use a different context.
I would love to hear some input on this. I'm aware that this may not be
the most-requested feature, but for large networks, this would be critical
functionality. How can we proceed?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30302#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list