Why do_shortcode is not executing the shortcode in data-* html attributes?
-
I’ve already asked this question on wordpress.stackexchange.com and so far I got only one user to reply me and he said that he was unable to reproduce the error.
My request to this sub-forum community is to test the following code, which can be a bug in WordPress. I can reproduce the error on my localhost machine as well as on the remote development server. I’m simply copy pasting the question to avoid wasting time.
This is on Vanilla installation. I’ve made a shortcode:-
/** * Creates a shortcode for shortcode_use_here * @author Omar Tariq <[email protected]> */ function callback_banana_abc( $args ){ /* Don't echo! Always return */ return 'yay!'; } add_shortcode( 'banana_abc', 'callback_banana_abc' );
And I’ve made a template that looks like this:-
<?php /* * Template Name: Test Template * Description: Hello world. */ $str = '<a herf="#" title="[banana_abc]" data-abc="[banana_abc]">[banana_abc]</a>'; echo do_shortcode($str);
The output is:-
<a herf="#" title="yay!" data-abc="[banana_abc]">yay!</a>
This is only for data-* attributes. It works fine when used in title attribute.
The actual shortcode is much more complex. I’ve made it small and to the point to avoid wasting time.
Please let me know if you can reproduce the error.
- The topic ‘Why do_shortcode is not executing the shortcode in data-* html attributes?’ is closed to new replies.