Currently I'm trying to get the post type labels plural. In detail:
$GLOBALS['wp_post_types'][ get_current_screen()->post_type ]->labels->name
This is how I'm trying to retrieve it - in the admin UI - using the public wp API functions:
$post_type_name = get_current_screen()->post_type;
$post_type_obj = get_post_type_object( $post_type_name );
get_post_type_labels( $post_type_obj );
The result is the following Error:
Fatal error: Cannot use object of type stdClass as array in D:\development\xampp\htdocs\wp_inst\wp-includes\post.php on line 1209
The problem is that the post type objects labels is also an object, while get_post_type_labels() calls _get_custom_object_labels() internally and seems to expect an array.
Fun are the last two lines of the _get_custom_object_labels() function:
$labels = array_merge( $defaults, $object->labels );
return (object)$labels;
So, am I using the wrong functions? Is the core function wrong? Is this core function only meant to be used during custom post type registration?
Note: Currently on WP version 3.3.2.