Skip to:
Content
Pages
Categories
Search
Top
Bottom

Broken delete buttons in 1.1.3

  • @peterverkooijen

    Participant

    Are delete buttons in v1.1.3 broken?

    Delete buttons on activities and wire posts open a pop-up ‘Are you sure?’ Then when you confirm it goes to ‘Page not found’.

    It looks like it should be Ajax, but something is probably missing. What could that be?

    I’ve also tested this in the BuddyPress Default 1.1.3 theme and get the same problem.

    This post may be about the same thing.

    In general, what should I look for to fix broken Ajax? I know certain divs have to be in place. What else?

Viewing 18 replies - 1 through 18 (of 18 total)
  • @djpaul

    Keymaster

    Hi Peter

    I’ve just tried this on my 1.1.3 site (with the default theme). I assume you are trying to delete items from the site wide activity widget. It works OK on one of my sites (default theme, no changes).

    When you are logged in as an administrator (obviously) and look at those hover ‘delete’ links, what URL do you get? Mine look like:

    a href=”http://example.com/activity/delete/887?_wpnonce=0df539b1″ class=”item-button delete-activity confirm”

    @peterverkooijen

    Participant

    Thanks for the feedback. I thought I’d seen somewhere that some Ajax had been taken out or simplified, but that’s not what’s going on here then.

    I must have broken something. What parts do I need to put Ajax back together? Where is the Javascript for these delete buttons?

    My delete link looks the same, including the class. I also have the template_notices line. I probably get the popup because Javascript is missing.

    This thread has some clues. I’ll get back to this next week…

    @peterverkooijen

    Participant

    I just did an entirely fresh install of WPMU 2.8.6 + BP 1.1.3 with default themes. I still get the same errors on the delete buttons (in the My Latest Activity feed and other places).

    Am I the only one who has this problem?

    What parts need to be in place for the Ajax around the delete buttons to work correctly?

    @boonebgorges

    Keymaster

    Peter – I’m not sure what’s causing your particular problem, but my understanding of most of the AJAX in BP is that you need the following parts:

    1) Correct class names in the theme files, or in the core files that generate the html

    2) If you’re using bp-sn-parent for a parent theme, the JS for AJAX is located in bp-sn-parent/_inc/js/ajax.js. (Search the file for class names from (1) if you want to know where to start in that file.) ajax.js contains the jquery that waits for user interaction with ajax-enabled elements on the page. When the user interacts (eg clicks on a delete button with class “acomment-delete” to delete an activity item), the code in ajax.js prepares the necessary post variables and sends them to the php handler mentioned in the post action.

    3) Those PHP action functions are located in bp-sn-parent/_inc/ajax.php. They do the server-side processing and return markup back to the javascript.

    Hope that points you in the right direction.

    @peterverkooijen

    Participant

    Thanks Boone Gorges. That at least gives me another thing to try.

    I’ll report back when I know more…

    EDIT: All these points should be OK though, since I have a clean install – I will double-check them.

    Could there have been a change in WPMU’s javascript files between 2.8.4 and 2.8.6 that clashes with Ajax in BP 1.1.3?

    @boonebgorges

    Keymaster

    Hm – I am running the same setup (WPMU 2.8.6/BP 1.1.3) in a production environment and have no problem with the delete button.

    Have you tried scattering alert statements to see where in the ajax process things are getting hung up? alert('Test'); in the javascript and return("test"); in ajax.php

    @peterverkooijen

    Participant

    Have you tried scattering alert statements to see where in the ajax process things are getting hung up?

    I can’t find a function in ajax.js with “delete-activity”, the class on the delete button, so I don’t no where to put that test. Is that function supposed to be there?

    In the 1.0 version of my site I had no classes at all on the delete link (custom theme). Deleting an item does not have fancy Ajax; the page reloads with “Wire message successfully deleted” in <div id=”message”>.

    At least that works! I’d like to just recreate that for my 1.1.3 version.

    So I tried removing the following:

    class="item-button delete-activity confirm"

    from the delete button link in bp-activity-templatetags.php.

    That kills the ugly “Are you sure?” popup, but it then goes to “Page Not Found’ and when you go back to the page the item is still there. So it also kills the delete process…

    Next trying to spot the differences with the process in version 1.0…

    How do those wpnonce links work? What do they do? There’s nothing about them in the codex.

    @peterverkooijen

    Participant

    In version 1.0 the delete link was part of a file bp-wire-ajax.php (deprecated in version 1.1.3.), via a bp_wire_delete_link() function in bp-wire-templatetags.php that looked like this:

    function bp_wire_delete_link() {
    echo bp_get_wire_delete_link();
    }
    function bp_get_wire_delete_link() {
    global $wire_posts_template, $bp;

    if ( empty( $bp->current_item ) )
    $uri = $bp->current_action;
    else
    $uri = $bp->current_item;

    if ( ( $wire_posts_template->wire_post->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() ) {
    if ( $bp->wire->slug == $bp->current_component || $bp->profile->slug == $bp->current_component ) {
    return apply_filters( 'bp_get_wire_delete_link', '<a href="' . wp_nonce_url( $bp->displayed_user->domain . $bp->wire->slug . '/delete/' . $wire_posts_template->wire_post->id, 'bp_wire_delete_link' ) . '">[' . __('Delete', 'buddypress') . ']</a>' );
    } else {
    return apply_filters( 'bp_get_wire_delete_link', '<a href="' . wp_nonce_url( site_url( $bp->{$bp->current_component}->slug . '/' . $uri . '/wire/delete/' . $wire_posts_template->wire_post->id ), 'bp_wire_delete_link' ) . '">[' . __('Delete', 'buddypress') . ']</a>' );
    }
    }
    }

    The same function in version 1.1.3 has some subtle differences:

    function bp_wire_delete_link() {
    echo bp_get_wire_delete_link();
    }
    function bp_get_wire_delete_link() {
    global $wire_posts_template, $bp;

    if ( empty( $bp->current_item ) )
    $uri = $bp->current_action;
    else
    $uri = $bp->current_item;

    if ( ( $wire_posts_template->wire_post->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() ) {
    if ( $bp->wire->slug == $bp->current_component || $bp->profile->slug == $bp->current_component ) {
    return apply_filters( 'bp_get_wire_delete_link', '<a class="item-button delete-post confirm" href="' . wp_nonce_url( $bp->displayed_user->domain . $bp->wire->slug . '/delete/' . $wire_posts_template->wire_post->id, 'bp_wire_delete_link' ) . '">' . __('Delete', 'buddypress') . '</a>' );
    } else {
    return apply_filters( 'bp_get_wire_delete_link', '<a class="item-button delete-post confirm" href="' . wp_nonce_url( site_url( $bp->{$bp->current_component}->slug . '/' . $uri . '/wire/delete/' . $wire_posts_template->wire_post->id ), 'bp_wire_delete_link' ) . '">' . __('Delete', 'buddypress') . '</a>' );
    }
    }
    }

    I’ll try to replace some code and will report back…

    @peterverkooijen

    Participant

    I installed the Buddymatic theme, but get exactly the same error. The problem must be in the Buddypress core files somewhere – I had reuploaded those to make sure they are the untouched 1.1.3 files.

    Any other suggestions what I could try to fix this or pinpoint the problem? This is driving me nuts…

    @peterverkooijen

    Participant

    I installed the Buddymatic theme, but get exactly the same error. The problem must be in the Buddypress core files somewhere – I had reuploaded those to make sure they are the untouched 1.1.3 files.

    Any other suggestions what I could try to fix this or pinpoint the problem? This is driving me nuts…

    The delete link looks like this:

    <span class="activity-delete-link"><a href="http://mysite.com/activity/delete/20?_wpnonce=0f239e493d" class="item-button delete-activity confirm">Delete</a></span>

    When I click I get the ‘Are you sure?’ popup and then when I click OK it redirects to ‘Page not found’ with the same wpnonce URL still in the address bar.

    Why? Where is it supposed to go? Which piece of code is supposed to handle this wpnonce URL?

    The problem is not in the theme. I tested two clean themes, default and buddymatic. Both had the same problem.

    The problem has to be in the bp core code…

    The delete button is produced by this function in bp-activity-templatetags.php:

    function bp_activity_delete_link() {
    echo bp_get_activity_delete_link();
    }
    function bp_get_activity_delete_link() {
    global $activities_template, $bp;

    return apply_filters( 'bp_get_activity_delete_link', '<a href="' . wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/' . $activities_template->activity->id, 'bp_activity_delete_link' ) . '" class="item-button delete-activity confirm">' . __( 'Delete', 'buddypress' ) . '</a>' );
    }

    When I remove ‘confirm’ from the class, the annoying ‘Are you sure?’ popup disappears, but the page still redirects to ‘Page not found’ and the unwanted wire item is still on the page.

    I assume this function only produces the link; there must be another function somewhere that is supposed to process it. Where?!

    ajax.js is loaded – I double-checked… – but what is the connection between the delete link and the javascript? Is that where the processing should take place?

    ajax.php has this:

    <div class="wire-post-metadata">
    <?php bp_wire_post_author_avatar() ?>
    <?php _e( 'On', 'buddypress' ) ?> <?php bp_wire_post_date() ?>
    <?php bp_wire_post_author_name() ?> <?php _e( 'said:', 'buddypress' ) ?>
    <?php bp_wire_delete_link() ?>
    </div>

    bp_wire_delete_link, not bp_activity_delete_link…

    @peterverkooijen

    Participant

    On the wire the delete button DOES work. The link again looks something like this:

    <a class="item-button delete-post confirm" href="http://mysite.com/members/admin/wire/delete/2?_wpnonce=4ce0247d7d">Delete</a>

    I still get the annoying ‘Are you sure?’ popup, but when I click OK the page refreshes with ‘Wire message successfully deleted’.

    Why/how are delete-activity and delete-post different? I tried with class ‘delete-post’ on the activity delete button, instead of ‘delete-activity’, but still get the same ‘Page not found’ error.

    To recap, the problem is only on delete buttons on the Activity wire. Am I really the only one with this problem (in 2.8.6+1.1.3)?

    @peterverkooijen

    Participant

    Probably same problem reported at the top of this thread, before I derailed it…

    @mwollny

    Member

    You’re not alone in this – I seem to be having the exact same problem. However I don’t even get the confirmation dialog, it’s going straight to the ‘Page not found’ error when I try to delete an activity. We’re still on BP 1.1.1, though. Have you made any progress with this during the last couple of days?

    @peterverkooijen

    Participant

    I’ve worked on another Ajax problem here. The delete buttons is probably something similar. I’ll have to go through the code in _inc/js/ajax.js when I have time again – assuming the delete button code is there as well.

    @mrk-1

    Participant

    I have to confirm this issue on my site.

    Did you already recognize the other thread Activity Stream bug?

    @mwollny

    Member

    Before the update from BP 1.1.1 to BP 1.1.3 I didn’t get the confirmation dialog before the delete-button took me straight to the ‘Page not found’ error, after the update, I get the confirmation dialog and then the 404. And yes, it seems to be the same Activitiy Stream bug described in the other thread, RSS feed not working either.

    @mrk-1

    Participant

    Looking forward to BP 1.2 / hopefully these issues will get solved!

    @mrk-1

    Participant

    You’ll find fixes for delete button and activity feed link issues in this thread:

    https://buddypress.org/forums/topic/activity-feed-feed-not-working-after-upgrade-113

    I suggest to close this thread and mark as resolved.

Viewing 18 replies - 1 through 18 (of 18 total)
  • The topic ‘Broken delete buttons in 1.1.3’ is closed to new replies.
Skip to toolbar