This enhances Advanced Custom Field plugin by adding an svg icon custom field.
- ACF 5.0.0 and up, that means the pro version.
- ACF 4 (not supported).
- Add a line to your repositories array:
"repositories": [ { "type": "package", "package": { "name": "akandco/acf-svg-icon", "type": "wordpress-muplugin", "version": "3.0.0", "dist": { "type": "zip", "url": "web/app/plugin-zips/acf-svg-icon-modified-3.0.0.zip" } } }, ... ]
- Add a line to your require block:
"akandco/acf-svg-icon": "^3",
- Add to mu-plugins:
"web/app/mu-plugins/{$name}/": [ "type:wordpress-muplugin", "akandco/acf-svg-icon", ...
- Run:
composer update
- Add icons to
assets/images/icons
and/or the Media Library
Add icons from our assets folder (using Sage)
// Add icons from our assets folder
add_filter('acf_svg_icon_filepath', function($filepath) {
$icons = glob(get_template_directory() . '/resources/images/icons/*.svg');
foreach ($icons as $filename) {
$filepath[] = $filename;
}
return $filepath;
});
Remove the inclusion of media library icons
// Remove the inclusion of media library icons
add_filter('acf_svg_icon_include_media_library', '__return_false');
If you gonna change some JS or CSS, we use GULP in order to uglify and minify assets. So please do the following for your PR:
- install node modules :
npm install
- install gulp dependencies :
npm install gulp
- then minify assets :
gulp dist
- Updated usage of
wp_localize_script
to support the new requirement of Wordpress 5.7
- Version bump as probs not compatible with previous versions since updates/overrides made
- Feature: add filter
acf_svg_icon_include_media_library
to disable icons/svgs in the media library
- No idea! Some stuff to fix sage assets folders probably?
- Fix: bug (or weird requirment) meant we needed a
-
in icon names
- FEATURE : add filter
acf_svg_icon_parsed_svg
to filter the icons list - FIX : fix PHP fatal error with SVG inclusion
- FIX : temporary fix an issue with acf_format method
- IMPROVE : respect WP coding standards
- FIX : Mixing custom and media sources
- FIX : Return array in get_all_svg_files function (reverted in 2.0.3)
- fix notice $acf->version property undefined on ACF versions under 5.6
- use built-in wrapper acf_get_setting('version') to retrieve version
- Add compatibility for ACF 5.6.0 and more versions
- Still keep compatibility for ACF 5.6.0 and lower versions
- Add some custom CSS for a more beautiful admin UI
- Now displaying the icon name, not anymore like a slug
- Improve readme
- Initial