feat: Update version to 1.5.0 and add brand context handling to prompts

This commit is contained in:
2026-01-23 17:59:32 +00:00
parent 43ddbddd11
commit d878bb7805
3 changed files with 64 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
/** /**
* Plugin Name: SitiAI Product Teksten * Plugin Name: SitiAI Product Teksten
* Description: Genereer productteksten met diverse AI-aanbieders rechtstreeks vanuit WooCommerce. * Description: Genereer productteksten met diverse AI-aanbieders rechtstreeks vanuit WooCommerce.
* Version: 1.4.5 * Version: 1.5.0
* Author: SitiAI * Author: SitiAI
* Text Domain: siti-ai-product-content-generator * Text Domain: siti-ai-product-content-generator
* Domain Path: /languages * Domain Path: /languages

View File

@@ -388,9 +388,66 @@ class Groq_AI_Prompt_Builder {
} }
} }
if ( ! empty( $fields['brands'] ) ) {
$brands_context = $this->get_product_brand_context_text( $post_id );
if ( '' !== $brands_context ) {
$parts[] = sprintf( __( 'Merken: %s', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $brands_context );
}
}
return implode( "\n\n", array_filter( $parts ) ); return implode( "\n\n", array_filter( $parts ) );
} }
private function get_product_brand_context_text( $post_id ) {
$post_id = absint( $post_id );
$taxonomy = $this->detect_brand_taxonomy();
if ( ! $post_id || '' === $taxonomy || ! taxonomy_exists( $taxonomy ) ) {
return '';
}
$terms = get_the_terms( $post_id, $taxonomy );
if ( empty( $terms ) || is_wp_error( $terms ) ) {
return '';
}
$entries = [];
foreach ( $terms as $term ) {
if ( ! $term || ! is_object( $term ) ) {
continue;
}
$name = isset( $term->name ) ? trim( wp_strip_all_tags( (string) $term->name ) ) : '';
if ( '' === $name ) {
continue;
}
$description = isset( $term->description ) ? trim( wp_strip_all_tags( (string) $term->description ) ) : '';
if ( '' !== $description ) {
$entries[] = sprintf( '%s - %s', $name, $description );
} else {
$entries[] = $name;
}
}
$entries = array_values( array_unique( array_filter( $entries ) ) );
if ( empty( $entries ) ) {
return '';
}
$context = implode( '; ', $entries );
/**
* Filters the product brand context string added to prompts.
*
* @param string $context
* @param int $post_id
* @param array $terms
* @param string $taxonomy
*/
return (string) apply_filters( 'groq_ai_product_brand_context', $context, $post_id, $terms, $taxonomy );
}
public function prepend_context_to_prompt( $prompt, $context ) { public function prepend_context_to_prompt( $prompt, $context ) {
$context = trim( (string) $context ); $context = trim( (string) $context );

View File

@@ -234,6 +234,11 @@ class Groq_AI_Settings_Manager {
'description' => __( 'Voeg gestructureerde productattributen toe (zoals kleur, maat, materiaal).', GROQ_AI_PRODUCT_TEXT_DOMAIN ), 'description' => __( 'Voeg gestructureerde productattributen toe (zoals kleur, maat, materiaal).', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
'default' => false, 'default' => false,
], ],
'brands' => [
'label' => __( 'Merken', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
'description' => __( 'Voegt gekoppelde productmerken toe (detecteert WooCommerce merk-taxonomieën).', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
'default' => true,
],
'images' => [ 'images' => [
'label' => __( 'Afbeeldingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ), 'label' => __( 'Afbeeldingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
'description' => __( 'Voeg een korte lijst toe met productafbeeldingen (beschrijving + URL).', GROQ_AI_PRODUCT_TEXT_DOMAIN ), 'description' => __( 'Voeg een korte lijst toe met productafbeeldingen (beschrijving + URL).', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
@@ -261,7 +266,7 @@ class Groq_AI_Settings_Manager {
$normalized = []; $normalized = [];
foreach ( $definitions as $key => $data ) { foreach ( $definitions as $key => $data ) {
$normalized[ $key ] = false; $normalized[ $key ] = ! empty( $data['default'] );
} }
if ( ! is_array( $fields ) ) { if ( ! is_array( $fields ) ) {