32, 'tag' => 'li', 'post_id' => $post_id ); spec_comment_layout( $comment, $args, $depth ); $html = ob_get_contents( ); ob_end_clean( ); $json = array ( ); $json[ 'depth' ] = $depth; $json[ 'post' ] = $post_id; $json[ 'comment_ID' ] = $comment->comment_ID; $json[ 'comment_parent' ] = $comment->comment_parent; $json[ 'comment_post_ID' ] = $comment->comment_post_ID; $json[ 'comment_approved' ] = $comment->comment_approved; $json[ 'html' ] = $html; die( json_encode( $json ) ); } function get_comment_changes( ) { global $spec_comment_log, $wpdb; $comment_log = $spec_comment_log->find( $_POST[ 'post_id' ], $_POST[ 'time' ], isset( $_POST[ 'action_id' ] ) ? $_POST[ 'action_id' ] : 0 ); $json = array( ); $comment_ids = array( ); if ( isset( $comment_log ) && ! empty( $comment_log ) ) { foreach( $comment_log as $comment ) { /* Step through the log creating an array of ids and adding stuff to the json output so we know what to do with the comment once we get to the JS. Some of these things will be overridden by the collect_comments data but this is mostly for the deletion of comments. */ $comment_ids[ ] = intval( $comment->comment_id ); $json[ $comment->comment_id ][ 'action' ] = $comment->action_taken; $json[ $comment->comment_id ][ 'action_id' ] = $comment->id; $json[ $comment->comment_id ][ 'post' ] = $comment->post_id; $json[ $comment->comment_id ][ 'comment_ID' ] = $comment->comment_id; $json[ $comment->comment_id ][ 'log_date' ] = $comment->date; } $comment_data = $spec_comment_log->collect_comments( $comment_ids ); foreach( $comment_data as $comment ) { // We don't know the depth, we'll work that out when we insert it then add the right depth then. $depth = $comment->comment_parent > 0 ? 2 : 1; $post_id = intval( $comment->comment_post_ID ); ob_start( ); // Render the content using the same function as we would normally. $args = array( 'avatar_size' => 32, 'tag' => 'li', 'post_id' => $post_id ); spec_comment_layout( $comment, $args, $depth ); $html = ob_get_contents( ); ob_end_clean( ); $json[ $comment->comment_ID ][ 'depth' ] = $depth; $json[ $comment->comment_ID ][ 'post' ] = $post_id; $json[ $comment->comment_ID ][ 'comment_date' ] = $comment->comment_date; $json[ $comment->comment_ID ][ 'comment_ID' ] = $comment->comment_ID; $json[ $comment->comment_ID ][ 'comment_parent' ] = $comment->comment_parent; $json[ $comment->comment_ID ][ 'comment_type' ] = empty( $comment->comment_type ) ? 'comment' : $comment->comment_type; $json[ $comment->comment_ID ][ 'comment_post_ID' ] = $comment->comment_post_ID; $json[ $comment->comment_ID ][ 'comment_approved' ] = $comment->comment_approved; $json[ $comment->comment_ID ][ 'html' ] = $html; } } echo json_encode( $json ); die; } }?>