I would like to rename the “Add Media” button (just above the post editor interface) to be “Add Images”. I can’t seem to find the appropriate filter for this. There seems to be a filter that has now been deprecated but I can’t figure out what the new method is. The legacy filter was media_buttons_context
.
1 Answer
The button text being a translatable string, you can make use of the gettext filter:
function wpse95025_rename_media_button( $translation, $text ) {
if( is_admin() && 'Add Media' === $text ) {
return 'Add Images';
}
return $translation;
}
add_filter( 'gettext', wpse95025_rename_media_button, 10, 2 );
For the sake of completeness:
Of course, you can also keep the new string translatable.
function wpse95025_rename_media_button( $translation, $text ) {
if( is_admin() && 'Add Media' === $text ) {
return __( 'Add Images', 'your-text-domain' );
}
return $translation;
}
add_filter( 'gettext', wpse95025_rename_media_button, 10, 2 );