Support » Themes and Templates » Delete in Frontend in P2

Delete in Frontend in P2

  • sosukeinu


    I found a couple of posts about this, but they were all closed to replies. I’ve added this to entry.php

    <?php if ( current_user_can( 'edit_post', get_the_id() ) ) : ?>
    						| <a href="<?php echo ( get_delete_post_link( get_the_id() ) ); ?>" class="delete-post-link" rel="<?php the_ID(); ?>"><?php _e( 'Delete', 'p2' ); ?></a>
    					<?php endif; ?>

    That adds the delete link, and it works with the ajax, but it appends a bunch of trash to the url like mysite.com/?trashed=1&ids=110. How can I force this to be stripped off the url after completing the delete? it causes some problems with replies in some browsers. Also, how would I use this same method to delete comments? thank you for your responses.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Alex


    +1 on this

    and it would be nice if you could go forth and add an “users can delete own posts & comments” option to the theme options 🙂



    @sosukeinu: did you as well figure out how to add an ajax-comments-move-to-trash-link for comment authors&administrators?

    Found this topic already, but they did not find a solution..



    well, if you add the code from my first post here to the entry.php in P2, it does an ajax delete, that is, the page stays the same, and the post disappears and appears in the trash in the backend, but it appends that ugly trash string to the URL. I haven’t found how to do this with comments yet, I expect it has something to do with line 190 in functions.php
    <span class="meta"><?php comment_time(); ?> <?php _e( 'on', 'p2' ); ?> <?php comment_date(); ?> <span class="actions"><a href="#comment-<?php comment_ID( ); ?>"><?php _e( 'Permalink', 'p2' ); ?></a><?php echo comment_reply_link(array( 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => ' | ' )); ?><?php edit_comment_link( __( 'Edit' , 'p2' ), ' | ','' ); ?></span><br /></span>
    or maybe line 319

    <span class="meta">
    						<span class="actions"><a href="$permalink">$permalink_text</a> $reply_link $edit_link</span>

    Either way, the ajax that controls the comment editing function could be copied/pasted/and altered to allow for deletion,…it think. That appears to be around line 645 in p2.js

    case "comment" :
    				var thisCommentEditArea;
    				$(element).hover( removeYellow, removeYellow );
    				if (inlineEditComments != 0 && isUserLoggedIn) {
    					thisCommentEditArea = $(element).find('div.comment-edit').eq(0);
    					$(element).find('a.comment-edit-link:first').click( function() {
    						return false;
    					thisCommentEditArea.editable(ajaxUrl, {event: 'edit', loadurl: ajaxUrl + '&action=get_comment&_inline_edit=' + nonce,
    						id: 'comment_ID', name: 'comment_content', type    : 'autogrow', cssclass: 'textedit', rows: '3',
    						indicator : '<img src="' + templateDir +'/i/indicator.gif">', loadtext: eetxt.loading, cancel: eetxt.cancel,
    						submit  : eetxt.save, tooltip   : '', width: '90%', onblur: 'ignore',
    						submitdata: {action:'save_comment',_inline_edit: nonce}});

    but I’m not well-versed enough to know exactly how to alter this to allow for true front-end ajax deletion. Perhaps someone with more knowledge can give us some direction. Until then, it’s going to be a lot of trial and error for me until i can get it to work. When I do, I’ll be sure to post my solution, though it probably won’t be the best. 🙂 Keep me posted as to whether you find an acceptable solution. Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Delete in Frontend in P2’ is closed to new replies.