| @@ -512,32 +512,40 @@ | ||
| 512 | 512 | <label class="mxch-field-label" for="mxch-content-model"><?php esc_html_e('Content Model', 'mxchat'); ?></label> |
| 513 | 513 | <div class="mxch-field-control"> |
| 514 | 514 | <select id="mxch-content-model" data-field="content_model" class="mxch-cg-select"> |
| 515 | 515 | <?php |
| 516 | - $content_model = $options['content_model'] ?? ($options['model'] ?? 'gpt-5.1-chat-latest'); | |
| 517 | - $models = array( | |
| 518 | - 'OpenAI' => array( | |
| 519 | - 'gpt-5.4' => 'GPT-5.4', | |
| 520 | - 'gpt-5.2' => 'GPT-5.2', | |
| 521 | - 'gpt-5.1-chat-latest' => 'GPT-5.1', | |
| 522 | - 'gpt-5' => 'GPT-5', | |
| 523 | - ), | |
| 524 | - 'Anthropic' => array( | |
| 525 | - 'claude-opus-4-6' => 'Claude Opus 4.6', | |
| 526 | - 'claude-sonnet-4-6' => 'Claude Sonnet 4.6', | |
| 527 | - 'claude-haiku-4-5-20251001' => 'Claude Haiku 4.5', | |
| 528 | - ), | |
| 529 | - 'Google' => array( | |
| 530 | - 'gemini-3-pro-preview' => 'Gemini 3 Pro', | |
| 531 | - 'gemini-2.5-pro' => 'Gemini 2.5 Pro', | |
| 532 | - ), | |
| 533 | - 'xAI' => array( | |
| 534 | - 'grok-4-0709' => 'Grok 4', | |
| 535 | - 'grok-4-1-fast-non-reasoning' => 'Grok 4.1 Fast', | |
| 536 | - 'grok-code-fast-1' => 'Grok Code Fast', | |
| 537 | - ), | |
| 516 | + $content_model = $options['content_model'] ?? ($options['model'] ?? 'gpt-5.6-sol'); | |
| 517 | + // Catalog-derived (plan ccb751): this select was the seventh | |
| 518 | + // hand-maintained model map and had drifted (it still offered | |
| 519 | + // a code model for content generation). It now renders from | |
| 520 | + // MxChat_Model_Catalog, restricted to the providers the | |
| 521 | + // generator can actually dispatch to — see | |
| 522 | + // MxChat_Content_Generator::supported_content_providers(). | |
| 523 | + $model_groups = MxChat_Model_Catalog::settings_dropdown_groups( | |
| 524 | + $content_model, | |
| 525 | + MxChat_Content_Generator::supported_content_providers() | |
| 538 | 526 | ); |
| 539 | - foreach ($models as $group => $group_models) { | |
| 527 | + // Round-trip guard: an install saved on an id the catalog no | |
| 528 | + // longer lists (e.g. grok-code-fast-1) keeps its selection | |
| 529 | + // rendered instead of silently snapping to the first option | |
| 530 | + // on the next save. | |
| 531 | + $mxch_cg_model_in_groups = false; | |
| 532 | + foreach ($model_groups as $group_models) { | |
| 533 | + if (array_key_exists($content_model, $group_models)) { | |
| 534 | + $mxch_cg_model_in_groups = true; | |
| 535 | + break; | |
| 536 | + } | |
| 537 | + } | |
| 538 | + if (!$mxch_cg_model_in_groups && $content_model !== '') { | |
| 539 | + $model_groups[__('Currently saved', 'mxchat')] = array( | |
| 540 | + /* translators: %s: model id */ | |
| 541 | + $content_model => sprintf(__('%s — no longer offered, choose a replacement', 'mxchat'), $content_model), | |
| 542 | + ); | |
| 543 | + } | |
| 544 | + foreach ($model_groups as $group => $group_models) { | |
| 545 | + if (empty($group_models)) { | |
| 546 | + continue; | |
| 547 | + } | |
| 540 | 548 | echo '<optgroup label="' . esc_attr($group) . '">'; |
| 541 | 549 | foreach ($group_models as $value => $label) { |
| 542 | 550 | $selected = selected($content_model, $value, false); |
| 543 | 551 | echo '<option value="' . esc_attr($value) . '" ' . $selected . '>' . esc_html($label) . '</option>'; |
| @@ -556,8 +564,9 @@ | ||
| 556 | 564 | <div class="mxch-field-control"> |
| 557 | 565 | <?php $image_model = $options['content_image_model'] ?? 'gpt-image-1.5'; ?> |
| 558 | 566 | <select id="mxch-image-model" data-field="content_image_model" class="mxch-cg-select"> |
| 559 | 567 | <optgroup label="<?php esc_attr_e('OpenAI', 'mxchat'); ?>"> |
| 568 | + <option value="gpt-image-2" <?php selected($image_model, 'gpt-image-2'); ?>><?php esc_html_e('GPT Image 2 (Latest)', 'mxchat'); ?></option> | |
| 560 | 569 | <option value="gpt-image-1.5" <?php selected($image_model, 'gpt-image-1.5'); ?>><?php esc_html_e('GPT Image 1.5', 'mxchat'); ?></option> |
| 561 | 570 | </optgroup> |
| 562 | 571 | <optgroup label="<?php esc_attr_e('xAI', 'mxchat'); ?>"> |
| 563 | 572 | <option value="grok-imagine-image-pro" <?php selected($image_model, 'grok-imagine-image-pro'); ?>><?php esc_html_e('Grok Imagine Pro', 'mxchat'); ?></option> |
| @@ -571,8 +580,32 @@ | ||
| 571 | 580 | </div> |
| 572 | 581 | <p class="mxch-field-description"><?php esc_html_e('Select the AI model used for generating images within your content.', 'mxchat'); ?></p> |
| 573 | 582 | </div> |
| 574 | 583 | |
| 584 | + <!-- Image Quality (GPT Image only) --> | |
| 585 | + <div class="mxch-field"> | |
| 586 | + <label class="mxch-field-label" for="mxch-image-quality"><?php esc_html_e('Image Quality', 'mxchat'); ?></label> | |
| 587 | + <div class="mxch-field-control"> | |
| 588 | + <?php $image_quality = $options['content_image_quality'] ?? 'auto'; ?> | |
| 589 | + <?php $quality_supported = (strpos($image_model, 'gpt-image') === 0); ?> | |
| 590 | + <select id="mxch-image-quality" data-field="content_image_quality" class="mxch-cg-select"<?php echo $quality_supported ? '' : ' disabled'; ?>> | |
| 591 | + <option value="auto" <?php selected($image_quality, 'auto'); ?>><?php esc_html_e('Auto (default)', 'mxchat'); ?></option> | |
| 592 | + <option value="low" <?php selected($image_quality, 'low'); ?>><?php esc_html_e('Low (fastest, cheapest)', 'mxchat'); ?></option> | |
| 593 | + <option value="medium" <?php selected($image_quality, 'medium'); ?>><?php esc_html_e('Medium', 'mxchat'); ?></option> | |
| 594 | + <option value="high" <?php selected($image_quality, 'high'); ?>><?php esc_html_e('High (best, slowest)', 'mxchat'); ?></option> | |
| 595 | + </select> | |
| 596 | + </div> | |
| 597 | + <p class="mxch-field-description"><?php esc_html_e('Quality control for OpenAI GPT Image models only. Grok Imagine and Gemini image models ignore this setting (their APIs do not expose an equivalent parameter).', 'mxchat'); ?></p> | |
| 598 | + </div> | |
| 599 | + <script>(function(){ | |
| 600 | + var m = document.getElementById('mxch-image-model'); | |
| 601 | + var q = document.getElementById('mxch-image-quality'); | |
| 602 | + if (!m || !q || q._wired) { return; } q._wired = true; | |
| 603 | + function sync(){ q.disabled = (m.value || '').indexOf('gpt-image') !== 0; } | |
| 604 | + m.addEventListener('change', sync); | |
| 605 | + sync(); | |
| 606 | + })();</script> | |
| 607 | + | |
| 575 | 608 | <!-- Enable Image Generation --> |
| 576 | 609 | <div class="mxch-field"> |
| 577 | 610 | <label class="mxch-toggle"> |
| 578 | 611 | <?php $enable_images = $options['content_enable_images'] ?? 'on'; ?> |
| @@ -582,8 +615,35 @@ | ||
| 582 | 615 | </label> |
| 583 | 616 | <p class="mxch-field-description"><?php esc_html_e('When enabled, AI will generate and place images throughout your content. When disabled, pages are generated with text-only layouts.', 'mxchat'); ?></p> |
| 584 | 617 | </div> |
| 585 | 618 | |
| 619 | + <!-- Images per Article --> | |
| 620 | + <div class="mxch-field"> | |
| 621 | + <label class="mxch-field-label" for="mxch-image-count"><?php esc_html_e('Images per Article', 'mxchat'); ?></label> | |
| 622 | + <div class="mxch-field-control"> | |
| 623 | + <?php $image_count = max(1, min(5, (int) ($options['content_image_count'] ?? 3))); ?> | |
| 624 | + <?php $images_on = ($options['content_enable_images'] ?? 'on') === 'on'; ?> | |
| 625 | + <div class="mxch-cg-slider-row"> | |
| 626 | + <input type="range" min="1" max="5" step="1" value="<?php echo esc_attr($image_count); ?>" | |
| 627 | + data-field="content_image_count" id="mxch-image-count" class="mxch-cg-slider"<?php echo $images_on ? '' : ' disabled'; ?>> | |
| 628 | + <span id="mxch-image-count-val" class="mxch-cg-slider-value"><?php echo esc_html($image_count); ?></span> | |
| 629 | + </div> | |
| 630 | + </div> | |
| 631 | + <p class="mxch-field-description"><?php esc_html_e('How many images to generate and place in each article (1–5). Default 3. The AI may generate fewer if the article has few sections suited to imagery.', 'mxchat'); ?></p> | |
| 632 | + </div> | |
| 633 | + <script>(function(){ | |
| 634 | + var s = document.getElementById('mxch-image-count'); | |
| 635 | + var v = document.getElementById('mxch-image-count-val'); | |
| 636 | + if (!s || !v || s._wired) { return; } s._wired = true; | |
| 637 | + s.addEventListener('input', function(){ v.textContent = s.value; }); | |
| 638 | + var e = document.querySelector('[data-field="content_enable_images"]'); | |
| 639 | + if (e) { | |
| 640 | + var syncCount = function(){ s.disabled = !e.checked; }; | |
| 641 | + e.addEventListener('change', syncCount); | |
| 642 | + syncCount(); | |
| 643 | + } | |
| 644 | + })();</script> | |
| 645 | + | |
| 586 | 646 | <!-- Internal Linking (Pro) --> |
| 587 | 647 | <div class="mxch-field mxch-cg-pro-field<?php echo $pro_internal_linking ? '' : ' mxch-cg-pro-locked'; ?>"> |
| 588 | 648 | <label class="mxch-toggle"> |
| 589 | 649 | <?php $internal_linking_val = $options['content_internal_linking'] ?? 'off'; ?> |
| @@ -628,8 +688,29 @@ | ||
| 628 | 688 | <?php endif; ?> |
| 629 | 689 | <?php endif; ?> |
| 630 | 690 | </div> |
| 631 | 691 | |
| 692 | + </div> | |
| 693 | + </div> | |
| 694 | + | |
| 695 | + <!-- ── Editor Assistant (moved from Settings → Behavior, plan-f7df40) ── --> | |
| 696 | + <div class="mxch-card"> | |
| 697 | + <div class="mxch-card-header"> | |
| 698 | + <h3 class="mxch-card-title"> | |
| 699 | + <svg class="mxch-card-title-icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 4V2"/><path d="M15 16v-2"/><path d="M8 9h2"/><path d="M20 9h2"/><path d="M17.8 11.8 19 13"/><path d="M15 9h.01"/><path d="M17.8 6.2 19 5"/><path d="m3 21 9-9"/><path d="M12.2 6.2 11 5"/></svg> | |
| 700 | + <?php esc_html_e('Editor Assistant', 'mxchat'); ?> | |
| 701 | + </h3> | |
| 702 | + </div> | |
| 703 | + <?php // mxchat-autosave-section: this toggle saves through the shared | |
| 704 | + // settings transport (mxchat-admin.js + the ajax-handler's | |
| 705 | + // mxchat_editor_assistant_enabled case), NOT the data-field | |
| 706 | + // transport the rest of this tab uses — keep those apart. ?> | |
| 707 | + <div class="mxch-card-body mxchat-autosave-section"> | |
| 708 | + <?php | |
| 709 | + mxchat_render_field_wrapper('mxchat_editor_assistant_enabled', __('Editor Assistant', 'mxchat'), function() use ($admin_instance) { | |
| 710 | + $admin_instance->mxchat_editor_assistant_toggle_callback(); | |
| 711 | + }, __('Add magic-wand AI writing actions (rewrite, summarize, translate, continue, fix grammar) to the WordPress block editor. Opens a sidebar in the post editor. Uses the chat AI model configured in MxChat Settings. Off by default.', 'mxchat')); | |
| 712 | + ?> | |
| 632 | 713 | </div> |
| 633 | 714 | </div> |
| 634 | 715 | |
| 635 | 716 | <!-- ── SEO Settings ── --> |