huubl/acf-icon-picker

此包最新版本(v1.0)没有可用的许可证信息。

添加ACF字段以选择SVG图标。

维护者

详细信息

github.com/huubl/acf-icon-picker

来源

安装次数: 1,864

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 49

语言:JavaScript

类型:wordpress插件

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

屏幕截图

Icon Picker

安装

通过Composer

  1. 在您的存储库数组中添加一行:{ "type": "git", "url": "https://github.com/houke/acf-icon-picker" }
  2. 在您的require块中添加一行:"houke/acf-icon-picker": "dev-master"
  3. 运行:composer update

手动

  1. acf-icon-picker文件夹复制到您的wp-content/plugins文件夹
  2. 通过插件管理页面激活图标选择器插件
  3. 通过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 - 首次发布