Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions src/wp-admin/edit-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,14 @@
<div class="form-wrap edit-term-notes">
<p>
<?php
$default_category_id = get_option( 'default_category' );
printf(
/* translators: %s: Default category. */
__( 'Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the default category %s. The default category cannot be deleted.' ),
/* translators: 1: Default category name, 2: URL to edit the default category, 3: URL to Writing Settings. */
__( 'Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the default category %1$s. The default category cannot be deleted, but it can be <a href="%2$s">renamed</a> or you can choose a <a href="%3$s">different default category</a>.' ),
/** This filter is documented in wp-includes/category-template.php */
'<strong>' . apply_filters( 'the_category', get_cat_name( get_option( 'default_category' ) ), '', '' ) . '</strong>'
'<strong>' . apply_filters( 'the_category', get_cat_name( $default_category_id ), '', '' ) . '</strong>',
esc_url( get_edit_term_link( $default_category_id, 'category' ) ),
esc_url( admin_url( 'options-writing.php#default_category' ) )
Copy link
Member

Choose a reason for hiding this comment

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

Ah, if the user cannot manage_options then this URL won't be accessible. So maybe the but it can be <a href="%2$s">renamed</a> or you can choose a <a href="%3$s">different default category</a> should be conditionally printed after the previous string only if the user can do so. This also goes for whether get_edit_term_link( $default_category_id, 'category' ) returns null, indicating that the user doesn't have the ability to modify a the term. I can imagine this being a common scenario actually, where a site may want to allow Editor role users to create and modify categories, except for the default category, leaving that only for the admin to manage.

Copy link
Author

Choose a reason for hiding this comment

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

I assume for translations, I should either break it into two sentences or have two complete sentences as the options. I don't know but I figure a language might not like assuming a dependent clause being forced to follow the primary clause (not to mention punctuation).

On mobile but I'll update that.

I appreciate your diligence in these reviews! This is a very old issue and was a very old patch that we're pulling out of the time capsule!

This comment was marked as duplicate.

Copy link
Member

Choose a reason for hiding this comment

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

That's right. Having a dependent clause as a separate translation string wouldn't work. So this would be one string:

Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the default category Uncategorized. The default category cannot be deleted.

And then, if the user can manage_options and can edit the term, add another sentence:

It can be renamed or you can choose a different default category.

Or if they just have term editing capability:

It can be renamed.

And then if they just have manage_options (which would surely include the previous capability, but there's no guarantees in WordPress!):

You can choose a different default category.

Might be something to get advice from Polyglots on.

);
?>
</p>
Expand Down
19 changes: 17 additions & 2 deletions src/wp-admin/includes/class-wp-terms-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ public function column_cb( $item ) {
public function column_name( $tag ) {
$taxonomy = $this->screen->taxonomy;

$default_term = get_option( 'default_' . $taxonomy );
$default_term_label = '';
if ( $tag->term_id === (int) $default_term ) {
$default_term_label = ' &mdash; <span class="taxonomy-default-label">' . __( 'Default' ) . '</span>';
}

$pad = str_repeat( '&#8212; ', max( 0, $this->level ) );

/**
Expand Down Expand Up @@ -422,8 +428,9 @@ public function column_name( $tag ) {
}

$output = sprintf(
'<strong>%s</strong><br />',
$name
'<strong>%s%s</strong><br />',
$name,
$default_term_label
);

/** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */
Expand Down Expand Up @@ -532,6 +539,14 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
);
}

if ( 'category' === $taxonomy && (int) get_option( 'default_category' ) === $tag->term_id ) {
Copy link
Member

@westonruter westonruter Feb 4, 2026

Choose a reason for hiding this comment

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

Suggested change
if ( 'category' === $taxonomy && (int) get_option( 'default_category' ) === $tag->term_id ) {
if ( 'category' === $taxonomy && (int) get_option( 'default_category' ) === $tag->term_id && current_user_can( 'manage_options' ) ) {

$actions['change-default'] = sprintf(
'<a href="%s">%s</a>',
admin_url( 'options-writing.php#default_category' ),
__( 'Change Default' )
);
}

/**
* Filters the action links displayed for each term in the Tags list table.
*
Expand Down
Loading