我想在管理员中为锚创建一个颜色选择器。我知道这可以通过CSS完成,但我有一个多站点,希望用户可以轻松设置链接颜色。
以下方法可行,但与背景色的颜色选择器不同,颜色显示存在延迟,因此我只是检查以下方面是否可以改进:
function tcx_register_theme_customizer( $wp_customize ) {
$wp_customize->add_setting(
\'tcx_link_color\',
array(
// \'default\' => \'#ff0000\'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
\'link_color\',
array(
\'label\' => __( \'Link Color\', \'tcx\' ),
\'section\' => \'colors\',
\'settings\' => \'tcx_link_color\'
)
)
);
}
add_action( \'customize_register\', \'tcx_register_theme_customizer\' );
function tcx_customizer_css() {
?>
<style type="text/css">
a { color: <?php echo get_theme_mod( \'tcx_link_color\' ); ?>; }
</style>
<?php
}
add_action( \'wp_head\', \'tcx_customizer_css\' );
感谢您的帮助