seothemes/core-custom-colors

通过配置添加颜色设置到自定义设置器

0.1.0 2018-08-01 12:02 UTC

This package is auto-updated.

Last update: 2024-09-26 13:59:20 UTC


README

使用CSS输出添加颜色设置到自定义设置器。

安装

应使用Composer安装此组件,命令为 composer require seothemes/core-custom-colors

使用方法

在您的配置文件中(通常位于 config/defaults.php),使用 CustomColors 作为数组键以添加要添加到自定义设置器的颜色设置列表。

例如

use SEOThemes\Core\CustomColors;

$custom_colors = [
	'background' => [
		'default' => '#ffffff',
		'output'  => [
			[
				'elements'   => [
					'.site-container',
				],
				'properties' => [
					'background-color' => '%s',
				],
			],
		],
	],
];

return [
    CustomColors::class => $custom_colors,
];

上述代码将在自定义设置器的 Colors 部分添加一个新的 Background Color 设置。它还将在网站的客户端输出以下CSS

.site-container{background-color:#fff}

加载组件

组件应在您的主题 functions.php 文件中加载,使用 Theme::setup 静态方法。代码应在 after_setup_theme 插件(或如果您使用Genesis框架,则为 genesis_setup)上运行。

add_action( 'after_setup_theme', function() {
    $config = include_once __DIR__ . '/config/defaults.php';
    D2\Core\Theme::setup( $config );
} );