个性化阅读
专注于IT技术分析

删除WordPress WooCommerce StoreFront标头样式

点击下载

WordPress WooCommerce StoreFront主题将样式放在WooCommerce StoreFront定制程序的标题中;

<style id='storefront-woocommerce-style-inline-css' type='text/css'></style>
<style id='storefront-style-inline-css' type='text/css'></style>

我似乎花了更多的时间来纠正这些样式, 而不是定义自己想要的东西。有谁知道如何删除它们或禁用Storefront定制程序?

标题样式

#1


对于任何与此斗争的人, 这是我发现的解决方案:

function my_theme_remove_storefront_standard_functionality() {

//remove customizer inline styles from parent theme as I don't need it.
set_theme_mod('storefront_styles', '');
set_theme_mod('storefront_woocommerce_styles', '');  

}

add_action( 'init', 'my_theme_remove_storefront_standard_functionality' );

#2


内联CSS的两个已添加到class-storefront-customizer.php中。

对于注销storefront-style-inline-css:

add_filter('storefront_customizer_css', '__return_false');

对于注销storefront-woocommerce-style-inline-css:

add_filter('storefront_customizer_woocommerce_css', '__return_false');

#3


我最近不得不删除它们, 最好的方法是使用Ngoc Nguyen的方法。

只需将以下代码放入你的functions.php中

function wpcustom_deregister_scripts_and_styles(){
    wp_deregister_style('storefront-woocommerce-style');
    wp_deregister_style('storefront-style');
}
add_action( 'wp_print_styles', 'wpcustom_deregister_scripts_and_styles', 100 );

#4


这可以在Storefront 2.0.4中使用吗?

因为我有这些过滤器:

add_filter( 'storefront_customizer_enabled', '__return_false' );
add_filter( 'storefront_customizer_css', '__return_false' );
add_filter( 'storefront_customizer_woocommerce_css', '__return_false' );

但我仍然有内联CSS。

在主题中提到了第一个过滤器:https://wordpress.org/support/topic/remove-inline-css-1?replies=8


#5


尝试这个:

add_filter( 'storefront_customizer_enabled', 'woa_storefront_disable_customizer' );

function woa_storefront_disable_customizer() {
    return false;
}

https://github.com/FrancySanchez/storefront-child/blob/master/functions.php


#6


我一直遇到这个问题, 尽管我的解决方案非常特定于我自己的应用程序, 但你可能会在其中找到用处。

我的问题是我想要带有浅灰色悬浮颜色的白色菜单文本。默认情况下, 遇到问题的内联css似乎会显示菜单文本颜色, 将其变浅一倍, 然后将该颜色设置为悬停颜色。显然, 白色无法淡化, 因此我的菜单在悬停时保持不变。这是我解决的方法:

在位于wp-content / themes / storefront_child / inc / customizer的文件” class-storefront-customizer.php”中, 定义了有关主题编辑器界面如何工作的功能。首先, 我执行以下功能:

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设置为所需的偏移颜色, 在我的情况下为#aeaeae。这会将编辑器的默认颜色设置为该值。此步骤不是必需的, 但确实使它更容易。

我还将此选项设置为与我不确定哪个选项真正生效的值相同。

$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中的值。希望这些信息对你有所帮助。


#7


经过几次试验, 我得到了解决该问题的最终解决方案!简单地说:-)删除” class-storefront-customizer.php”中的以下行, 它可以工作:

    add_action( 'wp_enqueue_scripts', array( $this, 'add_customizer_css' ), 130 );

问候赫伯特

赞(0)
未经允许不得转载:srcmini » 删除WordPress WooCommerce StoreFront标头样式

评论 抢沙发

评论前必须登录!