Skip to content

Instantly share code, notes, and snippets.

@ivo-ivanov
Last active April 29, 2020 12:53
Show Gist options
  • Save ivo-ivanov/3fb707c07816d9f8873474b98da978aa to your computer and use it in GitHub Desktop.
Save ivo-ivanov/3fb707c07816d9f8873474b98da978aa to your computer and use it in GitHub Desktop.
Rename post formats #wordpress
// Rename default post formats
add_filter(
'load_script_translations',
function( $translations, $file, $handle, $domain ) {
/**
* The post format labels used for the dropdown are defined in the
* "wp-editor" script.
*/
if ( 'wp-editor' === $handle ) {
/**
* The translations are formatted as JSON. Decode the JSON to modify
* them.
*/
$translations = json_decode( $translations, true );
/**
* The strings are inside locale_data > messages, where the original
* string is the key. The value is an array of translations.
*
* Singular strings only have one value in the array, while strings
* with singular and plural forms have a string for each in the array.
*/
$translations['locale_data']['messages']['Standard'] = [ 'Bild Oben' ];
$translations['locale_data']['messages']['Status'] = [ 'Nur Text' ];
$translations['locale_data']['messages']['Image'] = [ 'Bild Unten' ];
/**
* Re-encode the modified translations as JSON.
*/
$translations = wp_json_encode( $translations );
}
return $translations;
},
10,
4
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment