Hi,
We use the below modifiers given by yourself. But I am trying to change a simple mapping for price but when saving it just reverts back. I did a few tests and removing the following measurement mappings
Weight
[iwp_convert_kg_to_g({8})]
Length
[iwphd1359_seperate_dimensions(“{9}”, “0”)]
Width
[iwphd1359_seperate_dimensions(“{9}”, “1”)]
Height
[iwphd1359_seperate_dimensions(“{9}”, “2”)]
One removed I can change price mappings and it saves correctly. But then won’t allow me to save the measurement mappings back, saving them wipes them blank. I have always used these but now are causing an issue.
// Importwp modifiers
function iwp_generate_image_urls_list($input_string) {
// 1. First, attempt to extract the single URL from the Hyperlink() format.
$pattern_hyperlink = ‘/Hyperlink\(“([^”]+)”\)/i’;
$url_to_process = $input_string;
if (preg_match($pattern_hyperlink, $input_string, $matches)) {
// If it matches, use the extracted URL
$url_to_process = $matches[1];
}
// If it doesn’t match, $url_to_process remains the original string (which might be a plain URL).
// 2. Now, split the URL into its base path and extension.
// This regex captures the URL path before the last dot/extension into $matches[1]
// and the extension into $matches[2].
$pattern_split_url = ‘/^(.+)\.(jpg|jpeg|png|gif|webp)$/i’;
$base_url = ”;
$extension = ”;
if (preg_match($pattern_split_url, $url_to_process, $matches)) {
$base_url = $matches[1]; // e.g., https://…/P100848
$extension = $matches[2]; // e.g., jpg
} else {
// If the URL doesn’t look like a standard image path, return an empty string.
return ”;
}
// 3. Generate the array of URLs.
$urls = [];
// Add the original URL (without any suffix)
$urls[] = “{$base_url}.{$extension}”;
// Add the URLs with suffixes from _1 to _10
for ($i = 1; $i <= 10; $i++) {
$urls[] = “{$base_url}_{$i}.{$extension}”;
}
// 4. Return the array as a comma-separated string.
return implode(‘,’, $urls);
}
function iwp_convert_kg_to_g($weight_kg) {
// Check if the input is a valid number
if (!is_numeric($weight_kg)) {
return $weight_kg; // Return original value if not a number
}
// Convert kg to g (multiply by 1000)
$weight_g = floatval($weight_kg) * 1000;
return $weight_g;
}
function iwphd1359_desc_list(…$texts)
{
$output = ”;
$texts = array_values(array_filter(array_map(‘trim’, (array)$texts)));
if (empty($texts)) {
return $output;
}
return ‘<ul><li>’ . implode(‘</li><li>’, $texts) . ‘</li></ul>’;
}
function split_dimension($value, $part = ‘length’) {
if (empty($value)) {
return ”;
}
// Convert possible weird input types
if (is_array($value)) {
$value = reset($value);
} elseif (is_object($value) && property_exists($value, ‘value’)) {
$value = $value->value;
}
// Normalize all separators and spaces
$value = trim($value);
$value = str_replace([‘×’, ‘X’, ‘x’, ‘ ‘], ‘x’, $value); // includes non-breaking space
$value = preg_replace(‘/\s+/’, ”, $value); // remove all whitespace
// Now should look like “9x9x9”
$parts = explode(‘x’, strtolower($value));
// Safety: make sure we have 3 parts
$length = isset($parts[0]) ? floatval($parts[0]) : ”;
$width = isset($parts[1]) ? floatval($parts[1]) : ”;
$height = isset($parts[2]) ? floatval($parts[2]) : ”;
switch (strtolower($part)) {
case ‘width’:
return $width;
case ‘height’:
return $height;
default:
return $length;
}
}
function iwphd1359_seperate_dimensions($input = ”, $part = 0)
{
// Fix: Convert ImportWP preview array into a single text string
if (is_array($input)) {
$input = implode(‘ x ‘, $input);
} elseif (is_object($input) && property_exists($input, ‘value’)) {
$input = $input->value;
}
// Split by x / X / unicode ×
$input = str_replace([‘×’, ‘X’], ‘x’, (string)$input);
$parts = array_map(‘trim’, explode(‘x’, $input));
return isset($parts[(int)$part]) ? $parts[(int)$part] : ”;
}
/* Increase by 1.00 and round .99 – use [iwp_increase_and_round_price({price_column_name})] */
function iwp_increase_and_round_price($price) {
$increased_price = floatval($price) + 1.00;
$rounded_price = ceil($increased_price) – 0.01;
return number_format($rounded_price, 2, ‘.’, ”);
}