Skip to content

Commit a68b75f

Browse files
author
Bernhard Kau
committed
Add a callback for the bulk messages for post-types
1 parent ab12eda commit a68b75f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

templates/post_type_extended.mustache

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,32 @@ function {{machine_name}}_updated_messages( $messages ) {
4343
return $messages;
4444
}
4545
add_filter( 'post_updated_messages', '{{machine_name}}_updated_messages' );
46+
47+
/**
48+
* Sets the bulk post updated messages for the `{{machine_name}}` post type.
49+
*
50+
* @param array $bulk_messages Arrays of messages, each keyed by the corresponding post type. Messages are
51+
* keyed with 'updated', 'locked', 'deleted', 'trashed', and 'untrashed'.
52+
* @param int[] $bulk_counts Array of item counts for each message, used to build internationalized strings.
53+
* @return array Bulk messages for the `{{machine_name}}` post type.
54+
*/
55+
function {{machine_name}}_bulk_updated_messages( $bulk_messages, $bulk_counts ) {
56+
global $post;
57+
58+
$bulk_messages['{{slug}}'] = array(
59+
/* translators: %s: Number of {{label_plural}}. */
60+
'updated' => _n( '%s {{label}} updated.', '%s {{label_plural}} updated.', $bulk_counts['updated'], '{{textdomain}}' ),
61+
'locked' => ( 1 === $bulk_counts['locked'] ) ? __( '1 {{label}} not updated, somebody is editing it.', '{{textdomain}}' ) :
62+
/* translators: %s: Number of {{label_plural}}. */
63+
_n( '%s {{label}} not updated, somebody is editing it.', '%s {{label_plural}} not updated, somebody is editing them.', $bulk_counts['locked'], '{{textdomain}}' ),
64+
/* translators: %s: Number of {{label_plural}}. */
65+
'deleted' => _n( '%s {{label}} permanently deleted.', '%s {{label_plural}} permanently deleted.', $bulk_counts['deleted'], '{{textdomain}}' ),
66+
/* translators: %s: Number of {{label_plural}}. */
67+
'trashed' => _n( '%s {{label}} moved to the Trash.', '%s {{label_plural}} moved to the Trash.', $bulk_counts['trashed'], '{{textdomain}}' ),
68+
/* translators: %s: Number of {{label_plural}}. */
69+
'untrashed' => _n( '%s {{label}} restored from the Trash.', '%s {{label_plural}} restored from the Trash.', $bulk_counts['untrashed'], '{{textdomain}}' ),
70+
);
71+
72+
return $bulk_messages;
73+
}
74+
add_filter( 'bulk_post_updated_messages', '{{machine_name}}_bulk_updated_messages', 10, 2 );

0 commit comments

Comments
 (0)