Under Wordpress CMS, what I'm looking for is that after 5 seconds of clicking on a specific button the page is redirected to another url obtained by a php variable.
<script type="text/javascript">
function sample() {
setTimeout(function() {
window.open('<?php echo esc_attr(wpcoupon_coupon()->get_go_out_url()); ?>', '_self');
}, 5000);
}
</script>
And on the button:
<button class="ui right labeled icon button btn btn_secondary" onClick="sample();">
<i class="copy icon"></i>
<span><?php esc_html_e('Copy', 'wp-coupon'); ?></span>
The issue is that in a php file outside of wordpress and varying from the script <?php echo esc_attr(wpcoupon_coupon()->get_go_out_url()); ?>
by link works correctly, but by integrating the codes in single.php the url to which it redirects is example.com/nombre-de-la-entrada/url
, adding that last url when the redirect is executed.
I have tried to show by php <?php echo esc_attr(wpcoupon_coupon()->get_go_out_url()); ?>
and the url that our is correct.
Thank you very much in advance