Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 985f7dfbcd | |||
| cf7ee6b86e | |||
| 1d19b36493 |
@@ -22,12 +22,17 @@ class SitiWebUpdater {
|
|||||||
|
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
|
|
||||||
|
$this->set_plugin_properties();
|
||||||
add_action( 'admin_init', array( $this, 'set_plugin_properties' ) );
|
add_action( 'admin_init', array( $this, 'set_plugin_properties' ) );
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_plugin_properties() {
|
public function set_plugin_properties() {
|
||||||
|
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
}
|
||||||
|
|
||||||
$this->plugin = get_plugin_data( $this->file );
|
$this->plugin = get_plugin_data( $this->file );
|
||||||
$this->basename = plugin_basename( $this->file );
|
$this->basename = plugin_basename( $this->file );
|
||||||
$this->active = is_plugin_active( $this->basename );
|
$this->active = is_plugin_active( $this->basename );
|
||||||
@@ -66,6 +71,14 @@ class SitiWebUpdater {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function get_latest_version_from_response() {
|
||||||
|
if ( empty( $this->github_response['tag_name'] ) ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ltrim( $this->github_response['tag_name'], 'vV' );
|
||||||
|
}
|
||||||
|
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'modify_transient' ), 10, 1 );
|
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'modify_transient' ), 10, 1 );
|
||||||
add_filter( 'plugins_api', array( $this, 'plugin_popup' ), 10, 3);
|
add_filter( 'plugins_api', array( $this, 'plugin_popup' ), 10, 3);
|
||||||
@@ -88,15 +101,13 @@ class SitiWebUpdater {
|
|||||||
|
|
||||||
$this->get_repository_info(); // Get the repo info
|
$this->get_repository_info(); // Get the repo info
|
||||||
|
|
||||||
if ( empty( $this->github_response ) || empty( $this->github_response['tag_name'] ) ) {
|
$latest_version = $this->get_latest_version_from_response();
|
||||||
|
|
||||||
|
if ( null === $latest_version ) {
|
||||||
return $transient;
|
return $transient;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $checked[ $this->basename ] ) ) {
|
$out_of_date = version_compare( $latest_version, $checked[ $this->basename ], 'gt' ); // Check if we're out of date
|
||||||
return $transient;
|
|
||||||
}
|
|
||||||
|
|
||||||
$out_of_date = version_compare( $this->github_response['tag_name'], $checked[ $this->basename ], 'gt' ); // Check if we're out of date
|
|
||||||
|
|
||||||
if( $out_of_date ) {
|
if( $out_of_date ) {
|
||||||
|
|
||||||
@@ -108,7 +119,7 @@ class SitiWebUpdater {
|
|||||||
'url' => $this->plugin["PluginURI"],
|
'url' => $this->plugin["PluginURI"],
|
||||||
'slug' => $slug,
|
'slug' => $slug,
|
||||||
'package' => $new_files,
|
'package' => $new_files,
|
||||||
'new_version' => $this->github_response['tag_name']
|
'new_version' => $latest_version
|
||||||
);
|
);
|
||||||
|
|
||||||
$transient->response[$this->basename] = (object) $plugin; // Return it in response
|
$transient->response[$this->basename] = (object) $plugin; // Return it in response
|
||||||
@@ -126,8 +137,9 @@ class SitiWebUpdater {
|
|||||||
if( $args->slug == current( explode( '/' , $this->basename ) ) ) { // And it's our slug
|
if( $args->slug == current( explode( '/' , $this->basename ) ) ) { // And it's our slug
|
||||||
|
|
||||||
$this->get_repository_info(); // Get our repo info
|
$this->get_repository_info(); // Get our repo info
|
||||||
|
$latest_version = $this->get_latest_version_from_response();
|
||||||
|
|
||||||
if ( empty( $this->github_response ) || empty( $this->github_response['tag_name'] ) ) {
|
if ( null === $latest_version ) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +153,7 @@ class SitiWebUpdater {
|
|||||||
'num_ratings' => '10823',
|
'num_ratings' => '10823',
|
||||||
'downloaded' => '14249',
|
'downloaded' => '14249',
|
||||||
'added' => '2016-01-05',
|
'added' => '2016-01-05',
|
||||||
'version' => $this->github_response['tag_name'],
|
'version' => $latest_version,
|
||||||
'author' => $this->plugin["AuthorName"],
|
'author' => $this->plugin["AuthorName"],
|
||||||
'author_profile' => $this->plugin["AuthorURI"],
|
'author_profile' => $this->plugin["AuthorURI"],
|
||||||
'last_updated' => $this->github_response['published_at'],
|
'last_updated' => $this->github_response['published_at'],
|
||||||
|
|||||||
@@ -123,6 +123,36 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.groq-ai-title-suggestions {
|
||||||
|
border: 1px dashed #dcdcde;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 8px;
|
||||||
|
background: #fefefe;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.groq-ai-title-suggestions__options {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.groq-ai-title-suggestions__option {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.groq-ai-title-suggestions__option input[type='radio'] {
|
||||||
|
margin-top: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.groq-ai-title-suggestions__hint {
|
||||||
|
margin-top: 6px;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.groq-ai-modal__raw {
|
.groq-ai-modal__raw {
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
rankMathAction: field.getAttribute('data-rankmath-action') || '',
|
rankMathAction: field.getAttribute('data-rankmath-action') || '',
|
||||||
status: field.querySelector('.groq-ai-apply-status') || null,
|
status: field.querySelector('.groq-ai-apply-status') || null,
|
||||||
statusTimer: null,
|
statusTimer: null,
|
||||||
|
suggestionWrapper: field.querySelector('[data-title-suggestions]') || null,
|
||||||
|
suggestionOptions: field.querySelector('[data-title-suggestions-options]') || null,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -92,8 +94,8 @@
|
|||||||
statusField.setAttribute('data-status', type);
|
statusField.setAttribute('data-status', type);
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadingText = window.wp && wp.i18n ? wp.i18n.__('AI is bezig met schrijven...', 'groq-ai-product-text') : 'AI is bezig met schrijven...';
|
const loadingText = window.wp && wp.i18n ? wp.i18n.__('AI is bezig met schrijven...', 'siti-ai-product-content-generator') : 'AI is bezig met schrijven...';
|
||||||
const retryText = window.wp && wp.i18n ? wp.i18n.__('Probeer het opnieuw of pas je prompt/context aan.', 'groq-ai-product-text') : 'Probeer het opnieuw of pas je prompt/context aan.';
|
const retryText = window.wp && wp.i18n ? wp.i18n.__('Probeer het opnieuw of pas je prompt/context aan.', 'siti-ai-product-content-generator') : 'Probeer het opnieuw of pas je prompt/context aan.';
|
||||||
|
|
||||||
function toggleLoading(isLoading) {
|
function toggleLoading(isLoading) {
|
||||||
modal.classList.toggle('is-loading', isLoading);
|
modal.classList.toggle('is-loading', isLoading);
|
||||||
@@ -120,6 +122,7 @@
|
|||||||
jsonCopyButton.disabled = true;
|
jsonCopyButton.disabled = true;
|
||||||
}
|
}
|
||||||
resetFieldStatuses();
|
resetFieldStatuses();
|
||||||
|
clearTitleSuggestions();
|
||||||
|
|
||||||
fetch(GroqAIGenerator.ajaxUrl, {
|
fetch(GroqAIGenerator.ajaxUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -142,6 +145,7 @@
|
|||||||
entry.textarea.value = fields[key] || '';
|
entry.textarea.value = fields[key] || '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
updateTitleSuggestions(fields.title_suggestions);
|
||||||
resultField.textContent = (json.data.raw || '').trim();
|
resultField.textContent = (json.data.raw || '').trim();
|
||||||
resultWrapper.hidden = false;
|
resultWrapper.hidden = false;
|
||||||
if (jsonCopyButton) {
|
if (jsonCopyButton) {
|
||||||
@@ -317,6 +321,8 @@
|
|||||||
return ['textarea[name="rank_math_description"]'];
|
return ['textarea[name="rank_math_description"]'];
|
||||||
case 'focus_keywords':
|
case 'focus_keywords':
|
||||||
return ['input[name="rank_math_focus_keyword"]'];
|
return ['input[name="rank_math_focus_keyword"]'];
|
||||||
|
case 'slug':
|
||||||
|
return ['#post_name', 'input[name="post_name"]', '#new-post-slug'];
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -357,6 +363,89 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearTitleSuggestions() {
|
||||||
|
const entry = resultFields.title;
|
||||||
|
if (!entry || !entry.suggestionWrapper || !entry.suggestionOptions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
entry.suggestionOptions.innerHTML = '';
|
||||||
|
entry.suggestionWrapper.hidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateTitleSuggestions(options) {
|
||||||
|
const entry = resultFields.title;
|
||||||
|
if (!entry || !entry.suggestionWrapper || !entry.suggestionOptions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.suggestionOptions.innerHTML = '';
|
||||||
|
|
||||||
|
const sanitized = Array.isArray(options)
|
||||||
|
? options
|
||||||
|
.map((option) => (typeof option === 'string' ? option.trim() : ''))
|
||||||
|
.filter((option) => option.length > 0)
|
||||||
|
.slice(0, 3)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
if (!sanitized.length) {
|
||||||
|
entry.suggestionWrapper.hidden = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.suggestionWrapper.hidden = false;
|
||||||
|
|
||||||
|
const currentValue = entry.textarea ? entry.textarea.value.trim() : '';
|
||||||
|
const normalizedCurrent = currentValue.toLowerCase();
|
||||||
|
let selectedValue = '';
|
||||||
|
|
||||||
|
if (normalizedCurrent) {
|
||||||
|
const matched = sanitized.find((text) => text.toLowerCase() === normalizedCurrent);
|
||||||
|
if (matched) {
|
||||||
|
selectedValue = matched;
|
||||||
|
if (entry.textarea) {
|
||||||
|
entry.textarea.value = matched;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selectedValue) {
|
||||||
|
selectedValue = sanitized[0];
|
||||||
|
if (entry.textarea) {
|
||||||
|
entry.textarea.value = sanitized[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupName = `groq-ai-title-option-${Date.now()}`;
|
||||||
|
|
||||||
|
sanitized.forEach((text, index) => {
|
||||||
|
const optionId = `${groupName}-${index}`;
|
||||||
|
const optionWrapper = document.createElement('label');
|
||||||
|
optionWrapper.className = 'groq-ai-title-suggestions__option';
|
||||||
|
|
||||||
|
const radio = document.createElement('input');
|
||||||
|
radio.type = 'radio';
|
||||||
|
radio.name = groupName;
|
||||||
|
radio.id = optionId;
|
||||||
|
radio.value = text;
|
||||||
|
if (text === selectedValue) {
|
||||||
|
radio.checked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
radio.addEventListener('change', () => {
|
||||||
|
if (entry.textarea) {
|
||||||
|
entry.textarea.value = text;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const textSpan = document.createElement('span');
|
||||||
|
textSpan.textContent = text;
|
||||||
|
|
||||||
|
optionWrapper.appendChild(radio);
|
||||||
|
optionWrapper.appendChild(textSpan);
|
||||||
|
entry.suggestionOptions.appendChild(optionWrapper);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function resetContextToggles() {
|
function resetContextToggles() {
|
||||||
const defaults = GroqAIGenerator.contextDefaults || {};
|
const defaults = GroqAIGenerator.contextDefaults || {};
|
||||||
contextToggles.forEach((toggle) => {
|
contextToggles.forEach((toggle) => {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ services:
|
|||||||
WORDPRESS_DB_USER: wordpress
|
WORDPRESS_DB_USER: wordpress
|
||||||
WORDPRESS_DB_PASSWORD: wordpress
|
WORDPRESS_DB_PASSWORD: wordpress
|
||||||
WORDPRESS_DB_NAME: wordpress
|
WORDPRESS_DB_NAME: wordpress
|
||||||
WORDPRESS_DEBUG: 1
|
WORDPRESS_DEBUG: 0
|
||||||
WP_ENVIRONMENT_TYPE: local
|
WP_ENVIRONMENT_TYPE: local
|
||||||
volumes:
|
volumes:
|
||||||
- wordpress_data:/var/www/html
|
- wordpress_data:/var/www/html
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
/**
|
/**
|
||||||
* 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.2.0
|
* Version: 1.3.0
|
||||||
* Author: SitiAI
|
* Author: SitiAI
|
||||||
|
* Text Domain: siti-ai-product-content-generator
|
||||||
|
* Domain Path: /languages
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
@@ -27,6 +29,14 @@ if ( ! defined( 'GROQ_AI_PRODUCT_TEXT_VERSION' ) ) {
|
|||||||
define( 'GROQ_AI_PRODUCT_TEXT_VERSION', $groq_ai_version );
|
define( 'GROQ_AI_PRODUCT_TEXT_VERSION', $groq_ai_version );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! defined( 'GROQ_AI_PRODUCT_TEXT_DOMAIN' ) ) {
|
||||||
|
define( 'GROQ_AI_PRODUCT_TEXT_DOMAIN', 'siti-ai-product-content-generator' );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! defined( 'GROQ_AI_PRODUCT_TEXT_LEGACY_DOMAIN' ) ) {
|
||||||
|
define( 'GROQ_AI_PRODUCT_TEXT_LEGACY_DOMAIN', 'groq-ai-product-text' );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! defined( 'GROQ_AI_DEBUG_TRACE_ADDED' ) && defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
if ( ! defined( 'GROQ_AI_DEBUG_TRACE_ADDED' ) && defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||||
define( 'GROQ_AI_DEBUG_TRACE_ADDED', true );
|
define( 'GROQ_AI_DEBUG_TRACE_ADDED', true );
|
||||||
}
|
}
|
||||||
@@ -63,6 +73,9 @@ final class Groq_AI_Product_Text_Plugin {
|
|||||||
const CONVERSATION_OPTION_KEY = 'groq_ai_product_text_conversations';
|
const CONVERSATION_OPTION_KEY = 'groq_ai_product_text_conversations';
|
||||||
const MODELS_CACHE_OPTION_KEY = 'groq_ai_product_text_models';
|
const MODELS_CACHE_OPTION_KEY = 'groq_ai_product_text_models';
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
private $textdomain_loaded = false;
|
||||||
|
|
||||||
private static $instance = null;
|
private static $instance = null;
|
||||||
|
|
||||||
/** @var Groq_AI_Service_Container */
|
/** @var Groq_AI_Service_Container */
|
||||||
@@ -91,10 +104,36 @@ final class Groq_AI_Product_Text_Plugin {
|
|||||||
$this->settings_page = new Groq_AI_Product_Text_Settings_Page( $this, $this->get_provider_manager() );
|
$this->settings_page = new Groq_AI_Product_Text_Settings_Page( $this, $this->get_provider_manager() );
|
||||||
$this->product_ui = new Groq_AI_Product_Text_Product_UI( $this );
|
$this->product_ui = new Groq_AI_Product_Text_Product_UI( $this );
|
||||||
|
|
||||||
|
add_action( 'plugins_loaded', [ $this, 'maybe_load_textdomain_early' ], 0 );
|
||||||
|
add_action( 'init', [ $this, 'load_textdomain' ] );
|
||||||
add_action( 'plugins_loaded', [ $this, 'maybe_create_logs_table' ] );
|
add_action( 'plugins_loaded', [ $this, 'maybe_create_logs_table' ] );
|
||||||
add_action( 'load-plugins.php', [ $this, 'maybe_deactivate_if_woocommerce_missing' ] );
|
add_action( 'load-plugins.php', [ $this, 'maybe_deactivate_if_woocommerce_missing' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function load_textdomain() {
|
||||||
|
if ( $this->textdomain_loaded ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$relative_path = dirname( plugin_basename( GROQ_AI_PRODUCT_TEXT_FILE ) ) . '/languages';
|
||||||
|
|
||||||
|
load_plugin_textdomain( GROQ_AI_PRODUCT_TEXT_DOMAIN, false, $relative_path );
|
||||||
|
|
||||||
|
if ( defined( 'GROQ_AI_PRODUCT_TEXT_LEGACY_DOMAIN' ) && GROQ_AI_PRODUCT_TEXT_LEGACY_DOMAIN !== GROQ_AI_PRODUCT_TEXT_DOMAIN ) {
|
||||||
|
load_plugin_textdomain( GROQ_AI_PRODUCT_TEXT_LEGACY_DOMAIN, false, $relative_path );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->textdomain_loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function maybe_load_textdomain_early() {
|
||||||
|
if ( did_action( 'init' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->load_textdomain();
|
||||||
|
}
|
||||||
|
|
||||||
private function register_services() {
|
private function register_services() {
|
||||||
$this->container = new Groq_AI_Service_Container();
|
$this->container = new Groq_AI_Service_Container();
|
||||||
|
|
||||||
@@ -198,7 +237,7 @@ final class Groq_AI_Product_Text_Plugin {
|
|||||||
?>
|
?>
|
||||||
<div class="notice notice-error">
|
<div class="notice notice-error">
|
||||||
<p>
|
<p>
|
||||||
<?php esc_html_e( 'SitiAI Product Teksten vereist WooCommerce en is gedeactiveerd omdat WooCommerce niet actief is.', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'SitiAI Product Teksten vereist WooCommerce en is gedeactiveerd omdat WooCommerce niet actief is.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
@@ -208,15 +247,15 @@ final class Groq_AI_Product_Text_Plugin {
|
|||||||
$parts = [];
|
$parts = [];
|
||||||
|
|
||||||
if ( ! empty( $settings['store_context'] ) ) {
|
if ( ! empty( $settings['store_context'] ) ) {
|
||||||
$parts[] = sprintf( __( 'Winkelcontext: %s', 'groq-ai-product-text' ), $settings['store_context'] );
|
$parts[] = sprintf( __( 'Winkelcontext: %s', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $settings['store_context'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $settings['default_prompt'] ) ) {
|
if ( ! empty( $settings['default_prompt'] ) ) {
|
||||||
$parts[] = sprintf( __( 'Standaard prompt: %s', 'groq-ai-product-text' ), $settings['default_prompt'] );
|
$parts[] = sprintf( __( 'Standaard prompt: %s', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $settings['default_prompt'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $parts ) ) {
|
if ( empty( $parts ) ) {
|
||||||
return __( 'Nog geen promptinformatie opgeslagen.', 'groq-ai-product-text' );
|
return __( 'Nog geen promptinformatie opgeslagen.', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode( "\n\n", $parts );
|
return implode( "\n\n", $parts );
|
||||||
@@ -266,6 +305,10 @@ final class Groq_AI_Product_Text_Plugin {
|
|||||||
return $this->get_settings_manager()->get_image_context_mode( $settings );
|
return $this->get_settings_manager()->get_image_context_mode( $settings );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_image_context_limit( $settings = null ) {
|
||||||
|
return $this->get_settings_manager()->get_image_context_limit( $settings );
|
||||||
|
}
|
||||||
|
|
||||||
public function should_use_response_format( Groq_AI_Provider_Interface $provider, $settings ) {
|
public function should_use_response_format( Groq_AI_Provider_Interface $provider, $settings ) {
|
||||||
return ! $this->is_response_format_compat_enabled( $settings ) && $provider->supports_response_format();
|
return ! $this->is_response_format_compat_enabled( $settings ) && $provider->supports_response_format();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ class Groq_AI_Logs_Table extends WP_List_Table {
|
|||||||
|
|
||||||
public function get_columns() {
|
public function get_columns() {
|
||||||
return [
|
return [
|
||||||
'created_at' => __( 'Datum', 'groq-ai-product-text' ),
|
'created_at' => __( 'Datum', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'user_id' => __( 'Gebruiker', 'groq-ai-product-text' ),
|
'user_id' => __( 'Gebruiker', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'post_title' => __( 'Product', 'groq-ai-product-text' ),
|
'post_title' => __( 'Product', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'provider' => __( 'Provider', 'groq-ai-product-text' ),
|
'provider' => __( 'Provider', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'model' => __( 'Model', 'groq-ai-product-text' ),
|
'model' => __( 'Model', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'status' => __( 'Status', 'groq-ai-product-text' ),
|
'status' => __( 'Status', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'tokens_total' => __( 'Tokens', 'groq-ai-product-text' ),
|
'tokens_total' => __( 'Tokens', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ class Groq_AI_Logs_Table extends WP_List_Table {
|
|||||||
if ( ! $item['post_id'] ) {
|
if ( ! $item['post_id'] ) {
|
||||||
return '—';
|
return '—';
|
||||||
}
|
}
|
||||||
$title = $item['post_title'] ? $item['post_title'] : sprintf( __( 'Product #%d', 'groq-ai-product-text' ), (int) $item['post_id'] );
|
$title = $item['post_title'] ? $item['post_title'] : sprintf( __( 'Product #%d', GROQ_AI_PRODUCT_TEXT_DOMAIN ), (int) $item['post_id'] );
|
||||||
$link = get_edit_post_link( $item['post_id'] );
|
$link = get_edit_post_link( $item['post_id'] );
|
||||||
return $link ? sprintf( '<a href="%s">%s</a>', esc_url( $link ), esc_html( $title ) ) : esc_html( $title );
|
return $link ? sprintf( '<a href="%s">%s</a>', esc_url( $link ), esc_html( $title ) ) : esc_html( $title );
|
||||||
case 'user_id':
|
case 'user_id':
|
||||||
@@ -131,7 +131,7 @@ class Groq_AI_Logs_Table extends WP_List_Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function no_items() {
|
public function no_items() {
|
||||||
esc_html_e( 'Nog geen AI-logboeken gevonden.', 'groq-ai-product-text' );
|
esc_html_e( 'Nog geen AI-logboeken gevonden.', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function column_created_at( $item ) {
|
protected function column_created_at( $item ) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Groq_AI_Product_Text_Product_UI {
|
|||||||
public function register_meta_box() {
|
public function register_meta_box() {
|
||||||
add_meta_box(
|
add_meta_box(
|
||||||
'groq-ai-generator-box',
|
'groq-ai-generator-box',
|
||||||
__( 'Gebruik AI', 'groq-ai-product-text' ),
|
__( 'Gebruik AI', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
[ $this, 'render_meta_box' ],
|
[ $this, 'render_meta_box' ],
|
||||||
'product',
|
'product',
|
||||||
'side',
|
'side',
|
||||||
@@ -24,14 +24,14 @@ class Groq_AI_Product_Text_Product_UI {
|
|||||||
|
|
||||||
public function render_meta_box() {
|
public function render_meta_box() {
|
||||||
if ( ! current_user_can( 'edit_products' ) ) {
|
if ( ! current_user_can( 'edit_products' ) ) {
|
||||||
echo '<p>' . esc_html__( 'Je hebt geen toestemming om deze actie uit te voeren.', 'groq-ai-product-text' ) . '</p>';
|
echo '<p>' . esc_html__( 'Je hebt geen toestemming om deze actie uit te voeren.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) . '</p>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<p><?php esc_html_e( 'Laat de geselecteerde AI een concepttekst genereren op basis van een prompt.', 'groq-ai-product-text' ); ?></p>
|
<p><?php esc_html_e( 'Laat de geselecteerde AI een concepttekst genereren op basis van een prompt.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<button type="button" class="button button-primary groq-ai-open-modal" data-target="groq-ai-modal"><?php esc_html_e( 'Gebruik AI', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button button-primary groq-ai-open-modal" data-target="groq-ai-modal"><?php esc_html_e( 'Gebruik AI', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<p class="description" style="margin-top:8px;">
|
<p class="description" style="margin-top:8px;">
|
||||||
<?php esc_html_e( 'Klik om een prompt in te voeren en een voorsteltekst te genereren. Plak het resultaat in de beschrijving of korte beschrijving.', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Klik om een prompt in te voeren en een voorsteltekst te genereren. Plak het resultaat in de beschrijving of korte beschrijving.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</p>
|
</p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -85,25 +85,25 @@ class Groq_AI_Product_Text_Product_UI {
|
|||||||
?>
|
?>
|
||||||
<div id="groq-ai-modal" class="groq-ai-modal" aria-hidden="true">
|
<div id="groq-ai-modal" class="groq-ai-modal" aria-hidden="true">
|
||||||
<div class="groq-ai-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="groq-ai-modal-title">
|
<div class="groq-ai-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="groq-ai-modal-title">
|
||||||
<button type="button" class="groq-ai-modal__close" aria-label="<?php esc_attr_e( 'Sluiten', 'groq-ai-product-text' ); ?>">×</button>
|
<button type="button" class="groq-ai-modal__close" aria-label="<?php esc_attr_e( 'Sluiten', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>">×</button>
|
||||||
<div class="groq-ai-modal__dialog-inner">
|
<div class="groq-ai-modal__dialog-inner">
|
||||||
<h2 id="groq-ai-modal-title"><?php esc_html_e( 'Siti AI prompt', 'groq-ai-product-text' ); ?></h2>
|
<h2 id="groq-ai-modal-title"><?php esc_html_e( 'Siti AI prompt', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></h2>
|
||||||
<form id="groq-ai-form">
|
<form id="groq-ai-form">
|
||||||
<label for="groq-ai-prompt" class="screen-reader-text"><?php esc_html_e( 'Prompt', 'groq-ai-product-text' ); ?></label>
|
<label for="groq-ai-prompt" class="screen-reader-text"><?php esc_html_e( 'Prompt', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></label>
|
||||||
<textarea id="groq-ai-prompt" rows="6" placeholder="<?php esc_attr_e( 'Beschrijf hier wat de AI moet schrijven...', 'groq-ai-product-text' ); ?>"></textarea>
|
<textarea id="groq-ai-prompt" rows="6" placeholder="<?php esc_attr_e( 'Beschrijf hier wat de AI moet schrijven...', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>"></textarea>
|
||||||
<div class="groq-ai-modal__actions">
|
<div class="groq-ai-modal__actions">
|
||||||
<button type="submit" class="button button-primary">
|
<button type="submit" class="button button-primary">
|
||||||
<?php esc_html_e( 'Genereer tekst', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Genereer tekst', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="groq-ai-advanced-settings">
|
<div class="groq-ai-advanced-settings">
|
||||||
<button type="button" class="groq-ai-advanced-toggle" aria-expanded="false" aria-controls="groq-ai-advanced-panel">
|
<button type="button" class="groq-ai-advanced-toggle" aria-expanded="false" aria-controls="groq-ai-advanced-panel">
|
||||||
<span class="groq-ai-advanced-toggle__icon" aria-hidden="true"></span>
|
<span class="groq-ai-advanced-toggle__icon" aria-hidden="true"></span>
|
||||||
<?php esc_html_e( 'Geavanceerde instellingen', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Geavanceerde instellingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</button>
|
</button>
|
||||||
<div id="groq-ai-advanced-panel" class="groq-ai-context-options" hidden>
|
<div id="groq-ai-advanced-panel" class="groq-ai-context-options" hidden>
|
||||||
<h3><?php esc_html_e( 'Gebruik deze productinformatie in de prompt', 'groq-ai-product-text' ); ?></h3>
|
<h3><?php esc_html_e( 'Gebruik deze productinformatie in de prompt', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></h3>
|
||||||
<p class="description"><?php esc_html_e( 'Je kunt tijdelijk onderdelen uitzetten of weer inschakelen. Standaard zijn de opties aangevinkt zoals ingesteld op de instellingenpagina.', 'groq-ai-product-text' ); ?></p>
|
<p class="description"><?php esc_html_e( 'Je kunt tijdelijk onderdelen uitzetten of weer inschakelen. Standaard zijn de opties aangevinkt zoals ingesteld op de instellingenpagina.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<div class="groq-ai-context-options__grid">
|
<div class="groq-ai-context-options__grid">
|
||||||
<?php
|
<?php
|
||||||
$context_definitions = $this->plugin->get_context_field_definitions();
|
$context_definitions = $this->plugin->get_context_field_definitions();
|
||||||
@@ -126,81 +126,97 @@ class Groq_AI_Product_Text_Product_UI {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div class="groq-ai-modal__result" hidden>
|
<div class="groq-ai-modal__result" hidden>
|
||||||
<h3><?php esc_html_e( 'Resultaat', 'groq-ai-product-text' ); ?></h3>
|
<h3><?php esc_html_e( 'Resultaat', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></h3>
|
||||||
<div class="groq-ai-result-grid">
|
<div class="groq-ai-result-grid">
|
||||||
<div class="groq-ai-result-field" data-field="title" data-target-input="#title" data-label="<?php esc_attr_e( 'Producttitel', 'groq-ai-product-text' ); ?>">
|
<div class="groq-ai-result-field" data-field="title" data-target-input="#title" data-label="<?php esc_attr_e( 'Producttitel', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>">
|
||||||
<div class="groq-ai-result-field__header">
|
<div class="groq-ai-result-field__header">
|
||||||
<strong><?php esc_html_e( 'Producttitel', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Producttitel', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<div class="groq-ai-result-field__actions">
|
<div class="groq-ai-result-field__actions">
|
||||||
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="title"><?php esc_html_e( 'Kopieer', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="title"><?php esc_html_e( 'Kopieer', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<button type="button" class="button groq-ai-apply-field" data-field="title"><?php esc_html_e( 'Vul titel in', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button groq-ai-apply-field" data-field="title"><?php esc_html_e( 'Vul titel in', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="groq-ai-title-suggestions" data-title-suggestions hidden>
|
||||||
|
<p class="groq-ai-title-suggestions__label"><?php esc_html_e( 'Kies je favoriete titelvoorstel:', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
|
<div class="groq-ai-title-suggestions__options" data-title-suggestions-options></div>
|
||||||
|
<p class="description groq-ai-title-suggestions__hint"><?php esc_html_e( 'Je kunt de tekst hieronder altijd nog aanpassen.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
|
</div>
|
||||||
<textarea rows="2"></textarea>
|
<textarea rows="2"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="groq-ai-result-field" data-field="short_description" data-target-input="#excerpt" data-label="<?php esc_attr_e( 'Korte beschrijving', 'groq-ai-product-text' ); ?>">
|
<div class="groq-ai-result-field" data-field="slug" data-target-input="#slug" data-label="<?php esc_attr_e( 'Productslug', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>">
|
||||||
<div class="groq-ai-result-field__header">
|
<div class="groq-ai-result-field__header">
|
||||||
<strong><?php esc_html_e( 'Korte beschrijving', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Productslug', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<div class="groq-ai-result-field__actions">
|
<div class="groq-ai-result-field__actions">
|
||||||
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="short_description"><?php esc_html_e( 'Kopieer', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="slug"><?php esc_html_e( 'Kopieer', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<button type="button" class="button groq-ai-apply-field" data-field="short_description"><?php esc_html_e( 'Vul korte beschrijving in', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button groq-ai-apply-field" data-field="slug"><?php esc_html_e( 'Vul slug in', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
|
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<textarea rows="1"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="groq-ai-result-field" data-field="short_description" data-target-input="#excerpt" data-label="<?php esc_attr_e( 'Korte beschrijving', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>">
|
||||||
|
<div class="groq-ai-result-field__header">
|
||||||
|
<strong><?php esc_html_e( 'Korte beschrijving', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
|
<div class="groq-ai-result-field__actions">
|
||||||
|
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="short_description"><?php esc_html_e( 'Kopieer', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
|
<button type="button" class="button groq-ai-apply-field" data-field="short_description"><?php esc_html_e( 'Vul korte beschrijving in', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<textarea rows="3"></textarea>
|
<textarea rows="3"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="groq-ai-result-field" data-field="description" data-target-input="#content" data-label="<?php esc_attr_e( 'Beschrijving', 'groq-ai-product-text' ); ?>">
|
<div class="groq-ai-result-field" data-field="description" data-target-input="#content" data-label="<?php esc_attr_e( 'Beschrijving', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>">
|
||||||
<div class="groq-ai-result-field__header">
|
<div class="groq-ai-result-field__header">
|
||||||
<strong><?php esc_html_e( 'Beschrijving', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Beschrijving', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<div class="groq-ai-result-field__actions">
|
<div class="groq-ai-result-field__actions">
|
||||||
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="description"><?php esc_html_e( 'Kopieer', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="description"><?php esc_html_e( 'Kopieer', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<button type="button" class="button groq-ai-apply-field" data-field="description"><?php esc_html_e( 'Vul beschrijving in', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button groq-ai-apply-field" data-field="description"><?php esc_html_e( 'Vul beschrijving in', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<textarea rows="6"></textarea>
|
<textarea rows="6"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<?php if ( $rankmath_enabled ) : ?>
|
<?php if ( $rankmath_enabled ) : ?>
|
||||||
<div class="groq-ai-result-field" data-field="meta_title" data-target-input="#rank_math_title" data-rankmath-action="updateTitle" data-label="<?php esc_attr_e( 'Rank Math meta titel', 'groq-ai-product-text' ); ?>">
|
<div class="groq-ai-result-field" data-field="meta_title" data-target-input="#rank_math_title" data-rankmath-action="updateTitle" data-label="<?php esc_attr_e( 'Rank Math meta titel', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>">
|
||||||
<div class="groq-ai-result-field__header">
|
<div class="groq-ai-result-field__header">
|
||||||
<strong><?php esc_html_e( 'Rank Math meta titel', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Rank Math meta titel', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<div class="groq-ai-result-field__actions">
|
<div class="groq-ai-result-field__actions">
|
||||||
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="meta_title"><?php esc_html_e( 'Kopieer', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="meta_title"><?php esc_html_e( 'Kopieer', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<button type="button" class="button groq-ai-apply-field" data-field="meta_title"><?php esc_html_e( 'Vul meta titel in', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button groq-ai-apply-field" data-field="meta_title"><?php esc_html_e( 'Vul meta titel in', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<textarea rows="2"></textarea>
|
<textarea rows="2"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="groq-ai-result-field" data-field="meta_description" data-target-input="#rank_math_description" data-rankmath-action="updateDescription" data-label="<?php esc_attr_e( 'Rank Math meta description', 'groq-ai-product-text' ); ?>">
|
<div class="groq-ai-result-field" data-field="meta_description" data-target-input="#rank_math_description" data-rankmath-action="updateDescription" data-label="<?php esc_attr_e( 'Rank Math meta description', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>">
|
||||||
<div class="groq-ai-result-field__header">
|
<div class="groq-ai-result-field__header">
|
||||||
<strong><?php esc_html_e( 'Rank Math meta description', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Rank Math meta description', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<div class="groq-ai-result-field__actions">
|
<div class="groq-ai-result-field__actions">
|
||||||
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="meta_description"><?php esc_html_e( 'Kopieer', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="meta_description"><?php esc_html_e( 'Kopieer', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<button type="button" class="button groq-ai-apply-field" data-field="meta_description"><?php esc_html_e( 'Vul meta description in', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button groq-ai-apply-field" data-field="meta_description"><?php esc_html_e( 'Vul meta description in', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<textarea rows="3"></textarea>
|
<textarea rows="3"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="groq-ai-result-field" data-field="focus_keywords" data-target-input="#rank_math_focus_keyword" data-rankmath-action="updateKeywords" data-label="<?php esc_attr_e( 'Rank Math focus keyphrase', 'groq-ai-product-text' ); ?>">
|
<div class="groq-ai-result-field" data-field="focus_keywords" data-target-input="#rank_math_focus_keyword" data-rankmath-action="updateKeywords" data-label="<?php esc_attr_e( 'Rank Math focus keyphrase', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>">
|
||||||
<div class="groq-ai-result-field__header">
|
<div class="groq-ai-result-field__header">
|
||||||
<strong><?php esc_html_e( 'Rank Math focus keyphrase', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Rank Math focus keyphrase', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<div class="groq-ai-result-field__actions">
|
<div class="groq-ai-result-field__actions">
|
||||||
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="focus_keywords"><?php esc_html_e( 'Kopieer', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button button-secondary groq-ai-copy-field" data-field="focus_keywords"><?php esc_html_e( 'Kopieer', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<button type="button" class="button groq-ai-apply-field" data-field="focus_keywords"><?php esc_html_e( 'Vul focus keyphrase in', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button groq-ai-apply-field" data-field="focus_keywords"><?php esc_html_e( 'Vul focus keyphrase in', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
<span class="groq-ai-apply-status" aria-hidden="true"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<textarea rows="2" placeholder="<?php esc_attr_e( 'bijv. luxe massage apparaat, wellness cadeau', 'groq-ai-product-text' ); ?>"></textarea>
|
<textarea rows="2" placeholder="<?php esc_attr_e( 'bijv. luxe massage apparaat, wellness cadeau', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="groq-ai-modal__raw">
|
<div class="groq-ai-modal__raw">
|
||||||
<h4><?php esc_html_e( 'Ruwe JSON-output', 'groq-ai-product-text' ); ?></h4>
|
<h4><?php esc_html_e( 'Ruwe JSON-output', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></h4>
|
||||||
<pre id="groq-ai-output"></pre>
|
<pre id="groq-ai-output"></pre>
|
||||||
<button type="button" class="button groq-ai-copy-json"><?php esc_html_e( 'Kopieer JSON', 'groq-ai-product-text' ); ?></button>
|
<button type="button" class="button groq-ai-copy-json"><?php esc_html_e( 'Kopieer JSON', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="groq-ai-modal__status" aria-live="polite"></div>
|
<div class="groq-ai-modal__status" aria-live="polite"></div>
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
public function register_settings_pages() {
|
public function register_settings_pages() {
|
||||||
add_options_page(
|
add_options_page(
|
||||||
__( 'Siti AI Productteksten', 'groq-ai-product-text' ),
|
__( 'Siti AI Productteksten', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
__( 'Siti AI', 'groq-ai-product-text' ),
|
__( 'Siti AI', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'manage_options',
|
'manage_options',
|
||||||
'groq-ai-product-text',
|
'groq-ai-product-text',
|
||||||
[ $this, 'render_settings_page' ]
|
[ $this, 'render_settings_page' ]
|
||||||
@@ -25,8 +25,8 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
add_submenu_page(
|
add_submenu_page(
|
||||||
'options-general.php',
|
'options-general.php',
|
||||||
__( 'Siti AI Modules', 'groq-ai-product-text' ),
|
__( 'Siti AI Modules', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
__( 'Siti AI Modules', 'groq-ai-product-text' ),
|
__( 'Siti AI Modules', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'manage_options',
|
'manage_options',
|
||||||
'groq-ai-product-text-modules',
|
'groq-ai-product-text-modules',
|
||||||
[ $this, 'render_modules_page' ]
|
[ $this, 'render_modules_page' ]
|
||||||
@@ -34,8 +34,8 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
add_submenu_page(
|
add_submenu_page(
|
||||||
'options-general.php',
|
'options-general.php',
|
||||||
__( 'Siti AI AI-logboek', 'groq-ai-product-text' ),
|
__( 'Siti AI AI-logboek', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
__( 'Siti AI AI-logboek', 'groq-ai-product-text' ),
|
__( 'Siti AI AI-logboek', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'manage_options',
|
'manage_options',
|
||||||
'groq-ai-product-text-logs',
|
'groq-ai-product-text-logs',
|
||||||
[ $this, 'render_logs_page' ]
|
[ $this, 'render_logs_page' ]
|
||||||
@@ -43,8 +43,8 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
add_submenu_page(
|
add_submenu_page(
|
||||||
'options-general.php',
|
'options-general.php',
|
||||||
__( 'Siti AI Prompt instellingen', 'groq-ai-product-text' ),
|
__( 'Siti AI Prompt instellingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
__( 'Siti AI Prompt instellingen', 'groq-ai-product-text' ),
|
__( 'Siti AI Prompt instellingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'manage_options',
|
'manage_options',
|
||||||
'groq-ai-product-text-prompts',
|
'groq-ai-product-text-prompts',
|
||||||
[ $this, 'render_prompt_settings_page' ]
|
[ $this, 'render_prompt_settings_page' ]
|
||||||
@@ -72,14 +72,14 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
add_settings_section(
|
add_settings_section(
|
||||||
'groq_ai_product_text_general',
|
'groq_ai_product_text_general',
|
||||||
__( 'Algemene instellingen', 'groq-ai-product-text' ),
|
__( 'Algemene instellingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'__return_false',
|
'__return_false',
|
||||||
'groq-ai-product-text'
|
'groq-ai-product-text'
|
||||||
);
|
);
|
||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'groq_ai_provider',
|
'groq_ai_provider',
|
||||||
__( 'AI-aanbieder', 'groq-ai-product-text' ),
|
__( 'AI-aanbieder', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
[ $this, 'render_provider_field' ],
|
[ $this, 'render_provider_field' ],
|
||||||
'groq-ai-product-text',
|
'groq-ai-product-text',
|
||||||
'groq_ai_product_text_general'
|
'groq_ai_product_text_general'
|
||||||
@@ -87,7 +87,7 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'groq_ai_model',
|
'groq_ai_model',
|
||||||
__( 'Model', 'groq-ai-product-text' ),
|
__( 'Model', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
[ $this, 'render_model_field' ],
|
[ $this, 'render_model_field' ],
|
||||||
'groq-ai-product-text',
|
'groq-ai-product-text',
|
||||||
'groq_ai_product_text_general'
|
'groq_ai_product_text_general'
|
||||||
@@ -96,7 +96,7 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
foreach ( $this->provider_manager->get_providers() as $provider ) {
|
foreach ( $this->provider_manager->get_providers() as $provider ) {
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'groq_ai_api_key_' . $provider->get_key(),
|
'groq_ai_api_key_' . $provider->get_key(),
|
||||||
sprintf( __( '%s API-sleutel', 'groq-ai-product-text' ), $provider->get_label() ),
|
sprintf( __( '%s API-sleutel', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $provider->get_label() ),
|
||||||
[ $this, 'render_provider_api_key_field' ],
|
[ $this, 'render_provider_api_key_field' ],
|
||||||
'groq-ai-product-text',
|
'groq-ai-product-text',
|
||||||
'groq_ai_product_text_general',
|
'groq_ai_product_text_general',
|
||||||
@@ -108,14 +108,14 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
add_settings_section(
|
add_settings_section(
|
||||||
'groq_ai_product_text_prompts',
|
'groq_ai_product_text_prompts',
|
||||||
__( 'Prompt instellingen', 'groq-ai-product-text' ),
|
__( 'Prompt instellingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'__return_false',
|
'__return_false',
|
||||||
'groq-ai-product-text-prompts'
|
'groq-ai-product-text-prompts'
|
||||||
);
|
);
|
||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'groq_ai_store_context',
|
'groq_ai_store_context',
|
||||||
__( 'Winkelcontext', 'groq-ai-product-text' ),
|
__( 'Winkelcontext', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
[ $this, 'render_store_context_field' ],
|
[ $this, 'render_store_context_field' ],
|
||||||
'groq-ai-product-text-prompts',
|
'groq-ai-product-text-prompts',
|
||||||
'groq_ai_product_text_prompts'
|
'groq_ai_product_text_prompts'
|
||||||
@@ -123,7 +123,7 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'groq_ai_default_prompt',
|
'groq_ai_default_prompt',
|
||||||
__( 'Standaard prompt', 'groq-ai-product-text' ),
|
__( 'Standaard prompt', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
[ $this, 'render_default_prompt_field' ],
|
[ $this, 'render_default_prompt_field' ],
|
||||||
'groq-ai-product-text-prompts',
|
'groq-ai-product-text-prompts',
|
||||||
'groq_ai_product_text_prompts'
|
'groq_ai_product_text_prompts'
|
||||||
@@ -131,7 +131,7 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'groq_ai_context_fields',
|
'groq_ai_context_fields',
|
||||||
__( 'Standaard productcontext', 'groq-ai-product-text' ),
|
__( 'Standaard productcontext', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
[ $this, 'render_context_fields_field' ],
|
[ $this, 'render_context_fields_field' ],
|
||||||
'groq-ai-product-text-prompts',
|
'groq-ai-product-text-prompts',
|
||||||
'groq_ai_product_text_prompts'
|
'groq_ai_product_text_prompts'
|
||||||
@@ -139,7 +139,7 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'groq_ai_response_format_compat',
|
'groq_ai_response_format_compat',
|
||||||
__( 'Response-format compatibiliteit', 'groq-ai-product-text' ),
|
__( 'Response-format compatibiliteit', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
[ $this, 'render_response_format_compat_field' ],
|
[ $this, 'render_response_format_compat_field' ],
|
||||||
'groq-ai-product-text-prompts',
|
'groq-ai-product-text-prompts',
|
||||||
'groq_ai_product_text_prompts'
|
'groq_ai_product_text_prompts'
|
||||||
@@ -147,22 +147,30 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'groq_ai_image_context_mode',
|
'groq_ai_image_context_mode',
|
||||||
__( 'Afbeeldingen toevoegen', 'groq-ai-product-text' ),
|
__( 'Afbeeldingen toevoegen', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
[ $this, 'render_image_context_mode_field' ],
|
[ $this, 'render_image_context_mode_field' ],
|
||||||
'groq-ai-product-text-prompts',
|
'groq-ai-product-text-prompts',
|
||||||
'groq_ai_product_text_prompts'
|
'groq_ai_product_text_prompts'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'groq_ai_image_context_limit',
|
||||||
|
__( 'Maximaal aantal afbeeldingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
|
[ $this, 'render_image_context_limit_field' ],
|
||||||
|
'groq-ai-product-text-prompts',
|
||||||
|
'groq_ai_product_text_prompts'
|
||||||
|
);
|
||||||
|
|
||||||
add_settings_section(
|
add_settings_section(
|
||||||
'groq_ai_product_text_modules_rankmath',
|
'groq_ai_product_text_modules_rankmath',
|
||||||
__( 'Rank Math SEO', 'groq-ai-product-text' ),
|
__( 'Rank Math SEO', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'__return_false',
|
'__return_false',
|
||||||
'groq-ai-product-text-modules'
|
'groq-ai-product-text-modules'
|
||||||
);
|
);
|
||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'groq_ai_module_rankmath',
|
'groq_ai_module_rankmath',
|
||||||
__( 'Rank Math SEO', 'groq-ai-product-text' ),
|
__( 'Rank Math SEO', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
[ $this, 'render_rankmath_module_field' ],
|
[ $this, 'render_rankmath_module_field' ],
|
||||||
'groq-ai-product-text-modules',
|
'groq-ai-product-text-modules',
|
||||||
'groq_ai_product_text_modules_rankmath'
|
'groq_ai_product_text_modules_rankmath'
|
||||||
@@ -173,9 +181,9 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
$settings = $this->plugin->get_settings();
|
$settings = $this->plugin->get_settings();
|
||||||
$mode = isset( $settings['image_context_mode'] ) ? $settings['image_context_mode'] : 'url';
|
$mode = isset( $settings['image_context_mode'] ) ? $settings['image_context_mode'] : 'url';
|
||||||
$options = [
|
$options = [
|
||||||
'none' => __( 'Nee, geen afbeeldingen', 'groq-ai-product-text' ),
|
'none' => __( 'Nee, geen afbeeldingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'url' => __( 'Ja, voeg afbeeldings-URL’s toe aan de prompt', 'groq-ai-product-text' ),
|
'url' => __( 'Ja, voeg afbeeldings-URL’s toe aan de prompt', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'base64' => __( 'Ja, verstuur afbeeldingen als Base64 (indien ondersteund)', 'groq-ai-product-text' ),
|
'base64' => __( 'Ja, verstuur afbeeldingen als Base64 (indien ondersteund)', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
];
|
];
|
||||||
?>
|
?>
|
||||||
<select name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[image_context_mode]">
|
<select name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[image_context_mode]">
|
||||||
@@ -184,7 +192,24 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
<p class="description">
|
<p class="description">
|
||||||
<?php esc_html_e( 'Bepaal hoe productafbeeldingen worden meegestuurd: helemaal niet, als URL’s in de prompt of als Base64-bijlagen voor modellen die beeldcontext ondersteunen.', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Bepaal hoe productafbeeldingen worden meegestuurd: helemaal niet, als URL’s in de prompt of als Base64-bijlagen voor modellen die beeldcontext ondersteunen.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
|
</p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render_image_context_limit_field() {
|
||||||
|
$settings = $this->plugin->get_settings();
|
||||||
|
$limit = $this->plugin->get_image_context_limit( $settings );
|
||||||
|
?>
|
||||||
|
<input type="number"
|
||||||
|
name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[image_context_limit]"
|
||||||
|
min="1"
|
||||||
|
max="10"
|
||||||
|
step="1"
|
||||||
|
value="<?php echo esc_attr( $limit ); ?>"
|
||||||
|
class="small-text" />
|
||||||
|
<p class="description">
|
||||||
|
<?php esc_html_e( 'Stel hier het maximum aantal productafbeeldingen in dat wordt meegestuurd (we beginnen bij de uitgelichte afbeelding, gevolgd door de galerij).', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</p>
|
</p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -197,19 +222,19 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
$settings = $this->plugin->get_settings();
|
$settings = $this->plugin->get_settings();
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?php esc_html_e( 'Siti AI Productteksten', 'groq-ai-product-text' ); ?></h1>
|
<h1><?php esc_html_e( 'Siti AI Productteksten', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></h1>
|
||||||
<p style="margin-bottom:16px;">
|
<p style="margin-bottom:16px;">
|
||||||
<a href="<?php echo esc_url( admin_url( 'admin.php?page=groq-ai-product-text-prompts' ) ); ?>" class="button button-primary">
|
<a href="<?php echo esc_url( admin_url( 'admin.php?page=groq-ai-product-text-prompts' ) ); ?>" class="button button-primary">
|
||||||
<?php esc_html_e( 'Prompt instellingen', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Prompt instellingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</a>
|
</a>
|
||||||
<a href="<?php echo esc_url( admin_url( 'admin.php?page=groq-ai-product-text-modules' ) ); ?>" class="button button-secondary">
|
<a href="<?php echo esc_url( admin_url( 'admin.php?page=groq-ai-product-text-modules' ) ); ?>" class="button button-secondary">
|
||||||
<?php esc_html_e( 'Ga naar modules', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Ga naar modules', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</a>
|
</a>
|
||||||
<a href="<?php echo esc_url( admin_url( 'admin.php?page=groq-ai-product-text-logs' ) ); ?>" class="button">
|
<a href="<?php echo esc_url( admin_url( 'admin.php?page=groq-ai-product-text-logs' ) ); ?>" class="button">
|
||||||
<?php esc_html_e( 'Bekijk AI-logboek', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Bekijk AI-logboek', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p><?php esc_html_e( 'Kies je AI-aanbieder, stel de juiste API-sleutel en het gewenste model in.', 'groq-ai-product-text' ); ?></p>
|
<p><?php esc_html_e( 'Kies je AI-aanbieder, stel de juiste API-sleutel en het gewenste model in.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<form action="options.php" method="post">
|
<form action="options.php" method="post">
|
||||||
<?php
|
<?php
|
||||||
settings_fields( 'groq_ai_product_text_group' );
|
settings_fields( 'groq_ai_product_text_group' );
|
||||||
@@ -228,8 +253,8 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?php esc_html_e( 'Siti AI Modules', 'groq-ai-product-text' ); ?></h1>
|
<h1><?php esc_html_e( 'Siti AI Modules', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></h1>
|
||||||
<p><?php esc_html_e( 'Beheer aparte integraties zoals Rank Math. Het uitschakelen van een module verwijdert de bijbehorende AI-uitvoer automatisch uit de productmodal.', 'groq-ai-product-text' ); ?></p>
|
<p><?php esc_html_e( 'Beheer aparte integraties zoals Rank Math. Het uitschakelen van een module verwijdert de bijbehorende AI-uitvoer automatisch uit de productmodal.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<form action="options.php" method="post">
|
<form action="options.php" method="post">
|
||||||
<?php
|
<?php
|
||||||
settings_fields( 'groq_ai_product_text_group' );
|
settings_fields( 'groq_ai_product_text_group' );
|
||||||
@@ -249,13 +274,13 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
$settings = $this->plugin->get_settings();
|
$settings = $this->plugin->get_settings();
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?php esc_html_e( 'Prompt instellingen', 'groq-ai-product-text' ); ?></h1>
|
<h1><?php esc_html_e( 'Prompt instellingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></h1>
|
||||||
<p style="margin-bottom:16px;">
|
<p style="margin-bottom:16px;">
|
||||||
<a href="<?php echo esc_url( admin_url( 'options-general.php?page=groq-ai-product-text' ) ); ?>" class="button button-secondary">
|
<a href="<?php echo esc_url( admin_url( 'options-general.php?page=groq-ai-product-text' ) ); ?>" class="button button-secondary">
|
||||||
<?php esc_html_e( 'Terug naar algemene instellingen', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Terug naar algemene instellingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p><?php esc_html_e( 'Beheer hier de winkelcontext, standaardprompt, productcontext en response-format instellingen. Deze keuzes bepalen hoe elke prompt richting de AI wordt opgebouwd.', 'groq-ai-product-text' ); ?></p>
|
<p><?php esc_html_e( 'Beheer hier de winkelcontext, standaardprompt, productcontext en response-format instellingen. Deze keuzes bepalen hoe elke prompt richting de AI wordt opgebouwd.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<form action="options.php" method="post">
|
<form action="options.php" method="post">
|
||||||
<?php
|
<?php
|
||||||
settings_fields( 'groq_ai_product_text_group' );
|
settings_fields( 'groq_ai_product_text_group' );
|
||||||
@@ -264,8 +289,8 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
?>
|
?>
|
||||||
</form>
|
</form>
|
||||||
<div class="groq-ai-prompt-helper">
|
<div class="groq-ai-prompt-helper">
|
||||||
<h2><?php esc_html_e( 'Prompt generator', 'groq-ai-product-text' ); ?></h2>
|
<h2><?php esc_html_e( 'Prompt generator', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></h2>
|
||||||
<p><?php esc_html_e( 'Gebruik deze velden om belangrijke informatie voor de AI bij te houden (bijvoorbeeld tone of voice, USP’s of doelgroepen). Voeg ze toe aan je prompt met kopiëren en plakken.', 'groq-ai-product-text' ); ?></p>
|
<p><?php esc_html_e( 'Gebruik deze velden om belangrijke informatie voor de AI bij te houden (bijvoorbeeld tone of voice, USP’s of doelgroepen). Voeg ze toe aan je prompt met kopiëren en plakken.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<textarea class="large-text" rows="6" readonly><?php echo esc_textarea( $this->plugin->build_prompt_template_preview( $settings ) ); ?></textarea>
|
<textarea class="large-text" rows="6" readonly><?php echo esc_textarea( $this->plugin->build_prompt_template_preview( $settings ) ); ?></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -281,54 +306,54 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
$logs_table->prepare_items();
|
$logs_table->prepare_items();
|
||||||
?>
|
?>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?php esc_html_e( 'AI-logboek', 'groq-ai-product-text' ); ?></h1>
|
<h1><?php esc_html_e( 'AI-logboek', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></h1>
|
||||||
<p><?php esc_html_e( 'Bekijk recente AI-generaties inclusief status, gebruiker en tokens.', 'groq-ai-product-text' ); ?></p>
|
<p><?php esc_html_e( 'Bekijk recente AI-generaties inclusief status, gebruiker en tokens.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<form method="get">
|
<form method="get">
|
||||||
<input type="hidden" name="page" value="groq-ai-product-text-logs" />
|
<input type="hidden" name="page" value="groq-ai-product-text-logs" />
|
||||||
<?php $logs_table->search_box( __( 'Zoek logs', 'groq-ai-product-text' ), 'groq-ai-logs' ); ?>
|
<?php $logs_table->search_box( __( 'Zoek logs', GROQ_AI_PRODUCT_TEXT_DOMAIN ), 'groq-ai-logs' ); ?>
|
||||||
<?php $logs_table->display(); ?>
|
<?php $logs_table->display(); ?>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div id="groq-ai-log-modal" class="groq-ai-log-modal" aria-hidden="true">
|
<div id="groq-ai-log-modal" class="groq-ai-log-modal" aria-hidden="true">
|
||||||
<div class="groq-ai-log-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="groq-ai-log-modal-title">
|
<div class="groq-ai-log-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="groq-ai-log-modal-title">
|
||||||
<button type="button" class="groq-ai-log-modal__close" aria-label="<?php esc_attr_e( 'Sluiten', 'groq-ai-product-text' ); ?>">×</button>
|
<button type="button" class="groq-ai-log-modal__close" aria-label="<?php esc_attr_e( 'Sluiten', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>">×</button>
|
||||||
<div class="groq-ai-log-modal__content">
|
<div class="groq-ai-log-modal__content">
|
||||||
<h2 id="groq-ai-log-modal-title"><?php esc_html_e( 'Logdetails', 'groq-ai-product-text' ); ?></h2>
|
<h2 id="groq-ai-log-modal-title"><?php esc_html_e( 'Logdetails', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></h2>
|
||||||
<p class="description groq-ai-log-meta"></p>
|
<p class="description groq-ai-log-meta"></p>
|
||||||
<div class="groq-ai-log-fields">
|
<div class="groq-ai-log-fields">
|
||||||
<label>
|
<label>
|
||||||
<span><?php esc_html_e( 'Prompt', 'groq-ai-product-text' ); ?></span>
|
<span><?php esc_html_e( 'Prompt', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></span>
|
||||||
<textarea id="groq-ai-log-prompt" readonly rows="6"></textarea>
|
<textarea id="groq-ai-log-prompt" readonly rows="6"></textarea>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<span><?php esc_html_e( 'Response', 'groq-ai-product-text' ); ?></span>
|
<span><?php esc_html_e( 'Response', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></span>
|
||||||
<textarea id="groq-ai-log-response" readonly rows="6"></textarea>
|
<textarea id="groq-ai-log-response" readonly rows="6"></textarea>
|
||||||
</label>
|
</label>
|
||||||
<div class="groq-ai-log-tokens">
|
<div class="groq-ai-log-tokens">
|
||||||
<div>
|
<div>
|
||||||
<strong><?php esc_html_e( 'Tokens prompt', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Tokens prompt', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<span id="groq-ai-log-tokens-prompt">—</span>
|
<span id="groq-ai-log-tokens-prompt">—</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong><?php esc_html_e( 'Tokens response', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Tokens response', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<span id="groq-ai-log-tokens-completion">—</span>
|
<span id="groq-ai-log-tokens-completion">—</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong><?php esc_html_e( 'Tokens totaal', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Tokens totaal', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<span id="groq-ai-log-tokens-total">—</span>
|
<span id="groq-ai-log-tokens-total">—</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="groq-ai-log-images">
|
<div class="groq-ai-log-images">
|
||||||
<div>
|
<div>
|
||||||
<strong><?php esc_html_e( 'Afbeeldingsmodus', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Afbeeldingsmodus', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<span id="groq-ai-log-images-mode">—</span>
|
<span id="groq-ai-log-images-mode">—</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong><?php esc_html_e( 'Beschikbare afbeeldingen', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Beschikbare afbeeldingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<span id="groq-ai-log-images-available">—</span>
|
<span id="groq-ai-log-images-available">—</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong><?php esc_html_e( 'Base64 meegestuurd', 'groq-ai-product-text' ); ?></strong>
|
<strong><?php esc_html_e( 'Base64 meegestuurd', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></strong>
|
||||||
<span id="groq-ai-log-images-base64">—</span>
|
<span id="groq-ai-log-images-base64">—</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -436,7 +461,7 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
</option>
|
</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
<p class="description"><?php esc_html_e( 'Bepaal welke AI-dienst wordt aangesproken wanneer je teksten genereert.', 'groq-ai-product-text' ); ?></p>
|
<p class="description"><?php esc_html_e( 'Bepaal welke AI-dienst wordt aangesproken wanneer je teksten genereert.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,11 +477,11 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[model]"
|
name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[model]"
|
||||||
data-current-model="<?php echo esc_attr( $current_model ); ?>"
|
data-current-model="<?php echo esc_attr( $current_model ); ?>"
|
||||||
>
|
>
|
||||||
<option value=""><?php esc_html_e( 'Selecteer een model via "Live modellen ophalen"', 'groq-ai-product-text' ); ?></option>
|
<option value=""><?php esc_html_e( 'Selecteer een model via "Live modellen ophalen"', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></option>
|
||||||
</select>
|
</select>
|
||||||
<p class="description"><?php esc_html_e( 'Gebruik de knop hieronder om rechtstreeks via het API-endpoint beschikbare modellen op te halen. Zonder een live lijst blijft de selectie leeg.', 'groq-ai-product-text' ); ?></p>
|
<p class="description"><?php esc_html_e( 'Gebruik de knop hieronder om rechtstreeks via het API-endpoint beschikbare modellen op te halen. Zonder een live lijst blijft de selectie leeg.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<button type="button" class="button" id="groq-ai-refresh-models" style="margin-top:10px;">
|
<button type="button" class="button" id="groq-ai-refresh-models" style="margin-top:10px;">
|
||||||
<?php esc_html_e( 'Live modellen ophalen', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Live modellen ophalen', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</button>
|
</button>
|
||||||
<p id="groq-ai-refresh-models-status" class="description" aria-live="polite"></p>
|
<p id="groq-ai-refresh-models-status" class="description" aria-live="polite"></p>
|
||||||
</div>
|
</div>
|
||||||
@@ -476,7 +501,7 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
<?php
|
<?php
|
||||||
printf(
|
printf(
|
||||||
/* translators: %s: provider name */
|
/* translators: %s: provider name */
|
||||||
esc_html__( 'Voeg hier de API-sleutel voor %s toe.', 'groq-ai-product-text' ),
|
esc_html__( 'Voeg hier de API-sleutel voor %s toe.', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
esc_html( $provider->get_label() )
|
esc_html( $provider->get_label() )
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
@@ -489,15 +514,15 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
$settings = $this->plugin->get_settings();
|
$settings = $this->plugin->get_settings();
|
||||||
?>
|
?>
|
||||||
<textarea name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[store_context]" class="large-text" rows="4"><?php echo esc_textarea( $settings['store_context'] ); ?></textarea>
|
<textarea name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[store_context]" class="large-text" rows="4"><?php echo esc_textarea( $settings['store_context'] ); ?></textarea>
|
||||||
<p class="description"><?php esc_html_e( 'Beschrijf het merk, de tone of voice en andere relevante winkelinformatie.', 'groq-ai-product-text' ); ?></p>
|
<p class="description"><?php esc_html_e( 'Beschrijf het merk, de tone of voice en andere relevante winkelinformatie.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render_default_prompt_field() {
|
public function render_default_prompt_field() {
|
||||||
$settings = $this->plugin->get_settings();
|
$settings = $this->plugin->get_settings();
|
||||||
?>
|
?>
|
||||||
<textarea name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[default_prompt]" class="large-text" rows="4" placeholder="<?php esc_attr_e( 'Bijvoorbeeld: Schrijf een overtuigende productbeschrijving met nadruk op kwaliteit en levertijd.', 'groq-ai-product-text' ); ?>"><?php echo esc_textarea( $settings['default_prompt'] ); ?></textarea>
|
<textarea name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[default_prompt]" class="large-text" rows="4" placeholder="<?php esc_attr_e( 'Bijvoorbeeld: Schrijf een overtuigende productbeschrijving met nadruk op kwaliteit en levertijd.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>"><?php echo esc_textarea( $settings['default_prompt'] ); ?></textarea>
|
||||||
<p class="description"><?php esc_html_e( 'Deze tekst verschijnt vooraf ingevuld in de AI-popup, maar kan per product worden aangepast.', 'groq-ai-product-text' ); ?></p>
|
<p class="description"><?php esc_html_e( 'Deze tekst verschijnt vooraf ingevuld in de AI-popup, maar kan per product worden aangepast.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?></p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,10 +555,10 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
?>
|
?>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[response_format_compat]" value="1" <?php checked( $is_enabled ); ?> />
|
<input type="checkbox" name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[response_format_compat]" value="1" <?php checked( $is_enabled ); ?> />
|
||||||
<?php esc_html_e( 'Compatibele modus inschakelen (instructies toevoegen aan de prompt).', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Compatibele modus inschakelen (instructies toevoegen aan de prompt).', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</label>
|
</label>
|
||||||
<p class="description">
|
<p class="description">
|
||||||
<?php esc_html_e( 'Standaard gebruikt de plugin de response_format-functie van aanbieders zoals Groq en OpenAI voor gegarandeerde JSON-uitvoer. Schakel deze optie alleen in wanneer je problemen ervaart met oudere modellen of eigen integraties die deze functie niet ondersteunen.', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Standaard gebruikt de plugin de response_format-functie van aanbieders zoals Groq en OpenAI voor gegarandeerde JSON-uitvoer. Schakel deze optie alleen in wanneer je problemen ervaart met oudere modellen of eigen integraties die deze functie niet ondersteunen.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</p>
|
</p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -557,19 +582,19 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
<input type="hidden" name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[modules][rankmath][enabled]" value="0" />
|
<input type="hidden" name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[modules][rankmath][enabled]" value="0" />
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[modules][rankmath][enabled]" value="1" <?php checked( $enabled ); ?> <?php disabled( ! $rankmath_active ); ?> />
|
<input type="checkbox" name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[modules][rankmath][enabled]" value="1" <?php checked( $enabled ); ?> <?php disabled( ! $rankmath_active ); ?> />
|
||||||
<?php esc_html_e( 'Activeer Rank Math integratie (meta title, meta description en focus keywords genereren).', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Activeer Rank Math integratie (meta title, meta description en focus keywords genereren).', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</label>
|
</label>
|
||||||
<p class="description" style="margin-top:4px;">
|
<p class="description" style="margin-top:4px;">
|
||||||
<?php
|
<?php
|
||||||
if ( ! $rankmath_active ) {
|
if ( ! $rankmath_active ) {
|
||||||
esc_html_e( 'Installeer en activeer Rank Math om deze opties te gebruiken. Velden zijn momenteel alleen-lezen.', 'groq-ai-product-text' );
|
esc_html_e( 'Installeer en activeer Rank Math om deze opties te gebruiken. Velden zijn momenteel alleen-lezen.', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
} else {
|
} else {
|
||||||
esc_html_e( 'Wanneer ingeschakeld worden extra velden in de AI-modal getoond en automatisch gekoppeld aan Rank Math.', 'groq-ai-product-text' );
|
esc_html_e( 'Wanneer ingeschakeld worden extra velden in de AI-modal getoond en automatisch gekoppeld aan Rank Math.', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
<label for="groq-ai-rankmath-keywords">
|
<label for="groq-ai-rankmath-keywords">
|
||||||
<?php esc_html_e( 'Aantal focus keywords om te genereren', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Aantal focus keywords om te genereren', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
@@ -582,10 +607,10 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
<?php disabled( ! $rankmath_active ); ?>
|
<?php disabled( ! $rankmath_active ); ?>
|
||||||
/>
|
/>
|
||||||
<p class="description">
|
<p class="description">
|
||||||
<?php esc_html_e( 'Bepaal hoeveel zoekwoorden de AI maximaal mag teruggeven (bijvoorbeeld 3).', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Bepaal hoeveel zoekwoorden de AI maximaal mag teruggeven (bijvoorbeeld 3).', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</p>
|
</p>
|
||||||
<label for="groq-ai-rankmath-title-pixels">
|
<label for="groq-ai-rankmath-title-pixels">
|
||||||
<?php esc_html_e( 'Maximale meta title breedte (pixels)', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Maximale meta title breedte (pixels)', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
@@ -599,10 +624,10 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
<?php disabled( ! $rankmath_active ); ?>
|
<?php disabled( ! $rankmath_active ); ?>
|
||||||
/>
|
/>
|
||||||
<p class="description">
|
<p class="description">
|
||||||
<?php esc_html_e( 'Bepaal hoe breed (in pixels) de meta title maximaal mag zijn volgens de SERP-richtlijnen.', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Bepaal hoe breed (in pixels) de meta title maximaal mag zijn volgens de SERP-richtlijnen.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</p>
|
</p>
|
||||||
<label for="groq-ai-rankmath-pixels">
|
<label for="groq-ai-rankmath-pixels">
|
||||||
<?php esc_html_e( 'Maximale meta description breedte (pixels)', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Maximale meta description breedte (pixels)', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
@@ -616,7 +641,7 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
<?php disabled( ! $rankmath_active ); ?>
|
<?php disabled( ! $rankmath_active ); ?>
|
||||||
/>
|
/>
|
||||||
<p class="description">
|
<p class="description">
|
||||||
<?php esc_html_e( 'Gebruik het SERP-voorbeeld als referentie. De AI krijgt door dat de meta description deze pixelbreedte niet mag overschrijden.', 'groq-ai-product-text' ); ?>
|
<?php esc_html_e( 'Gebruik het SERP-voorbeeld als referentie. De AI krijgt door dat de meta description deze pixelbreedte niet mag overschrijden.', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
@@ -660,7 +685,7 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
'refreshNonce' => wp_create_nonce( 'groq_ai_refresh_models' ),
|
'refreshNonce' => wp_create_nonce( 'groq_ai_refresh_models' ),
|
||||||
'excludedModels' => Groq_AI_Model_Exclusions::get_all(),
|
'excludedModels' => Groq_AI_Model_Exclusions::get_all(),
|
||||||
'placeholders' => [
|
'placeholders' => [
|
||||||
'selectModel' => __( 'Selecteer een model via "Live modellen ophalen"', 'groq-ai-product-text' ),
|
'selectModel' => __( 'Selecteer een model via "Live modellen ophalen"', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -669,7 +694,7 @@ class Groq_AI_Product_Text_Settings_Page {
|
|||||||
$cached_models = $this->plugin->get_cached_models_for_provider( $provider_key );
|
$cached_models = $this->plugin->get_cached_models_for_provider( $provider_key );
|
||||||
$cached_models = Groq_AI_Model_Exclusions::filter_models( $provider_key, $cached_models );
|
$cached_models = Groq_AI_Model_Exclusions::filter_models( $provider_key, $cached_models );
|
||||||
$data['providers'][ $provider->get_key() ] = [
|
$data['providers'][ $provider->get_key() ] = [
|
||||||
'default_label' => sprintf( __( 'Gebruik standaardmodel (%s)', 'groq-ai-product-text' ), $provider->get_default_model() ),
|
'default_label' => sprintf( __( 'Gebruik standaardmodel (%s)', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $provider->get_default_model() ),
|
||||||
'models' => $cached_models,
|
'models' => $cached_models,
|
||||||
'supports_live' => $provider->supports_live_models(),
|
'supports_live' => $provider->supports_live_models(),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class Groq_AI_Ajax_Controller {
|
|||||||
|
|
||||||
public function handle_generate_text() {
|
public function handle_generate_text() {
|
||||||
if ( ! current_user_can( 'edit_products' ) ) {
|
if ( ! current_user_can( 'edit_products' ) ) {
|
||||||
wp_send_json_error( [ 'message' => __( 'Je hebt geen toestemming voor deze actie.', 'groq-ai-product-text' ) ], 403 );
|
wp_send_json_error( [ 'message' => __( 'Je hebt geen toestemming voor deze actie.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) ], 403 );
|
||||||
}
|
}
|
||||||
|
|
||||||
check_ajax_referer( 'groq_ai_generate', 'nonce' );
|
check_ajax_referer( 'groq_ai_generate', 'nonce' );
|
||||||
@@ -37,6 +37,7 @@ class Groq_AI_Ajax_Controller {
|
|||||||
$model = $this->plugin->get_selected_model( $provider, $settings );
|
$model = $this->plugin->get_selected_model( $provider, $settings );
|
||||||
$context_fields = $prompt_builder->parse_context_fields_from_request( isset( $_POST['context_fields'] ) ? $_POST['context_fields'] : '', $settings );
|
$context_fields = $prompt_builder->parse_context_fields_from_request( isset( $_POST['context_fields'] ) ? $_POST['context_fields'] : '', $settings );
|
||||||
$image_context_mode = $this->plugin->get_image_context_mode( $settings );
|
$image_context_mode = $this->plugin->get_image_context_mode( $settings );
|
||||||
|
$image_context_limit = $this->plugin->get_image_context_limit( $settings );
|
||||||
|
|
||||||
if ( 'none' === $image_context_mode ) {
|
if ( 'none' === $image_context_mode ) {
|
||||||
$context_fields['images'] = false;
|
$context_fields['images'] = false;
|
||||||
@@ -44,7 +45,8 @@ class Groq_AI_Ajax_Controller {
|
|||||||
|
|
||||||
$image_context_enabled = ! empty( $context_fields['images'] );
|
$image_context_enabled = ! empty( $context_fields['images'] );
|
||||||
$use_base64_payloads = $image_context_enabled && 'base64' === $image_context_mode && $provider->supports_image_context();
|
$use_base64_payloads = $image_context_enabled && 'base64' === $image_context_mode && $provider->supports_image_context();
|
||||||
$image_context_count = $image_context_enabled ? $prompt_builder->get_product_image_count( $post_id ) : 0;
|
$total_image_count = $image_context_enabled ? $prompt_builder->get_product_image_count( $post_id ) : 0;
|
||||||
|
$image_context_count = $image_context_enabled ? min( $image_context_limit, $total_image_count ) : 0;
|
||||||
|
|
||||||
$prompt_image_mode = 'none';
|
$prompt_image_mode = 'none';
|
||||||
if ( $image_context_enabled ) {
|
if ( $image_context_enabled ) {
|
||||||
@@ -59,17 +61,19 @@ class Groq_AI_Ajax_Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$product_context_text = $prompt_builder->build_product_context_block( $post_id, $context_fields, $prompt_image_mode );
|
$product_context_text = $prompt_builder->build_product_context_block( $post_id, $context_fields, $prompt_image_mode, $image_context_limit );
|
||||||
$image_context_payloads = [];
|
$image_context_payloads = [];
|
||||||
if ( $use_base64_payloads ) {
|
if ( $use_base64_payloads ) {
|
||||||
$image_context_payloads = $prompt_builder->get_product_image_payloads( $post_id );
|
$image_context_payloads = $prompt_builder->get_product_image_payloads( $post_id, $image_context_limit );
|
||||||
}
|
}
|
||||||
$prompt_with_context = $prompt_builder->prepend_context_to_prompt( $prompt, $product_context_text );
|
$prompt_with_context = $prompt_builder->prepend_context_to_prompt( $prompt, $product_context_text );
|
||||||
|
|
||||||
$image_context_meta = [
|
$image_context_meta = [
|
||||||
'requested_mode' => $image_context_mode,
|
'requested_mode' => $image_context_mode,
|
||||||
'effective_mode' => $prompt_image_mode,
|
'effective_mode' => $prompt_image_mode,
|
||||||
'available' => $image_context_count,
|
'limit' => $image_context_limit,
|
||||||
|
'available' => $total_image_count,
|
||||||
|
'used' => $image_context_count,
|
||||||
'base64_sent' => $use_base64_payloads ? count( $image_context_payloads ) : 0,
|
'base64_sent' => $use_base64_payloads ? count( $image_context_payloads ) : 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -160,7 +164,7 @@ class Groq_AI_Ajax_Controller {
|
|||||||
|
|
||||||
public function handle_refresh_models() {
|
public function handle_refresh_models() {
|
||||||
if ( ! current_user_can( 'manage_options' ) ) {
|
if ( ! current_user_can( 'manage_options' ) ) {
|
||||||
wp_send_json_error( [ 'message' => __( 'Geen toestemming.', 'groq-ai-product-text' ) ], 403 );
|
wp_send_json_error( [ 'message' => __( 'Geen toestemming.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) ], 403 );
|
||||||
}
|
}
|
||||||
|
|
||||||
check_ajax_referer( 'groq_ai_refresh_models', 'nonce' );
|
check_ajax_referer( 'groq_ai_refresh_models', 'nonce' );
|
||||||
@@ -169,13 +173,13 @@ class Groq_AI_Ajax_Controller {
|
|||||||
$api_key = isset( $_POST['apiKey'] ) ? sanitize_text_field( wp_unslash( $_POST['apiKey'] ) ) : '';
|
$api_key = isset( $_POST['apiKey'] ) ? sanitize_text_field( wp_unslash( $_POST['apiKey'] ) ) : '';
|
||||||
|
|
||||||
if ( empty( $provider_key ) || empty( $api_key ) ) {
|
if ( empty( $provider_key ) || empty( $api_key ) ) {
|
||||||
wp_send_json_error( [ 'message' => __( 'Provider en API-sleutel zijn verplicht.', 'groq-ai-product-text' ) ], 400 );
|
wp_send_json_error( [ 'message' => __( 'Provider en API-sleutel zijn verplicht.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) ], 400 );
|
||||||
}
|
}
|
||||||
|
|
||||||
$provider = $this->plugin->get_provider_manager()->get_provider( $provider_key );
|
$provider = $this->plugin->get_provider_manager()->get_provider( $provider_key );
|
||||||
|
|
||||||
if ( ! $provider || ! $provider->supports_live_models() ) {
|
if ( ! $provider || ! $provider->supports_live_models() ) {
|
||||||
wp_send_json_error( [ 'message' => __( 'Deze aanbieder ondersteunt het ophalen van modellen niet.', 'groq-ai-product-text' ) ], 400 );
|
wp_send_json_error( [ 'message' => __( 'Deze aanbieder ondersteunt het ophalen van modellen niet.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) ], 400 );
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $provider->fetch_live_models( $api_key );
|
$result = $provider->fetch_live_models( $api_key );
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ abstract class Groq_AI_Abstract_OpenAI_Provider implements Groq_AI_Provider_Inte
|
|||||||
public function fetch_live_models( $api_key ) {
|
public function fetch_live_models( $api_key ) {
|
||||||
$endpoint = $this->get_models_endpoint();
|
$endpoint = $this->get_models_endpoint();
|
||||||
if ( empty( $endpoint ) ) {
|
if ( empty( $endpoint ) ) {
|
||||||
return new WP_Error( 'groq_ai_models_endpoint_missing', __( 'Geen model-endpoint beschikbaar voor deze aanbieder.', 'groq-ai-product-text' ) );
|
return new WP_Error( 'groq_ai_models_endpoint_missing', __( 'Geen model-endpoint beschikbaar voor deze aanbieder.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = wp_remote_get(
|
$response = wp_remote_get(
|
||||||
@@ -41,7 +41,7 @@ abstract class Groq_AI_Abstract_OpenAI_Provider implements Groq_AI_Provider_Inte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $body['data'] ) || ! is_array( $body['data'] ) ) {
|
if ( empty( $body['data'] ) || ! is_array( $body['data'] ) ) {
|
||||||
return new WP_Error( 'groq_ai_empty_response', __( 'Geen modeldata ontvangen.', 'groq-ai-product-text' ) );
|
return new WP_Error( 'groq_ai_empty_response', __( 'Geen modeldata ontvangen.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$models = [];
|
$models = [];
|
||||||
@@ -52,7 +52,7 @@ abstract class Groq_AI_Abstract_OpenAI_Provider implements Groq_AI_Provider_Inte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $models ) ) {
|
if ( empty( $models ) ) {
|
||||||
return new WP_Error( 'groq_ai_empty_response', __( 'Geen modeldata ontvangen.', 'groq-ai-product-text' ) );
|
return new WP_Error( 'groq_ai_empty_response', __( 'Geen modeldata ontvangen.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $models;
|
return $models;
|
||||||
@@ -66,7 +66,7 @@ abstract class Groq_AI_Abstract_OpenAI_Provider implements Groq_AI_Provider_Inte
|
|||||||
$api_key = $this->get_api_key( $settings );
|
$api_key = $this->get_api_key( $settings );
|
||||||
|
|
||||||
if ( empty( $api_key ) ) {
|
if ( empty( $api_key ) ) {
|
||||||
return new WP_Error( 'groq_ai_missing_api_key', sprintf( __( 'Stel eerst de API-sleutel voor %s in.', 'groq-ai-product-text' ), $this->get_label() ) );
|
return new WP_Error( 'groq_ai_missing_api_key', sprintf( __( 'Stel eerst de API-sleutel voor %s in.', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $this->get_label() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$messages = [
|
$messages = [
|
||||||
@@ -116,7 +116,7 @@ abstract class Groq_AI_Abstract_OpenAI_Provider implements Groq_AI_Provider_Inte
|
|||||||
if ( empty( $body['choices'][0]['message']['content'] ) ) {
|
if ( empty( $body['choices'][0]['message']['content'] ) ) {
|
||||||
return new WP_Error(
|
return new WP_Error(
|
||||||
'groq_ai_empty_response',
|
'groq_ai_empty_response',
|
||||||
sprintf( __( 'Geen antwoord ontvangen van %s.', 'groq-ai-product-text' ), $this->get_label() )
|
sprintf( __( 'Geen antwoord ontvangen van %s.', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $this->get_label() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Groq_AI_Provider_Google implements Groq_AI_Provider_Interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_label() {
|
public function get_label() {
|
||||||
return __( 'Google AI (Gemini)', 'groq-ai-product-text' );
|
return __( 'Google AI (Gemini)', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_default_model() {
|
public function get_default_model() {
|
||||||
@@ -61,7 +61,7 @@ class Groq_AI_Provider_Google implements Groq_AI_Provider_Interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $body['models'] ) || ! is_array( $body['models'] ) ) {
|
if ( empty( $body['models'] ) || ! is_array( $body['models'] ) ) {
|
||||||
return new WP_Error( 'groq_ai_empty_response', __( 'Geen modeldata ontvangen.', 'groq-ai-product-text' ) );
|
return new WP_Error( 'groq_ai_empty_response', __( 'Geen modeldata ontvangen.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$models = [];
|
$models = [];
|
||||||
@@ -73,7 +73,7 @@ class Groq_AI_Provider_Google implements Groq_AI_Provider_Interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $models ) ) {
|
if ( empty( $models ) ) {
|
||||||
return new WP_Error( 'groq_ai_empty_response', __( 'Geen modeldata ontvangen.', 'groq-ai-product-text' ) );
|
return new WP_Error( 'groq_ai_empty_response', __( 'Geen modeldata ontvangen.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $models;
|
return $models;
|
||||||
@@ -87,7 +87,7 @@ class Groq_AI_Provider_Google implements Groq_AI_Provider_Interface {
|
|||||||
$api_key = isset( $settings[ $this->get_option_key() ] ) ? $settings[ $this->get_option_key() ] : '';
|
$api_key = isset( $settings[ $this->get_option_key() ] ) ? $settings[ $this->get_option_key() ] : '';
|
||||||
|
|
||||||
if ( empty( $api_key ) ) {
|
if ( empty( $api_key ) ) {
|
||||||
return new WP_Error( 'groq_ai_missing_api_key', sprintf( __( 'Stel eerst de API-sleutel voor %s in.', 'groq-ai-product-text' ), $this->get_label() ) );
|
return new WP_Error( 'groq_ai_missing_api_key', sprintf( __( 'Stel eerst de API-sleutel voor %s in.', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $this->get_label() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$endpoint = add_query_arg(
|
$endpoint = add_query_arg(
|
||||||
@@ -123,7 +123,7 @@ class Groq_AI_Provider_Google implements Groq_AI_Provider_Interface {
|
|||||||
$parts[] = [
|
$parts[] = [
|
||||||
'text' => sprintf(
|
'text' => sprintf(
|
||||||
/* translators: %s: image label */
|
/* translators: %s: image label */
|
||||||
__( 'Contextafbeelding: %s', 'groq-ai-product-text' ),
|
__( 'Contextafbeelding: %s', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
$label
|
$label
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@@ -181,7 +181,7 @@ class Groq_AI_Provider_Google implements Groq_AI_Provider_Interface {
|
|||||||
if ( empty( $body['candidates'][0]['content']['parts'] ) ) {
|
if ( empty( $body['candidates'][0]['content']['parts'] ) ) {
|
||||||
return new WP_Error(
|
return new WP_Error(
|
||||||
'groq_ai_empty_response',
|
'groq_ai_empty_response',
|
||||||
sprintf( __( 'Geen antwoord ontvangen van %s.', 'groq-ai-product-text' ), $this->get_label() )
|
sprintf( __( 'Geen antwoord ontvangen van %s.', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $this->get_label() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Groq_AI_Provider_Groq extends Groq_AI_Abstract_OpenAI_Provider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_label() {
|
public function get_label() {
|
||||||
return __( 'Groq', 'groq-ai-product-text' );
|
return __( 'Groq', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_default_model() {
|
public function get_default_model() {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class Groq_AI_Provider_OpenAI extends Groq_AI_Abstract_OpenAI_Provider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_label() {
|
public function get_label() {
|
||||||
return __( 'OpenAI', 'groq-ai-product-text' );
|
return __( 'OpenAI', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_default_model() {
|
public function get_default_model() {
|
||||||
|
|||||||
@@ -13,17 +13,17 @@ class Groq_AI_Prompt_Builder {
|
|||||||
|
|
||||||
public function build_system_prompt( $settings, $conversation_id ) {
|
public function build_system_prompt( $settings, $conversation_id ) {
|
||||||
$context = isset( $settings['store_context'] ) ? trim( $settings['store_context'] ) : '';
|
$context = isset( $settings['store_context'] ) ? trim( $settings['store_context'] ) : '';
|
||||||
$base_instruction = __( 'Je bent een copywriter voor een WooCommerce winkel en schrijft overtuigende productbeschrijvingen.', 'groq-ai-product-text' );
|
$base_instruction = __( 'Je bent een copywriter voor een WooCommerce winkel en schrijft overtuigende productbeschrijvingen.', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
|
|
||||||
if ( $context ) {
|
if ( $context ) {
|
||||||
$base_instruction = sprintf(
|
$base_instruction = sprintf(
|
||||||
__( 'Je bent een copywriter voor een WooCommerce winkel. Gebruik de volgende context indien beschikbaar: %s', 'groq-ai-product-text' ),
|
__( 'Je bent een copywriter voor een WooCommerce winkel. Gebruik de volgende context indien beschikbaar: %s', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
$context
|
$context
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
__( 'Conversatie-ID: %1$s. %2$s', 'groq-ai-product-text' ),
|
__( 'Conversatie-ID: %1$s. %2$s', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
$conversation_id,
|
$conversation_id,
|
||||||
$base_instruction
|
$base_instruction
|
||||||
);
|
);
|
||||||
@@ -46,7 +46,7 @@ class Groq_AI_Prompt_Builder {
|
|||||||
|
|
||||||
public function parse_structured_response( $raw, $settings = null ) {
|
public function parse_structured_response( $raw, $settings = null ) {
|
||||||
if ( empty( $raw ) ) {
|
if ( empty( $raw ) ) {
|
||||||
return new WP_Error( 'groq_ai_empty_response', __( 'Geen data ontvangen van de AI.', 'groq-ai-product-text' ) );
|
return new WP_Error( 'groq_ai_empty_response', __( 'Geen data ontvangen van de AI.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$clean = trim( $raw );
|
$clean = trim( $raw );
|
||||||
@@ -58,7 +58,7 @@ class Groq_AI_Prompt_Builder {
|
|||||||
$decoded = json_decode( $clean, true );
|
$decoded = json_decode( $clean, true );
|
||||||
|
|
||||||
if ( ! is_array( $decoded ) ) {
|
if ( ! is_array( $decoded ) ) {
|
||||||
return new WP_Error( 'groq_ai_parse_error', __( 'Kon de AI-respons niet als JSON lezen. Probeer het opnieuw.', 'groq-ai-product-text' ) );
|
return new WP_Error( 'groq_ai_parse_error', __( 'Kon de AI-respons niet als JSON lezen. Probeer het opnieuw.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = [
|
$fields = [
|
||||||
@@ -67,6 +67,40 @@ class Groq_AI_Prompt_Builder {
|
|||||||
'description' => trim( (string) ( $decoded['description'] ?? '' ) ),
|
'description' => trim( (string) ( $decoded['description'] ?? '' ) ),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$title_suggestions = [];
|
||||||
|
if ( isset( $decoded['title_suggestions'] ) && is_array( $decoded['title_suggestions'] ) ) {
|
||||||
|
foreach ( $decoded['title_suggestions'] as $suggestion ) {
|
||||||
|
$suggestion = sanitize_text_field( (string) $suggestion );
|
||||||
|
$suggestion = trim( preg_replace( '/\s+/', ' ', $suggestion ) );
|
||||||
|
|
||||||
|
if ( '' === $suggestion ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title_suggestions[] = $suggestion;
|
||||||
|
|
||||||
|
if ( count( $title_suggestions ) >= 3 ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $title_suggestions ) && '' !== $fields['title'] ) {
|
||||||
|
$title_suggestions[] = $fields['title'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( '' === $fields['title'] && ! empty( $title_suggestions ) ) {
|
||||||
|
$fields['title'] = $title_suggestions[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields['title_suggestions'] = $title_suggestions;
|
||||||
|
|
||||||
|
$slug_value = isset( $decoded['slug'] ) ? sanitize_title( $decoded['slug'] ) : '';
|
||||||
|
if ( '' === $slug_value && '' !== $fields['title'] ) {
|
||||||
|
$slug_value = sanitize_title( $fields['title'] );
|
||||||
|
}
|
||||||
|
$fields['slug'] = $slug_value;
|
||||||
|
|
||||||
if ( $this->settings_manager->is_module_enabled( 'rankmath', $settings ) ) {
|
if ( $this->settings_manager->is_module_enabled( 'rankmath', $settings ) ) {
|
||||||
$keyword_limit = $this->settings_manager->get_rankmath_focus_keyword_limit( $settings );
|
$keyword_limit = $this->settings_manager->get_rankmath_focus_keyword_limit( $settings );
|
||||||
$focus_keywords = [];
|
$focus_keywords = [];
|
||||||
@@ -98,8 +132,22 @@ class Groq_AI_Prompt_Builder {
|
|||||||
$fields['focus_keywords'] = implode( ', ', $focus_keywords );
|
$fields['focus_keywords'] = implode( ', ', $focus_keywords );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( implode( '', $fields ) === '' ) {
|
$primary_values = [
|
||||||
return new WP_Error( 'groq_ai_parse_error', __( 'De AI-respons bevatte geen bruikbare velden.', 'groq-ai-product-text' ) );
|
$fields['title'],
|
||||||
|
$fields['short_description'],
|
||||||
|
$fields['description'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$has_primary_content = false;
|
||||||
|
foreach ( $primary_values as $value ) {
|
||||||
|
if ( '' !== trim( (string) $value ) ) {
|
||||||
|
$has_primary_content = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $has_primary_content ) {
|
||||||
|
return new WP_Error( 'groq_ai_parse_error', __( 'De AI-respons bevatte geen bruikbare velden.', GROQ_AI_PRODUCT_TEXT_DOMAIN ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
@@ -125,7 +173,7 @@ class Groq_AI_Prompt_Builder {
|
|||||||
return $normalized;
|
return $normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build_product_context_block( $post_id, $fields, $image_mode = 'url' ) {
|
public function build_product_context_block( $post_id, $fields, $image_mode = 'url', $image_limit = 3 ) {
|
||||||
$post_id = absint( $post_id );
|
$post_id = absint( $post_id );
|
||||||
|
|
||||||
if ( ! $post_id ) {
|
if ( ! $post_id ) {
|
||||||
@@ -137,35 +185,35 @@ class Groq_AI_Prompt_Builder {
|
|||||||
if ( ! empty( $fields['title'] ) ) {
|
if ( ! empty( $fields['title'] ) ) {
|
||||||
$title = get_the_title( $post_id );
|
$title = get_the_title( $post_id );
|
||||||
if ( $title ) {
|
if ( $title ) {
|
||||||
$parts[] = sprintf( __( 'Titel: %s', 'groq-ai-product-text' ), wp_strip_all_tags( $title ) );
|
$parts[] = sprintf( __( 'Titel: %s', GROQ_AI_PRODUCT_TEXT_DOMAIN ), wp_strip_all_tags( $title ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $fields['short_description'] ) ) {
|
if ( ! empty( $fields['short_description'] ) ) {
|
||||||
$excerpt = get_post_field( 'post_excerpt', $post_id );
|
$excerpt = get_post_field( 'post_excerpt', $post_id );
|
||||||
if ( $excerpt ) {
|
if ( $excerpt ) {
|
||||||
$parts[] = sprintf( __( 'Korte beschrijving: %s', 'groq-ai-product-text' ), wp_strip_all_tags( $excerpt ) );
|
$parts[] = sprintf( __( 'Korte beschrijving: %s', GROQ_AI_PRODUCT_TEXT_DOMAIN ), wp_strip_all_tags( $excerpt ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $fields['description'] ) ) {
|
if ( ! empty( $fields['description'] ) ) {
|
||||||
$content = get_post_field( 'post_content', $post_id );
|
$content = get_post_field( 'post_content', $post_id );
|
||||||
if ( $content ) {
|
if ( $content ) {
|
||||||
$parts[] = sprintf( __( 'Beschrijving: %s', 'groq-ai-product-text' ), wp_strip_all_tags( $content ) );
|
$parts[] = sprintf( __( 'Beschrijving: %s', GROQ_AI_PRODUCT_TEXT_DOMAIN ), wp_strip_all_tags( $content ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $fields['attributes'] ) ) {
|
if ( ! empty( $fields['attributes'] ) ) {
|
||||||
$attributes = $this->get_product_attributes_text( $post_id );
|
$attributes = $this->get_product_attributes_text( $post_id );
|
||||||
if ( $attributes ) {
|
if ( $attributes ) {
|
||||||
$parts[] = sprintf( __( 'Attributen: %s', 'groq-ai-product-text' ), $attributes );
|
$parts[] = sprintf( __( 'Attributen: %s', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $attributes );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $fields['images'] ) && 'url' === $image_mode ) {
|
if ( ! empty( $fields['images'] ) && 'url' === $image_mode ) {
|
||||||
$images = $this->get_product_images_text( $post_id );
|
$images = $this->get_product_images_text( $post_id, $image_limit );
|
||||||
if ( $images ) {
|
if ( $images ) {
|
||||||
$parts[] = sprintf( __( 'Afbeeldingen: %s', 'groq-ai-product-text' ), $images );
|
$parts[] = sprintf( __( 'Afbeeldingen: %s', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $images );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +227,7 @@ class Groq_AI_Prompt_Builder {
|
|||||||
return $prompt;
|
return $prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
$intro = __( 'Gebruik de volgende productcontext bij het schrijven:', 'groq-ai-product-text' );
|
$intro = __( 'Gebruik de volgende productcontext bij het schrijven:', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
|
|
||||||
return $intro . "\n" . $context . "\n\n" . $prompt;
|
return $intro . "\n" . $context . "\n\n" . $prompt;
|
||||||
}
|
}
|
||||||
@@ -191,19 +239,36 @@ class Groq_AI_Prompt_Builder {
|
|||||||
$desc_pixels = $this->settings_manager->get_rankmath_meta_description_pixel_limit( $settings );
|
$desc_pixels = $this->settings_manager->get_rankmath_meta_description_pixel_limit( $settings );
|
||||||
|
|
||||||
$properties = [
|
$properties = [
|
||||||
|
'title_suggestions' => [
|
||||||
|
'type' => 'array',
|
||||||
|
'description' => __( 'Exact drie korte producttitelvoorstellen in het Nederlands. Kies de beste ook als title.', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
|
'minItems' => 3,
|
||||||
|
'maxItems' => 3,
|
||||||
|
'items' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'minLength' => 3,
|
||||||
|
'maxLength' => 120,
|
||||||
|
],
|
||||||
|
],
|
||||||
'title' => [
|
'title' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( 'Korte, overtuigende producttitel in het Nederlands.', 'groq-ai-product-text' ),
|
'description' => __( 'Korte, overtuigende producttitel in het Nederlands.', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'minLength' => 3,
|
'minLength' => 3,
|
||||||
],
|
],
|
||||||
|
'slug' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => __( 'Productslug voor de URL (alleen kleine letters, cijfers en koppeltekens).', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
|
'minLength' => 3,
|
||||||
|
'pattern' => '^[a-z0-9\\-]+$',
|
||||||
|
],
|
||||||
'short_description' => [
|
'short_description' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( "Korte HTML-beschrijving in <p>-tags (maximaal 2 alinea's).", 'groq-ai-product-text' ),
|
'description' => __( "Korte HTML-beschrijving in <p>-tags (maximaal 2 alinea's).", GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'minLength' => 10,
|
'minLength' => 10,
|
||||||
],
|
],
|
||||||
'description' => [
|
'description' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => __( 'Uitgebreide HTML-productbeschrijving met paragrafen en eventueel lijsten.', 'groq-ai-product-text' ),
|
'description' => __( 'Uitgebreide HTML-productbeschrijving met paragrafen en eventueel lijsten.', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'minLength' => 20,
|
'minLength' => 20,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -213,7 +278,7 @@ class Groq_AI_Prompt_Builder {
|
|||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => sprintf(
|
'description' => sprintf(
|
||||||
/* translators: 1: maximum character count, 2: maximum pixels */
|
/* translators: 1: maximum character count, 2: maximum pixels */
|
||||||
__( 'SEO-meta title (max. %1$d tekens en %2$d pixels).', 'groq-ai-product-text' ),
|
__( 'SEO-meta title (max. %1$d tekens en %2$d pixels).', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
60,
|
60,
|
||||||
$title_pixels
|
$title_pixels
|
||||||
),
|
),
|
||||||
@@ -223,7 +288,7 @@ class Groq_AI_Prompt_Builder {
|
|||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'description' => sprintf(
|
'description' => sprintf(
|
||||||
/* translators: 1: maximum character count, 2: maximum pixels */
|
/* translators: 1: maximum character count, 2: maximum pixels */
|
||||||
__( 'SEO-meta description (max. %1$d tekens en %2$d pixels).', 'groq-ai-product-text' ),
|
__( 'SEO-meta description (max. %1$d tekens en %2$d pixels).', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
160,
|
160,
|
||||||
$desc_pixels
|
$desc_pixels
|
||||||
),
|
),
|
||||||
@@ -231,7 +296,7 @@ class Groq_AI_Prompt_Builder {
|
|||||||
];
|
];
|
||||||
$properties['focus_keywords'] = [
|
$properties['focus_keywords'] = [
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'description' => __( 'Lijst met korte zoekwoorden zonder hashtags of extra tekst.', 'groq-ai-product-text' ),
|
'description' => __( 'Lijst met korte zoekwoorden zonder hashtags of extra tekst.', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'maxItems' => max( 1, $keyword_limit ),
|
'maxItems' => max( 1, $keyword_limit ),
|
||||||
'items' => [
|
'items' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
@@ -243,7 +308,7 @@ class Groq_AI_Prompt_Builder {
|
|||||||
$schema = [
|
$schema = [
|
||||||
'type' => 'object',
|
'type' => 'object',
|
||||||
'properties' => $properties,
|
'properties' => $properties,
|
||||||
'required' => [ 'title', 'short_description', 'description' ],
|
'required' => [ 'title_suggestions', 'title', 'slug', 'short_description', 'description' ],
|
||||||
'additionalProperties' => false,
|
'additionalProperties' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -258,7 +323,9 @@ class Groq_AI_Prompt_Builder {
|
|||||||
|
|
||||||
private function get_structured_response_instructions( $settings = null ) {
|
private function get_structured_response_instructions( $settings = null ) {
|
||||||
$schema_parts = [
|
$schema_parts = [
|
||||||
|
'"title_suggestions":["...","...","..."]',
|
||||||
'"title":"..."',
|
'"title":"..."',
|
||||||
|
'"slug":"..."',
|
||||||
'"short_description":"..."',
|
'"short_description":"..."',
|
||||||
'"description":"..."',
|
'"description":"..."',
|
||||||
];
|
];
|
||||||
@@ -274,7 +341,7 @@ class Groq_AI_Prompt_Builder {
|
|||||||
|
|
||||||
$instruction = sprintf(
|
$instruction = sprintf(
|
||||||
/* translators: %s: JSON structure example */
|
/* translators: %s: JSON structure example */
|
||||||
__( 'Geef ALLEEN een geldig JSON-object terug met deze structuur: %s. Gebruik dubbele aanhalingstekens, geen Markdown of extra tekst. Gebruik \\n voor regeleinden. Zorg dat zowel short_description als description nooit leeg zijn.', 'groq-ai-product-text' ),
|
__( 'Geef ALLEEN een geldig JSON-object terug met deze structuur: %s. Gebruik dubbele aanhalingstekens, geen Markdown of extra tekst. Gebruik \\n voor regeleinden. Zorg dat zowel short_description als description nooit leeg zijn.', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
$json_structure
|
$json_structure
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -284,14 +351,16 @@ class Groq_AI_Prompt_Builder {
|
|||||||
$desc_pixels = $this->settings_manager->get_rankmath_meta_description_pixel_limit( $settings );
|
$desc_pixels = $this->settings_manager->get_rankmath_meta_description_pixel_limit( $settings );
|
||||||
$instruction .= ' ' . sprintf(
|
$instruction .= ' ' . sprintf(
|
||||||
/* translators: 1: focus keyword limit, 2: meta title pixel limit, 3: meta description pixel limit */
|
/* translators: 1: focus keyword limit, 2: meta title pixel limit, 3: meta description pixel limit */
|
||||||
__( 'Beperk meta_title tot maximaal 60 tekens en %2$d pixels en meta_description tot maximaal 160 tekens en %3$d pixels. Lever maximaal %1$d focuskeywords in het focus_keywords-array (korte termen zonder hashtag of extra tekst).', 'groq-ai-product-text' ),
|
__( 'Beperk meta_title tot maximaal 60 tekens en %2$d pixels en meta_description tot maximaal 160 tekens en %3$d pixels. Lever maximaal %1$d focuskeywords in het focus_keywords-array (korte termen zonder hashtag of extra tekst).', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
$keyword_limit,
|
$keyword_limit,
|
||||||
$title_pixels,
|
$title_pixels,
|
||||||
$desc_pixels
|
$desc_pixels
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$instruction .= ' ' . __( 'Zorg dat short_description en description geldige HTML bevatten (gebruik minimaal <p>-tags en waar relevant lijstjes of benadrukking). Voeg geen extra tekst buiten het JSON-object toe.', 'groq-ai-product-text' );
|
$instruction .= ' ' . __( 'Lever exact drie verschillende titelvoorstellen in title_suggestions en kopieer de beste keuze naar title.', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
|
$instruction .= ' ' . __( 'Zorg dat short_description en description geldige HTML bevatten (gebruik minimaal <p>-tags en waar relevant lijstjes of benadrukking). Voeg geen extra tekst buiten het JSON-object toe.', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
|
$instruction .= ' ' . __( 'Maak de slug URL-vriendelijk, gebruik alleen kleine letters, cijfers en koppeltekens en geen spaties.', GROQ_AI_PRODUCT_TEXT_DOMAIN );
|
||||||
|
|
||||||
return $instruction;
|
return $instruction;
|
||||||
}
|
}
|
||||||
@@ -358,9 +427,14 @@ class Groq_AI_Prompt_Builder {
|
|||||||
return implode( '; ', $lines );
|
return implode( '; ', $lines );
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_product_images_text( $post_id ) {
|
private function get_product_images_text( $post_id, $limit = 3 ) {
|
||||||
|
$limit = max( 0, (int) $limit );
|
||||||
$image_ids = $this->get_product_image_ids( $post_id );
|
$image_ids = $this->get_product_image_ids( $post_id );
|
||||||
|
|
||||||
|
if ( $limit > 0 ) {
|
||||||
|
$image_ids = array_slice( $image_ids, 0, $limit );
|
||||||
|
}
|
||||||
|
|
||||||
if ( empty( $image_ids ) ) {
|
if ( empty( $image_ids ) ) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -380,7 +454,13 @@ class Groq_AI_Prompt_Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get_product_image_payloads( $post_id, $limit = 3, $max_filesize = 1572864 ) {
|
public function get_product_image_payloads( $post_id, $limit = 3, $max_filesize = 1572864 ) {
|
||||||
$image_ids = array_slice( $this->get_product_image_ids( $post_id ), 0, max( 1, (int) $limit ) );
|
$limit = max( 0, (int) $limit );
|
||||||
|
|
||||||
|
if ( $limit <= 0 ) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$image_ids = array_slice( $this->get_product_image_ids( $post_id ), 0, $limit );
|
||||||
|
|
||||||
if ( empty( $image_ids ) ) {
|
if ( empty( $image_ids ) ) {
|
||||||
return [];
|
return [];
|
||||||
@@ -476,7 +556,7 @@ class Groq_AI_Prompt_Builder {
|
|||||||
$label = trim( wp_strip_all_tags( (string) $label ) );
|
$label = trim( wp_strip_all_tags( (string) $label ) );
|
||||||
|
|
||||||
if ( '' === $label ) {
|
if ( '' === $label ) {
|
||||||
$label = sprintf( __( 'Afbeelding %d', 'groq-ai-product-text' ), $position );
|
$label = sprintf( __( 'Afbeelding %d', GROQ_AI_PRODUCT_TEXT_DOMAIN ), $position );
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = get_attached_file( $attachment_id );
|
$path = get_attached_file( $attachment_id );
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class Groq_AI_Settings_Manager {
|
|||||||
'context_fields' => $this->get_default_context_fields(),
|
'context_fields' => $this->get_default_context_fields(),
|
||||||
'modules' => $this->get_default_modules_settings(),
|
'modules' => $this->get_default_modules_settings(),
|
||||||
'image_context_mode' => 'url',
|
'image_context_mode' => 'url',
|
||||||
|
'image_context_limit' => 3,
|
||||||
'response_format_compat' => false,
|
'response_format_compat' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -59,6 +60,9 @@ class Groq_AI_Settings_Manager {
|
|||||||
$settings['image_context_mode'] = 'url';
|
$settings['image_context_mode'] = 'url';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$limit = isset( $settings['image_context_limit'] ) ? $this->sanitize_image_context_limit_value( $settings['image_context_limit'] ) : 3;
|
||||||
|
$settings['image_context_limit'] = $limit;
|
||||||
|
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +84,7 @@ class Groq_AI_Settings_Manager {
|
|||||||
'context_fields' => $this->get_default_context_fields(),
|
'context_fields' => $this->get_default_context_fields(),
|
||||||
'modules' => $this->get_default_modules_settings(),
|
'modules' => $this->get_default_modules_settings(),
|
||||||
'image_context_mode' => 'url',
|
'image_context_mode' => 'url',
|
||||||
|
'image_context_limit' => 3,
|
||||||
'response_format_compat' => false,
|
'response_format_compat' => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -104,6 +109,8 @@ class Groq_AI_Settings_Manager {
|
|||||||
$image_mode = 'url';
|
$image_mode = 'url';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$image_limit = isset( $input['image_context_limit'] ) ? $this->sanitize_image_context_limit_value( $input['image_context_limit'] ) : $defaults['image_context_limit'];
|
||||||
|
|
||||||
$context_fields = $this->normalize_context_fields( $context_posted ? $raw_input['context_fields'] : $defaults['context_fields'] );
|
$context_fields = $this->normalize_context_fields( $context_posted ? $raw_input['context_fields'] : $defaults['context_fields'] );
|
||||||
|
|
||||||
if ( 'none' === $image_mode ) {
|
if ( 'none' === $image_mode ) {
|
||||||
@@ -122,6 +129,7 @@ class Groq_AI_Settings_Manager {
|
|||||||
'google_api_key' => sanitize_text_field( $input['google_api_key'] ),
|
'google_api_key' => sanitize_text_field( $input['google_api_key'] ),
|
||||||
'response_format_compat' => ! empty( $raw_input['response_format_compat'] ),
|
'response_format_compat' => ! empty( $raw_input['response_format_compat'] ),
|
||||||
'image_context_mode' => $image_mode,
|
'image_context_mode' => $image_mode,
|
||||||
|
'image_context_limit' => $image_limit,
|
||||||
'context_fields' => $context_fields,
|
'context_fields' => $context_fields,
|
||||||
'modules' => $this->sanitize_modules_settings(
|
'modules' => $this->sanitize_modules_settings(
|
||||||
$modules_posted ? $raw_input['modules'] : [],
|
$modules_posted ? $raw_input['modules'] : [],
|
||||||
@@ -136,28 +144,28 @@ class Groq_AI_Settings_Manager {
|
|||||||
if ( null === $this->context_field_definitions ) {
|
if ( null === $this->context_field_definitions ) {
|
||||||
$this->context_field_definitions = [
|
$this->context_field_definitions = [
|
||||||
'title' => [
|
'title' => [
|
||||||
'label' => __( 'Producttitel', 'groq-ai-product-text' ),
|
'label' => __( 'Producttitel', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'description' => __( 'Voeg de huidige producttitel toe als context.', 'groq-ai-product-text' ),
|
'description' => __( 'Voeg de huidige producttitel toe als context.', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'default' => true,
|
'default' => true,
|
||||||
],
|
],
|
||||||
'short_description' => [
|
'short_description' => [
|
||||||
'label' => __( 'Korte beschrijving', 'groq-ai-product-text' ),
|
'label' => __( 'Korte beschrijving', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'description' => __( 'Gebruik de bestaande korte beschrijving (indien aanwezig).', 'groq-ai-product-text' ),
|
'description' => __( 'Gebruik de bestaande korte beschrijving (indien aanwezig).', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'default' => true,
|
'default' => true,
|
||||||
],
|
],
|
||||||
'description' => [
|
'description' => [
|
||||||
'label' => __( 'Volledige beschrijving', 'groq-ai-product-text' ),
|
'label' => __( 'Volledige beschrijving', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'description' => __( 'Stuurt de huidige productbeschrijving mee als bronmateriaal.', 'groq-ai-product-text' ),
|
'description' => __( 'Stuurt de huidige productbeschrijving mee als bronmateriaal.', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'default' => true,
|
'default' => true,
|
||||||
],
|
],
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'label' => __( 'Attributen', 'groq-ai-product-text' ),
|
'label' => __( 'Attributen', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'description' => __( 'Voeg gestructureerde productattributen toe (zoals kleur, maat, materiaal).', 'groq-ai-product-text' ),
|
'description' => __( 'Voeg gestructureerde productattributen toe (zoals kleur, maat, materiaal).', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'default' => false,
|
'default' => false,
|
||||||
],
|
],
|
||||||
'images' => [
|
'images' => [
|
||||||
'label' => __( 'Afbeeldingen', 'groq-ai-product-text' ),
|
'label' => __( 'Afbeeldingen', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'description' => __( 'Voeg een korte lijst toe met productafbeeldingen (beschrijving + URL).', 'groq-ai-product-text' ),
|
'description' => __( 'Voeg een korte lijst toe met productafbeeldingen (beschrijving + URL).', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||||
'default' => false,
|
'default' => false,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -268,6 +276,16 @@ class Groq_AI_Settings_Manager {
|
|||||||
return in_array( $mode, $allowed_modes, true ) ? $mode : 'url';
|
return in_array( $mode, $allowed_modes, true ) ? $mode : 'url';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_image_context_limit( $settings = null ) {
|
||||||
|
if ( null === $settings ) {
|
||||||
|
$settings = $this->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit = isset( $settings['image_context_limit'] ) ? $settings['image_context_limit'] : 3;
|
||||||
|
|
||||||
|
return $this->sanitize_image_context_limit_value( $limit );
|
||||||
|
}
|
||||||
|
|
||||||
public function is_response_format_compat_enabled( $settings = null ) {
|
public function is_response_format_compat_enabled( $settings = null ) {
|
||||||
if ( null === $settings ) {
|
if ( null === $settings ) {
|
||||||
$settings = $this->all();
|
$settings = $this->all();
|
||||||
@@ -341,4 +359,14 @@ class Groq_AI_Settings_Manager {
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function sanitize_image_context_limit_value( $value ) {
|
||||||
|
$limit = absint( $value );
|
||||||
|
|
||||||
|
if ( $limit <= 0 ) {
|
||||||
|
$limit = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return min( 10, $limit );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
0
languages/.gitkeep
Normal file
0
languages/.gitkeep
Normal file
Reference in New Issue
Block a user