WordPress.org

Ready to get started?Download WordPress

Forums

Auto ThickBox Plus
[resolved] thickbox class not added when the_content filter is called (7 posts)

  1. thomask
    Member
    Posted 2 years ago #

    I have found very strange bug. I have a shortcode, e.g. [test] with very simple code;

    function test_shortcode() {
       $return = apply_filters('the_content', 'aaa');
       return $return;
    }
    add_shortcode( 'test', 'test_shortcode' );

    when you put this [test] shortcode on the page with images, the thickbox class is then not added to the image anchor, so image is then not opened with the thickbox effect.

    Page with such problem e.g. http://money.mediacentrum.cz/money-s3/vlastnosti-systemu/cestovni-nahrady/ - the shortcode did the blue box on the top, when there is no such shortcode (e.g. http://money.mediacentrum.cz/money-s4/moznosti-systemu/ceniky/) it works as a charm.

    P.S.: small offtopic question - your plugin can open external pages in thickbox iframe. Is there any way how i could open actual iframe in thickbox - e.g. oembed youtube videos like that on the first link above?

    http://wordpress.org/extend/plugins/auto-thickbox-plus/

  2. thomask
    Member
    Posted 2 years ago #

    btw i have been looking into anchor-utils.php and see, that the same filter is passed to the_content, the_excerpt, widget_text, comment_text

    but the bug appears only with the_content.

    So it maybe a conflict with your filter and some of my filters/plugins, but it still does not make sense why using this filter in other shortcode somewhere else on the page will result in destroying other plugin somewhere else filtering other content

  3. attosoft
    Member
    Plugin Author

    Posted 2 years ago #

    Hi thomask,

    Thank you for the bug report.

    anchor-utils::filter() function does not seem to be called properly when [test] shortcode is defined.
    I debugged it and changed $priority in add_filter('the_content', ..., 100) function.
    The plugin works if $priority is less than or equal to 11, and it does not work if $priority is greater than or equal to 12.

    This is strange bug as you say.
    I guess there is a problem in add_filter() or apply_filters() function.
    i.e. I think this is a bug in not the plugin but WordPress.

    P.S.: small offtopic question - your plugin can open external pages in thickbox iframe. Is there any way how i could open actual iframe in thickbox - e.g. oembed youtube videos like that on the first link above?

    See Usage.

    Here is sample codes to open Google Maps, YouTube, Vimeo and Dailymotion. You need to use embedded URL.

    <a href="http://youtube.com/embed/K-Rs6YEZAt8">YouTube</a>

  4. thomask
    Member
    Posted 2 years ago #

    Yes, changing priority to 11 did work. Strange. I guess that there is some filter, which is turned on content with shortcodes.

    about the iframe question - this i know, i just wondered, if there is way, how i could open iframe in thickbox, when clicking the iframe. But it was a silly question. Proper sollution would be to add e.g. image from youtube with thickbox a href to youtube. I will look into youtube oembed, this could be quite easily done.

    The bigger problem are other external pages - thickbox got problem opening external URLs in Chrome, as chrome do not allow it, because of its default Access-Control-Allow-Origin. It is shame and make the function almost entirely useless, i wonder, that it would be much better to standard DOM create iframe with src=path in lightbox window, then trying to load the content using javascript, what may be insecure, so chrome block it. But this is standard jQuery thickbox behaviour, so i guess you cannot do anything with that.

  5. thomask
    Member
    Posted 2 years ago #

    ups, it works (i do not know why it does not before, probably the same problem), forgot my last sentence - you add TB_iframe to the URL and it works, i didn't know about this param (it is not described on thickbox page). briliant ;-)

  6. attosoft
    Member
    Plugin Author

    Posted 2 years ago #

    I made a typo. Correct code written in Usage is as follows.

    <a href="http://youtube.com/embed/K-Rs6YEZAt8" class="thickbox">YouTube</a>

    The plugin adds TB_iframe parameter to URL automatically when external links has thickbox class. And the plugin adds thickbox class to links automatically when its URL has TB_iframe parameter.

  7. attosoft
    Member
    Plugin Author

    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic