-
-
Notifications
You must be signed in to change notification settings - Fork 512
Open
Labels
Description
Is your feature request related to a problem? Please describe.
There is a merge option available in Post::terms() that lets the caller specify whether they'd like all terms in one flat array, or broken out by taxonomy:
// merge = true (default): one flat array
// these are equivalent:
$post->terms();
$post->terms( [], ['merge' => true] );
// -> [ (category 123), (category 456), ... , (tag 789), ... ]
// merge = false: sub-arrays by taxonomy
$post->terms( [], ['merge' => false] );
// -> [
// 'category' => [ (category 123), (category 456), ... ],
// 'post_tag' => [ (tag 789), ... ],
// ]This is nice but there's no reason it needs to exist solely in Post. We can push it down into Timber::get_terms() without breaking API changes.
Describe the solution you’d like
Same as above, but at a higher level of abstraction in Timber::get_terms():
// merge = true (default): one flat array
Timber::get_terms( [], ['merge' => true] );
// -> [ (category 123), (category 456), ... , (tag 789), ... ]
// merge = false: sub-arrays by taxonomy
Timber::get_terms( [], ['merge' => false] );
// -> [
// 'category' => [ (category 123), (category 456), ... ],
// 'post_tag' => [ (tag 789), ... ],
// ]Post::terms() would simply forward the merge option; calling code would not change.
Describe alternatives you’ve considered
...Not doing this?
Additional context
Reactions are currently unavailable