Marcus
Forum Replies Created
-
Forum: Plugins
In reply to: [Plus WebP or AVIF] Palette Image Not Supported and PHP Fatal ErrorI found bug//
The issue i encountering with the
filesize()function stems from it trying to retrieve the size of a file that doesn’t physically exist on the server, resulting in a “stat failed” warning. To handle this safely, you can add a check to ensure the file exists before callingfilesize(). Here’s how you can modify your code:$webp_file_path = $path . wp_basename( $file_thumb_webp ); if ( file_exists( $webp_file_path ) ) { $webp_size = filesize( $webp_file_path ); $metadata_webp['sizes'][ $key ]['filesize'] = $webp_size; } else { // Handle the case where the file doesn't exist, or simply skip it. }This modification ensures that
filesize()is only called when the file physically exists, preventing the “stat failed” warning.Consider adding additional logic or error handling if needed, depending on how you want to manage cases where files are missing.
Hi. Thanks for respond. I can find this version of files what do that issues maybe need make debug version what file make error.
To address the issue of
Palette image not supported by webpin your code, you can add a function to convert palette images to true color format, as suggested. Here’s how you can integrate the proposed changes into your code:- Add the
convert_to_truecolorfunction for image conversion:
private function convert_to_truecolor($image) { if (imageistruecolor($image)) { return $image; } $width = imagesx($image); $height = imagesy($image); $truecolor_image = imagecreatetruecolor($width, $height); // Preserve transparency imagealphablending($truecolor_image, false); imagesavealpha($truecolor_image, true); // Copy the palette image to the true color image imagecopy($truecolor_image, $image, 0, 0, 0, 0, $width, $height); imagedestroy($image); return $truecolor_image; }- Modify the
handle_upload_prefilterfunction to use this function before image processing:
function handle_upload_prefilter($file) { global $bir_options; if (substr($file['type'], 0, 5) != 'image') return $file; if ($bir_options == null) $bir_options = new Bir_options_var(); self::$original_image = null; self::$original_image_name = null; self::$uniq_id = null; // Specify desired dimensions for resized image $resize = false; $quality = 100; if ($bir_options->resize_active == 1) { $max_width = $bir_options->max_width; $max_height = $bir_options->max_height; $quality = $bir_options->quality; $resize = true; } else if ($bir_options->optimize_active == 1 || $bir_options->webp_active == 1) { $max_width = 5000; $max_height = 5000; $quality = $bir_options->quality; $resize = true; } // Full path of the temporary file $file_path = $file['tmp_name']; $ris_filter = apply_filters('op_bir_resize_image_bulk', wp_basename($file_path), 0); if (is_array($ris_filter) && count($ris_filter) == 2) { if (array_key_exists('width', $ris_filter) && array_key_exists('height', $ris_filter)) { $max_width = $ris_filter['width']; $max_height = $ris_filter['height']; } else { $max_width = array_shift($ris_filter); $max_height = array_shift($ris_filter); } if (array_key_exists('quality', $ris_filter) && $ris_filter['quality'] > 0 && $ris_filter['quality'] <= 100) { $quality = $ris_filter['quality']; } } elseif (is_bool($ris_filter)) { $resize = $ris_filter; } if (substr($file['name'], -4) == '.gif' || $file["type"] == 'image/gif') { $resize = false; } if (substr($file['name'], -4) == '.svg' || stripos($file["type"], 'svg') !== false) { $resize = false; } self::$original_image_name = $file['name']; if ($resize) { $ext2 = pathinfo($file['tmp_name'], PATHINFO_EXTENSION); $file_original = str_replace(".".$ext2, '', $file['tmp_name']); $file_original .= '-original.'.$ext2; copy($file['tmp_name'], $file_original); self::$original_image = $file_original; // Load the image and convert it to true color if necessary $image = wp_get_image_editor($file_path); if (!is_wp_error($image)) { $image_resource = $image->get_image(); $image_resource = $this->convert_to_truecolor($image_resource); $image->save($file_path, null, $quality); } $source_image = wp_get_image_editor($file_path); if (!is_wp_error($source_image)) { $source_image->resize($max_width, $max_height); if ($quality != 100) $source_image->set_quality($quality); $mime_type = $file["type"]; if ($bir_options->webp_active == 1) { $mime_type = 'image/webp'; $file["type"] = $mime_type; $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $file['name'] = str_replace('.'.$ext, '', $file['name']); $file['name'] .= '.webp'; } $new_image = $source_image->save($file["tmp_name"], $mime_type); if ($bir_options->webp_active == 1) { $get_image = imagecreatefromwebp($new_image['path']); imagewebp($get_image, $new_image['path'], $quality); } unlink($file["tmp_name"]); rename($new_image['path'], $file["tmp_name"]); $file['size'] = $new_image['filesize']; } } if ($bir_options->rename_active == 1) { $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $post_id = (isset($_REQUEST['post'])) ? absint($_REQUEST['post']) : 0; $file['name'] = Bir_rename_functions::get_name_from_file($bir_options->rename, $file["tmp_name"], 0, $post_id, $file["name"]).'.'.$ext; self::$uniq_id = Bir_rename_functions::$current_uniq; } return $file; }This code checks if the image is palette-based and converts it to true color format before further processing, including resizing or converting to WebP format. This should help prevent the
Palette image not supported by webperror.Forum: Plugins
In reply to: [Plus WebP or AVIF] Palette Image Not Supported and PHP Fatal ErrorI make a test
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0604 seconds.)
SELECT ID, post_title, post_mime_type FROM wp_posts WHERE post_type = 'attachment' AND (post_mime_type = '' OR post_mime_type IS NULL);as you can see, there are no errors or empty values.
Since your query did not return any results, it means all your records in the
wp_poststable for theattachmenttype have correct or non-empty MIME types. This is a good sign, as it indicates the issue is not related to missing or incorrect MIME types.However, if the issue with converting images to WebP persists, you should check other possible causes and solutions. Steps for Further Diagnosis and Resolution
- Check Logging:
- Ensure you have added the logging function in your code to track images that cannot be converted. This will help identify the problematic images.
private function log_unsupported_webp_file( $filename ) { if ( class_exists( 'WC_Logger' ) ) { WC_Logger::instance()->debug( 'Unsupported WebP file: ' . $filename ); } } - Check GIF Images with Palettes:
- For GIF images with color palettes, make sure they are properly handled in your code. Here’s an example:
case 'image/gif': $src = imagecreatefromgif( $filename ); if ($src === false) { $this->log_unsupported_webp_file( $filename ); return false; } $img = imagecreatetruecolor( imagesx( $src ), imagesy( $src ) ); imagealphablending( $img, true ); imagecopy( $img, $src, 0, 0, 0, 0, imagesx( $src ), imagesy( $src ) ); imagedestroy( $src ); break; - Update Conversion Function:
- In your
create_webpfunction, ensure all images are properly processed and converted to WebP format.
private function create_webp( $filename, $mime_type, $filename_webp ) { if ( ! file_exists( $filename ) ) { return false; } if ( file_exists( $filename_webp ) ) { return false; }$pluswebp_settings = get_option( 'pluswebp' ); @set_time_limit( 60 ); wp_raise_memory_limit( 'pluswebp' ); $ret = false; switch ( $mime_type ) { case 'image/jpeg': $src = imagecreatefromjpeg( $filename ); break; case 'image/png': $src = imagecreatefrompng( $filename ); break; case 'image/gif': $src = imagecreatefromgif( $filename ); if ($src === false) { $this->log_unsupported_webp_file( $filename ); return false; } break; default: $this->log_unsupported_webp_file( $filename ); return false; } $img = imagecreatetruecolor( imagesx( $src ), imagesy( $src ) ); imagealphablending( $img, true ); imagecopy( $img, $src, 0, 0, 0, 0, imagesx( $src ), imagesy( $src ) ); imagedestroy( $src ); $ret = imagewebp( $img, $filename_webp, $pluswebp_settings['quality'] ); imagedestroy( $img ); return $ret;} - In your
- Check Plugin Settings:
- Ensure the settings for the Plus WebP plugin are correctly configured, especially the quality and image processing parameters.
- Check PHP Errors:
- Ensure there are no other PHP errors in your environment that might be interrupting the conversion process. Check PHP error logs for any issues.
Here’s the detailed explanation the issues with Palette image format support for WebP in your plugin’s code: Key Areas in the Code
- Function
check_image_editor:static function check_image_editor() { // ... (other code parts)$img = wp_get_image_editor($path_check_img_url); if (is_wp_error($img)) { self::$global_bulk_image_resizer_check_editor = $img->get_error_message(); if ($img->get_error_code() == 'image_no_editor') { if ( (! extension_loaded( 'gd' ) || ! function_exists( 'gd_info' )) && ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false )) ) { self::$global_bulk_image_resizer_check_editor = __('There seems to be no php library for manipulating images.', 'bulk-image-resizer'); } } return self::$global_bulk_image_resizer_check_editor; } else { self::$global_bulk_image_resizer_check_editor = ''; return ''; }} - Function
op_get_image_info:static function op_get_image_info($path_img) { // ... (other code parts) $img = wp_get_image_editor($path_img); if (is_wp_error($img)) { return $result; } $result['is_valid'] = true; // ... (other code parts) } - Additional code for handling truecolor images:
php if ($img->get_error_code() == 'image_palette_not_supported') { $truecolor_image = imagecreatetruecolor(imagesx($image), imagesy($image)); imagecopy($truecolor_image, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); $image = $truecolor_image; }
Comments for Developers
- Checking and handling image editor support:
In thecheck_image_editorfunction, image editor support is verified. It’s crucial to add checks and error handling for images in Palette format for WebP. This can be achieved by converting such images to the truecolor format before further processing. - Image processing in
op_get_image_infofunction:
Theop_get_image_infofunction processes images usingwp_get_image_editor. In case of errors with theimage_palette_not_supportedcode, logic should be added to convert images to truecolor format to avoid errors during processing. - General handling of WebP images:
Add checks and conversion to truecolor format in all functions where WebP image processing occurs to prevent issues related to Palette image support.
These changes will help mitigate errors related to processing Palette format images in WebP by converting them to truecolor format where necessary.
Maybe that help:
// Function to convert palette images to true color images
private function convert_to_truecolor($image) {
if (imageistruecolor($image)) {
return $image;
}
$width = imagesx($image);
$height = imagesy($image);
$truecolor_image = imagecreatetruecolor($width, $height);
// Preserve transparency
imagealphablending($truecolor_image, false);
imagesavealpha($truecolor_image, true);
// Copy the palette image to the true color image
imagecopy($truecolor_image, $image, 0, 0, 0, 0, $width, $height);
imagedestroy($image);
return $truecolor_image;
}Modify the handle_upload_prefilter function to use the convert_to_truecolor function before processing the image:
function handle_upload_prefilter($file) {
global $bir_options;
if (substr($file['type'], 0, 5) != 'image') return $file;
if ($bir_options == null) $bir_options = new Bir_options_var();
self::$original_image = null;
self::$original_image_name = null;
self::$uniq_id = null;
// Specifica le dimensioni desiderate per l'immagine ridimensionata
$resize = false;
$quality = 100;
if ($bir_options->resize_active == 1) {
$max_width = $bir_options->max_width;
$max_height = $bir_options->max_height;
$quality = $bir_options->quality;
$resize = true;
} else if ($bir_options->optimize_active == 1 || $bir_options->webp_active == 1) {
$max_width = 5000;
$max_height = 5000;
$quality = $bir_options->quality;
$resize = true;
}
// Percorso completo del file temporaneo
$file_path = $file['tmp_name'];
$ris_filter = apply_filters('op_bir_resize_image_bulk', wp_basename($file_path), 0);
if (is_array($ris_filter) && count($ris_filter) == 2) {
if (array_key_exists('width', $ris_filter) && array_key_exists('height', $ris_filter)) {
$max_width = $ris_filter['width'];
$max_height = $ris_filter['height'];
} else {
$max_width = array_shift($ris_filter);
$max_height = array_shift($ris_filter);
}
if (array_key_exists('quality', $ris_filter) && $ris_filter['quality'] > 0 && $ris_filter['quality'] <= 100) {
$quality = $ris_filter['quality'];
}
} elseif (is_bool($ris_filter)) {
$resize = $ris_filter;
}
if (substr($file['name'], -4) == '.gif' || $file["type"] == 'image/gif') {
$resize = false;
}
if (substr($file['name'], -4) == '.svg' || stripos($file["type"], 'svg') !== false) {
$resize = false;
}
self::$original_image_name = $file['name'];
if ($resize) {
$ext2 = pathinfo($file['tmp_name'], PATHINFO_EXTENSION);
$file_original = str_replace(".".$ext2, '', $file['tmp_name']);
$file_original .= '-original.'.$ext2;
copy($file['tmp_name'], $file_original);
self::$original_image = $file_original;
// Load the image and convert it to true color if necessary
$image = wp_get_image_editor($file_path);
if (!is_wp_error($image)) {
$image_resource = $image->get_image();
$image_resource = $this->convert_to_truecolor($image_resource);
$image->save($file_path, null, $quality);
}
$source_image = wp_get_image_editor($file_path);
if (!is_wp_error($source_image)) {
$source_image->resize($max_width, $max_height);
if ($quality != 100) $source_image->set_quality($quality);
$mime_type = $file["type"];
if ($bir_options->webp_active == 1) {
$mime_type = 'image/webp';
$file["type"] = $mime_type;
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
$file['name'] = str_replace('.'.$ext, '', $file['name']);
$file['name'] .= '.webp';
}
$new_image = $source_image->save($file["tmp_name"], $mime_type);
if ($bir_options->webp_active == 1) {
$get_image = imagecreatefromwebp($new_image['path']);
imagewebp($get_image, $new_image['path'], $quality);
}
unlink($file["tmp_name"]);
rename($new_image['path'], $file["tmp_name"]);
$file['size'] = $new_image['filesize'];
}
}
if ($bir_options->rename_active == 1) {
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
$post_id = (isset($_REQUEST['post'])) ? absint($_REQUEST['post']) : 0;
$file['name'] = Bir_rename_functions::get_name_from_file($bir_options->rename, $file["tmp_name"], 0, $post_id, $file["name"]).'.'.$ext;
self::$uniq_id = Bir_rename_functions::$current_uniq;
}
return $file;
}These changes add support for converting palette images to true color format before any further processing such as resizing or format conversion to avoid the PHP Fatal error: Palette image not supported by webp
It is necessary to add support for
$truecolor_image = imagecreatetruecolor(imagesx($image), imagesy($image));so that it supports conversion or highlights all such separate moments in a pass and statistics to see which files it cannot process. The problem is that it stops at 36 percent and logs the errorPHP Fatal error: Palette image not supported by webp, and then the process just doesn’t start and constantly says “Maybe you have some plugin that is interfering, because I didn’t get a valid json back. Try disabling the debug mode of the site or press ok to try to continue.”Forum: Plugins
In reply to: [Google for WooCommerce] Have a issue with description export to feedThank you for your valuable response, with the hint about the hook I was able to write my own action filter that effectively filtered everything during the re-scanning. It was really important for me not to interfere with the plugin’s code, so your hook suggestion was invaluable. I’ve written my own filter function and also set up different levels of logging to see the content before and after processing in the WC Logger logs. // Thank you.
Forum: Plugins
In reply to: [Google for WooCommerce] Have a issue with description export to feedI found this part code: i add to
/**
* Get the description for the WooCommerce product.
*
* @return string
*/
protected function get_wc_product_description(): string {
/**
* Filters whether the short product description should be used for the synced product.
*
* @param bool $use_short_description
*/
$use_short_description = apply_filters( 'woocommerce_gla_use_short_description', false );
$description = ! empty( $this->wc_product->get_description() ) && ! $use_short_description ?
$this->wc_product->get_description() :
$this->wc_product->get_short_description();
// prepend the parent product description to the variation product
if ( $this->is_variation() ) {
$parent_description = ! empty( $this->parent_wc_product->get_description() ) && ! $use_short_description ?
$this->parent_wc_product->get_description() :
$this->parent_wc_product->get_short_description();
$new_line = ! empty( $description ) && ! empty( $parent_description ) ? PHP_EOL : '';
$description = $parent_description . $new_line . $description;
}
/**
* Filters whether the shortcodes should be applied for product descriptions when syncing a product or be stripped out.
*
* @since 1.4.0
*
* @param bool $apply_shortcodes Shortcodes are applied if set totrueand stripped out if set tofalse.
* @param WC_Product $wc_product WooCommerce product object.
*/
$apply_shortcodes = apply_filters( 'woocommerce_gla_product_description_apply_shortcodes', false, $this->wc_product );
if ( $apply_shortcodes ) {
// Apply active shortcodes
$description = do_shortcode( $description );
} else {
// Strip out active shortcodes
$description = strip_shortcodes( $description );
}
// Strip out invalid unicode.
$description = mb_convert_encoding( $description, 'UTF-8', 'UTF-8' );
$description = preg_replace(
'/[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\x9F]/u',
'',
$description
);
// Strip out emojis and other non-printable characters.
$description = preg_replace('/[\x{1F600}-\x{1F64F}\x{1F300}-\x{1F5FF}\x{1F680}-\x{1F6FF}\x{1F700}-\x{1F77F}\x{1F780}-\x{1F7FF}\x{1F800}-\x{1F8FF}\x{1F900}-\x{1F9FF}\x{1FA00}-\x{1FA6F}\x{1FA70}-\x{1FAFF}\x{2600}-\x{26FF}\x{2700}-\x{27BF}\x{2300}-\x{23FF}\x{2B50}\x{2B06}\x{2934}-\x{2935}\x{3297}\x{3299}\x{3030}\x{303D}\x{00A9}\x{00AE}\x{2122}\x{23F3}\x{24C2}\x{23E9}-\x{23EF}\x{25B6}\x{23F8}-\x{23FA}]+/u', '', $description);
// Strip out invalid HTML tags (e.g. script, style, canvas, etc.) along with attributes of all tags.
$valid_html_tags = array_keys( wp_kses_allowed_html( 'post' ) );
$kses_allowed_tags = array_fill_keys( $valid_html_tags, [] );
$description = wp_kses( $description, $kses_allowed_tags );
// Trim the description if it's more than 5000 characters.
$description = mb_substr( $description, 0, 5000, 'utf-8' );
/**
* Filters the product's description.
*
* @param string $description Product description.
* @param WC_Product $wc_product WooCommerce product object.
*/
return apply_filters( 'woocommerce_gla_product_attribute_value_description', $description, $this->wc_product );
}This code uses two preg_replace functions:
- The first preg_replace removes non-printable characters that are not emojis (from \x00 to \x1F and \x80 to \x9F).
- The second preg_replace removes specific emojis by their Unicode codes.
But maybe the plugin has a hook??? I can’t change the original code((
Thank u for feedback) + add new issues PHP8.3.8 work Nginx Proxy Ubuntu 22 / Apache2 + PHP-FPM
[26-Jun-2024 14:10:33 UTC] PHP Warning: Attempt to read property “ID” on null in /home/admin/web/domain/public_html/wp-content/plugins/google-analytics-premium/pro/includes/frontend/class-frontend.php on line 301
Forum: Plugins
In reply to: [Wallet for WooCommerce] Cant delete Log Balance get errorThese errors indicate issues within the Kadence WooCommerce Email Designer plugin (
kadence-woocommerce-email-designer.php):- Undefined property: The “Undefined property” warning suggests that the object on which the
$user_loginproperty is being accessed does not have such a property defined. This typically happens if the object is not initialized correctly or if$user_loginis not a valid property in that context. - Deprecated str_replace: The “Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated” warning indicates that the
str_replace()function is being called with a$replaceparameter that isnull. In newer PHP versions, this usage is deprecated.
What to do:
- Check the plugin code: Ensure that all object properties are properly handled and initialized in the Kadence WooCommerce Email Designer plugin code before accessing them.
- Update the plugin: Make sure you are using the latest version of the plugin, as newer versions may fix bugs and improve compatibility with PHP updates.
- Fix function calls: Replace deprecated function calls highlighted in the warnings with their appropriate alternatives according to the latest PHP recommendations.
Forum: Plugins
In reply to: [WooCommerce] How add Content-Length to X-Sendfile / X-Accel-RedirectHow i can to that PM? Support team?
Forum: Plugins
In reply to: [WooCommerce] How add Content-Length to X-Sendfile / X-Accel-RedirectBug Report: Apache2 + X-Sendfile Not Working with Content-Length
Issue Description: When using Apache2 with X-Sendfile, files are not being delivered correctly when the Content-Length header is specified. I am planning to try a solution using Nginx to send files with Content-Length, but I’m unsure if it will help resolve the issue.
Steps Taken to Address the Issue:
- Apache2 + X-Sendfile Setup: Configured settings for file delivery via X-Sendfile.
- Content-Length Issue: Observed that files fail to deliver properly when the Content-Length header is set.
- Consideration of Nginx: Exploring the possibility of switching to Nginx and utilizing its solution for delivering files along with the Content-Length header.
Current Status: Uncertain if transitioning to Nginx will effectively resolve the file delivery issue when specifying the Content-Length header. Further testing is planned to evaluate the effectiveness of this approach.
Please understand that investigations are ongoing, and I am focused on finding the optimal solution for this particular issue.
Forum: Plugins
In reply to: [WooCommerce] How add Content-Length to X-Sendfile / X-Accel-RedirectNo.. Files no get Content-Length i dont know why..
Forum: Plugins
In reply to: [WooCommerce] How add Content-Length to X-Sendfile / X-Accel-RedirectSo i will try do that a now
Solution
// Remove the built-in function download_file_xsendfile from the hook
remove_action( ‘woocommerce_download_file_xsendfile’, array( ‘WC_Download_Handler’, ‘download_file_xsendfile’ ), 10 );// Add your custom function with additional headers
add_action( ‘woocommerce_download_file_xsendfile’, ‘trys_download_file_xsendfile’, 20, 2 );/**
- Custom function to download a file using X-Sendfile, X-Lighttpd-Sendfile, or X-Accel-Redirect if available.
* - @param string $file_path File path.
- @param string $filename File name.
*/
function trys_download_file_xsendfile( $file_path, $filename ) {
// Parse the file path
$parsed_file_path = WC_Download_Handler::parse_file_path( $file_path ); // Fallback to force download method for remote files if WooCommerce setting disallows xsendfile for remote files
if ( $parsed_file_path[‘remote_file’] && ! apply_filters( ‘woocommerce_use_xsendfile_for_remote’, false ) ) {
do_action( ‘woocommerce_download_file_force’, $file_path, $filename );
return;
} // Check for mod_xsendfile support on Apache
if ( function_exists( ‘apache_get_modules’ ) && in_array( ‘mod_xsendfile’, apache_get_modules(), true ) ) {
WC_Download_Handler::download_headers( $parsed_file_path[‘file_path’], $filename ); // Set headers// Set X-Sendfile for Apache $filepath = apply_filters( 'woocommerce_download_file_xsendfile_file_path', $parsed_file_path['file_path'], $file_path, $filename, $parsed_file_path ); header( 'X-Sendfile: ' . $filepath ); header( 'Content-Length: ' . filesize( $parsed_file_path['file_path'] ) ); // Add Content-Length exit;} elseif ( stristr( getenv( ‘SERVER_SOFTWARE’ ), ‘lighttpd’ ) ) {
WC_Download_Handler::download_headers( $parsed_file_path[‘file_path’], $filename ); // Set headers// Set X-Lighttpd-Sendfile for Lighttpd $filepath = apply_filters( 'woocommerce_download_file_xsendfile_lighttpd_file_path', $parsed_file_path['file_path'], $file_path, $filename, $parsed_file_path ); header( 'X-Lighttpd-Sendfile: ' . $filepath ); header( 'Content-Length: ' . filesize( $parsed_file_path['file_path'] ) ); // Add Content-Length exit;} elseif ( stristr( getenv( ‘SERVER_SOFTWARE’ ), ‘nginx’ ) || stristr( getenv( ‘SERVER_SOFTWARE’ ), ‘cherokee’ ) ) {
WC_Download_Handler::download_headers( $parsed_file_path[‘file_path’], $filename ); // Set headers// Set X-Accel-Redirect for Nginx or Cherokee $xsendfile_path = trim( preg_replace( '^' . str_replace( '\\', '/', getcwd() ) . '', '', $parsed_file_path['file_path'] ), '/' ); $xsendfile_path = apply_filters( 'woocommerce_download_file_xsendfile_x_accel_redirect_file_path', $xsendfile_path, $file_path, $filename, $parsed_file_path ); header( "X-Accel-Redirect: /$xsendfile_path" ); header( 'Content-Length: ' . filesize( $parsed_file_path['file_path'] ) ); // Add Content-Length exit; } // Fallback if X-Sendfile or X-Accel-Redirect methods are not supported
wc_get_logger()->warning(
sprintf(
/* translators: %1$s contains the filepath of the digital asset. */
__( ‘%1$s could not be served using the X-Accel-Redirect/X-Sendfile method. A Force Download will be used instead.’, ‘woocommerce’ ),
$file_path
)
);
WC_Download_Handler::download_file_force( $file_path, $filename ); // Force download
}
Forum: Plugins
In reply to: [WooCommerce] Support the new Woocommerce Beta Editor for ACFHi! I understand everything, but my question was different. You haven’t published any documentation on how to work and interact specifically with the fields of the new editor, and I am familiar with the WooCommerce documentation.
You haven’t created hooks or provided a way to interact with the fields (blocks), and there are no templates available to modify sections like DOWNLOADS, where I would like to add my own button. Unfortunately, I can’t do this because there is no documentation regarding the new editor for developers, only for user settings.
- Add the