Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
_get_custom_object_labels() WordPress Function
The get_custom_object_labels() function allows you to change the labels for custom post types and custom taxonomies. This is useful if you want to change the way your custom content is displayed on your site. For example, you could change the label for a custom post type from "Posts" to "Articles" or change the label for a custom taxonomy from "Categories" to "Topics".
_get_custom_object_labels( object $object, array $nohier_vs_hier_defaults ) #
Build an object with custom-something object (post type, taxonomy) labels out of a custom-something object
Parameters
- $object
(object)(Required)A custom-something object.
- $nohier_vs_hier_defaults
(array)(Required)Hierarchical vs non-hierarchical default labels.
Return
(object) Object containing labels for the given custom-something object.
Source
File: wp-includes/post.php
function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) { $object->labels = (array) $object->labels; if ( isset( $object->label ) && empty( $object->labels['name'] ) ) { $object->labels['name'] = $object->label; } if ( ! isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) { $object->labels['singular_name'] = $object->labels['name']; } if ( ! isset( $object->labels['name_admin_bar'] ) ) { $object->labels['name_admin_bar'] = isset( $object->labels['singular_name'] ) ? $object->labels['singular_name'] : $object->name; } if ( ! isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) ) { $object->labels['menu_name'] = $object->labels['name']; } if ( ! isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) ) { $object->labels['all_items'] = $object->labels['menu_name']; } if ( ! isset( $object->labels['archives'] ) && isset( $object->labels['all_items'] ) ) { $object->labels['archives'] = $object->labels['all_items']; } $defaults = array(); foreach ( $nohier_vs_hier_defaults as $key => $value ) { $defaults[ $key ] = $object->hierarchical ? $value[1] : $value[0]; } $labels = array_merge( $defaults, $object->labels ); $object->labels = (object) $object->labels; return (object) $labels; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |