I’m trying to use add_action to add HTML output to a plugin’s front end area,
Below is the snippet from plugin
<ul class="dashboard-links">
<li><a href="https://wordpress.stackexchange.com/questions/300750/<?php echo $dashboard_links["commissions'] ?>"><?php _e( 'Commissions', 'yith-woocommerce-affiliates' ) ?></a></li>
<li><a href="https://wordpress.stackexchange.com/questions/300750/<?php echo $dashboard_links["clicks'] ?>"><?php _e( 'Clicks', 'yith-woocommerce-affiliates' ) ?></a></li>
<li><a href="https://wordpress.stackexchange.com/questions/300750/<?php echo $dashboard_links["payments'] ?>"><?php _e( 'Payments', 'yith-woocommerce-affiliates' ) ?></a></li>
<li><a href="https://wordpress.stackexchange.com/questions/300750/<?php echo $dashboard_links["generate_link'] ?>"><?php _e( 'Generate link', 'yith-woocommerce-affiliates' ) ?></a></li>
<li><a href="https://wordpress.stackexchange.com/questions/300750/<?php echo $dashboard_links["settings'] ?>"><?php _e( 'Settings', 'yith-woocommerce-affiliates' ) ?></a></li>
<?php do_action( 'yith_wcaf_after_dashboard_links', $dashboard_links ) ?>
</ul>
I’m trying to extend it by adding the snippet written below in functions.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 );
This is the snippet which I’m g, I also tried passing $dashboard_links
to the function but it didn’t worked.
1 Answer
You need to echo
your data. Try this instead –
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 );