我正在使用 YITH-request-quote,我想在发送电子邮件后更改 CSS 样式。 原始公共(public)功能如下:
public function trigger( $args ) {
$this->raq = $args;
$this->raq['raq_content'] = YITH_Request_Quote()->get_raq_return();
$recipients = (array) $this->get_recipient();
if( $this->enable_cc ){
$recipients[] = $this->raq['user_email'];
}
$recipients = implode(',',$recipients);
$return = $this->send( $recipients, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
if ( $return ) {
YITH_Request_Quote()->clear_raq_list();
yith_ywraq_add_notice( __('Your request has been sent successfully','yith-woocommerce-request-a-quote'), 'success' );
}else {
yith_ywraq_add_notice( __( 'There was a problem in sending your request. Please try again.', 'yith-woocommerce-request-a-quote' ), 'error' );
}
}
我尝试添加:
if ( $return ) {
YITH_Request_Quote()->clear_raq_list();
?>
<style>.raq-message {display:none !important;}</style>
<?php
yith_ywraq_add_notice( __('Your request has been sent successfully','yith-woocommerce-request-a-quote'), 'success' );
但是没有用。
邮件发送成功后如何添加css样式?
最佳答案
您可能必须将样式添加到钩子(Hook),具体取决于调用 trigger
函数的位置:
if( $return ){
YITH_Request_Quote()->clear_raq_list();
// Add style to a header hook, like `wp_head` or `wp_print_styles`
add_action( 'wp_head', function(){
echo '<style>.raq-message { display: none !important; }</style>';
});
yith_ywraq_add_notice( __('Your request has been sent successfully','yith-woocommerce-request-a-quote'), 'success' );
} else {
yith_ywraq_add_notice( __( 'There was a problem in sending your request. Please try again.', 'yith-woocommerce-request-a-quote' ), 'error' );
}
关于php - 邮件发送成功后在public函数上添加css样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50656440/