houke/acf-icon-picker

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

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

安装次数: 6,535

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 49

语言:JavaScript

类型:wordpress插件

1.9.0 2021-01-14 09:19 UTC

This package is auto-updated.

Last update: 2024-09-27 11:18:58 UTC


README

允许您创建一个'图标选择器'acf字段。

请注意

我不再自己开发此插件,但仍将接受PR。

描述

将您希望主题中可用的svg图标添加到主题img文件夹中的acf文件夹。该字段返回svg的名称。

兼容性

此ACF字段类型与以下版本兼容

  • ACF 6
  • 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 - 首次发布