模板中有一些HTML元素,例如,templates/emails/email-header.php第41行table#template_container,它沒有行內樣式:
< table border="0"/span> cellpadding="0"/span> cellspacing="0"/span> width="600"/span> id="template_container">
但是當它在前端呈現時,它出現了大量的行內樣式:
< table border="0"/span> cellpadding="0"/span> cellspacing="0"/span> width="600"/span> id="team_container"
style="background-color: #ffffffff; border: 1px solid #dedede; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1); border-radius: 3px;">
如何以及在哪里進行這種樣式注入?
如何避免這種樣式注入?
怎樣才能避免這種樣式注入呢?
我想在模板中撰寫自己的行內樣式。什么是正確的方法?
我注意到有些注入,像上面的例子,取決于元素的ID,所以我可以洗掉它們的ID,但其他情況是在一個變數中,如templates/emails/email-header.php第48行:
<h1>< ? php echo $email_heading; ? ></h1>
它被呈現為:
<h1 style="font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; font-size: 30px; font-weight: 300; line-height: 150%; margin: 0; text-align: left; text-shadow: 0 1px 0#ffffff; color: #202020; background-color: inherit;">HTML電子郵件模板</h1>。
希望得到任何幫助。謝謝你。
uj5u.com熱心網友回復:
1)來自#template_container的樣式注入可以在templates/emails/email-styles.php第58-63行@version 4.0.0.
span class="hljs-selector-id">#template_container {
box-shadow: 0 1px 4px rgba(0, 0, 0, 0. 1) !important;
background-color: <?php echo esc_attr( $body ); ? >;
border: 1px solid <?php echo esc_attr( $bg_darker_10 ); ? > 。
border-radius: 3px ! important;
}
2) $email_heading在呼叫模板檔案時被傳遞,見includes/class-wc-emails.php第263 - 270行 @version 2.3.0
/**。
* 獲得電子郵件的標題。
*
* @param mixed $email_heading 郵件的標題。
*/
public function email_header($email_heading ) {
wc_get_template( 'emails/email-header.php', array( 'email_heading' => $email_heading ) );
}
然而,樣式注入也是通過templates/emails/email-styles.php在176-185行@version 4.0.0
發生的。span class="hljs-selector-tag">h1 {
color: <?php echo esc_attr( $base ); ? > 。
font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
字體大小。30px;
font-weight: 300;
line-height: 150%;
margin: 0;
text-align: <?php echo is_rtl() ? 'right' : 'left'; ?> 。
text-shadow。0 1px 0 <?php echo esc_attr( $base_lighter_20 ); ? > 。
}
所以要回答你的問題:
如果你想應用你自己的樣式,或者想修改現有的樣式。你將不得不覆寫模板檔案。模板檔案可以通過復制到yourtheme/woocommerce/emails/email-styles.php而被覆寫。
還可以看到。模板結構&;通過主題覆寫模板 - 如何編輯檔案
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/316137.html
標籤:
上一篇:分布式檔案存盤服務器之Minio物件存盤技術參考指南
下一篇:為WCF訊息設定HTML內容型別
