huubl / acf-icon-picker
此包最新版本(v1.0)没有可用的许可证信息。
添加ACF字段以选择SVG图标。
v1.0
2019-06-27 20:35 UTC
This package is auto-updated.
Last update: 2024-09-08 23:08:58 UTC
README
允许您创建一个'图标选择器'acf字段。
请注意
我不再自己开发这个插件,但我仍然会接受PR。
描述
将您希望主题中可用的svg图标添加到主题中img文件夹内的acf文件夹中。字段返回svg的名称。
兼容性
此ACF字段类型与以下兼容
[x] ACF 6 [x] ACF 5
屏幕截图
安装
通过Composer
- 在您的存储库数组中添加一行:
{ "type": "git", "url": "https://github.com/houke/acf-icon-picker" }
- 在您的require块中添加一行:
"houke/acf-icon-picker": "dev-master"
- 运行:composer update
手动
- 将
acf-icon-picker
文件夹复制到您的wp-content/plugins
文件夹 - 通过插件管理页面激活图标选择器插件
- 通过ACF创建一个新字段并选择图标选择器类型
过滤器
使用以下过滤器来覆盖默认的图标文件夹、路径和/或URL
// 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__ ); }
对于Sage/Bedrock编辑filters.php
/// modify the path to the icons directory add_filter('acf_icon_path_suffix', function ( $path_suffix ) { return '/assets/images/icons/'; // After assets folder you can define folder structure } ); // modify the path to the above prefix add_filter('acf_icon_path', function ( $path_suffix ) { return '/app/public/web/themes/THEME_NAME/resources'; } ); // modify the URL to the icons directory to display on the page add_filter('acf_icon_url', function ( $path_suffix ) { return get_stylesheet_directory_uri(); } );
变更日志
- 1.9.1 - ACF 6兼容性修复。感谢idflood
- 1.9.0 - 修复删除时Gutenberg预览未更新的问题。感谢cherbst
- 1.8.0 - 修复Gutenberg无法保存图标的问题。感谢tlewap
- 1.7.0 - 添加两个新过滤器以更好地控制图标路径。感谢benjibee
- 1.6.0 - 带有许多图标的性能修复。感谢idflood
- 1.5.0 - 修复搜索包含空格的图标名称时破坏预览的问题
- 1.4.0 - 添加过滤器以更改存储svg图标的文件夹
- 1.3.0 - 在模态框中添加关闭选项
- 1.2.0 - 添加搜索过滤器输入以通过名称过滤图标
- 1.1.0 - 当字段不是必填项时,添加按钮以删除选定的图标
- 1.0.0 - 首次发布