';
echo '
AI Product Assistant Debug Information
';
echo '
Plugin Version: ' . esc_html(AIPA_VERSION) . '
';
// API Settings
echo '
';
echo 'API Settings:
';
echo 'API Provider: ' . esc_html(isset($options['api_provider']) ? $options['api_provider'] : 'Not set') . '
';
echo 'API URL: ' . esc_html(isset($options['api_url']) && !empty($options['api_url']) ? $options['api_url'] : 'Using default URL') . '
';
echo 'API Model: ' . esc_html(isset($options['api_model']) ? $options['api_model'] : 'Not set') . '
';
echo 'API Key Set: ' . esc_html(isset($options['api_key']) && !empty($options['api_key']) ? 'Yes' : 'No') . '
';
if (isset($options['format_template'])) {
echo 'Response Format Template: ' . esc_html($options['format_template']) . '
';
}
echo '
';
// Search Settings
echo '
';
echo 'Search Settings:
';
// Search Fields
echo 'Search Fields: ';
$search_fields = isset($options['search_fields']) ? $options['search_fields'] : array();
$enabled_fields = array();
if (isset($search_fields['title']) && $search_fields['title']) $enabled_fields[] = 'Title';
if (isset($search_fields['short_description']) && $search_fields['short_description']) $enabled_fields[] = 'Short Description';
if (isset($search_fields['content']) && $search_fields['content']) $enabled_fields[] = 'Content';
if (isset($search_fields['categories']) && $search_fields['categories']) $enabled_fields[] = 'Categories';
if (isset($search_fields['attributes']) && $search_fields['attributes']) $enabled_fields[] = 'Attributes';
if (isset($search_fields['regular_price']) && $search_fields['regular_price']) $enabled_fields[] = 'Regular Price';
if (isset($search_fields['sale_price']) && $search_fields['sale_price']) $enabled_fields[] = 'Sale Price';
echo esc_html(implode(', ', $enabled_fields)) . '
';
// Search Button Settings
echo 'Show Floating Search Button: ' . (isset($options['show_floating_button']) && $options['show_floating_button'] ? 'Yes' : 'No') . '
';
echo 'Search Button Icon Type: ' . esc_html(isset($options['search_button_icon_type']) ? $options['search_button_icon_type'] : 'Default') . '
';
echo 'Search Button Icon Text: ' . esc_html(isset($options['search_button_icon']) ? $options['search_button_icon'] : 'Not set') . '
';
echo 'Search Button Icon Image: ' . (isset($options['search_button_icon_image']) && !empty($options['search_button_icon_image']) ? 'Set' : 'Not set') . '
';
// Inline Search Button Settings
echo 'Inline Button Icon Type: ' . esc_html(isset($options['button_icon_type']) ? $options['button_icon_type'] : 'Default') . '
';
echo 'Inline Button Icon Text: ' . esc_html(isset($options['button_icon']) ? $options['button_icon'] : 'Not set') . '
';
echo 'Inline Button Icon Image: ' . (isset($options['button_icon_image']) && !empty($options['button_icon_image']) ? 'Set' : 'Not set') . '
';
// Display Options
echo 'Show Out of Stock Products: ' . (isset($options['show_out_of_stock']) && $options['show_out_of_stock'] ? 'Yes' : 'No') . '
';
echo 'Show AI Explanation: ' . (isset($options['show_explanation']) && $options['show_explanation'] ? 'Yes' : 'No') . '
';
echo 'Show Add to Cart Button: ' . (isset($options['show_add_to_cart']) && $options['show_add_to_cart'] ? 'Yes' : 'No') . '
';
echo 'Use Native Template: ' . (isset($options['use_native_template']) && $options['use_native_template'] ? 'Yes' : 'No') . '
';
echo '
';
// Cart Analysis Settings
echo '
';
echo 'Cart Analysis Settings:
';
echo 'Enable Cart Analysis: ' . (isset($options['enable_cart_analysis']) && $options['enable_cart_analysis'] ? 'Yes' : 'No') . '
';
echo '
';
// Performance Settings
echo '
';
echo 'Performance Settings:
';
echo 'Products Per Batch: ' . esc_html(isset($options['search_batch_size']) ? $options['search_batch_size'] : '100') . '
';
// Calculate dynamic default for max batches
$display_max_batches = 1; // fallback
if (isset($options['max_batches'])) {
$display_max_batches = $options['max_batches'];
} else {
$batch_size_for_calc = isset($options['search_batch_size']) ? intval($options['search_batch_size']) : 100;
if ($product_count > 0) {
$display_max_batches = ceil($product_count / $batch_size_for_calc);
}
}
echo 'Max Batches for Deep Search: ' . esc_html($display_max_batches) . '
';
// Description length limits
echo 'Product Description Length Limit: ' . esc_html(isset($options['description_length_limit']) ? $options['description_length_limit'] : 'Not set') . '
';
echo 'Short Description Length Limit: ' . esc_html(isset($options['short_description_length_limit']) ? $options['short_description_length_limit'] : 'Not set') . '
';
// Product count information
$product_count = (int) wp_count_posts('product')->publish;
echo 'Total Products: ' . esc_html($product_count) . '
';
// Calculate approximate token usage
$batch_size = isset($options['search_batch_size']) ? intval($options['search_batch_size']) : 100;
$token_estimate = $batch_size * 150 + 300; // Rough estimate
echo 'Estimated Token Usage Per Batch: ~' . esc_html($token_estimate) . '
';
// Use the same dynamic calculation for max batches
echo 'Estimated Token Usage for Full Deep Search: ~' . esc_html($token_estimate * $display_max_batches) . '
';
echo '
';
// Script Loading Check
echo '
';
echo 'Script Loading Check:
';
echo 'Frontend JS Loaded: ' . (wp_script_is('aipa-frontend-js') ? 'Yes' : 'No') . '
';
echo 'Frontend CSS Loaded: ' . (wp_style_is('aipa-frontend-css') ? 'Yes' : 'No') . '
';
echo 'Admin JS Loaded: ' . (wp_script_is('aipa-admin-script') ? 'Yes' : 'No') . '
';
echo 'Admin CSS Loaded: ' . (wp_style_is('aipa-admin-style') ? 'Yes' : 'No') . '
';
echo '
';
echo '
';
}
}
add_action('wp_footer', 'aipa_debug_mode');
add_action('admin_footer', 'aipa_debug_mode'); // Also show in admin interface