ACF Icomoon Plugin v4.0.13 Path Processing Fix
-
# ACF Icomoon Plugin v4.0.13 Path Processing Fix
## Problem Description
The ACF Icomoon plugin version 4.0.13 introduced a bug in theviivue_get_icomoon_json_path()function that breaks file paths containing duplicate directory names.
### Example of the Issue
**Your original path:**<br>/Users/username_user/Desktop/company_name/Projects/project_name/app/public/project_name/www/wp-content/themes/project_name/assets/icons/acf-selection.json<br>
**What v4.0.13 produces (BROKEN):**<br>/Users/username_user/Desktop/company_name/Projects/project_name/app/public/www/wp-content/themes/assets/icons/acf-selection.json<br>
Notice how the two additional instances of "project_name" are removed, breaking the path.
## Root Cause
The problematic code inacf-icomoon.4.0.13/acf-icomoon/includes/helper.php(lines 32-34):php<br>$theme_path = get_stylesheet_directory();<br>$json_path_array = array_unique(array_merge(explode('/', $theme_path), explode('/', $json_path)));<br>$json_path = implode('/', $json_path_array);<br>
Thearray_unique()function removes duplicate values from the array, which eliminates legitimate duplicate directory names in the path.
## How v4.0.12 Handled This
Version 4.0.12 used a completely different approach in theviivue_get_icomoon_json()function:php<br>$folder_path = viivue_array_key_exists('dirname', pathinfo(get_template_directory()));<br>$recursive_dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folder_path));<br>$filename = viivue_array_key_exists('basename', pathinfo($json_path));<br><br>if(!empty($json_path)){<br> foreach($recursive_dir as $file){<br> if($file->getBasename() == $filename){<br> $json_path = $file->getPathname();<br> break;<br> }<br> }<br>}<br>
This approach searched for the JSON file by filename rather than trying to manipulate the path.
## The Fix Applied
The fixedviivue_get_icomoon_json_path()function now:
1. **Preserves the original path structure** - No morearray_unique()that removes duplicate directory names
2. **Handles absolute paths correctly** - If the path exists as-is, use it directly
3. **Handles relative paths** - Resolves relative paths against the theme directory
4. **Maintains backward compatibility** - Still works with existing configurations
### Fixed Codephp<br>function viivue_get_icomoon_json_path($json_path = ''){<br> if(!empty($json_path)){<br> $file_name = basename($json_path);<br> <br> // only accept JSON file<br> if(pathinfo($file_name, PATHINFO_EXTENSION) !== 'json'){<br> return '';<br> }<br> <br> // If the json_path is already absolute and exists, use it directly<br> if(file_exists($json_path)){<br> return $json_path;<br> }<br> <br> // If it's a relative path, try to resolve it relative to the theme directory<br> $theme_path = get_stylesheet_directory();<br> $full_path = $theme_path . '/' . ltrim($json_path, '/');<br> <br> if(file_exists($full_path)){<br> return $full_path;<br> }<br> <br> // If that doesn't work, return the original path for further processing<br> return $json_path;<br> }else{<br> $json_path = ACFICOMOON_STYLESHEET_DIR . '/assets/fonts/selection.json';<br> if(!file_exists($json_path)){<br> return '';<br> }<br> }<br> <br> return $json_path;<br>}<br>
## Files Modified
-acf-icomoon.4.0.13/acf-icomoon/includes/helper.php- Fixed theviivue_get_icomoon_json_path()function
## Testing
To test the fix:
1. Use the modified version 4.0.13 with your project
2. Configure the JSON path to point to your selection.json file
3. Verify that paths with duplicate directory names work correctly
## Recommendation
This fix should be submitted to the plugin developers as it addresses a legitimate bug that affects users with project structures containing duplicate directory names in their paths.
The fix maintains the intended functionality of validating JSON paths while removing the problematicarray_unique()call that was breaking valid paths.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘ACF Icomoon Plugin v4.0.13 Path Processing Fix’ is closed to new replies.