首页 > 解决方案 > 在 php 文件的回显中使用 html 和 php 的组合(WooCommerce 和 mailpoet)

问题描述

我想在我的 WordPress 网站上的 php 文件中的 echo 部分调用简码。我已经尝试了一些东西,但似乎没有任何效果。

$email_footer_info  = 'If you have any quetions please contact us <a href="mailto:webmaster@example.com" style="color:#bbb;text-decoration:underline" target="_blank">webmaster@example.com.</a><br><a href="/unsubscribe-link/" style="color:#bbb;text-decoration:underline" target="_blank">Unsubscribe</a> from our mailing lists'; // Email Footer Info

我试图用简码替换超链接 /unsubscribe-link/ 但它不起作用:

<?php echo do_shortcode('[link:subscription_unsubscribe_url]'); ?>

最终结果将允许用户通过单击取消订阅来取消订阅 mailpoet 列表。

这就是它的样子

这是完整的代码:

<?php
/**
 * Email Footer
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/email-footer.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see         https://docs.woocommerce.com/document/template-structure/
 * @author      WooThemes
 * @package     WooCommerce/Templates/Emails
 * @version     3.7.0
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

$theme_path =   get_stylesheet_directory_uri().'/woocommerce/emails/images'; // Image Path

$email_offer_banner_url     = ""; // Offer Banner URL

$email_facebook_url         = "http://example.com"; // Facebook URL
$email_twitter_url          = "http://example.com"; // Twitter URL
$email_instagram_url        = ""; // Instagram URL
$email_pinterest_url        = ""; // Pinterest URL
$email_googleplus_url       = ""; // Google Plus URL

$email_appstore_url         = ""; // Appstore URL
$email_playstore_url        = ""; // Playstore URL

$email_link_name_1          = "About us";           // Footer Link 1 Name
$email_link_name_2          = "Email Preferences";  // Footer Link 2 Name
$email_link_name_3          = "Privacy Policy";     // Footer Link 3 Name

$email_link_url_1           = "/about-us/"; // Footer Link 1 URL
$email_link_url_2           = "/email-preferences/"; // Footer Link 2 URL
$email_link_url_3           = "/privacy-policy/"; // Footer Link 3 URL

$email_address_info         = "&copy;&nbsp;My Business Inc. | 800 Broadway, Suite 1500 | New York, NY 000123, USA."; // Email Address Info

$email_footer_info  = 'If you have any quetions please contact us <a href="mailto:webmaster@example.com" style="color:#bbb;text-decoration:underline" target="_blank">webmaster@example.com.</a><br><a href="/unsibscribe-link/" style="color:#bbb;text-decoration:underline" target="_blank">Unsubscribe</a> from our mailing lists'; // Email Footer Info

?>

                            
                            </td>
                        </tr>

                        <tr>
                            <td height="20" style="font-size:1px;line-height:1px;">&nbsp;</td>
                        </tr>

                        <tr>
                            <td height="20" style="font-size:1px;line-height:1px;">&nbsp;</td>
                        </tr>
                    </table>
                    <!-- Table Card Close// -->

                    <?php if( $email_offer_banner_url != "" ) :?>

                    <table border="0" cellpadding="0" cellspacing="0" width="100%" class="space">
                        <tr>
                            <td style="font-size:1px;line-height:1px" height="30">&nbsp;</td>
                        </tr>
                    </table>

                    <table border="0" cellpadding="0" cellspacing="0" width="100%" class="offerCard">
                        <tr>
                            <td align="center" valign="middle">

                                <table border="0" cellpadding="0" cellspacing="0" width="100%" class="offerTable">
                                    <tr>
                                        <td align="center" valign="middle" class="offerImg">
                                            <!-- Offer Banner // -->
                                            <?php

                                                if ( $email_offer_banner_url != "" ) {
                                                    echo '<a href="' . $email_offer_banner_url . '" style="text-decoration:none;" ><img src="' . $theme_path . '/offer-banner.jpg" width="580" alt="Offer" border="0" style="width:100%; max-width:580px;height:auto; display:block;" /></a>';
                                                }

                                            ?>
                                        </td>
                                    </tr>
                                </table>

                            </td>
                        </tr>
                    </table>

                    <?php endif; ?>

                </td>
            </tr>
        </table>

        <!-- Email Wrapper Footer Open // -->
        <table border="0" cellpadding="0" cellspacing="0" style="max-width:600px;" width="100%" class="wrapperFooter">
            <tr>
                <td align="center" valign="top">
                    <!-- Content Table Open// -->
                    <table border="0" cellpadding="0" cellspacing="0" width="100%" class="footer">
                        <tr>
                            <td height="30" style="font-size:1px;line-height:1px;">&nbsp;</td>
                        </tr>
                        <tr>
                            <td align="center" valign="top" style="padding-top:10px;padding-bottom:10px;padding-left:10px;padding-right:10px;" class="socialLinks">

                                <?php if( $email_facebook_url != "" || $email_twitter_url != "" || $email_instagram_url != "" || $email_pinterest_url != "" || $email_googleplus_url != "" ) :?>

                                <?php

                                    if ( $email_facebook_url != "" ) {
                                        echo '<a href="' . $email_facebook_url . '" style="display:inline-block;" ><img src="' . $theme_path . '/facebook.png" width="40" height="40" alt="Facebook" style="height:auto; width:100%; max-width:40px; margin-left:2px; margin-right:2px" /></a>';
                                    }

                                    if ( $email_twitter_url != "" ) {
                                        echo '<a href="' . $email_twitter_url . '" style="display:inline-block;" ><img src="' . $theme_path . '/twitter.png" width="40" height="40" alt="Twitter" style="height:auto; width:100%; max-width:40px; margin-left:2px; margin-right:2px" /></a>';
                                    }

                                    if ( $email_instagram_url != "" ) {
                                        echo '<a href="' . $email_instagram_url . '" style="display:inline-block;" ><img src="' . $theme_path . '/instagram.png" width="40" height="40" alt="Instagram" style="height:auto; width:100%; max-width:40px; margin-left:2px; margin-right:2px" /></a>';
                                    }

                                    if ( $email_pinterest_url != "" ) {
                                        echo '<a href="' . $email_pinterest_url . '" style="display:inline-block;" ><img src="' . $theme_path . '/pinterest.png" width="40" height="40" alt="Pinterest" style="height:auto; width:100%; max-width:40px; margin-left:2px; margin-right:2px" /></a>';
                                    }

                                    if ( $email_googleplus_url != "" ) {
                                        echo '<a href="' . $email_googleplus_url . '" style="display:inline-block;" ><img src="' . $theme_path . '/google.png" width="40" height="40" alt="Google" style="height:auto; width:100%; max-width:40px; margin-left:2px; margin-right:2px" /></a>';
                                    }
                                ?>

                                <?php endif; ?>
                            </td>
                        </tr>

                        <tr>
                            <td align="center" valign="top" style="padding-top:10px;padding-bottom:5px;padding-left:10px;padding-right:10px;" class="brandInfo">
                                <!-- Brand Information // -->
                                <?php if( $email_address_info != "" ) :?>
                                    <?php
                                        if ( $email_address_info != "" ) {
                                            echo '<p class="text font-secondary" >'. $email_address_info .'
                                            </p>';
                                        }
                                    ?>
                                <?php endif; ?>
                            </td>
                        </tr>

                        <tr>
                            <td align="center" valign="top" style="padding-top:0px;padding-bottom:20px;padding-left:10px;padding-right:10px;" class="footerLinks">
                                <!-- Use Full Links (Privacy Policy)// -->
                                <p class="text font-secondary">
                                    <?php if( $email_link_name_1 != "" || $email_link_name_2 != "" || $email_link_name_3 != "" || $email_link_url_1 != "" || $email_link_url_2 != "" || $email_link_url_3 != "" ) :?>

                                    <?php

                                        if ( $email_link_url_1 != "" || $email_link_name_1 != "" ) {
                                            echo '<a href="' . $email_link_url_1 . '" style="color:#BBBBBB;text-decoration:underline;"> '. $email_link_name_1 .' </a>&nbsp;|&nbsp;';
                                        }

                                        if ( $email_link_url_2 != "" || $email_link_name_2 != "" ) {
                                            echo '<a href="' . $email_link_url_2 . '" style="color:#BBBBBB;text-decoration:underline;"> '. $email_link_name_2 .' </a>&nbsp;|&nbsp;';
                                        }

                                        if ( $email_link_url_3 != "" || $email_link_name_3 != "" ) {
                                            echo '<a href="' . $email_link_url_3 . '" style="color:#BBBBBB;text-decoration:underline;"> '. $email_link_name_3 .' </a>';
                                        }

                                    ?>

                                    <?php endif; ?>

                                </p>
                            </td>
                        </tr>

                        <tr>
                            <td align="center" valign="top" style="padding-top:0px;padding-bottom:10px;padding-left:10px;padding-right:10px;" class="footerEmailInfo">
                                <!-- Information of NewsLetter (Subscribe Info)// -->
                                <?php if( $email_footer_info != "" ) :?>
                                    <?php
                                        if ( $email_footer_info != "" ) {
                                            echo '<p class="text font-secondary" >'. $email_footer_info .'
                                            </p>';
                                        }
                                    ?>
                                <?php endif; ?>
                            </td>
                        </tr>

                        <tr>
                            <td align="center" valign="top" style="padding-top:10px;padding-bottom:10px;padding-left:10px;padding-right:10px;" class="appLinks">
                                <!-- App Links (Anroid)// -->
                                <?php if( $email_appstore_url != "" || $email_playstore_url != "" ) :?>

                                <?php

                                    if ( $email_appstore_url != "" ) {
                                        echo '<a href="' . $email_appstore_url . '" style="display:inline-block;" ><img src="' . $theme_path . '/app-store.png" width="120" alt="App Store" border="0" style="height:auto; margin:5px; width:100%; max-width:120px;" /></a>';
                                    }

                                    if ( $email_playstore_url != "" ) {
                                        echo '<a href="' . $email_playstore_url . '" style="display:inline-block;" ><img src="' . $theme_path . '/play-store.png" width="120" alt="Play Store" border="0" style="height:auto; margin:5px; width:100%; max-width:120px;" /></a>';
                                    }
                                ?>

                                <?php endif; ?>
                            </td>
                        </tr>


                        <!-- Space -->
                        <tr>
                            <td height="30" style="font-size:1px;line-height:1px;">&nbsp;</td>
                        </tr>
                    </table>
                    <!-- Content Table Close// -->
                </td>
            </tr>

            <!-- Space -->
            <tr>
                <td height="30" style="font-size:1px;line-height:1px;">&nbsp;</td>
            </tr>
        </table>
        <!-- Email Wrapper Footer Close // -->

        <!--[if (gte mso 9)|(IE)]></td></tr></table><![endif]-->
        </td>
    </tr>
</table>
</body>
</html>

标签: wordpress

解决方案


推荐阅读