@@ -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 }
0 commit comments