boxuk/wp-iconography

此软件包最新版本(0.0.7)没有提供许可证信息。

为块编辑器添加Material Icons

安装次数: 2,907

依赖关系: 0

建议者: 0

安全: 0

星标: 0

关注者: 3

分支: 0

公开问题: 0

类型:wordpress-plugin

0.0.7 2024-09-16 09:26 UTC

This package is auto-updated.

Last update: 2024-09-16 09:31:00 UTC


README

为WordPress块编辑器添加将图标内联添加到内容的能力。

快速开始!

将此插件添加到您的WordPress网站,并包含配置文件,即可使用!

如果您使用composer,那么操作非常简单,只需composer require boxuk/wp-iconography

配置

配置文件基于一个允许您快速定义配置的架构。它们会自动从wp-content/themes/{theme_name}/icons/*.config.json加载,或者您可以使用提供的过滤器定义任何自定义路径。

add_filter(
	'boxuk_iconography_files',
	function ( $config_files ) {
		$config_files['example'] = __DIR__ . '/config/example.config.json';
		return $config_files;
	}
);

插件中也包含示例配置文件,因此如果您想加载Material Symbols,只需加载此片段中包含的配置即可。

add_filter(
	'boxuk_iconography_files',
	function ( $config_files ) {
		$plugin_dir = WP_CONTENT_DIR . '/mu-plugins/wp-iconography'; // make sure this is valid for your project!


		// Remove any unnecessary
		$config_files['material-symbols-outlined']        = $plugin_dir . '/config/material-symbols-outlined.config.json';
		$config_files['material-symbols-outlined-filled'] = $plugin_dir . '/config/material-symbols-outlined-filled.config.json';
		$config_files['material-symbols-sharp']           = $plugin_dir . '/config/material-symbols-sharp.config.json';
		$config_files['material-symbols-sharp-filled']    = $plugin_dir . '/config/material-symbols-sharp-filled.config.json';
		$config_files['material-symbols-rounded']         = $plugin_dir . '/config/material-symbols-rounded.config.json';
		$config_files['material-symbols-rounded-filled']  = $plugin_dir . '/config/material-symbols-rounded-filled.config.json';
		return $config_files;
	}
);

有许多过滤器可供更改图标加载的方式,因此请自由查看源代码中的可用过滤器。如果某个函数对您不起作用,我们始终欢迎PR!

配置架构

配置架构包括

  • 标题 - 在编辑器中输出的名称。
  • 名称 - 图标集的唯一键/名称。我建议使用namespace/name格式。
  • 标签名称 - 这将是用于生成输出图标所使用的HTML标签。
  • 类名称 - 这用于生成输出图标的输出。
  • URL - 要加载的CSS文件
  • 附加CSS - 可能相关的任何内联CSS。
  • 图标 - 一个数组
    • 标签 - 用于管理员界面的值。用于搜索并在悬停时显示。
    • 内容 - 生成HTML中的内容。

示例JSON文件

{
	"title": "Example",
	"name": "boxuk/example",
	"tagName": "span",
	"className": "boxuk-icon-example",
	"url": "...",
	"additionalCSS": ".boxuk-icon-example { font-weight: 700; }",
	"icons": [
		{ "label": "Example", "content": "example-content" }
	]
}

生成的输出

<span class="boxuk-icon-example">example-content</span>

贡献

请勿在此提交任何Pull Requests。它们将被关闭。

请在此处提交您的PR:https://github.com/boxuk/wp-packages

这个仓库是我们所说的“子树分割”:主仓库的只读子集。我们期待您的PR!