我正在尝试使用add\\u操作将HTML输出添加到插件的前端区域,下面是插件的代码片段
<ul class="dashboard-links">
<li><a href="<?php echo $dashboard_links[\'commissions\'] ?>"><?php _e( \'Commissions\', \'yith-woocommerce-affiliates\' ) ?></a></li>
<li><a href="<?php echo $dashboard_links[\'clicks\'] ?>"><?php _e( \'Clicks\', \'yith-woocommerce-affiliates\' ) ?></a></li>
<li><a href="<?php echo $dashboard_links[\'payments\'] ?>"><?php _e( \'Payments\', \'yith-woocommerce-affiliates\' ) ?></a></li>
<li><a href="<?php echo $dashboard_links[\'generate_link\'] ?>"><?php _e( \'Generate link\', \'yith-woocommerce-affiliates\' ) ?></a></li>
<li><a href="<?php echo $dashboard_links[\'settings\'] ?>"><?php _e( \'Settings\', \'yith-woocommerce-affiliates\' ) ?></a></li>
<?php do_action( \'yith_wcaf_after_dashboard_links\', $dashboard_links ) ?>
</ul>
我试图通过在函数中添加下面编写的代码片段来扩展它。php
function add_link_to_aff() {
$html_output = "<li><a href=\'#\'><?php _e( \'Test\', \'yith-woocommerce-affiliates\' ) ?></a></li>";
return $html_output;
}
add_action( \'yith_wcaf_after_dashboard_links\', \'add_link_to_aff\', 10 );
这是我g的片段,我也试着传递
$dashboard_links
但它不起作用。
最合适的回答,由SO网友:mukto90 整理而成
你需要echo
您的数据。试试这个-
function add_link_to_aff() {
$html_output = "<li><a href=\'#\'>" . __( \'Test\', \'yith-woocommerce-affiliates\' ) . "</a></li>";
echo $html_output;
}
add_action( \'yith_wcaf_after_dashboard_links\', \'add_link_to_aff\', 10 );