fix(performance): correctly disable cleanup button when no actionable items remain

- Fix initial state where cleanup button stayed enabled after full cleanup
- Extend logic to detect "nothing to clean" cases:
  - no optimized images available for cleanup
  - all originals already deleted
- Align PHP initial render logic with runtime JS behavior
- Improve UX consistency between page load and live updates
This commit is contained in:
2026-04-25 15:07:21 +02:00
parent 937b36b27f
commit 7b5bd18dcd
2 changed files with 197 additions and 38 deletions
+27 -1
View File
@@ -84,7 +84,7 @@ function zeitfresser_customize_register( $wp_customize ) {
'type' => 'checkbox',
'section' => 'ztfr_performance_tools',
'label' => 'Auto Delete Original Pictures on Upload',
'description' => 'Automatically deletes original images after optimization. ⚠️ This action cannot be undone.',
'description' => 'Automatically deletes original images after optimization.',
)
);
}
@@ -236,3 +236,29 @@ function zeitfresser_customize_controls_dependency_js() {
<?php
}
add_action( 'customize_controls_enqueue_scripts', 'zeitfresser_customize_controls_dependency_js' );
add_action( 'customize_controls_enqueue_scripts', function() {
?>
<style>
/* 🔥 Settings Label Bolt */
#customize-control-ztfr_auto_optimize label,
#customize-control-ztfr_auto_delete label {
font-weight: 600;
display: block;
margin-bottom: 2px;
line-height: 1.4;
}
/* 🔥 Warning line under description */
#customize-control-ztfr_auto_delete .description::after {
content: "⚠ This action cannot be undone.";
display: block;
margin-top: 6px;
color: #b32d2e;
font-weight: 500;
}
</style>
<?php
});