From 96616877ac3792030f2dced3d33726addceb9bdc Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 4 Nov 2015 16:03:25 +0000 Subject: [PATCH] Taxonomy: Introduce the dynamic `taxonomy_labels_{$taxonomy}` filter, which can be used to manipulate the labels for a given taxonomy. The addition of this hook brings parity with the earlier-introduced `post_type_labels_{$post_type}` filter, which allows for similarly manipulating labels for a given post type. Note: It isn't possible to unset or remove default labels via either of these hooks, only to overwrite. This is because WordPress relies on defaults being set for use in various UIs and admin experiences. Props flixos90. Fixes #34554. Built from https://develop.svn.wordpress.org/trunk@35504 git-svn-id: http://core.svn.wordpress.org/trunk@35468 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy-functions.php | 24 +++++++++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/wp-includes/taxonomy-functions.php b/wp-includes/taxonomy-functions.php index 706caf1bf6..592966b681 100644 --- a/wp-includes/taxonomy-functions.php +++ b/wp-includes/taxonomy-functions.php @@ -540,7 +540,29 @@ function get_taxonomy_labels( $tax ) { ); $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; - return _get_custom_object_labels( $tax, $nohier_vs_hier_defaults ); + $labels = _get_custom_object_labels( $tax, $nohier_vs_hier_defaults ); + + $taxonomy = $tax->name; + + $default_labels = clone $labels; + + /** + * Filter the labels of a specific taxonomy. + * + * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. + * + * @since 4.4.0 + * + * @see get_taxonomy_labels() for the full list of taxonomy labels. + * + * @param object $labels Object with labels for the taxonomy as member variables. + */ + $labels = apply_filters( "taxonomy_labels_{$taxonomy}", $labels ); + + // Ensure that the filtered labels contain all required default values. + $labels = (object) array_merge( (array) $default_labels, (array) $labels ); + + return $labels; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 71562c971c..4d49c5f662 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-beta2-35503'; +$wp_version = '4.4-beta2-35504'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.