• All of a sudden, after working fine, when I write a new post using the form at the top of the homepage, the real time update does happen (the ajax loading of the new post written) and I get a message pop up in the middle of the screen saying:

    “your update has been posted”

    I have to refresh the page to see the post. Any ideas why? I have added nothing in terms of changes to the theme before it stopped working and haven’t changed any plugins.

    Any help would be appreciated. Thanks,

Viewing 15 replies - 31 through 45 (of 45 total)
  • Hi,
    i’ve investigated the problem and i’ve come to a solution (at least for me) by editing the file in p2/inc/ajax.php.

    1st of all I’m running a PHP version lower than 5.2 which lacks native support for JSON.
    For what i can see, wordpress 2.9x has introduced a compatibility file to provide json_encode e json_decode for PHP < 5.2 in wp-include/compat.php which requires wp-include/class-json.php, the JSON_service class.

    Now, also P2 provides this class since for updates it relies on json encoded AJAX responses (see line 199 in p2/inc/ajax.php), but in a different version, which i think causes some conflicts:

    WordPress 2.9x : v 1.3 2009/05/22 23:51:00
    P2:              v 1.31 2006/06/28 05:54:17

    My solution has been to call directly the WP class (p2/inc/ajax.php from line 198):

    nocache_headers();
    echo json_encode( array(
        'numberofnewposts' => $number_of_new_posts,
        'html' => $posts_html,
        'lastposttime' => gmdate('Y-m-d H:i:s')
    ) );

    changed to:

    require (ABSPATH . WPINC . '/class-json.php');
    $json = new Services_JSON();
    nocache_headers();
    echo $json->encode( array(
        'numberofnewposts' => $number_of_new_posts,
        'html' => $posts_html,
        'html' => '',
        'lastposttime' => gmdate('Y-m-d H:i:s')
    ) );

    uh… and in reply to myself:
    i also had to comment line 7 in p2/functions.php to prevent the inclusion of P2 JSON file.

    I think you solved it dwj!

    I tried what you did, and replaced the lines in ajax.php and commented out line 7 in functions.php, and P2 1.1.3 is now working on my WP 2.9.1 blog.

    One change I had to make was I edited out the following line. Including it made the page look like it was going to refresh, but the update did not appear:

    'html' => '',

    What was that additional line supposed to do?

    So, it looks like they’ve included the same JSON class twice in different versions, and that’s causing the conflict. Hopefully this gets fixed in the next version of P2.

    great! thanks dwj I will try this as soon as possible and get back here for any updates

    thanks dwj, works properly now for me

    @hesadanza Yep thanx for feedback, the 'html' => '' thing is a typo. for future reference here is the correct code:

    in p2/inc/ajax.php from line 198 change:

    nocache_headers();
    echo json_encode( array(
        'numberofnewposts' => $number_of_new_posts,
        'html' => $posts_html,
        'lastposttime' => gmdate('Y-m-d H:i:s')
    ) );

    to:

    require (ABSPATH . WPINC . '/class-json.php');
    $json = new Services_JSON();
    nocache_headers();
    echo $json->encode( array(
        'numberofnewposts' => $number_of_new_posts,
        'html' => $posts_html,
        'lastposttime' => gmdate('Y-m-d H:i:s')
    ) );

    and comment line 7 in p2/functions.php

    One thing that I still seem to be missing is the yellow fading flash when I enter a new post. Now it just inserts the post, and everything drops down, but without the P2 yellow flash. Comments still seem to show the yellow flash when they update the page, but newly created posts don’t.

    Thread Starter Equal

    (@equalmark)

    I have recently changed from using the P2 theme on WPMU to using it on standard WP and it is now working no problem.

    Must be something to do with WP MU?

    “Must be something to do with WP MU? “

    Looks like it, doesn’t work for me out of the box on Multisite 3.0 in *any* browser.

    Ah, do both things dwj mentioned, not just the first, doh, works a treat.

    I tried doing both items DWJ recommended and it didn’t fix it back for me?

    Does anyone know what actually causes this to break in the first place?

    I like others had it working fine, then suddenly it breaks!

    Any other suggestions on how I can fix?

    I’ve done a quick write up based on what DWJ recommended. It covers not only fixing Auto Update for new posts, but for replies as well, as they are handled by two different functions.

    https://www.joebeaudoin.net/2010/07/getting-p2-to-auto-update/

    I caanot get this to work?

    Using

    wordpress Version 3.0.1

    P2 1.1.6.2

    Also cannot get the reply to show just permalink showing?

    errantthought

    (@errantthought)

    FYI: dwj’s solution worked for me.

    Running: wordpress 3.0.1 and p2 1.1.7 on apache 2.0.55, php 5.1.2

    errantthought

    (@errantthought)

    Fix has to be reapplied after theme update.

Viewing 15 replies - 31 through 45 (of 45 total)
  • The topic ‘P2 Theme – Real Time Updating Not Working’ is closed to new replies.