Skip to:
Content

BuddyPress.org

Ticket #8415: 8415.bpNouveau.patch

File 8415.bpNouveau.patch, 6.1 KB (added by imath, 4 years ago)
  • src/bp-templates/bp-nouveau/buddypress/activity/comment.php

    diff --git src/bp-templates/bp-nouveau/buddypress/activity/comment.php src/bp-templates/bp-nouveau/buddypress/activity/comment.php
    index 4b8b3b3fa..6990cb58c 100644
     
    66 * each activity.
    77 *
    88 * @since 3.0.0
    9  * @version 7.0.0
     9 * @version 10.0.0
    1010 */
    1111
    1212bp_nouveau_activity_hook( 'before', 'comment' ); ?>
    1313
    14 <li id="acomment-<?php bp_activity_comment_id(); ?>" class="comment-item" data-bp-activity-comment-id="<?php bp_activity_comment_id(); ?>">
     14<li id="acomment-<?php bp_activity_comment_id(); ?>" class="comment-item" <?php bp_nouveau_activity_data_attribute_id(); ?>>
    1515        <div class="acomment-avatar item-avatar">
    1616                <a href="<?php bp_activity_comment_user_link(); ?>">
    1717                        <?php
  • src/bp-templates/bp-nouveau/buddypress/activity/entry.php

    diff --git src/bp-templates/bp-nouveau/buddypress/activity/entry.php src/bp-templates/bp-nouveau/buddypress/activity/entry.php
    index f4d15a1a5..471944678 100644
     
    66 * each activity.
    77 *
    88 * @since 3.0.0
    9  * @version 3.0.0
     9 * @version 10.0.0
    1010 */
    1111
    1212bp_nouveau_activity_hook( 'before', 'entry' ); ?>
    1313
    14 <li class="<?php bp_activity_css_class(); ?>" id="activity-<?php bp_activity_id(); ?>" data-bp-activity-id="<?php bp_activity_id(); ?>" data-bp-timestamp="<?php bp_nouveau_activity_timestamp(); ?>">
     14<li class="<?php bp_activity_css_class(); ?>" id="activity-<?php bp_activity_id(); ?>" <?php bp_nouveau_activity_data_attribute_id(); ?> data-bp-timestamp="<?php bp_nouveau_activity_timestamp(); ?>">
    1515
    1616        <div class="activity-avatar item-avatar">
    1717
  • src/bp-templates/bp-nouveau/includes/activity/ajax.php

    diff --git src/bp-templates/bp-nouveau/includes/activity/ajax.php src/bp-templates/bp-nouveau/includes/activity/ajax.php
    index 2469c5bbe..0043e9d4c 100644
     
    33 * Activity Ajax functions
    44 *
    55 * @since 3.0.0
    6  * @version 8.1.0
     6 * @version 10.0.0
    77 */
    88
    99// Exit if accessed directly.
    function bp_nouveau_ajax_delete_activity() { 
    232232
    233233        // Deleting an activity comment.
    234234        if ( ! empty( $_POST['is_comment'] ) ) {
     235                // Get replies before they are deleted.
     236                $replies   = (array) BP_Activity_Activity::get_child_comments( $activity->id );
     237                $reply_ids = wp_list_pluck( $replies, 'id' );
     238
    235239                if ( ! bp_activity_delete_comment( $activity->item_id, $activity->id ) ) {
    236240                        wp_send_json_error( $response );
     241
     242                        // The comment and its replies has been deleted successfully.
     243                } else {
     244                        $response = array(
     245                                'deleted' => array_merge(
     246                                        array( $activity->id ),
     247                                        $reply_ids
     248                                ),
     249                        );
    237250                }
    238251
    239252        // Deleting an activity.
    240253        } else {
    241254                if ( ! bp_activity_delete( array( 'id' => $activity->id, 'user_id' => $activity->user_id ) ) ) {
    242255                        wp_send_json_error( $response );
     256
     257                        // The activity has been deleted successfully.
     258                } else {
     259                        $response = array(
     260                                'deleted' => array( $activity->id ),
     261                        );
    243262                }
    244263        }
    245264
    246265        /** This action is documented in bp-activity/bp-activity-actions.php */
    247266        do_action( 'bp_activity_action_delete_activity', $activity->id, $activity->user_id );
    248267
    249         // The activity has been deleted successfully
    250         $response = array( 'deleted' => $activity->id );
    251 
    252268        // If on a single activity redirect to user's home.
    253269        if ( ! empty( $_POST['is_single'] ) ) {
    254270                $response['redirect'] = bp_core_get_user_domain( $activity->user_id );
  • src/bp-templates/bp-nouveau/includes/activity/template-tags.php

    diff --git src/bp-templates/bp-nouveau/includes/activity/template-tags.php src/bp-templates/bp-nouveau/includes/activity/template-tags.php
    index a1299feea..48662dcc1 100644
     
    33 * Activity Template tags
    44 *
    55 * @since 3.0.0
    6  * @version 8.1.0
     6 * @version 10.0.0
    77 */
    88
    99// Exit if accessed directly.
    function bp_nouveau_activity_hook( $when = '', $suffix = '' ) { 
    146146        bp_nouveau_hook( $hook );
    147147}
    148148
     149/**
     150 * Output the `data-bp-activity-id` or `data-bp-activity-comment-id` attribute
     151 * according to the activity type.
     152 *
     153 * @since 10.0.0
     154 */
     155function bp_nouveau_activity_data_attribute_id() {
     156        $attribute  = 'data-bp-%1$s-id="%2$s"';
     157        $type       = 'activity';
     158        $id         = (int) bp_get_activity_id();
     159        $comment_id = (int) bp_get_activity_comment_id();
     160
     161        if ( 'activity_comment' === bp_get_activity_type() || $comment_id ) {
     162                $type = 'activity-comment';
     163
     164
     165                if ( $comment_id ) {
     166                        $id = $comment_id;
     167                }
     168        }
     169
     170        printf( $attribute, $type, $id );
     171}
     172
    149173/**
    150174 * Checks if an activity of the loop has some content.
    151175 *
  • src/bp-templates/bp-nouveau/js/buddypress-activity.js

    diff --git src/bp-templates/bp-nouveau/js/buddypress-activity.js src/bp-templates/bp-nouveau/js/buddypress-activity.js
    index 3a76427f3..0ce7b0bde 100644
     
    11/* jshint browser: true */
    22/* global BP_Nouveau */
    33/* @since 3.0.0 */
    4 /* @version 8.0.0 */
     4/* @version 10.0.0 */
    55window.bp = window.bp || {};
    66
    77( function( bp, $ ) {
    window.bp = window.bp || {}; 
    569569                                                }
    570570
    571571                                                if ( activity_comment_id ) {
    572                                                         deleted_comments_count = 1;
    573 
    574572                                                        // Move the form if needed
    575573                                                        activity_item.append( activity_comment_li.find( 'form' ) );
    576574
    577                                                         // Count child comments if there are some
    578                                                         $.each( activity_comment_li.find( 'li' ), function() {
    579                                                                 deleted_comments_count += 1;
    580                                                         } );
     575                                                        deleted_comments_count = 1;
     576                                                        if ( response.data.deleted ) {
     577                                                                deleted_comments_count = response.data.deleted.length;
     578
     579                                                                response.data.deleted.forEach( function( cid ) {
     580                                                                        $( '[data-bp-activity-comment-id="' + cid + '"]' ).remove();
     581                                                                } );
     582                                                        } else {
     583                                                                // Count child comments if there are some
     584                                                                $.each( activity_comment_li.find( 'li' ), function() {
     585                                                                        deleted_comments_count += 1;
     586                                                                } );
     587                                                        }
    581588
    582589                                                        // Update the button count
    583590                                                        comment_count_span = activity_item.find( '.acomment-reply span.comment-count' );