php - 邮件发送成功后在public函数上添加css样式

标签 php html css wordpress

我正在使用 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/

相关文章:

html - 影响布局的未知表格/单元格填充/边距

php - Laravel Eloquent orderBy 日期字段不返回所有值

php - 从 HTML5 表单获取日期 - 并发布到 MySQL

javascript - 如何通过 AJAX 弹出一个简单的警报框?

javascript - 选择表单中具有给定数据 ID 的所有选项

css - 当窗口大小改变时,垂直列表脱节

jquery - 此 jQuery/HTML 代码中的性能/可访问性问题?

php - 带有 PHP 的 PayPal IPN - EOF 异常

php - PDOException : could not find driver when using phpunit

html - Polymer 1.1 中的共享样式和外部样式表