• Resolved Juhanuha

    (@juhanuha)


    Hi and thanks for the great plugin. Made my life easier on product updating!

    I am using the plugin to show certain attribute descriptions on main content.
    I want to show YouTube video too, but inserting the link is not working like normally in pages, it just shows the link. HTML code is working otherwise ok, but Iframe is not working at all, it also shows the full code on the page.

    Where should I start to make changes so this could work?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author mjke87

    (@mjke87)

    Hi @juhanuha,

    If you simply add a URL it will just display the URL. This behavior is expected. If you wish you display an iFrame I suggest to use the embed shortcode. Simply enclose your YouTube video with embed tags as follows.

    [embed]https://youtu.be/XOY3ZUO6P0k[/embed]

    More information is available here:
    https://codex.www.ads-software.com/Embed_Shortcode

    Please let me know if this solves your problem.
    Cheers, Mike

    Thread Starter Juhanuha

    (@juhanuha)

    Its the same with embed shortcode and with iframe html code. It doesnt work, shows just the whole code/embed tags.

    Plugin Author mjke87

    (@mjke87)

    Hi @juhanuha,

    Thank you for your valuable inputs. I was able to reproduce this behavior. I discovered the problem by looking at the source code of the plugin.

    It seems like shortcodes only work if the attribute description is being displayed in a separate tab, if you are displaying them in the main description, it seems like shortcodes (and possibly HTML) does not work.

    This means:
    – When using “Product Attribute Tab Description” in separate tab HTML and shortcodes work.
    – When using “Product Attribute Tab Description” in main description only HTML works.
    – When using “Standard Attribute Description” in separate tab HTML and shortcodes work.
    – When using “Standard Attribute Description” in main description neither HTML nor shortcodes work, but depends on other active filters form plugins and themes.

    I will try to fix this behavior in the next release, so that HTML and shortcode always work.

    In the meantime you can use the following quick-fix:

    
    add_filter('woocommerce_product_attribute_tab_content_term', function($content, $term, $attribute, $display_type) {
        $content = str_replace(']]>', ']]>', $content);
        $content = do_shortcode($content);
        return $content;
    }, 10, 4);
    

    Add this code somewhere in your functions.php file.

    Kind regards,
    Mike

    Plugin Author mjke87

    (@mjke87)

    Done. I added this fix to the new version 1.1.1.
    You can simply update your plugin to resolve this issue.

    Thread Starter Juhanuha

    (@juhanuha)

    Hi Mjke87 and thanks for the fast response! Did not expect that ??

    Unfortunatly I did not quite get there yet. Updated the plugin and…

    Putting down just the link still says the same issue, just the link shows up.
    Embed code = nothing shows up, neither video or link
    HTML I did not try yet, looks like my firewall bans the iframe code putted up at all and doesnt save the file anymore.

    I would go without iframe is possible as the embed code is nearly there (and it is easier for my staff to update the pages).

    I am using the default description and in product info as I do not use any tabs for more mobile friendly reading of the pages (the same happened also in tabbed version, FYI). I also tried to add your code you posted earlier, did not help.

    Do you have ideas what could cause the video not showing up? If it works for you with those settings it must be some plugin/theme but which ones I should start to look at?

    Plugin Author mjke87

    (@mjke87)

    HI @juhanuha,

    That’s a bummer, but the other issue was nonetheless a necessary fix, and is tightly related to the problem at hand. I’m sure together we’ll figure it out.

    Here’s what I can say as of now:
    – Inserting only the plain URL will not trigger any magic and display an iframe, but you will rather just see the “naked” URL.
    – Inserting the URL via a <a> HTML-Element should work properly, however, since it is valid HTML and worked in my tests just fine.
    – Inserting the <iframe> embed code you get from YouTube or whatever, must – consequently – also work, because it is valid HTML as well and also worked without problems in my tests.

    So you may use iframe-HTML and it should work safely.

    But I agree with you that using the embed shortcode would be much cleaner, and anyhow shortcode support is intended. I’ll see what I can do and maybe kick out another update soon.

    I keep you posted.

    Cheers, Mike

    • This reply was modified 6 years, 10 months ago by mjke87.
    Plugin Author mjke87

    (@mjke87)

    Hi again,

    I was able to reproduce the problem with the [embed] shortcode and could fix the issue. Check out the latest version 1.1.2 and let me know if it now works as expected.

    Strangely, changing from do_shortcode($content) to apply_filters('the_content', $content); resolved the issue. Not sure why.

    Cheers,
    Mike

    Thread Starter Juhanuha

    (@juhanuha)

    Hi Mike,

    weird. Now it broke it totally. All the products that uses the plugin, wont load further than half way page and then just stops.

    Thread Starter Juhanuha

    (@juhanuha)

    Update. Works fine in Tabs (embed video too!)

    But if the content is in the product info, the error mentioned above.

    edit:

    tried to switch theme too, no help.

    • This reply was modified 6 years, 10 months ago by Juhanuha.
    • This reply was modified 6 years, 10 months ago by Juhanuha.
    • This reply was modified 6 years, 10 months ago by Juhanuha.
    Plugin Author mjke87

    (@mjke87)

    Hi @juhanuha,

    Alright, I did some more digging and found out that the latest change is usually a working alternative to do_shortcode but can have unwanted side-effects, because a lot of plugins use the the_content filter. Calling it more than once can cause problems. I will undo this change and go with do_shortcode again.

    I did also some more research about how do_shortcode exactly works. You can use the following code snippet to find out which shortcodes are available at a certain point in your code:

    global $shortcode_tags;
    print_r($shortcode_tags);

    The result is eye-opening; all shortcodes are available, except …… [embed]. The reason is that embed is not a regular shortcode. Check here for more details if you’re interested: https://wordpress.stackexchange.com/a/23213

    So in short:
    – Do shortcode works for all shortcodes except embed
    – Embed only works with the_content filter
    – Using the_content cannot be used because it breaks the design
    – Hence we will continue to use do_shortcode, but embed won’t work

    You can go ahead and test different shortcodes with version 1.1.1. It works like a charm; only embed doesn’t. This is a pity, but I don’t have a solution for this right now. Sorry about the bad news. If I ever find something, I’ll let you know.

    You could make your own embed delegate shortcode and call the embed functions if you like. It wouldn’t take much. Some along the lines as follows:

    add_shortcode('my_embed', 'my_embed_callback');
    function my_embed_callback($atts, $content = null) {
      if ($content) {
        global $wp_embed;
        return $wp_embed->run_shortcode("[embed]$content[/embed]");
      }
    }

    Then you could use it like this:
    [my_embed]https://some.url/abc[/my_embed]

    Not pretty, but it would work.

    Good luck and kind regards,
    Mike

    Thread Starter Juhanuha

    (@juhanuha)

    Thanks Mike!

    I see the problem. Weird problem thou ??

    With Iframe, everything works out good.

    I think you should remove the 1.1.2 version (or update to .3) to remove the version that causes trouble you mentioned above.

    Thank you so much for your help, making a donation for your plugin and hoping a lot more of people finds it, its a time saver! ??

    Plugin Author mjke87

    (@mjke87)

    Hi juhanuha,

    Yeah I already updated to version 1.1.3.
    Thank you very much for your support and good luck with your site ??

    Cheers, Mike

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Youtube or iframe is not working’ is closed to new replies.