Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site Editor: Set the <title> on the list page to be same as the CPT name #36805

Merged
merged 2 commits into from Nov 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/full-site-editing/edit-site-page.php
Expand Up @@ -263,3 +263,18 @@ function register_site_editor_homepage_settings() {
);
}
add_action( 'init', 'register_site_editor_homepage_settings', 10 );

/**
* Sets the HTML <title> in the Site Editor list page to be the title of the CPT
* being edited, e.g. 'Templates'.
*/
function gutenberg_set_site_editor_list_page_title() {
global $title;
if ( gutenberg_is_edit_site_list_page() ) {
$post_type = get_post_type_object( $_GET['postType'] );
if ( $post_type ) {
$title = $post_type->labels->name;
}
}
}
add_action( 'load-appearance_page_gutenberg-edit-site', 'gutenberg_set_site_editor_list_page_title' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not using the admin_title filter - https://developer.wordpress.org/reference/hooks/admin_title/?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to write this in a way that's pretty close to how it will look when added to Core, which is that we'll just change $title here:

https://github.com/WordPress/wordpress-develop/blob/37abb3a4707ea81696eea516b84e0cfc7c70327d/src/wp-admin/site-editor.php#L27