Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress wrap div inside echo shortcode php

I'm trying to wrap a div using a shortcode that I'm calling from within my themes template.

So far I have this:

<?php echo do_shortcode('[tooltip content="Delete" url=""]'.<div class="delete-button-comments"><?php if ( bp_activity_user_can_delete() ) bp_activity_delete_link(); ?></div>.'[/tooltip]'); ?>

but I'm getting a syntax error (which I know why) but if I delimit the periods and apostrophes nothing happens at all.

So basically I would like to wrap the tooltips shortcode around the div that displays the icon that the div displays.


1 Answers

bp_activity_delete_link echoes the link, you should use bp_get_activity_delete_link() to return the value. Not exactly sure what you're trying to do, maybe something like:

<?php
    $link = ( bp_activity_user_can_delete() ) ? '<div class="delete-button-comments">' . bp_get_activity_delete_link() . '</div>' : '';
    echo do_shortcode('[tooltip content="Delete" url=""]' . $link . '[/tooltip]');
?>
like image 160
diggy Avatar answered Mar 03 '26 14:03

diggy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!