Skip to content

Commit

Permalink
Override WP labels for post and page types
Browse files Browse the repository at this point in the history
… to conform to sentence-style capitalisation across the editor UI.

(This is a quick commit to show the idea. Do expand on it and polish.)

From Slack: "If we used this it would have to be properly marked [e.g.
@todo] and commented so that before the next core release we could
revisit these labels as a whole."
  • Loading branch information
mcsf committed Dec 11, 2019
1 parent 4a223d1 commit c7f1e89
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@ function gutenberg_override_translation_file( $file, $handle ) {
}
add_filter( 'load_script_translation_file', 'gutenberg_override_translation_file', 10, 2 );

/**
* Filters the default labels for common post types to change the case style
* from capitalized (e.g. "Featured Image") to sentence-style (e.g. "Featured
* image").
*
* See: https://github.com/WordPress/gutenberg/pull/18758
*
* @param object Object with all the labels as member variables.
*
* @return object Object with all the labels, including overridden ones.
*/
function gutenberg_override_posttype_labels( $labels ) {
$labels->featured_image = 'Featured image';
return $labels;
}
foreach ( array( 'post', 'page' ) as $post_type ) {
add_filter( "post_type_labels_{$post_type}", 'gutenberg_override_posttype_labels' );
}

/**
* Registers a style according to `wp_register_style`. Honors this request by
* deregistering any style by the same handler before registration.
Expand Down

0 comments on commit c7f1e89

Please sign in to comment.