PluginProbe
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress / 3.3.1
QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress v3.3.1
4.1.2 4.1.1 4.1.0 4.0.1 4.0.0 3.3.1 3.3.0 trunk 1.0.0 2.0.0 2.1.0 3.0.0 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8
quickwebp / admin / templates / page-settings.php

page-settings.php in QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress 3.3.1, at admin/templates/page-settings.php

1,211 lines 58.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 /**
6 * The admin settings of the plugin.
7 * @since 1.0.0
8 */
9 $wpmtk_is_active = in_array( 'wpmastertoolkit/wp-mastertoolkit.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) );
10
11 if ( isset( $_POST['quickwebp_settings_conversion'] ) ) {
12 update_option( 'quickwebp_settings_onboarding_completed', '1' );
13 }
14
15 $show_onboarding = '1' !== (string) get_option( 'quickwebp_settings_onboarding_completed', '0' );
16
17 $conversion_enabled = '1' === (string) get_option( 'quickwebp_settings_conversion', quickwebp_settings_default( 'quickwebp_settings_conversion' ) );
18 $save_original = get_option( 'quickwebp_settings_conversion_save_original', quickwebp_settings_default( 'quickwebp_settings_conversion_save_original' ) );
19 $save_original = is_array( $save_original ) ? $save_original : array();
20 $save_original_enabled = in_array( 'checked', $save_original, true );
21 $display_mode = get_option( 'quickwebp_settings_conversion_display_webp_mode', quickwebp_settings_default( 'quickwebp_settings_conversion_display_webp_mode' ) );
22
23 $profile_label = __( 'Custom profile', QUICKWEBP_TEXT_DOMAIN );
24 if ( $conversion_enabled && ! $save_original_enabled ) {
25 $profile_label = __( 'New site profile', QUICKWEBP_TEXT_DOMAIN );
26 }
27 if ( $conversion_enabled && $save_original_enabled ) {
28 $profile_label = __( 'Existing site profile', QUICKWEBP_TEXT_DOMAIN );
29 }
30 ?>
31 <div class="quickwebp-settings-v2" data-current-profile="<?php echo esc_attr( $profile_label ); ?>">
32 <style>
33 .quickwebp-settings-v2 {
34 --quickwebp-surface: #ffffff;
35 --quickwebp-text: #111827;
36 --quickwebp-muted: #4b5563;
37 --quickwebp-border: #d6deeb;
38 --quickwebp-accent: #0f766e;
39 --quickwebp-accent-soft: #e6f7f6;
40 --quickwebp-info-soft: #eef4ff;
41 --quickwebp-warning-soft: #fff8e8;
42 max-width: 1320px;
43 margin-top: 14px;
44 color: var(--quickwebp-text);
45 }
46
47 .quickwebp-hero {
48 background: linear-gradient(120deg, #e9f8f6 0%, #eef4ff 45%, #ffffff 100%);
49 border: 1px solid var(--quickwebp-border);
50 border-radius: 14px;
51 padding: 20px;
52 margin-bottom: 16px;
53 }
54
55 .quickwebp-hero h1 {
56 margin: 0 0 8px;
57 font-size: 28px;
58 line-height: 1.2;
59 }
60
61 .quickwebp-hero p {
62 margin: 0;
63 color: var(--quickwebp-muted);
64 font-size: 14px;
65 }
66
67 .quickwebp-layout {
68 display: grid;
69 grid-template-columns: minmax(0, 1fr) 320px;
70 gap: 16px;
71 align-items: start;
72 }
73
74 .quickwebp-main,
75 .quickwebp-aside {
76 min-width: 0;
77 }
78
79 .quickwebp-card {
80 background: var(--quickwebp-surface);
81 border: 1px solid var(--quickwebp-border);
82 border-radius: 14px;
83 margin-bottom: 14px;
84 overflow: hidden;
85 }
86
87 .quickwebp-card-head {
88 padding: 14px 16px;
89 border-bottom: 1px solid #ebeff7;
90 background: #fbfdff;
91 }
92
93 .quickwebp-card-head h2 {
94 margin: 0;
95 font-size: 16px;
96 line-height: 1.3;
97 }
98
99 .quickwebp-card-head p {
100 margin: 4px 0 0;
101 color: var(--quickwebp-muted);
102 font-size: 13px;
103 }
104
105 .quickwebp-card-body {
106 padding: 10px 16px 4px;
107 }
108
109 .quickwebp-card-body .form-table {
110 margin-top: 0;
111 }
112
113 .quickwebp-card-body .form-table th {
114 width: 300px;
115 }
116
117 .quickwebp-card-body .form-table td,
118 .quickwebp-card-body .form-table th {
119 padding-top: 12px;
120 padding-bottom: 12px;
121 }
122
123 .quickwebp-onboarding-grid {
124 display: grid;
125 grid-template-columns: repeat(2, minmax(0, 1fr));
126 gap: 10px;
127 margin: 10px 0 0;
128 }
129
130 .quickwebp-onboarding-option {
131 border: 1px solid var(--quickwebp-border);
132 border-radius: 10px;
133 padding: 12px;
134 background: #fff;
135 text-align: left;
136 cursor: pointer;
137 }
138
139 .quickwebp-onboarding-option strong {
140 display: block;
141 margin-bottom: 3px;
142 }
143
144 .quickwebp-onboarding-option span {
145 color: var(--quickwebp-muted);
146 font-size: 12px;
147 }
148
149 .quickwebp-onboarding-option:hover,
150 .quickwebp-onboarding-option:focus {
151 border-color: #88bbb7;
152 background: #f8fffe;
153 outline: none;
154 }
155
156 .quickwebp-onboarding-feedback {
157 margin: 8px 0 0;
158 color: #0f5b56;
159 font-weight: 600;
160 }
161
162 .quickwebp-guidance-box {
163 margin: 6px 0 0;
164 padding: 10px;
165 border-radius: 8px;
166 background: var(--quickwebp-info-soft);
167 border: 1px solid #cad7f7;
168 }
169
170 .quickwebp-guidance-message {
171 margin: 0;
172 color: #1f3a73;
173 font-size: 12px;
174 }
175
176 .quickwebp-display-warning {
177 margin: 8px 0 0;
178 padding: 8px 10px;
179 border-radius: 8px;
180 background: var(--quickwebp-warning-soft);
181 border: 1px solid #f6dc9e;
182 color: #8a5a00;
183 font-size: 12px;
184 font-weight: 600;
185 }
186
187 .quickwebp-aside-inner {
188 position: sticky;
189 top: 36px;
190 }
191
192 .quickwebp-summary-list {
193 margin: 0;
194 padding: 0;
195 list-style: none;
196 }
197
198 .quickwebp-summary-list li {
199 border: 1px solid #e7edf8;
200 border-radius: 10px;
201 padding: 10px;
202 margin-bottom: 8px;
203 background: #fff;
204 }
205
206 .quickwebp-summary-label {
207 display: block;
208 margin-bottom: 2px;
209 color: var(--quickwebp-muted);
210 font-size: 12px;
211 }
212
213 .quickwebp-summary-value {
214 display: block;
215 font-size: 13px;
216 font-weight: 700;
217 }
218
219 .quickwebp-quick-links {
220 display: grid;
221 gap: 6px;
222 }
223
224 .quickwebp-quick-links a {
225 text-decoration: none;
226 color: #0f5b56;
227 font-weight: 600;
228 font-size: 13px;
229 }
230
231 .quickwebp-migration-video {
232 max-width: 100%;
233 border-radius: 10px;
234 border: 1px solid #d9e4fb;
235 margin-top: 8px;
236 }
237
238 .quickwebp-submit-wrap {
239 display: flex;
240 align-items: center;
241 gap: 10px;
242 margin-top: 12px;
243 padding: 14px 16px;
244 border: 1px solid var(--quickwebp-border);
245 border-radius: 12px;
246 background: #fff;
247 }
248
249 .quickwebp-submit-wrap .submit {
250 margin: 0;
251 padding: 0;
252 }
253
254 .quickwebp-submit-note {
255 margin: 0;
256 color: var(--quickwebp-muted);
257 font-size: 12px;
258 }
259
260 .quickwebp-credits {
261 margin-top: 8px;
262 color: var(--quickwebp-muted);
263 font-size: 12px;
264 }
265
266 .quickwebp-seo-example {
267 margin-top: 10px;
268 border: 1px solid #dbe6fb;
269 border-radius: 10px;
270 background: #f8fbff;
271 padding: 12px;
272 }
273
274 .quickwebp-seo-example h3 {
275 margin: 0 0 4px;
276 font-size: 13px;
277 }
278
279 .quickwebp-seo-example p {
280 margin: 0 0 8px;
281 color: var(--quickwebp-muted);
282 font-size: 12px;
283 }
284
285 .quickwebp-seo-example-input {
286 width: 100%;
287 margin-bottom: 8px;
288 }
289
290 .quickwebp-seo-example-grid {
291 display: grid;
292 grid-template-columns: repeat(2, minmax(0, 1fr));
293 gap: 8px;
294 }
295
296 .quickwebp-seo-example-item {
297 background: #fff;
298 border: 1px solid #e3ebfb;
299 border-radius: 8px;
300 padding: 8px;
301 }
302
303 .quickwebp-seo-example-item.is-disabled {
304 opacity: 0.45;
305 background: #f3f5f9;
306 border-color: #dde3ef;
307 }
308
309 .quickwebp-seo-example-item strong {
310 display: block;
311 margin-bottom: 3px;
312 font-size: 11px;
313 color: #4f648f;
314 text-transform: uppercase;
315 letter-spacing: 0.02em;
316 }
317
318 .quickwebp-seo-example-item span {
319 display: block;
320 font-size: 12px;
321 color: #1f2937;
322 word-break: break-word;
323 }
324
325 .quickwebp-cleanup-example {
326 margin-top: 10px;
327 border: 1px solid #d9efdb;
328 border-radius: 10px;
329 background: #f8fff8;
330 padding: 12px;
331 }
332
333 .quickwebp-cleanup-example h3 {
334 margin: 0 0 4px;
335 font-size: 13px;
336 }
337
338 .quickwebp-cleanup-example p {
339 margin: 0 0 8px;
340 color: var(--quickwebp-muted);
341 font-size: 12px;
342 }
343
344 .quickwebp-cleanup-example-input {
345 width: 100%;
346 margin-bottom: 8px;
347 }
348
349 .quickwebp-cleanup-example-grid {
350 display: grid;
351 grid-template-columns: repeat(2, minmax(0, 1fr));
352 gap: 8px;
353 }
354
355 .quickwebp-cleanup-example-item {
356 background: #fff;
357 border: 1px solid #dceede;
358 border-radius: 8px;
359 padding: 8px;
360 }
361
362 .quickwebp-cleanup-example-item strong {
363 display: block;
364 margin-bottom: 3px;
365 font-size: 11px;
366 color: #3f6f44;
367 text-transform: uppercase;
368 letter-spacing: 0.02em;
369 }
370
371 .quickwebp-cleanup-example-item span {
372 display: block;
373 font-size: 12px;
374 color: #1f2937;
375 word-break: break-word;
376 }
377
378 .quickwebp-cleanup-example-item.is-disabled {
379 opacity: 0.45;
380 background: #f3f5f9;
381 border-color: #dde3ef;
382 }
383
384 @media (max-width: 1190px) {
385 .quickwebp-layout {
386 grid-template-columns: minmax(0, 1fr);
387 }
388
389 .quickwebp-aside-inner {
390 position: static;
391 }
392
393 .quickwebp-onboarding-grid {
394 grid-template-columns: minmax(0, 1fr);
395 }
396
397 .quickwebp-seo-example-grid {
398 grid-template-columns: minmax(0, 1fr);
399 }
400
401 .quickwebp-cleanup-example-grid {
402 grid-template-columns: minmax(0, 1fr);
403 }
404 }
405 </style>
406
407 <header class="quickwebp-hero">
408 <h1><?php esc_html_e( 'QuickWebP Settings', QUICKWEBP_TEXT_DOMAIN ); ?></h1>
409 <p><?php esc_html_e( 'Configure your image workflow with coherent presets, guarded options, and an optimized media delivery strategy.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
410 </header>
411
412 <form action="" method="post" class="quickwebp-settings-form">
413 <div class="quickwebp-layout">
414 <main class="quickwebp-main">
415 <?php if ( $show_onboarding ) : ?>
416 <section class="quickwebp-card" id="quickwebp-onboarding">
417 <div class="quickwebp-card-head">
418 <h2><?php esc_html_e( 'Quick setup assistant', QUICKWEBP_TEXT_DOMAIN ); ?></h2>
419 <p><?php esc_html_e( 'Start from a recommended profile and refine only what you need.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
420 </div>
421 <div class="quickwebp-card-body">
422 <div class="quickwebp-onboarding-grid">
423 <button type="button" class="quickwebp-onboarding-option quickwebp-onboarding-apply" data-profile="new-site">
424 <strong><?php esc_html_e( 'New site with few media', QUICKWEBP_TEXT_DOMAIN ); ?></strong>
425 <span><?php esc_html_e( 'Replace originals on upload for the simplest and fastest workflow.', QUICKWEBP_TEXT_DOMAIN ); ?></span>
426 </button>
427 <button type="button" class="quickwebp-onboarding-option quickwebp-onboarding-apply" data-profile="existing-site">
428 <strong><?php esc_html_e( 'Existing site with many media', QUICKWEBP_TEXT_DOMAIN ); ?></strong>
429 <span><?php esc_html_e( 'Keep originals, enable rewrite delivery, and run bulk optimization.', QUICKWEBP_TEXT_DOMAIN ); ?></span>
430 </button>
431 </div>
432 <p class="quickwebp-onboarding-feedback" aria-live="polite"></p>
433 </div>
434 </section>
435 <?php endif; ?>
436
437 <section class="quickwebp-card" id="quickwebp-conversion">
438 <div class="quickwebp-card-head">
439 <h2><?php esc_html_e( 'Conversion and Delivery', QUICKWEBP_TEXT_DOMAIN ); ?></h2>
440 <p><?php esc_html_e( 'Define how images are converted, preserved, and delivered on frontend pages.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
441 </div>
442 <div class="quickwebp-card-body">
443 <table class="form-table">
444
445 <?php $this->render_component( array(
446 'type' => 'toggle',
447 'name' => 'quickwebp_settings_conversion',
448 'label' => __( 'Enable/disable image conversion to WEBP format', QUICKWEBP_TEXT_DOMAIN ),
449 'default' => quickwebp_settings_default( 'quickwebp_settings_conversion' ),
450 'classes' => 'toggle-with-children',
451 ) ); ?>
452
453 <tbody class="form-table children">
454
455 <?php $this->render_component( array(
456 'type' => 'range-slider',
457 'min' => 0,
458 'max' => 100,
459 'step' => 1,
460 'unit' => '%',
461 'name' => 'quickwebp_settings_conversion_quality',
462 'label' => __( 'Quality', QUICKWEBP_TEXT_DOMAIN ),
463 'default' => quickwebp_settings_default( 'quickwebp_settings_conversion_quality' )
464 ) ); ?>
465
466 <?php $this->render_component( array(
467 'type' => 'range-slider',
468 'min' => 0,
469 'max' => 100,
470 'step' => 1,
471 'unit' => '%',
472 'name' => 'quickwebp_settings_conversion_sharpen',
473 'label' => __( 'Sharpen', QUICKWEBP_TEXT_DOMAIN ),
474 'default' => quickwebp_settings_default( 'quickwebp_settings_conversion_sharpen' )
475 ) ); ?>
476
477 <?php $this->render_component( array(
478 'type' => 'checkbox',
479 'name' => 'quickwebp_settings_conversion_ignore_webp',
480 'label' => __( 'Do not compress images already in WebP', QUICKWEBP_TEXT_DOMAIN ),
481 'default' => quickwebp_settings_default( 'quickwebp_settings_conversion_ignore_webp' ),
482 'options' => array(
483 array(
484 'label' => '',
485 'value' => 'checked'
486 )
487 )
488 ) ); ?>
489
490 <?php $this->render_component( array(
491 'type' => 'checkbox',
492 'name' => 'quickwebp_settings_conversion_save_original',
493 'label' => __( 'Save original images', QUICKWEBP_TEXT_DOMAIN ),
494 'default' => quickwebp_settings_default( 'quickwebp_settings_conversion_save_original' ),
495 'options' => array(
496 array(
497 'label' => '',
498 'value' => 'checked'
499 )
500 )
501 ) ); ?>
502
503 <tr class="quickwebp-guidance-row">
504 <th>
505 <label><?php esc_html_e( 'Consistency guidance', QUICKWEBP_TEXT_DOMAIN ); ?></label>
506 </th>
507 <td>
508 <div class="quickwebp-guidance-box">
509 <p class="quickwebp-guidance-message" aria-live="polite"></p>
510 </div>
511 </td>
512 </tr>
513
514 <tr>
515 <th>
516 <label><?php esc_html_e( 'Before saving, test your configuration with preview mode.', QUICKWEBP_TEXT_DOMAIN ); ?></label>
517 </th>
518 <td>
519 <?php include QUICKWEBP_PLUGIN_PATH . 'admin/templates/popup-settings-preview.php'; ?>
520 </td>
521 </tr>
522
523 <?php
524 $description_for_nginx = $is_nginx ? __( "If you choose to use rewrite rules, the file conf/quickwebp.conf will be created and must be included into the server's configuration file (then restart the server).", QUICKWEBP_TEXT_DOMAIN ) : '';
525
526 $this->render_component( array(
527 'type' => 'radio',
528 'name' => 'quickwebp_settings_conversion_display_webp_mode',
529 'label' => __( 'Display images in WebP format on the site', QUICKWEBP_TEXT_DOMAIN ),
530 'description' => sprintf( __( 'If activated, this option allows to deliver optimized images in bulk via QuickWebP in WebP format (useless for images converted to import). %s', QUICKWEBP_TEXT_DOMAIN ), $description_for_nginx ),
531 'default' => quickwebp_settings_default( 'quickwebp_settings_conversion_display_webp_mode' ),
532 'options' => array(
533 array(
534 'label' => __( 'Deactivate', QUICKWEBP_TEXT_DOMAIN ),
535 'value' => 'disabled'
536 ),
537 array(
538 'label' => __( 'Use <picture> tags', QUICKWEBP_TEXT_DOMAIN ),
539 'value' => 'picture'
540 ),
541 array(
542 'label' => sprintf( __( 'Use rewrite rules %s', QUICKWEBP_TEXT_DOMAIN ), $is_nginx ? '(beta)' : '' ),
543 'value' => 'rewrite'
544 )
545 )
546 ) );
547 ?>
548
549 <tr class="quickwebp-display-warning-row" style="display:none;">
550 <th>
551 <label><?php esc_html_e( 'Why this is locked', QUICKWEBP_TEXT_DOMAIN ); ?></label>
552 </th>
553 <td>
554 <p class="quickwebp-display-warning"></p>
555 </td>
556 </tr>
557
558 <tr class="quickwebp-row-bulk-optimization">
559 <th>
560 <label><?php esc_html_e( 'Bulk optimization', QUICKWEBP_TEXT_DOMAIN ); ?></label>
561 </th>
562 <td>
563 <?php include QUICKWEBP_PLUGIN_PATH . 'admin/templates/bulk-optimization.php'; ?>
564 </td>
565 </tr>
566
567 </tbody>
568
569 </table>
570 </div>
571 </section>
572
573 <section class="quickwebp-card" id="quickwebp-resize">
574 <div class="quickwebp-card-head">
575 <h2><?php esc_html_e( 'Resize', QUICKWEBP_TEXT_DOMAIN ); ?></h2>
576 <p><?php esc_html_e( 'Keep your uploads under control to reduce bandwidth and processing costs.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
577 </div>
578 <div class="quickwebp-card-body">
579 <table class="form-table">
580 <?php $this->render_component( array(
581 'type' => 'toggle',
582 'name' => 'quickwebp_settings_resize',
583 'label' => __( 'Enable/disable image resizing', QUICKWEBP_TEXT_DOMAIN ),
584 'default' => quickwebp_settings_default( 'quickwebp_settings_resize' ),
585 'classes' => 'toggle-with-children',
586 'description' => __( 'By default, WordPress limits the maximum width of uploaded images to 2560 pixels.', QUICKWEBP_TEXT_DOMAIN ),
587 ) ); ?>
588
589 <tbody class="form-table children">
590 <?php $this->render_component( array(
591 'type' => 'number',
592 'name' => 'quickwebp_settings_resize_value',
593 'label' => __( 'Max size', QUICKWEBP_TEXT_DOMAIN ),
594 'default' => quickwebp_settings_default( 'quickwebp_settings_resize_value' )
595 ) ); ?>
596 </tbody>
597 </table>
598 </div>
599 </section>
600
601 <section class="quickwebp-card" id="quickwebp-seo">
602 <div class="quickwebp-card-head">
603 <h2><?php esc_html_e( 'SEO metadata automation', QUICKWEBP_TEXT_DOMAIN ); ?></h2>
604 <p><?php esc_html_e( 'Auto-fill media fields from image names for a faster editorial workflow.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
605 </div>
606 <div class="quickwebp-card-body">
607 <table class="form-table">
608 <?php $this->render_component( array(
609 'type' => 'toggle',
610 'name' => 'quickwebp_settings_completion',
611 'label' => __( 'Enable/disable smart media completion for SEO', QUICKWEBP_TEXT_DOMAIN ),
612 'default' => quickwebp_settings_default( 'quickwebp_settings_completion' ),
613 'classes' => 'toggle-with-children',
614 'description' => __( 'This feature will automatically complete the media information (title, caption, alt text, description) from the image name.', QUICKWEBP_TEXT_DOMAIN ),
615 ) ); ?>
616
617 <tbody class="form-table children">
618 <?php $this->render_component( array(
619 'type' => 'checkbox',
620 'name' => 'quickwebp_settings_completion_options',
621 'default' => quickwebp_settings_default( 'quickwebp_settings_completion_options' ),
622 'options' => array(
623 array(
624 'label' => __( 'Title completion from image name', QUICKWEBP_TEXT_DOMAIN ),
625 'value' => 'title',
626 ),
627 array(
628 'label' => __( 'Caption completion from image name.', QUICKWEBP_TEXT_DOMAIN ),
629 'value' => 'caption',
630 ),
631 array(
632 'label' => __( 'Alt text completion from image name.', QUICKWEBP_TEXT_DOMAIN ),
633 'value' => 'alt',
634 ),
635 array(
636 'label' => __( 'Description completion from image name.', QUICKWEBP_TEXT_DOMAIN ),
637 'value' => 'description',
638 )
639 )
640 ) ); ?>
641 </tbody>
642 </table>
643
644 <div class="quickwebp-seo-example">
645 <h3><?php esc_html_e( 'Live example', QUICKWEBP_TEXT_DOMAIN ); ?></h3>
646 <p><?php esc_html_e( 'Use a descriptive filename once (including spaces or apostrophes), and metadata is auto-filled from that original filename without the extension.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
647 <input
648 type="text"
649 class="quickwebp-seo-example-input"
650 value="Men's Summer Shoes - Limited Edition 2026.jpg"
651 aria-label="<?php echo esc_attr__( 'SEO metadata example filename', QUICKWEBP_TEXT_DOMAIN ); ?>"
652 >
653
654 <div class="quickwebp-seo-example-grid">
655 <div class="quickwebp-seo-example-item">
656 <strong><?php esc_html_e( 'Title', QUICKWEBP_TEXT_DOMAIN ); ?></strong>
657 <span class="quickwebp-seo-preview-title"></span>
658 </div>
659 <div class="quickwebp-seo-example-item">
660 <strong><?php esc_html_e( 'Caption', QUICKWEBP_TEXT_DOMAIN ); ?></strong>
661 <span class="quickwebp-seo-preview-caption"></span>
662 </div>
663 <div class="quickwebp-seo-example-item">
664 <strong><?php esc_html_e( 'Alt text', QUICKWEBP_TEXT_DOMAIN ); ?></strong>
665 <span class="quickwebp-seo-preview-alt"></span>
666 </div>
667 <div class="quickwebp-seo-example-item">
668 <strong><?php esc_html_e( 'Description', QUICKWEBP_TEXT_DOMAIN ); ?></strong>
669 <span class="quickwebp-seo-preview-description"></span>
670 </div>
671 </div>
672 </div>
673 </div>
674 </section>
675
676 <section class="quickwebp-card" id="quickwebp-tools">
677 <div class="quickwebp-card-head">
678 <h2><?php esc_html_e( 'Other tools', QUICKWEBP_TEXT_DOMAIN ); ?></h2>
679 <p><?php esc_html_e( 'Fine tune file naming, paste behavior, and backend image library.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
680 </div>
681 <div class="quickwebp-card-body">
682 <table class="form-table">
683 <?php $this->render_component( array(
684 'type' => 'toggle',
685 'name' => 'quickwebp_settings_cleanup',
686 'label' => __( 'Enable/disable file name cleanup', QUICKWEBP_TEXT_DOMAIN ),
687 'default' => quickwebp_settings_default( 'quickwebp_settings_cleanup' ),
688 // 'description' => __( 'Remove special characters from file names.', QUICKWEBP_TEXT_DOMAIN ),
689 ) ); ?>
690
691 <tr class="quickwebp-cleanup-example-row">
692 <th>
693
694 </th>
695 <td>
696 <div class="quickwebp-cleanup-example">
697 <p><?php esc_html_e( 'Use a filename with spaces, apostrophes, or accents to preview the cleaned filename.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
698 <input
699 type="text"
700 class="quickwebp-cleanup-example-input"
701 value="Men's Summer Shoes - Limited Edition 2026.jpg"
702 aria-label="<?php echo esc_attr__( 'Cleanup filename example input', QUICKWEBP_TEXT_DOMAIN ); ?>"
703 >
704 <div class="quickwebp-cleanup-example-grid">
705 <div class="quickwebp-cleanup-example-item">
706 <strong><?php esc_html_e( 'Original filename', QUICKWEBP_TEXT_DOMAIN ); ?></strong>
707 <span class="quickwebp-cleanup-preview-original"></span>
708 </div>
709 <div class="quickwebp-cleanup-example-item">
710 <strong><?php esc_html_e( 'Cleaned filename', QUICKWEBP_TEXT_DOMAIN ); ?></strong>
711 <span class="quickwebp-cleanup-preview-cleaned"></span>
712 </div>
713 </div>
714 </div>
715 </td>
716 </tr>
717
718 <?php $this->render_component( array(
719 'type' => 'toggle',
720 'name' => 'quickwebp_settings_paste_image',
721 'label' => __( 'Enable/disable paste picture directly (beta)', QUICKWEBP_TEXT_DOMAIN ),
722 'default' => quickwebp_settings_default( 'quickwebp_settings_paste_image' ),
723 'description' => __( 'With this feature you can paste directly your picture in WordPress media.', QUICKWEBP_TEXT_DOMAIN ),
724 ) ); ?>
725
726 <?php $this->render_component( array(
727 'type' => 'select',
728 'options' => array(
729 array(
730 'value' => 'gd',
731 'label' => 'GD'
732 ),
733 array(
734 'value' => 'imagick',
735 'label' => 'Imagick'
736 )
737 ),
738 'name' => 'quickwebp_settings_library',
739 'label' => __( 'Library to use', QUICKWEBP_TEXT_DOMAIN ),
740 'default' => quickwebp_settings_default( 'quickwebp_settings_library' ),
741 'description' => __( 'We use the GD library as the default option. However, if the GD library is not available, we will use Imagick instead.', QUICKWEBP_TEXT_DOMAIN )
742 ) ); ?>
743 </table>
744 </div>
745 </section>
746
747 <section class="quickwebp-card" id="quickwebp-migration">
748 <div class="quickwebp-card-head">
749 <h2><?php esc_html_e( 'Migration notice', QUICKWEBP_TEXT_DOMAIN ); ?></h2>
750 <p><?php esc_html_e( 'QuickWebP is now available inside WPMasterToolKit.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
751 </div>
752 <div class="quickwebp-card-body">
753 <p><?php esc_html_e( 'QuickWebP is now part of the WPMasterToolKit plugin. You can download it for free on the WordPress repository.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
754 <video autoplay loop muted controls class="quickwebp-migration-video">
755 <source src="<?php echo esc_url( QUICKWEBP_PLUGIN_URL . 'public/assets/video/wpmastertoolkit.mp4' ); ?>" type="video/mp4">
756 <?php esc_html_e( 'Your browser does not support the video tag.', QUICKWEBP_TEXT_DOMAIN ); ?>
757 </video>
758 <?php if ( $wpmtk_is_active ) : ?>
759 <p><strong><?php esc_html_e( 'You can now deactivate QuickWebP and finish the migration.', QUICKWEBP_TEXT_DOMAIN ); ?></strong></p>
760 <?php else : ?>
761 <p>
762 <a href="<?php echo esc_url( admin_url( 'plugin-install.php?s=wpmastertoolkit&tab=search&type=term' ) ); ?>" class="button button-primary" target="_blank"><?php esc_html_e( 'Download WPMasterToolKit', QUICKWEBP_TEXT_DOMAIN ); ?></a>
763 <a href="https://wordpress.org/plugins/wpmastertoolkit/" class="button button-secondary" target="_blank"><?php esc_html_e( 'Download WPMasterToolKit from wordpress.org', QUICKWEBP_TEXT_DOMAIN ); ?></a>
764 </p>
765 <?php endif; ?>
766 </div>
767 </section>
768
769 <div class="quickwebp-submit-wrap">
770 <?php submit_button( __( 'Save settings', QUICKWEBP_TEXT_DOMAIN ), 'primary', 'submit', false ); ?>
771 <p class="quickwebp-submit-note"><?php esc_html_e( 'Your consistency rules are enforced automatically when saving.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
772 </div>
773
774 <div class="quickwebp-credits">
775 <p>
776 <?php esc_html_e( 'This plugin is developed by', QUICKWEBP_TEXT_DOMAIN ); ?>
777 <a href="https://webdeclic.com/" target="_blank">Webdeclic</a>.
778 <?php esc_html_e( 'You can support this project here:', QUICKWEBP_TEXT_DOMAIN ); ?>
779 <a href="https://www.buymeacoffee.com/ludwig" target="_blank"><?php esc_html_e( 'Buy me a coffee', QUICKWEBP_TEXT_DOMAIN ); ?></a>.
780 </p>
781 <p>
782 <?php esc_html_e( 'You can show all Webdeclic plugins on', QUICKWEBP_TEXT_DOMAIN ); ?>
783 <a href="https://wordpress.org/plugins/search/webdeclic/" target="_blank">wordpress.org</a>.
784 </p>
785 </div>
786 </main>
787
788 <aside class="quickwebp-aside">
789 <div class="quickwebp-aside-inner">
790 <section class="quickwebp-card">
791 <div class="quickwebp-card-head">
792 <h2><?php esc_html_e( 'Live configuration summary', QUICKWEBP_TEXT_DOMAIN ); ?></h2>
793 <p><?php esc_html_e( 'This panel updates instantly while you edit your settings.', QUICKWEBP_TEXT_DOMAIN ); ?></p>
794 </div>
795 <div class="quickwebp-card-body">
796 <ul class="quickwebp-summary-list">
797 <li>
798 <span class="quickwebp-summary-label"><?php esc_html_e( 'Conversion', QUICKWEBP_TEXT_DOMAIN ); ?></span>
799 <span class="quickwebp-summary-value quickwebp-summary-conversion-side"><?php echo esc_html( $conversion_enabled ? __( 'Enabled', QUICKWEBP_TEXT_DOMAIN ) : __( 'Disabled', QUICKWEBP_TEXT_DOMAIN ) ); ?></span>
800 </li>
801 <li>
802 <span class="quickwebp-summary-label"><?php esc_html_e( 'Original images', QUICKWEBP_TEXT_DOMAIN ); ?></span>
803 <span class="quickwebp-summary-value quickwebp-summary-originals-side"><?php echo esc_html( $save_original_enabled ? __( 'Preserved', QUICKWEBP_TEXT_DOMAIN ) : __( 'Replaced', QUICKWEBP_TEXT_DOMAIN ) ); ?></span>
804 </li>
805 <li>
806 <span class="quickwebp-summary-label"><?php esc_html_e( 'Frontend display', QUICKWEBP_TEXT_DOMAIN ); ?></span>
807 <span class="quickwebp-summary-value quickwebp-summary-display-side"><?php echo esc_html( $display_mode ); ?></span>
808 </li>
809 <li>
810 <span class="quickwebp-summary-label"><?php esc_html_e( 'Bulk optimization', QUICKWEBP_TEXT_DOMAIN ); ?></span>
811 <span class="quickwebp-summary-value quickwebp-summary-bulk-side"><?php echo esc_html( $save_original_enabled ? __( 'Available', QUICKWEBP_TEXT_DOMAIN ) : __( 'Unavailable', QUICKWEBP_TEXT_DOMAIN ) ); ?></span>
812 </li>
813 </ul>
814 </div>
815 </section>
816
817 <section class="quickwebp-card">
818 <div class="quickwebp-card-head">
819 <h2><?php esc_html_e( 'Quick navigation', QUICKWEBP_TEXT_DOMAIN ); ?></h2>
820 </div>
821 <div class="quickwebp-card-body quickwebp-quick-links">
822 <?php if ( $show_onboarding ) : ?>
823 <a href="#quickwebp-onboarding"><?php esc_html_e( 'Quick setup assistant', QUICKWEBP_TEXT_DOMAIN ); ?></a>
824 <?php endif; ?>
825 <a href="#quickwebp-conversion"><?php esc_html_e( 'Conversion and delivery', QUICKWEBP_TEXT_DOMAIN ); ?></a>
826 <a href="#quickwebp-resize"><?php esc_html_e( 'Resize', QUICKWEBP_TEXT_DOMAIN ); ?></a>
827 <a href="#quickwebp-seo"><?php esc_html_e( 'SEO metadata automation', QUICKWEBP_TEXT_DOMAIN ); ?></a>
828 <a href="#quickwebp-tools"><?php esc_html_e( 'Other tools', QUICKWEBP_TEXT_DOMAIN ); ?></a>
829 <a href="#quickwebp-migration"><?php esc_html_e( 'Migration notice', QUICKWEBP_TEXT_DOMAIN ); ?></a>
830 </div>
831 </section>
832 </div>
833 </aside>
834 </div>
835 </form>
836
837 <script>
838 document.addEventListener('DOMContentLoaded', function () {
839 const conversionToggle = document.querySelector('input[type="checkbox"][name="quickwebp_settings_conversion"]');
840 const saveOriginalCheckbox = document.querySelector('input[type="checkbox"][name="quickwebp_settings_conversion_save_original[]"]');
841 const displayModeInputs = document.querySelectorAll('input[type="radio"][name="quickwebp_settings_conversion_display_webp_mode"]');
842 const disabledDisplayModeInput = document.querySelector('input[type="radio"][name="quickwebp_settings_conversion_display_webp_mode"][value="disabled"]');
843 const pictureDisplayModeInput = document.querySelector('input[type="radio"][name="quickwebp_settings_conversion_display_webp_mode"][value="picture"]');
844 const rewriteDisplayModeInput = document.querySelector('input[type="radio"][name="quickwebp_settings_conversion_display_webp_mode"][value="rewrite"]');
845 const bulkRow = document.querySelector('.quickwebp-row-bulk-optimization');
846 const guidanceMessage = document.querySelector('.quickwebp-guidance-message');
847 const displayWarningRow = document.querySelector('.quickwebp-display-warning-row');
848 const displayWarningText = document.querySelector('.quickwebp-display-warning');
849 const onboardingButtons = document.querySelectorAll('.quickwebp-onboarding-apply');
850 const onboardingFeedback = document.querySelector('.quickwebp-onboarding-feedback');
851 const seoExampleInput = document.querySelector('.quickwebp-seo-example-input');
852 const seoPreviewTitle = document.querySelector('.quickwebp-seo-preview-title');
853 const seoPreviewCaption = document.querySelector('.quickwebp-seo-preview-caption');
854 const seoPreviewAlt = document.querySelector('.quickwebp-seo-preview-alt');
855 const seoPreviewDescription = document.querySelector('.quickwebp-seo-preview-description');
856 const completionToggle = document.querySelector('input[type="checkbox"][name="quickwebp_settings_completion"]');
857 const completionOptionInputs = document.querySelectorAll('input[type="checkbox"][name="quickwebp_settings_completion_options[]"]');
858 const cleanupToggle = document.querySelector('input[type="checkbox"][name="quickwebp_settings_cleanup"]');
859 const cleanupExampleInput = document.querySelector('.quickwebp-cleanup-example-input');
860 const cleanupPreviewOriginal = document.querySelector('.quickwebp-cleanup-preview-original');
861 const cleanupPreviewCleaned = document.querySelector('.quickwebp-cleanup-preview-cleaned');
862
863 const displayModeRow = displayModeInputs.length ? displayModeInputs[0].closest('tr') : null;
864 const disabledDisplayModeLabel = disabledDisplayModeInput ? disabledDisplayModeInput.closest('label') : null;
865 const conversionCard = document.querySelector('#quickwebp-conversion');
866
867 const summary = {
868 sideConversion: document.querySelector('.quickwebp-summary-conversion-side'),
869 sideOriginals: document.querySelector('.quickwebp-summary-originals-side'),
870 sideDisplay: document.querySelector('.quickwebp-summary-display-side'),
871 sideBulk: document.querySelector('.quickwebp-summary-bulk-side')
872 };
873
874 const strings = {
875 noOriginals: <?php echo wp_json_encode( __( 'Current mode: originals are replaced on upload. Frontend display mode and bulk optimization are hidden because they are designed for preserved originals.', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
876 withOriginals: <?php echo wp_json_encode( __( 'Current mode: originals are preserved. Choose a frontend display strategy and run bulk optimization for existing media.', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
877 conversionOff: <?php echo wp_json_encode( __( 'Conversion is disabled. Frontend display mode is forced to Deactivate.', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
878 warningNoOriginals: <?php echo wp_json_encode( __( 'Display mode is locked to Deactivate because original images are not preserved.', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
879 warningConversionOff: <?php echo wp_json_encode( __( 'Display mode is locked to Deactivate because image conversion is disabled.', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
880 appliedNewSite: <?php echo wp_json_encode( __( 'Preset applied: New site profile. Originals are replaced and display mode is set to Deactivate.', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
881 appliedExistingSite: <?php echo wp_json_encode( __( 'Preset applied: Existing site profile. Originals are preserved and rewrite mode is selected.', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
882 profileNew: <?php echo wp_json_encode( __( 'New site profile', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
883 profileExisting: <?php echo wp_json_encode( __( 'Existing site profile', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
884 profileCustom: <?php echo wp_json_encode( __( 'Custom profile', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
885 enabled: <?php echo wp_json_encode( __( 'Enabled', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
886 disabled: <?php echo wp_json_encode( __( 'Disabled', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
887 preserved: <?php echo wp_json_encode( __( 'Preserved', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
888 replaced: <?php echo wp_json_encode( __( 'Replaced', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
889 available: <?php echo wp_json_encode( __( 'Available', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
890 unavailable: <?php echo wp_json_encode( __( 'Unavailable', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
891 disabledPreview: <?php echo wp_json_encode( __( 'Disabled in current settings', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
892 cleanupDisabledPreview: <?php echo wp_json_encode( __( 'Cleanup disabled in current settings', QUICKWEBP_TEXT_DOMAIN ) ); ?>,
893 };
894
895 function setDisplayMode(value) {
896 displayModeInputs.forEach((input) => {
897 input.checked = input.value === value;
898 });
899 }
900
901 function getSelectedDisplayMode() {
902 const selected = Array.from(displayModeInputs).find((input) => input.checked);
903 return selected ? selected.value : 'disabled';
904 }
905
906 function isSaveOriginalEnabled() {
907 return !!saveOriginalCheckbox && saveOriginalCheckbox.checked;
908 }
909
910 function isConversionEnabled() {
911 return !!conversionToggle && conversionToggle.checked;
912 }
913
914 function getProfile(hasOriginals, conversionEnabled) {
915 if (!conversionEnabled) {
916 return strings.profileCustom;
917 }
918
919 return hasOriginals ? strings.profileExisting : strings.profileNew;
920 }
921
922 function updateSummary() {
923 const hasOriginals = isSaveOriginalEnabled();
924 const conversionEnabled = isConversionEnabled();
925 const displayMode = getSelectedDisplayMode();
926 const profile = getProfile(hasOriginals, conversionEnabled);
927
928 if (summary.sideConversion) {
929 summary.sideConversion.textContent = conversionEnabled ? strings.enabled : strings.disabled;
930 }
931
932 if (summary.sideOriginals) {
933 summary.sideOriginals.textContent = hasOriginals ? strings.preserved : strings.replaced;
934 }
935
936 if (summary.sideDisplay) {
937 summary.sideDisplay.textContent = displayMode;
938 }
939
940 if (summary.sideBulk) {
941 summary.sideBulk.textContent = hasOriginals && conversionEnabled ? strings.available : strings.unavailable;
942 }
943 }
944
945 function updateUiConsistency() {
946 const hasOriginals = isSaveOriginalEnabled();
947 const conversionEnabled = isConversionEnabled();
948 const forceDisabled = !hasOriginals || !conversionEnabled;
949
950 if (displayModeRow) {
951 displayModeRow.style.display = hasOriginals && conversionEnabled ? '' : 'none';
952 }
953
954 if (bulkRow) {
955 bulkRow.style.display = hasOriginals && conversionEnabled ? '' : 'none';
956 }
957
958 if (guidanceMessage) {
959 if (!conversionEnabled) {
960 guidanceMessage.textContent = strings.conversionOff;
961 } else {
962 guidanceMessage.textContent = hasOriginals ? strings.withOriginals : strings.noOriginals;
963 }
964 }
965
966 if (displayWarningRow && displayWarningText) {
967 displayWarningRow.style.display = forceDisabled ? '' : 'none';
968
969 if (!conversionEnabled) {
970 displayWarningText.textContent = strings.warningConversionOff;
971 } else {
972 displayWarningText.textContent = strings.warningNoOriginals;
973 }
974 }
975
976 if (disabledDisplayModeLabel) {
977 disabledDisplayModeLabel.style.display = hasOriginals && conversionEnabled ? 'none' : '';
978 }
979
980 if (disabledDisplayModeInput) {
981 disabledDisplayModeInput.disabled = hasOriginals && conversionEnabled;
982 }
983
984 if (forceDisabled) {
985 setDisplayMode('disabled');
986 updateSummary();
987 return;
988 }
989
990 if (disabledDisplayModeInput && disabledDisplayModeInput.checked) {
991 if (pictureDisplayModeInput) {
992 pictureDisplayModeInput.checked = true;
993 } else if (rewriteDisplayModeInput) {
994 rewriteDisplayModeInput.checked = true;
995 }
996 }
997
998 updateSummary();
999 }
1000
1001 function extractBaseFilename(value) {
1002 if (!value) {
1003 return 'example image';
1004 }
1005
1006 const base = value.replace(/\.[^/.]+$/, '');
1007 const normalized = base
1008 .replace(/\s+/g, ' ')
1009 .trim();
1010
1011 return normalized || 'example image';
1012 }
1013
1014 function updateSeoLiveExample() {
1015 if (!seoExampleInput || !seoPreviewTitle || !seoPreviewCaption || !seoPreviewAlt || !seoPreviewDescription) {
1016 return;
1017 }
1018
1019 const optionsMap = {
1020 title: {
1021 checked: !!document.querySelector('input[type="checkbox"][name="quickwebp_settings_completion_options[]"][value="title"]:checked'),
1022 preview: seoPreviewTitle
1023 },
1024 caption: {
1025 checked: !!document.querySelector('input[type="checkbox"][name="quickwebp_settings_completion_options[]"][value="caption"]:checked'),
1026 preview: seoPreviewCaption
1027 },
1028 alt: {
1029 checked: !!document.querySelector('input[type="checkbox"][name="quickwebp_settings_completion_options[]"][value="alt"]:checked'),
1030 preview: seoPreviewAlt
1031 },
1032 description: {
1033 checked: !!document.querySelector('input[type="checkbox"][name="quickwebp_settings_completion_options[]"][value="description"]:checked'),
1034 preview: seoPreviewDescription
1035 }
1036 };
1037
1038 const completionEnabled = !!completionToggle && completionToggle.checked;
1039 const baseFilename = extractBaseFilename(seoExampleInput.value);
1040
1041 optionsMap.title.preview.textContent = baseFilename;
1042 optionsMap.caption.preview.textContent = baseFilename;
1043 optionsMap.alt.preview.textContent = baseFilename;
1044 optionsMap.description.preview.textContent = baseFilename;
1045
1046 Object.keys(optionsMap).forEach((key) => {
1047 const item = optionsMap[key];
1048 const container = item.preview.closest('.quickwebp-seo-example-item');
1049 const isEnabled = completionEnabled && item.checked;
1050
1051 if (!isEnabled) {
1052 item.preview.textContent = strings.disabledPreview;
1053 }
1054
1055 if (container) {
1056 container.classList.toggle('is-disabled', !isEnabled);
1057 }
1058 });
1059 }
1060
1061 function sanitizeFilenamePreview(value) {
1062 const inputValue = (value || '').trim();
1063 if (!inputValue) {
1064 return 'example-image.jpg';
1065 }
1066
1067 const lastDot = inputValue.lastIndexOf('.');
1068 const hasExtension = lastDot > 0 && lastDot < inputValue.length - 1;
1069 const extension = hasExtension ? inputValue.slice(lastDot + 1).toLowerCase() : '';
1070 const basename = hasExtension ? inputValue.slice(0, lastDot) : inputValue;
1071
1072 let normalized = basename;
1073 if (normalized.normalize) {
1074 normalized = normalized.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
1075 }
1076
1077 normalized = normalized
1078 .replace(/[']/g, '-')
1079 .replace(/[^A-Za-z0-9\s-]/g, '')
1080 .toLowerCase()
1081 .trim()
1082 .replace(/\s+/g, '-')
1083 .replace(/-+/g, '-')
1084 .replace(/^-+|-+$/g, '');
1085
1086 if (!normalized) {
1087 normalized = 'image';
1088 }
1089
1090 return extension ? normalized + '.' + extension : normalized;
1091 }
1092
1093 function updateCleanupLiveExample() {
1094 if (!cleanupExampleInput || !cleanupPreviewOriginal || !cleanupPreviewCleaned) {
1095 return;
1096 }
1097
1098 const original = cleanupExampleInput.value || '';
1099 const cleaned = sanitizeFilenamePreview(original);
1100 const isCleanupEnabled = !!cleanupToggle && cleanupToggle.checked;
1101
1102 cleanupPreviewOriginal.textContent = original || 'example image.jpg';
1103
1104 const cleanedContainer = cleanupPreviewCleaned.closest('.quickwebp-cleanup-example-item');
1105 if (!isCleanupEnabled) {
1106 cleanupPreviewCleaned.textContent = strings.cleanupDisabledPreview;
1107 if (cleanedContainer) {
1108 cleanedContainer.classList.add('is-disabled');
1109 }
1110 return;
1111 }
1112
1113 cleanupPreviewCleaned.textContent = cleaned;
1114 if (cleanedContainer) {
1115 cleanedContainer.classList.remove('is-disabled');
1116 }
1117 }
1118
1119 onboardingButtons.forEach((button) => {
1120 button.addEventListener('click', function () {
1121 const profile = this.getAttribute('data-profile');
1122
1123 if (conversionToggle) {
1124 conversionToggle.checked = true;
1125 conversionToggle.dispatchEvent(new Event('change', { bubbles: true }));
1126 }
1127
1128 if (!saveOriginalCheckbox) {
1129 return;
1130 }
1131
1132 if (profile === 'new-site') {
1133 saveOriginalCheckbox.checked = false;
1134 setDisplayMode('disabled');
1135
1136 if (onboardingFeedback) {
1137 onboardingFeedback.textContent = strings.appliedNewSite;
1138 }
1139 }
1140
1141 if (profile === 'existing-site') {
1142 saveOriginalCheckbox.checked = true;
1143 if (rewriteDisplayModeInput) {
1144 rewriteDisplayModeInput.checked = true;
1145 } else {
1146 setDisplayMode('picture');
1147 }
1148
1149 if (onboardingFeedback) {
1150 onboardingFeedback.textContent = strings.appliedExistingSite;
1151 }
1152 }
1153
1154 updateUiConsistency();
1155
1156 if (conversionCard) {
1157 conversionCard.scrollIntoView({ behavior: 'smooth', block: 'start' });
1158 }
1159 });
1160 });
1161
1162 if (saveOriginalCheckbox) {
1163 saveOriginalCheckbox.addEventListener('change', updateUiConsistency);
1164 }
1165
1166 if (conversionToggle) {
1167 conversionToggle.addEventListener('change', updateUiConsistency);
1168 }
1169
1170 displayModeInputs.forEach((input) => {
1171 input.addEventListener('change', updateSummary);
1172 });
1173
1174 if (seoExampleInput) {
1175 seoExampleInput.addEventListener('input', updateSeoLiveExample);
1176 updateSeoLiveExample();
1177 }
1178
1179 if (cleanupExampleInput) {
1180 cleanupExampleInput.addEventListener('input', updateCleanupLiveExample);
1181 updateCleanupLiveExample();
1182 }
1183
1184 if (completionToggle) {
1185 completionToggle.addEventListener('change', updateSeoLiveExample);
1186 }
1187
1188 if (cleanupToggle) {
1189 cleanupToggle.addEventListener('change', updateCleanupLiveExample);
1190 }
1191
1192 completionOptionInputs.forEach((input) => {
1193 input.addEventListener('change', updateSeoLiveExample);
1194 });
1195
1196 document.querySelectorAll('.quickwebp-quick-links a[href^="#"]').forEach((anchor) => {
1197 anchor.addEventListener('click', function (event) {
1198 const target = document.querySelector(this.getAttribute('href'));
1199 if (!target) {
1200 return;
1201 }
1202
1203 event.preventDefault();
1204 target.scrollIntoView({ behavior: 'smooth', block: 'start' });
1205 });
1206 });
1207
1208 updateUiConsistency();
1209 });
1210 </script>
1211 </div>