agence-adeliom / acf-icon-picker
此包最新版本(1.0.0)的许可信息不可用。
1.0.0
2022-07-29 12:35 UTC
Requires
- php: ^8.0
- composer/installers: ^1.0 || ^2.0
- vinkla/extended-acf: *
This package is auto-updated.
Last update: 2024-09-08 17:30:29 UTC
README
允许创建ACF类型为 'icon-picker' 的字段。
注意,在icomoon中,请务必导出类版本,而不是基于标签i(与BO冲突)
[class^="icon-"], [class*=" icon-"] {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: '#{$icomoon-font-family}' !important;
speak: never;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
}
描述
使用icomoon图标,直接在主题/ assets/fonts 文件夹中设置(请从根目录提取所有内容)。
兼容性
ACF字段兼容:[x] ACF 5
直接作为函数添加,以确保与ACF wordplate字段的兼容性
截图
安装
- 更新composer.json
"repositories": { ... "adeliom-icon-picker": { "type": "vcs", "url": "https://github.com/agence-adeliom/acf-icon-picker.git" }, ... } ... "require": { ... "agence-adeliom/acf-icon-picker": "dev-master" }
- 运行
composer update
- 从Wordpress管理后台激活插件
- 在您希望的位置创建一个字段,就像创建其他任何字段一样
use Adeliom\Acf\Fields\IconPicker; ... IconPicker::make("Icône", "icon")->required()->icons(['name-of-your-icon', '....']);
旧版本
acf_icon_picker([ 'name' => 'icon-picker', 'label' => __('Icone', ''), 'required' => true, ... ])
过滤器
如果不同的路径或URL不在您的Theme/assets/fonts/文件夹中,以下是一些过滤器:
// modify the path to the icons directory add_filter( 'acf_icon_path_suffix', 'acf_icon_path_suffix' ); function acf_icon_path_suffix( $path_suffix ) { return 'assets/img/icons/'; } // modify the path to the above prefix add_filter( 'acf_icon_path', 'acf_icon_path' ); function acf_icon_path( $path_suffix ) { return plugin_dir_path( __FILE__ ); } // modify the URL to the icons directory to display on the page add_filter( 'acf_icon_url', 'acf_icon_url' ); function acf_icon_url( $path_suffix ) { return plugin_dir_url( __FILE__ ); } // allowed to choose between Image or Font add_filter( 'acf_icon_image', 'acf_icon_image' ); function acf_icon_image() { return true; } // modify the format (default : svg) add_filter( 'acf_icon_image_format', 'acf_icon_image_format' ); function acf_icon_image_format() { return "png"; } // modify the filename (fantasticon) add_filter( 'acf_icon_filename', 'acf_icon_filename' ); function acf_icon_filename() { return "icons.scss"; }