我在我的父主题中有代码函数php作为路径my\\u parent\\u theme/include/addon/myfile。我曾尝试使用get样式表加载父函数,但没有成功。我只是不知道如何处理我的文件来更改一些css。
这是我在my\\u parent\\u theme/include/addon/myfile中的函数
add_filter( \'larismanis_style\', \'larismanis_wc_cart_popup_style\' );
function larismanis_wc_cart_popup_style( $style ) {
if ( larismanis_get_integration_wc( \'wc_cartpopup_disable\' ) ) {
return $style;
}
$style = $style.\'.tp-cart-popup .modal-body { padding-bottom:0; }\';
$style = $style.\'.tp-cart-popup button.close { background: none; border: none; }\';
$style = $style.\'.tp-cart-popup .woocommerce ul.cart_list { margin: 0; }\';
$style = $style.\'.tp-cart-popup .woocommerce ul.cart_list li { padding-left: 0; }\';
$style = $style.\'.tp-cart-popup .woocommerce ul.cart_list li .remove { display: none; }\';
$style = $style.\'.woocommerce ul.products li.product .added_to_cart.wc-forward, .woocommerce form.cart .added_to_cart.wc-forward, .tp-cart-popup-notices .button { display: none !important; }\';
$style = $style.\'.tp-cart-popup .woocommerce.widget_shopping_cart .cart_list li { padding: 0 0 1em; }\';
$style = $style.\'.tp-cart-popup-notices .woocommerce-error, .tp-cart-popup-notices .woocommerce-info, .tp-cart-popup-notices .woocommerce-message { margin-bottom: 1em; }\';
$style = $style.\'.woocommerce a.button.alt.single_add_to_cart_button.loading, .woocommerce button.button.alt.single_add_to_cart_button.loading, .woocommerce input.button.alt.single_add_to_cart_button.loading { padding-right: 3rem; }\';
$style = $style.\'.tp-cart-popup-loading { padding: 0 0 1.5rem; } .tp-cart-popup-loading .spinkit-wave{display:block;position:relative;top:50%;left:50%;width:50px;height:40px;margin:0 0 0 -25px;font-size:10px;text-align:center}.spinkit-wave .spinkit-rect{display:block;float:left;width:6px;height:50px;margin:0 2px;background-color:#e91e63;-webkit-animation:spinkit-wave-stretch-delay 1.2s infinite ease-in-out;animation:spinkit-wave-stretch-delay 1.2s infinite ease-in-out}.spinkit-wave .spinkit-rect1{-webkit-animation-delay:-1.2s;animation-delay:-1.2s}.spinkit-wave .spinkit-rect2{-webkit-animation-delay:-1.1s;animation-delay:-1.1s}.spinkit-wave .spinkit-rect3{-webkit-animation-delay:-1s;animation-delay:-1s}.spinkit-wave .spinkit-rect4{-webkit-animation-delay:-.9s;animation-delay:-.9s}.spinkit-wave .spinkit-rect5{-webkit-animation-delay:-.8s;animation-delay:-.8s}@-webkit-keyframes spinkit-wave-stretch-delay{0%,100%,40%{-webkit-transform:scaleY(.5);transform:scaleY(.5)}20%{-webkit-transform:scaleY(1);transform:scaleY(1)}}@keyframes spinkit-wave-stretch-delay{0%,100%,40%{-webkit-transform:scaleY(.5);transform:scaleY(.5)}20%{-webkit-transform:scaleY(1);transform:scaleY(1)}}\';
return $style;
}
如何使用if function\\u exists()更改该函数所需的一些css
任何帮助都将不胜感激!
SO网友:Jacob Peattie
function_exists()
这对你没有帮助。这需要在父主题中,你才能做任何事情。
要改变chid主题的唯一方法是使用remove_filter()
将其从父主题中删除,然后将其复制到子主题并添加该版本。
因此,请将此添加到您的孩子主题中:
add_action(
\'after_setup_theme\',
function() {
remove_filter( \'larismanis_style\', \'larismanis_wc_cart_popup_style\' );
add_filter( \'larismanis_style\', \'child_larismanis_wc_cart_popup_style\' );
}
);
function child_larismanis_wc_cart_popup_style( $style ) {
if ( larismanis_get_integration_wc( \'wc_cartpopup_disable\' ) ) {
return $style;
}
$style = $style.\'.tp-cart-popup .modal-body { padding-bottom:0; }\';
$style = $style.\'.tp-cart-popup button.close { background: none; border: none; }\';
$style = $style.\'.tp-cart-popup .woocommerce ul.cart_list { margin: 0; }\';
$style = $style.\'.tp-cart-popup .woocommerce ul.cart_list li { padding-left: 0; }\';
$style = $style.\'.tp-cart-popup .woocommerce ul.cart_list li .remove { display: none; }\';
$style = $style.\'.woocommerce ul.products li.product .added_to_cart.wc-forward, .woocommerce form.cart .added_to_cart.wc-forward, .tp-cart-popup-notices .button { display: none !important; }\';
$style = $style.\'.tp-cart-popup .woocommerce.widget_shopping_cart .cart_list li { padding: 0 0 1em; }\';
$style = $style.\'.tp-cart-popup-notices .woocommerce-error, .tp-cart-popup-notices .woocommerce-info, .tp-cart-popup-notices .woocommerce-message { margin-bottom: 1em; }\';
$style = $style.\'.woocommerce a.button.alt.single_add_to_cart_button.loading, .woocommerce button.button.alt.single_add_to_cart_button.loading, .woocommerce input.button.alt.single_add_to_cart_button.loading { padding-right: 3rem; }\';
$style = $style.\'.tp-cart-popup-loading { padding: 0 0 1.5rem; } .tp-cart-popup-loading .spinkit-wave{display:block;position:relative;top:50%;left:50%;width:50px;height:40px;margin:0 0 0 -25px;font-size:10px;text-align:center}.spinkit-wave .spinkit-rect{display:block;float:left;width:6px;height:50px;margin:0 2px;background-color:#e91e63;-webkit-animation:spinkit-wave-stretch-delay 1.2s infinite ease-in-out;animation:spinkit-wave-stretch-delay 1.2s infinite ease-in-out}.spinkit-wave .spinkit-rect1{-webkit-animation-delay:-1.2s;animation-delay:-1.2s}.spinkit-wave .spinkit-rect2{-webkit-animation-delay:-1.1s;animation-delay:-1.1s}.spinkit-wave .spinkit-rect3{-webkit-animation-delay:-1s;animation-delay:-1s}.spinkit-wave .spinkit-rect4{-webkit-animation-delay:-.9s;animation-delay:-.9s}.spinkit-wave .spinkit-rect5{-webkit-animation-delay:-.8s;animation-delay:-.8s}@-webkit-keyframes spinkit-wave-stretch-delay{0%,100%,40%{-webkit-transform:scaleY(.5);transform:scaleY(.5)}20%{-webkit-transform:scaleY(1);transform:scaleY(1)}}@keyframes spinkit-wave-stretch-delay{0%,100%,40%{-webkit-transform:scaleY(.5);transform:scaleY(.5)}20%{-webkit-transform:scaleY(1);transform:scaleY(1)}}\';
return $style;
}
现在您可以编辑
child_larismanis_wc_cart_popup_style()
函数更改CSS,而无需编辑父主题。