From 403892ab6169801a343e0a8918b7fa6975ec2104 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Tue, 9 Dec 2025 09:09:32 -0500 Subject: [PATCH] Calendar: Remove 'taxonomy hierarchical' from editable fields for performance and usability Re: https://github.com/Automattic/Edit-Flow/issues/756 Stop hierarchical taxonomies like categories from being edited inside the calendar, while continuing to allow non-hierarchical taxonomies (tags) to be edited. This avoids the horrific performance punishment on sites with many categories due to the full list of categories being inserted as a hidden field inside each and every post on the calendar. It also avoids using a single-select field to update categories, which removes all categories but the one chosen when saved. Users are better off editing the post directly if they need to change the categories. Co-authored-by: Jer Clarke --- modules/calendar/calendar.php | 36 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/modules/calendar/calendar.php b/modules/calendar/calendar.php index 9a77b643..3dd68503 100644 --- a/modules/calendar/calendar.php +++ b/modules/calendar/calendar.php @@ -1102,12 +1102,6 @@ public function get_editable_html( $type, $value ) { case 'taxonomy': return ''; break; - case 'taxonomy hierarchical': - return wp_dropdown_categories( array( - 'echo' => 0, - 'hide_empty' => 0, - ) ); - break; } } @@ -1181,27 +1175,28 @@ public function get_post_information_fields( $post ) { } else { $value = ''; } - //Used when editing editorial metadata and post meta - if ( is_taxonomy_hierarchical( $taxonomy->name ) ) { - $type = 'taxonomy hierarchical'; - } else { - $type = 'taxonomy'; - } - $information_fields[ $key ] = array( 'label' => $taxonomy->label, 'value' => $value, - 'type' => $type, ); - if ( 'page' == $post->post_type ) { - $ed_cap = 'edit_page'; + // Only allow non-hierarchical taxonomies to be edited in the calendar. + // Hierarchical taxonomies (like categories) cause performance issues and + // the single-select UI removes all but one category when saved. + if ( is_taxonomy_hierarchical( $taxonomy->name ) ) { + $information_fields[ $key ]['type'] = 'taxonomy hierarchical'; } else { - $ed_cap = 'edit_post'; - } + $information_fields[ $key ]['type'] = 'taxonomy'; - if ( current_user_can( $ed_cap, $post->ID ) ) { - $information_fields[ $key ]['editable'] = true; + if ( 'page' == $post->post_type ) { + $ed_cap = 'edit_page'; + } else { + $ed_cap = 'edit_post'; + } + + if ( current_user_can( $ed_cap, $post->ID ) ) { + $information_fields[ $key ]['editable'] = true; + } } } @@ -1698,7 +1693,6 @@ public function handle_ajax_update_metadata() { } else { switch ( $_POST['metadata_type'] ) { case 'taxonomy': - case 'taxonomy hierarchical': $response = wp_set_post_terms( $post->ID, $incoming_metadata_value, $metadata_term ); break; default: