将 CSS 规则应用于 woocommerce 产品后端页面 [英] Apply CSS Rule to woocommerce Product BACKEND page

查看:31
本文介绍了将 CSS 规则应用于 woocommerce 产品后端页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们尝试将特定的 css 规则应用于产品后端页面而不是前端页面.

We try to apply a certain css rule to a product backend page not the frontend page.

但是有两种类型的页面,一种是单击创建产品时,另一种是单击编辑产品时.

But there are 2 types of pages one which is when you click create product and one when you click edit product.

我们需要将 css 规则应用于这两个页面.

We need to apply the css rule to both of these pages.

我们通过以下解决方案在后端单击添加产品时确定部分 url 获得了一半的答案:

We achieved half of the answer by determining part of url when we click add product in the backend by the solution below:

add_action( 'init', 'bbloomer_apply_css_if_url_contains_string' );

function bbloomer_apply_css_if_url_contains_string() {

$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];

    if(false !== strpos( $url, 'post_type=product' )){
    echo '<style type="text/css">
         #ovaem_sectionid { display: none !important }
         </style>';
} 

}

我们希望如果有类似 (is_Product) 的东西,但后端可以用于添加新产品或编辑现有产品页面以应用此 css 时.

We hope if there is a thing like (is_Product) but for the backend can be used for both when adding a new product or when editing an existing product page to apply this css.

推荐答案

包含 .post-type-product 类,用作第一个选择器

<body> contains .post-type-product class, use it as the first selector

function my_custom_css() {
    echo '<style>
        .post-type-product #ovaem_sectionid {
            display: none !important;
        } 
    </style>';
}
add_action('admin_head', 'my_custom_css' );

这篇关于将 CSS 规则应用于 woocommerce 产品后端页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆