WebP Express CloudHost.es Fix v0.25.9-cloudhost

 Fixed bulk conversion getting stuck on missing files
 Added robust error handling and timeout protection
 Improved JavaScript response parsing
 Added file existence validation
 Fixed missing PHP class imports
 Added comprehensive try-catch error recovery

🔧 Key fixes:
- File existence checks before conversion attempts
- 30-second timeout protection per file
- Graceful handling of 500 errors and JSON parsing issues
- Automatic continuation to next file on failures
- Cache busting for JavaScript updates

🎯 Result: Bulk conversion now completes successfully even with missing files

🚀 Generated with Claude Code (https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-23 10:22:32 +02:00
commit 37cf714058
553 changed files with 55249 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
use \WebPExpress\DismissableMessages;
use \WebPExpress\State;
use \WebPExpress\TestRun;
/*
$testResult = TestRun::getConverterStatus();
if ($testResult !== false) {
$workingConvertersIds = $testResult['workingConverters'];
} else {
$workingConvertersIds = [];
}
*/
$workingConvertersIds = State::getState('workingConverterIds', []);
if (in_array('vips', $workingConvertersIds)) {
if (in_array('cwebp', $workingConvertersIds)) {
DismissableMessages::printDismissableMessage(
'info',
'<p>I have some good news and... more good news! WebP Express now supports Vips and Vips is working on your server. ' .
'Vips is one of the best method for converting WebPs, on par with cwebp, which you also have working. ' .
'You may want to use Vips instead of cwebp. Your choice.</p>',
'0.14.0/say-hello-to-vips',
'Got it!'
);
} else {
DismissableMessages::printDismissableMessage(
'info',
'<p>I have some good news and... more good news! WebP Express now supports Vips and Vips is working on your server. ' .
'Vips is one of the best method for converting WebPs and has therefore been inserted at the top of the list.' .
'</p>',
'0.14.0/say-hello-to-vips',
'Got it!'
);
}
} else {
// show message?
}

View File

@@ -0,0 +1,10 @@
<?php
use \WebPExpress\DismissableMessages;
// introduced in 0.14.0 (migrate 9)
DismissableMessages::printDismissableMessage(
'info',
'WebP Express 0.14 handles PNG to WebP conversions quite well. Perhaps it is time to enable PNGs? ',
'0.14.0/suggest-enable-pngs',
'Got it!'
);

View File

@@ -0,0 +1,45 @@
<?php
use \WebPExpress\DismissableMessages;
use \WebPExpress\State;
use \WebPExpress\TestRun;
$convertersSupportingEncodingAuto = ['cwebp', 'vips', 'imagick', 'imagemagick', 'gmagick', 'graphicsmagick'];
$workingConvertersIds = State::getState('workingConverterIds', []);
$workingAndActiveConverterIds = State::getState('workingAndActiveConverterIds', []);
$firstActiveAndWorkingConverterId = (isset($workingAndActiveConverterIds[0]) ? $workingAndActiveConverterIds[0] : '');
if (in_array($firstActiveAndWorkingConverterId, $convertersSupportingEncodingAuto)) {
DismissableMessages::printDismissableMessage(
'info',
'<p>WebP Express 0.14 has new options for the conversions. Especially, it can now produce lossless webps, and ' .
'it can automatically try both lossy and lossless and select the smallest. You can play around with the ' .
'new options when your click "test" next to a converter.</p>' .
'<p>Once satisfied, dont forget to ' .
'wipe your existing converted files (there is a "Delete converted files" button for that here on this page).</p>',
'0.14.0/suggest-wipe-because-lossless',
'Got it!'
);
} else {
if ($firstActiveAndWorkingConverterId == 'gd') {
foreach ($workingConvertersIds as $workingId) {
if (in_array($workingId, $convertersSupportingEncodingAuto)) {
DismissableMessages::printDismissableMessage(
'info',
'<p>WebP Express 0.14 has new options for the conversions. Especially, it can now produce lossless webps, and ' .
'it can automatically try both lossy and lossless and select the smallest. You can play around with the ' .
'new options when your click "test" next to a converter.</p>' .
'<p>Once satisfied, dont forget to wipe your existing converted files (there is a "Delete converted files" ' .
'button for that here on this page)</p>' .
'<p>Btw: The "gd" conversion method that you are using does not support lossless encoding ' .
'(in fact Gd only supports very few conversion options), but fortunately, you have at least one ' .
'other conversion method working, so you can simply start using that instead.</p>',
'0.14.0/suggest-wipe-because-lossless',
'Got it!'
);
break;
}
}
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace WebPExpress;
// introduced in 0.14.0 (migrate 9)
DismissableMessages::printDismissableMessage(
'info',
'WebP Express 0.15 introduced a new "scope" setting which determines which folders that WebP Express ' .
'operates in. It has been set to "All content" in order not to change behaviour. ' .
'However, I would usually recommend limitting scope to "Uploads and Themes".',
'0.15.0/new-scope-setting-content',
'Got it!'
);

View File

@@ -0,0 +1,13 @@
<?php
namespace WebPExpress;
// introduced in 0.14.0 (migrate 9)
DismissableMessages::printDismissableMessage(
'info',
'WebP Express 0.15 introduced a new "scope" setting which determines which folders that WebP Express ' .
'operates in. It has been set to work on "index" (any images in the whole install, including wp-adimn) ' .
'in order not to change the behaviour. However, I would usually recommend a more limitted scope, ie. "Uploads and Themes".',
'0.15.0/new-scope-setting-index',
'Got it!'
);

View File

@@ -0,0 +1,12 @@
<?php
namespace WebPExpress;
DismissableMessages::printDismissableMessage(
'info',
'WebP Express 0.15 introduced a new "scope" setting which determines which folders that WebP Express ' .
'operates in. The migration script did not set it to include "uploads" because it seemed that it ' .
'would not be possible to write the .htaccess rules there.',
'0.15.0/new-scope-setting-no-uploads',
'Got it!'
);

View File

@@ -0,0 +1,15 @@
<?php
namespace WebPExpress;
/*
DismissableMessages::printDismissableMessage(
'error',
'Sorry, due to a bug, the combination of having destination folder set to "mingled" and ' .
'File extension set to "Set to .webp" ' .
'does not currently work. Please change the settings. ' .
'I shall fix this soon!',
'0.15.1/problems-with-mingled-set',
'Got it!'
);
*/

View File

@@ -0,0 +1,19 @@
<?php
namespace WebPExpress;
/*echo '<p>You are running on NGINX. WebP Express works well on NGINX, however this UI is not streamlined NGINX yet. </p>' .
'<p><b>You should head over to the </b>' .
'<a href="https://wordpress.org/plugins/webp-express/#i%20am%20on%20nginx%20or%20openresty" target="_blank"><b>NGINX section in the FAQ</b></a>' .
'<b> to learn how to use WebP Express on NGINX</b></p>';*/
DismissableMessages::printDismissableMessage(
'warning',
'<p>You are running on NGINX. WebP Express works well on NGINX, however this UI is not streamlined NGINX yet. </p>' .
'<p><b>You should head over to the </b>' .
'<a href="https://wordpress.org/plugins/webp-express/#i%20am%20on%20nginx%20or%20openresty" target="_blank"><b>NGINX section in the FAQ</b></a>' .
'<b> to learn how to use WebP Express on NGINX</b></p>',
'0.16.0/nginx-link-to-faq',
'Got it!'
);

View File

@@ -0,0 +1,34 @@
<?php
namespace WebPExpress;
$elementorActivated = in_array('elementor/elementor.php', get_option('active_plugins', []));
$showMessage = false;
if ($elementorActivated) {
try {
// The following is wrapped in a try statement because it depends on Elementor classes which might be subject to change
if (\Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_css_loading' ) === false) {
$showMessage = true;
}
} catch (\Exception $e) {
// Well, just bad luck.
}
}
if ($showMessage) {
DismissableMessages::printDismissableMessage(
'info',
'<p>' .
'You see this message because you using Elementor, you rely solely on Alter HTML for webp, and Elementor is currently set up to use external css. ' .
'You might want to reconfigure Elementor so it inlines the CSS. This will allow Alter HTML to replace the image urls of backgrounds. ' .
'To reconfigure, go to <i>Elementor > Settings > Experiments</i> and activate "Improved CSS Loading". ' .
'Note: This requires that Alter HTML is configured to "Replace image URLs". ' .
'For more information, <a target="_blank" href="https://wordpress.org/support/topic/background-images-not-working-as-webp-elementor/#post-15060686">' .
'head over here</a>' .
'</p>',
'0.23.0/elementor',
'Got it!'
);
} else {
DismissableMessages::dismissMessage('0.23.0/elementor');
}