This enhance Advanced Custom Field plugin by adding a custom field.
This ACF field is a select2 field in order to include your great fonts. It will allow you to select icons and then return the corresponding class icon.
This ACF field type is compatible with:
- ACF 5.0.0 and up, that means the pro version.
- ACF 4 (not supported).
- Add a line to your repositories array:
{ "type": "git", "url": "https://github.com/BeAPI/acf-svg-icon" }
- Add a line to your require block:
"bea/acf-svg-icon": "dev-master"
- Run:
composer update
- Copy the plugin folder into your plugins folder.
- Activate the plugin via the plugins admin page.
- Create a new field via ACF and select the SVG Icon selector.
You can upload media in your library, it must be an SVG, and then it will be displayed into the SVG dropdown. In this case, consider using Scalable Vector Graphics (svg) for security.
To load several SVGs from your theme (development), use the following filter to add the main sprite SVG file :
<?php add_filter( 'acf_svg_icon_filepath', 'bea_svg_icon_filepath' );
function bea_svg_icon_filepath( $filepath ) {
if ( is_file( get_stylesheet_directory() . '/assets/icons/icons.svg' ) ) {
$filepath[] = get_stylesheet_directory() . '/assets/icons/icons.svg';
}
return $filepath;
}
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
- FEATURE : Skip media type for displaying svgs as we use the URL
- FIX : fix PHP fatal error in the REST API for ACF's values from the field
- FEATURE : add french translation
- FEATURE : return sprite name if multiple SVG sprites are registered
- FIX : Replace
gulp-uglify
withgulp-uglify-es
- CHORE : set required Node version in package.json
- 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