• Resolved Biranit

    (@biranit)


    Hi,

    Love love love this plugin. I have one problem, though:

    if an editor adds a video to a live blog entry (by way of pasting the link to it in the visual editor, as we have auto-embeding enabled), it is not auto-embeded on the update. Even previous elements have a problem: the first time the page loads, the video shows up, and then a few seconds later, which the polling timeout has reached, it ‘reloads’ without the video and only the link text showing up.

    This is, I assume, because the entries are not parsed as normal content. But is there a way for me to work around this?

    Thanks,

    Biranit

    http://wordpress.org/extend/plugins/live-blogging/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author chrisnorthwood

    (@chrisnorthwood)

    Hi Biranit,

    Entries should parse as normal content (they go through the the_content filter) so I’m not sure why you’re seeing that behaviour. I’m afraid I don’t have the time to debug, however if you do find the cause and fix, please let me know so I can fix it.

    Thanks,

    Chris Northwood

    Thread Starter Biranit

    (@biranit)

    Hi Chris,

    I have a feeling this has to do with the auto-embed now using the IFRAME version of youtube/vimeo/etc. It’s just a hunch.

    I’ll keep investigating and let you know if I find the reason and/or the solution.

    Cheers,

    Bira

    Thread Starter Biranit

    (@biranit)

    OK, this took a LOT of investigative work and trials and errors πŸ™‚

    The problem is that autoembed does NOT work outside the loop. This is because it has to cache the result, or else it will need to query the embed source every time. So it has to run within the global $post.

    CHRIS:
    In your function live_blogging_ajax() you have a loop running, however you are using the deprecated function $q->next_post(). Changing this to $q->the_post() fixes the autoembed issue altogether, and everything works perfectly.

    Not sure exactly why you use next_post() (which is, as I noted, deprecated).

    Cheers,

    Bira

    Plugin Author chrisnorthwood

    (@chrisnorthwood)

    Hi Bira,

    You’ve linked to the wrong next_post there, the one that’s used is the one in here, which isn’t deprecated: http://codex.wordpress.org/Class_Reference/WP_Query. The difference between the next_post and the the_post method is that next_post doesn’t set the global loop variables, which it’s needed as technically it’s a sub loop within another loop.

    Chris

    Thread Starter Biranit

    (@biranit)

    OK, fair enough re the wrong link. But autoembed will not work with next_post exactly because you’re not setting the global post.

    Give it a try yourself and see πŸ™‚

    Plugin Author chrisnorthwood

    (@chrisnorthwood)

    Yes, but setting the global post will break the containing loop, I think.

    Thread Starter Biranit

    (@biranit)

    Nope, it does not. I did that change and evrything works flawlessly πŸ™‚

    Plugin Author chrisnorthwood

    (@chrisnorthwood)

    I’ve just tried this on a clean install and the TwentyEleven theme, and it does indeed break the containing loop (as the live blog will set the global post variable, then everything that comes after the_content in the theme will then access the global post value which contains the last live blog entry). On the TwentyEleven theme, changing the code to the_post stops comments displaying, and the entry metadata now refers to the last liveblog entry, rather than the post which contains the live blog.

    Saving the post value before going into the child loop and then resetting it at the end appears to work though, so I’ve just committed that.

    Chris

    Thread Starter Biranit

    (@biranit)

    Chris: you’re awesome. Thank you πŸ™‚

    Thread Starter Biranit

    (@biranit)

    Chris, just thought I’d give you a head’s up, in case anyone ever comes asking about this:

    Some of my shortcodes were not working on live blogging, particularly the Blackbird Pie Twitter embed, which is actually a fantastic companion for live blogging.

    I split hairs over this for three days, eventually discovering it wasn’t working because on the BBP plugin, it used if (!is_admin()) before doing add_shortcode and wp_embed_register_handler. And, since the polling uses admin-ajax.php, then obviously the is_admin() condition fails…

    This has nothing to do with you, but I figured I’d let you know if someone comes asking why this-and-that isn’t working. Quite a few plugins that are geared towards frontend stuff use the !is_admin() condition, and obviously admin-ajax.php fails that. So it’s something worth keeing in mind πŸ™‚

    Cheers,

    Bira

    Thread Starter Biranit

    (@biranit)

    Hi Chris,

    First off, thanks for the credit in the changelog. I was floored seeing my name there! πŸ™‚

    A couple issues with this fix, though:

    1) you applied the fix (of changing next_post to the_post) to the function live_blogging_shortcode where, in fact, this was never an issue (at least not for me), because the autoembeding and other shortcodes were parsed _after_ the [liveblog] shortcode was parsed. But, I suppose it makes no harm really to have it done there too.

    However, you did not apply this fix to the function live_blogging_ajax – where I ran into the issue (I use polling). (It could also be implemented in the function live_blog_chatbox_get_posts)

    2) Just a suggestion: you don’t really need to store $post in an interim variable. It’s enough that you add wp_reset_postdata(); after the custom query’s loop. This restores the previous $post variable to global, but with less code πŸ™‚

    while ($q->have_posts())
        {
            $q->the_post();
            $r[] = array(
                    'liveblog' => $liveblog_id,
                    'id' => $q->post->ID,
                    'type' => 'entry',
                    'html' => live_blogging_get_entry($q->post)
                );
          }
          wp_reset_postdata();

    Cheers!

    Bira

    Plugin Author chrisnorthwood

    (@chrisnorthwood)

    Credit’s due where credit’s due πŸ™‚

    Okay, I appear to have been misunderstanding you! Of course, ajax won’t break anything as it’s not a subloop. I’ll look at fixing this.

    Sorry for the bad fix!

    Chris

    Plugin Author chrisnorthwood

    (@chrisnorthwood)

    Fixed and new version out πŸ™‚

    Thanks again!

    Thread Starter Biranit

    (@biranit)

    You’re great Chris. Thank you. Pleasure doing business with you πŸ˜‰

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Plugin: Live Blogging] Auto-embeding of youtube video not working’ is closed to new replies.