You never need do_shortcode()
, better said, almost never, there are a few cases where do_shortcode()
could be appropiate.
Note how you could do just:
echo shorten_url( 'http://mylink.com ' );
instead of:
echo do_shortcode('[shorten]http://mylink.com[/shorten]');
Think about shortcodes as PHP functions placeholders; they are intended to be use where you can not execute PHP directly, like the content of post. But if you can execute PHP directly, like in a PHP script, there is no reason to use shortcodes, which is the placeholder, you can use the PHP function directly. There are a lot of benefits, meanly a better performance because do_shortcode()
performs some preg regex that you don’t neet at all.
So, you can use the shortlink everywehere you need. For example:
<?php $numerado = 1; { while( have_rows('voo') ): the_row(); ?>
<li class="elemento">
<a href="https://wordpress.stackexchange.com/questions/217725/<?php echo shorten_url( get_sub_field("op1') ); ?>" rel="nofollow" target="_blank" class="prawyklik">
<span class="a"><b class="icon-controller-play play"></b> <?php _e('Option','mundothemes'); ?> <?php echo $numerado; ?></span>
<span class="b">
<img src="http://www.google.com/s2/favicons?domain=<?php echo get_sub_field('op2'); ?>" alt="<?php echo get_sub_field('op2'); ?>">
<?php echo get_sub_field('op2'); ?>
</span>
<span class="c"><?php echo get_sub_field('op3'); ?></span>
<span class="d"><?php echo get_sub_field('op4'); ?></span>
</a>
</li>
<?php $numerado++; ?>
<?php endwhile; } ?>