From 987c8c151588221648b002608fc7350196e13450 Mon Sep 17 00:00:00 2001 From: Sarai Chinwag Date: Mon, 23 Mar 2026 03:55:26 +0000 Subject: [PATCH] fix(publish): Use correct parameter name when assigning taxonomies The WordPress publish handler was checking $parameters[$taxonomy] where $taxonomy is the taxonomy name (e.g., 'post_tag'), but the AI tool parameter name is mapped differently (e.g., 'post_tag' -> 'tags'). This caused tags to never be assigned when 'ai_decides' was configured, because the handler looked for the wrong parameter key. Changes: - Make TaxonomyHandler::getParameterName() public static - Use getParameterName() in WordPress.php to get correct parameter key Fixes missing tag assignment when using ai_decides taxonomy selection. --- inc/Core/Steps/Publish/Handlers/WordPress/WordPress.php | 7 +++++-- inc/Core/WordPress/TaxonomyHandler.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/inc/Core/Steps/Publish/Handlers/WordPress/WordPress.php b/inc/Core/Steps/Publish/Handlers/WordPress/WordPress.php index dcbf384e9..4cdd42ab9 100644 --- a/inc/Core/Steps/Publish/Handlers/WordPress/WordPress.php +++ b/inc/Core/Steps/Publish/Handlers/WordPress/WordPress.php @@ -104,8 +104,11 @@ protected function executePublish( array $parameters, array $handler_config ): a $field_key = "taxonomy_{$taxonomy}_selection"; $selection = $handler_config[ $field_key ] ?? SelectionMode::SKIP; - if ( SelectionMode::isAiDecides( $selection ) && ! empty( $parameters[ $taxonomy ] ) ) { - $taxonomies[ $taxonomy ] = $parameters[ $taxonomy ]; + // Get the parameter name (e.g., 'post_tag' -> 'tags') + $param_name = TaxonomyHandler::getParameterName( $taxonomy ); + + if ( SelectionMode::isAiDecides( $selection ) && ! empty( $parameters[ $param_name ] ) ) { + $taxonomies[ $taxonomy ] = $parameters[ $param_name ]; } elseif ( SelectionMode::isPreSelected( $selection ) ) { $taxonomies[ $taxonomy ] = $selection; } diff --git a/inc/Core/WordPress/TaxonomyHandler.php b/inc/Core/WordPress/TaxonomyHandler.php index 495a2351c..1a204f7bc 100644 --- a/inc/Core/WordPress/TaxonomyHandler.php +++ b/inc/Core/WordPress/TaxonomyHandler.php @@ -241,7 +241,7 @@ private function processAiDecidedTaxonomy( int $post_id, object $taxonomy, array * @param string $taxonomy_name WordPress taxonomy name * @return string Corresponding parameter name for AI tools */ - private function getParameterName( string $taxonomy_name ): string { + public static function getParameterName( string $taxonomy_name ): string { if ( 'category' === $taxonomy_name ) { return 'category'; } elseif ( 'post_tag' === $taxonomy_name ) {