我一直有这个问题,虽然我的解决方案是相当具体到我自己的应用程序,你会发现在它的使用。
我的问题是我想要白色的菜单文字和浅灰色的悬停颜色。默认情况下,您遇到问题的内联css似乎会使菜单文本颜色变亮,将其减少一个因子,并将该颜色设置为悬停颜色。显然,白色不能点亮,所以我的菜单在悬停时保持不变。下面是我如何解决这个问题:
在文件“class-storefront-customizer。.PHP”位于的wp-content /主题/ storefront_child/INC /定制上有主题编辑器界面是如何工作的定义函数首先,我采取了以下功能:
public static function get_storefront_default_setting_values() {
return apply_filters('storefront_setting_default_values', $args = array(
'storefront_heading_color' => '#333333',
'storefront_text_color' => '#6d6d6d',
'storefront_accent_color' => '#aeaeae',
'storefront_header_background_color' => '#ffffff',
'storefront_header_text_color' => '#6d6d6d',
'storefront_header_link_color' => '#333333',
'storefront_footer_background_color' => '#f0f0f0',
'storefront_footer_heading_color' => '#333333',
'storefront_footer_text_color' => '#6d6d6d',
'storefront_footer_link_color' => '#333333',
'storefront_button_background_color' => '#eeeeee',
'storefront_button_text_color' => '#333333',
'storefront_button_alt_background_color' => '#333333',
'storefront_button_alt_text_color' => '#ffffff',
'storefront_layout' => 'right',
'background_color' => 'ffffff',
));
}
我设置storefront_accent_color VAR作为偏移颜色我想要的,在我的情况下#eaeae。这将默认颜色设置为该值的编辑器。这一步是没有必要,但更容易。
我也设置此选项为相同的值,因为我不是肯定这将真正生效...
$wp_customize->add_setting('storefront_accent_color', array(
'default' => apply_filters('storefront_default_accent_color', '#aeaeae'),
'sanitize_callback' => 'sanitize_hex_color',
));
在这个文件的第501行是函数get_css()的定义,它设置了内联css,你看到你正试图摆脱。对于我来说,我需要改变的值在本节:
.main-navigation ul li a:hover,
.main-navigation ul li:hover > a,
.site-title a:hover,
a.cart-contents:hover,
.site-header-cart .widget_shopping_cart a:hover,
.site-header-cart:hover > li > a,
.site-header ul.menu li.current-menu-item > a {
color: ' . storefront_adjust_color_brightness($storefront_theme_mods['header_link_color'], 80) . ';
}
我改变了这个CSS属性的值设置为:
color: ' . $storefront_theme_mods['accent_color'] . ';
这并没有改变悬停抵消我的设定颜色。它做的事情是改变编辑器。
所以最后一步是进入编辑器,进入版式选项卡,选择强调色,撞默认的颜色按钮(现在应该拿出我的颜色),然后保存。之后,我的菜单正常工作。
这是一个有点长,你问的不太什么,但我把它全部中说明如何操作是输出成内联CSS值。希望这些信息对你有所帮助。
我发现,在店面引用> INC>类storefront.php线181和店面> INC> woocommerce>类店面,woocommerce.php线76 ......如果,可以帮助你。在那2个文件的开头有一些注册钩子。我会删除我的答案,然后...希望你会快速找到解决方案 – LoicTheAztec
我认为它的钩子内的某种钩子 – Stuart