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

Remove slug and status columns from templates list in Appearance > Templates #35996

Merged
merged 1 commit into from
Nov 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions lib/full-site-editing/templates-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
* @return array Filtered $columns.
*/
function gutenberg_templates_lists_custom_columns( array $columns ) {
$columns['slug'] = __( 'Slug', 'gutenberg' );
$columns['description'] = __( 'Description', 'gutenberg' );
$columns['status'] = __( 'Status', 'gutenberg' );
$columns['theme'] = __( 'Theme', 'gutenberg' );
if ( isset( $columns['date'] ) ) {
unset( $columns['date'] );
Expand All @@ -29,29 +27,11 @@ function gutenberg_templates_lists_custom_columns( array $columns ) {
* @param int $post_id Post ID.
*/
function gutenberg_render_templates_lists_custom_column( $column_name, $post_id ) {
if ( 'slug' === $column_name ) {
$post = get_post( $post_id );
echo esc_html( $post->post_name );
return;
}

if ( 'description' === $column_name && has_excerpt( $post_id ) ) {
the_excerpt( $post_id );
return;
}

if ( 'status' === $column_name ) {
$post_status = get_post_status( $post_id );
// The auto-draft status doesn't have localized labels.
if ( 'auto-draft' === $post_status ) {
echo esc_html_x( 'Auto-Draft', 'Post status', 'gutenberg' );
return;
}
$post_status_object = get_post_status_object( $post_status );
echo esc_html( $post_status_object->label );
return;
}

if ( 'theme' === $column_name ) {
$terms = get_the_terms( $post_id, 'wp_theme' );
if ( empty( $terms ) || is_wp_error( $terms ) ) {
Expand Down