Skip to content

Commit 52e5831

Browse files
kraftbjwestonruter
andauthored
Apply suggestions from code review
Co-authored-by: Weston Ruter <[email protected]>
1 parent c985c34 commit 52e5831

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

src/wp-admin/edit-tags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@
634634
/** This filter is documented in wp-includes/category-template.php */
635635
'<strong>' . apply_filters( 'the_category', get_cat_name( $default_category_id ), '', '' ) . '</strong>',
636636
esc_url( get_edit_term_link( $default_category_id, 'category' ) ),
637-
esc_url( admin_url( 'options-writing.php#default-category-row' ) )
637+
esc_url( admin_url( 'options-writing.php#default_category' ) )
638638
);
639639
?>
640640
</p>

src/wp-admin/includes/class-wp-terms-list-table.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,11 @@ public function display_rows_or_placeholder() {
243243
}
244244

245245
// Handle custom display of default category by showing it first in the list.
246-
$default_category = false;
247-
$default_category_id = 0;
246+
$default_category = null;
248247
if ( 'category' === $taxonomy ) {
249-
$default_category_id = (int) get_option( 'default_category' );
250-
$default_category = get_term( $default_category_id, 'category' );
251-
if ( ! $default_category || is_wp_error( $default_category ) ) {
252-
$default_category = false;
253-
$default_category_id = 0;
248+
$default_category = get_term( (int) get_option( 'default_category' ), 'category' );
249+
if ( ! ( $default_category instanceof WP_Term ) ) {
250+
$default_category = null;
254251
}
255252
}
256253

@@ -270,15 +267,15 @@ public function display_rows_or_placeholder() {
270267
* Some funky recursion to get the job done (paging & parents mainly) is contained within.
271268
* Skip it for non-hierarchical taxonomies for performance sake.
272269
*/
273-
$this->_rows( $taxonomy, $this->items, $children, $offset, $number, $count, 0, 0, $default_category_id );
270+
$this->_rows( $taxonomy, $this->items, $children, $offset, $number, $count, 0, 0, $default_category->term_id );
274271
} else {
275272
// Only show pinned default category on the first page.
276273
if ( $default_category && 0 === $offset ) {
277274
$this->single_row( $default_category );
278275
}
279276

280277
foreach ( $this->items as $term ) {
281-
if ( $default_category_id && $default_category_id === $term->term_id ) {
278+
if ( $default_category && $default_category->term_id === $term->term_id ) {
282279
continue;
283280
}
284281
$this->single_row( $term );
@@ -573,7 +570,7 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
573570
if ( 'category' === $taxonomy && (int) get_option( 'default_category' ) === $tag->term_id ) {
574571
$actions['change-default'] = sprintf(
575572
'<a href="%s">%s</a>',
576-
admin_url( 'options-writing.php#default-category-row' ),
573+
admin_url( 'options-writing.php#default_category' ),
577574
__( 'Change Default' )
578575
);
579576
}

src/wp-admin/options-writing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
</fieldset></td>
7979
</tr>
8080
<?php endif; ?>
81-
<tr id="default-category-row">
81+
<tr>
8282
<th scope="row"><label for="default_category"><?php _e( 'Default Post Category' ); ?></label></th>
8383
<td>
8484
<?php

0 commit comments

Comments
 (0)