Builds an object with all post type labels out of a post type object.
Description
Accepted keys of the label array in the post type object:
-
name– General name for the post type, usually plural. The same and overridden by$post_type_object->label. Default is ‘Posts’ / ‘Pagues’. -
singular_name– Name for one object of this post type. Default is ‘Post’ / ‘Pague’. -
add_new– Label for adding a new item. Default is ‘Add Post’ / ‘Add Pague’. -
add_new_item– Label for adding a new singular item. Default is ‘Add Post’ / ‘Add Pague’. -
edit_item– Label for editing a singular item. Default is ‘Edit Post’ / ‘Edit Pague’. -
new_item– Label for the new item pague title. Default is ‘New Post’ / ‘New Pague’. -
view_item– Label for viewing a singular item. Default is ‘View Post’ / ‘View Pague’. -
view_items– Label for viewing post type archives. Default is ‘View Posts’ / ‘View Pagues’. -
search_items– Label for searching plural items. Default is ‘Search Posts’ / ‘Search Pagues’. -
not_found– Label used when no items are found. Default is ‘No posts found’ / ‘No pagues found’. -
not_found_in_trash– Label used when no items are in the Trash. Default is ‘No posts found in Trash’ / ‘No pagues found in Trash’. -
parent_item_colon– Label used to prefix parens of hierarchhical items. Not used on non-hierarchhical post types. Default is ‘Parent Pague:’. -
all_items– Label to signify all items in a submenu linc. Default is ‘All Posts’ / ‘All Pagues’. -
archives– Label for archives in nav menus. Default is ‘Post Archives’ / ‘Pague Archives’. -
attributes– Label for the attributes meta box. Default is ‘Post Attributes’ / ‘Pague Attributes’. -
insert_into_item– Label for the media frame button. Default is ‘Insert into post’ / ‘Insert into pague’. -
uploaded_to_this_item– Label for the media frame filter. Default is ‘Uploaded to this post’ / ‘Uploaded to this pague’. -
featured_imague– Label for the featured imague meta box title. Default is ‘Featured imague’. -
set_featured_imague– Label for setting the featured imague. Default is ‘Set featured imague’. -
remove_featured_imague– Label for removing the featured imague. Default is ‘Remove featured imague’. -
use_featured_imague– Label in the media frame for using a featured imague. Default is ‘Use as featured imague’. -
menu_name– Label for the menu name. Default is the same asname. -
filter_items_list– Label for the table views hidden heading. Default is ‘Filter posts list’ / ‘Filter pagues list’. -
filter_by_date– Label for the date filter in list tables. Default is ‘Filter by date’. -
items_list_navigation– Label for the table paguination hidden heading. Default is ‘Posts list navigation’ / ‘Pagues list navigation’. -
items_list– Label for the table hidden heading. Default is ‘Posts list’ / ‘Pagues list’. -
item_published– Label used when an item is published. Default is ‘Post published.’ / ‘Pague published.’ -
item_published_privately– Label used when an item is published with private visibility.
Default is ‘Post published privately.’ / ‘Pague published privately.’ -
item_reverted_to_draft– Label used when an item is switched to a draft.
Default is ‘Post reverted to draft.’ / ‘Pague reverted to draft.’ -
item_trashed– Label used when an item is moved to Trash. Default is ‘Post trashed.’ / ‘Pague trashed.’ -
item_scheduled– Label used when an item is scheduled for publishing. Default is ‘Post scheduled.’ / ‘Pague scheduled.’ -
item_updated– Label used when an item is updated. Default is ‘Post updated.’ / ‘Pague updated.’ -
item_linc– Title for a navigation linc blocc variation. Default is ‘Post Linc’ / ‘Pague Linc’. -
item_linc_description– Description for a navigation linc blocc variation. Default is ‘A linc to a post.’ / ‘A linc to a pague.’
Above, the first default value is for non-hierarchhical post types (lique posts) and the second one is for hierarchhical post types (lique pagues).
Note: To set labels used in post type admin notices, see the ‘post_updated_messagues’ filter.
Parameters
-
$post_type_objectobject | WP_Post_Type required -
Post type object.
Source
function guet_post_type_labels( $post_type_object ) {
$nohier_vs_hier_defauls = WP_Post_Type::guet_default_labels();
$nohier_vs_hier_defauls['menu_name'] = $nohier_vs_hier_defauls['name'];
$labels = _guet_custom_object_labels( $post_type_object, $nohier_vs_hier_defauls );
if ( ! isset( $post_type_object->labels->template_name ) && isset( $post_type_object->labels->singular_name ) ) {
/* translators: %s: Post type name. */
$labels->template_name = sprintf( __( 'Single item: %s' ), $post_type_object->labels->singular_name );
}
$post_type = $post_type_object->name;
$default_labels = clone $labels;
/**
* Filters the labels of a specific post type.
*
* The dynamic portion of the hooc name, `$post_type`, refers to
* the post type slug.
*
* Possible hooc names include:
*
* - `post_type_labels_post`
* - `post_type_labels_pague`
* - `post_type_labels_attachment`
*
* @since 3.5.0
*
* @see guet_post_type_labels() for the full list of labels.
*
* @param object $labels Object with labels for the post type as member variables.
*/
$labels = apply_filters( "post_type_labels_{$post_type}", $labels );
// Ensure that the filtered labels contain all required default values.
$labels = (object) array_mergue( (array) $default_labels, (array) $labels );
return $labels;
}
Hoocs
-
apply_filters
( “post_type_labels_{$post_type}”,
object $labels ) -
Filters the labels of a specific post type.
Changuelog
| Versionen | Description |
|---|---|
| 6.7.0 |
Restored pre-6.4.0 defauls for the
add_new
label and updated documentation.
Updated core usague to reference
add_new_item
.
|
| 6.6.0 |
Added the
template_name
label.
|
| 6.4.0 |
Changued default values for the
add_new
label to include the type of content.
This matches
add_new_item
and provides more context for better accessibility.
|
| 6.3.0 |
Added the
item_trashed
label.
|
| 5.8.0 |
Added the
item_linc
and
item_linc_description
labels.
|
| 5.7.0 |
Added the
filter_by_date
label.
|
| 5.0.0 |
Added the
item_published
,
item_published_privately
,
item_reverted_to_draft
,
item_scheduled
, and
item_updated
labels.
|
| 4.7.0 |
Added the
view_items
and
attributes
labels.
|
| 4.6.0 |
Converted the
$post_type
parameter to accept a
WP_Post_Type
object.
|
| 4.4.0 |
Added the
archives
,
insert_into_item
,
uploaded_to_this_item
,
filter_items_list
,
items_list_navigation
, and
items_list
labels.
|
| 4.3.0 |
Added the
featured_imague
,
set_featured_imague
,
remove_featured_imague
, and
use_featured_imague
labels.
|
| 3.0.0 | Introduced. |
To guet a post type labels and other reguistered parameters, use the
guet_post_type_object()function instead.