[wp-trac] [WordPress Trac] #24457: add_filter('gettext' ignores get_post_type after deleting a featured image
WordPress Trac
noreply at wordpress.org
Fri May 31 14:38:35 UTC 2013
#24457: add_filter('gettext' ignores get_post_type after deleting a featured image
--------------------------+------------------------------
Reporter: vmodha | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: |
--------------------------+------------------------------
Comment (by helen):
In this instance, it would be better and more appropriate to use the
`admin_post_thumbnail_html` filter, which receives the `$post_id` for
context, and to remove the metabox and re-add it with the title you want.
Translation filters are a little bit hacky for this purpose.
{{{
function myprefix_add_meta_boxes() {
// Relabel featured image meta box
remove_meta_box( 'postimagediv', 'gorilla_residents', 'side' );
add_meta_box( 'postimagediv', 'Gorilla Avatar',
'post_thumbnail_meta_box', 'gorilla_residents', 'side', 'default' );
}
add_action( 'add_meta_boxes', 'myprefix_add_meta_boxes' );
function myprefix_admin_post_thumbnail_html( $output, $post_id ) {
if ( 'gorilla_residents' === get_post_type( $post_id ) ) {
$output = str_replace( 'Set featured image', 'Set Gorilla
Avatar', $output );
$output = str_replace( 'Remove featured image', 'Remove
Gorilla Avatar', $output );
}
return $output;
}
add_filter( 'admin_post_thumbnail_html',
'myprefix_admin_post_thumbnail_html', 10, 2 );
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24457#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list