Skip to:
Content

BuddyPress.org

Ticket #8222: 8222.patch

File 8222.patch, 18.5 KB (added by passoniate, 6 years ago)

Patch

  • src/bp-activity/js/mentions.js

     
    8787                                 * @since 2.1.0
    8888                                 */
    8989                                before_reposition: function( offset ) {
    90                                         // get the iframe, if any, already applied with atwho.
     90                                        // get the iframe, if any, already applied with at who.
    9191                                        var caret,
    9292                                                        line,
    9393                                                        iframeOffset,
     
    126126                                        // New position is under the caret (never above) and positioned to follow.
    127127                                        // Dynamic sizing based on the input area (remove 'px' from end).
    128128                                        line = parseInt( this.$inputor.css( 'line-height' ).substr( 0, this.$inputor.css( 'line-height' ).length - 2 ), 10 );
    129                                         if ( !line || line < 5 ) { // sanity check, and catch no line-height.
     129                                        if ( !line || line < 5 ) { // Sanity check, and catch no line-height.
    130130                                                line = 19;
    131131                                        }
    132132
  • src/bp-blogs/bp-blogs-activity.php

     
    287287
    288288        $blog_url = false;
    289289
    290         // Try to get the blog url from the activity object
     290        // Try to get the blog url from the activity object.
    291291        if ( isset( $activity->blog_url ) ) {
    292292                $blog_url = $activity->blog_url;
    293293        } else {
     
    296296
    297297        $blog_name = false;
    298298
    299         // Try to get the blog name from the activity object
     299        // Try to get the blog name from the activity object.
    300300        if ( isset( $activity->blog_name ) ) {
    301301                $blog_name = $activity->blog_name;
    302302        } else {
     
    313313
    314314        $post_url = false;
    315315
    316         // Try to get the post url from the activity object
     316        // Try to get the post url from the activity object.
    317317        if ( isset( $activity->post_url ) ) {
    318318                $post_url = $activity->post_url;
    319319
     
    328328
    329329        $post_title = false;
    330330
    331         // Should be the case when the comment has just been published
     331        // Should be the case when the comment has just been published.
    332332        if ( isset( $activity->post_title ) ) {
    333333                $post_title = $activity->post_title;
    334334
    335         // If activity already exists try to get the post title from activity meta
     335        // If activity already exists try to get the post title from activity meta.
    336336        } elseif ( ! empty( $activity->id ) ) {
    337337                $post_title = bp_activity_get_meta( $activity->id, 'post_title' );
    338338        }
     
    789789                $user = bp_core_get_core_userdata( $params['user_id'] );
    790790        }
    791791
    792         // Get associated post type and set default comment parent
     792        // Get associated post type and set default comment parent.
    793793        $post_type      = bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'post_type' );
    794794        $comment_parent = 0;
    795795
     
    805805                'comment_author_email' => $user->user_email,
    806806                'comment_author_url'   => bp_core_get_user_domain( $params['user_id'], $user->user_nicename, $user->user_login ),
    807807                'comment_content'      => $params['content'],
    808                 'comment_type'         => '', // Could be interesting to add 'buddypress' here...
     808                'comment_type'         => '', // Could be interesting to add 'buddyPress' here...
    809809                'comment_parent'       => (int) $comment_parent,
    810810                'user_id'              => $params['user_id'],
    811811                'comment_approved'     => 1
     
    909909        $activity_ids   = bp_activity_recurse_comments_activity_ids( $activity );
    910910        $activity_ids[] = $activity_id;
    911911
    912         // Handle multisite
     912        // Handle multisite.
    913913        // switch to the blog where the comment was made.
    914914        switch_to_blog( $parent_activity->item_id );
    915915
     
    923923        // emulate bp_activity_delete_comment().
    924924        BP_Activity_Activity::rebuild_activity_comment_tree( $parent_activity_id );
    925925
    926         // Avoid the error message although the comments were successfully deleted
     926        // Avoid the error message although the comments were successfully deleted.
    927927        $deleted = true;
    928928
    929929        // We're overriding the default bp_activity_delete_comment() functionality
     
    946946                return;
    947947        }
    948948
    949         // fetch parent activity item
     949        // Fetch parent activity item.
    950950        $parent_activity = new BP_Activity_Activity( $activity->item_id );
    951951
    952         // if parent activity isn't a post type having the buddypress-activity support for comments, stop now!
     952        // If parent activity isn't a post type having the buddypress-activity support for comments, stop now!
    953953        if ( ! bp_activity_type_supports( $parent_activity->type, 'post-type-comment-tracking' ) ) {
    954954                return;
    955955        }
     
    971971        // Handle multisite.
    972972        switch_to_blog( $parent_activity->item_id );
    973973
    974         // Get the comment status
     974        // Get the comment status.
    975975        $post_comment_status = wp_get_comment_status( $post_comment_id );
    976976        $old_comment_status  = $post_comment_status;
    977977
    978         // No need to edit the activity, as it's the activity who's updating the comment
     978        // No need to edit the activity, as it's the activity who's updating the comment.
    979979        remove_action( 'transition_comment_status', 'bp_activity_transition_post_type_comment_status', 10 );
    980980        remove_action( 'bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment', 10 );
    981981
     
    995995                }
    996996        }
    997997
    998         // Restore actions
     998        // Restore actions.
    999999        add_action( 'transition_comment_status',     'bp_activity_transition_post_type_comment_status', 10, 3 );
    10001000        add_action( 'bp_activity_post_type_comment', 'bp_blogs_comment_sync_activity_comment',          10, 4 );
    10011001
     
    10541054                return $args;
    10551055        }
    10561056
    1057         // Get the associated post type
     1057        // Get the associated post type.
    10581058        $post_type = bp_activity_post_type_get_tracking_arg( $args['action'], 'post_type' );
    10591059
    1060         // Bail if this is not an activity associated with a post type
     1060        // Bail if this is not an activity associated with a post type.
    10611061        if ( empty( $post_type ) ) {
    10621062                return $args;
    10631063        }
    10641064
    1065         // Bail if this is an activity about posts and not comments
     1065        // Bail if this is an activity about posts and not comments.
    10661066        if ( bp_activity_post_type_get_tracking_arg( $args['action'], 'comment_action_id' ) ) {
    10671067                return $args;
    10681068        }
     
    12351235
    12361236        // It's a post type supporting comment tracking.
    12371237        if ( bp_activity_type_supports( $type, 'post-type-comment-tracking' ) ) {
    1238                 // The activity type is supporting comments or replies
     1238                // The activity type is supporting comments or replies.
    12391239                if ( bp_activity_type_supports( $type, 'post-type-comment-reply' ) ) {
    12401240                        // Setup some globals we'll need to reference later.
    12411241                        bp_blogs_setup_activity_loop_globals( $activities_template->activity );
     
    12501250                        if ( isset( buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) && buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) {
    12511251                                $retval = false;
    12521252                        }
    1253                 // The activity type does not support comments or replies
     1253                // The activity type does not support comments or replies.
    12541254                } else {
    12551255                        $retval = false;
    12561256                }
     
    12851285                return $retval;
    12861286        }
    12871287
    1288         // Check the parent activity
     1288        // Check the parent activity.
    12891289        $parent_activity = new BP_Activity_Activity( bp_get_activity_item_id() );
    12901290
    12911291        if ( isset( $parent_activity->type ) && bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'post_type' ) ) {
     
    14381438        if ( ! empty( $blog_comment_id ) ) {
    14391439                $bp = buddypress();
    14401440
    1441                 // Check if a comment action id is set for the parent activity
     1441                // Check if a comment action id is set for the parent activity.
    14421442                $comment_action_id = bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'comment_action_id' );
    14431443
    1444                 // Use the action string callback for the activity type
     1444                // Use the action string callback for the activity type.
    14451445                if ( ! empty( $comment_action_id ) ) {
    14461446                        // Fake a 'new_{post_type}_comment' by cloning the activity object.
    14471447                        $object = clone $activity;
    14481448
    1449                         // Set the type of the activity to be a comment about a post type
     1449                        // Set the type of the activity to be a comment about a post type.
    14501450                        $object->type = $comment_action_id;
    14511451
    14521452                        // Use the blog ID as the item_id.
     
    14551455                        // Use comment ID as the secondary_item_id.
    14561456                        $object->secondary_item_id = $blog_comment_id;
    14571457
    1458                         // Get the format callback for this activity comment
     1458                        // Get the format callback for this activity comment.
    14591459                        $format_callback = bp_activity_post_type_get_tracking_arg( $comment_action_id, 'format_callback' );
    14601460
    1461                         // now format the activity action using the 'new_{post_type}_comment' action callback
     1461                        // Now format the activity action using the 'new_{post_type}_comment' action callback.
    14621462                        if ( is_callable( $format_callback ) ) {
    14631463                                $retval = call_user_func_array( $format_callback, array( '', $object ) );
    14641464                        }
  • src/bp-blogs/bp-blogs-functions.php

     
    4545
    4646        // Parse query arguments.
    4747        $r = bp_parse_args( $args, array(
    48                 'type'              => 'active', // 'active', 'alphabetical', 'newest', or 'random'
    49                 'include_blog_ids'  => false,    // Array of blog IDs to include
    50                 'user_id'           => false,    // Limit to blogs this user can post to
    51                 'search_terms'      => false,    // Limit to blogs matching these search terms
    52                 'per_page'          => 20,       // The number of results to return per page
    53                 'page'              => 1,        // The page to return if limiting per page
    54                 'update_meta_cache' => true      // Whether to pre-fetch blogmeta
     48                'type'              => 'active', // 'active', 'alphabetical', 'newest', or 'random'.
     49                'include_blog_ids'  => false,    // Array of blog IDs to include.
     50                'user_id'           => false,    // Limit to blogs this user can post to.
     51                'search_terms'      => false,    // Limit to blogs matching these search terms.
     52                'per_page'          => 20,       // The number of results to return per page.
     53                'page'              => 1,        // The page to return if limiting per page.
     54                'update_meta_cache' => true      // Whether to pre-fetch blogmeta.
    5555        ), 'blogs_get_blogs' );
    5656
    5757        // Get the blogs.
     
    106106                'site_id'  => $wpdb->siteid
    107107        ), 'record_existing_blogs' );
    108108
    109         // Truncate all BP blogs tables if starting fresh
     109        // Truncate all BP blogs tables if starting fresh.
    110110        if ( empty( $r['offset'] ) && empty( $r['blog_ids'] ) ) {
    111111                $bp = buddypress();
    112112
    113                 // Truncate user blogs table
     113                // Truncate user blogs table.
    114114                $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name}" );
    115115                if ( is_wp_error( $truncate ) ) {
    116116                        return false;
    117117                }
    118118
    119                 // Truncate user blogmeta table
     119                // Truncate user blogmeta table.
    120120                $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name_blogmeta}" );
    121121                if ( is_wp_error( $truncate ) ) {
    122122                        return false;
     
    123123                }
    124124        }
    125125
    126         // Multisite
     126        // Multisite.
    127127        if ( is_multisite() ) {
    128128                $sql = array();
    129129                $sql['select'] = $wpdb->prepare( "SELECT blog_id, last_updated FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0 AND site_id = %d", $r['site_id'] );
    130130
    131                 // Omit root blog if large network
     131                // Omit root blog if large network.
    132132                if ( bp_is_large_install() ) {
    133133                        $sql['omit_root_blog'] = $wpdb->prepare( "AND blog_id != %d", bp_get_root_blog_id() );
    134134                }
    135135
    136                 // Filter by selected blog IDs
     136                // Filter by selected blog IDs.
    137137                if ( ! empty( $r['blog_ids'] ) ) {
    138138                        $in        = implode( ',', wp_parse_id_list( $r['blog_ids'] ) );
    139139                        $sql['in'] = "AND blog_id IN ({$in})";
     
    161161                }
    162162        }
    163163
    164          // Bail if there are no blogs
     164         // Bail if there are no blogs.
    165165         if ( empty( $blogs ) ) {
    166                 // Make sure we remove our offset marker
     166                // Make sure we remove our offset marker.
    167167                if ( is_multisite() ) {
    168168                        bp_delete_option( '_bp_record_blogs_offset' );
    169169                }
     
    192192                foreach ( (array) $users as $user_id ) {
    193193                        bp_blogs_add_user_to_blog( $user_id, false, $blog->blog_id );
    194194
    195                         // Clear cache
     195                        // Clear cache.
    196196                        bp_blogs_clear_blog_object_cache( $blog->blog_id, $user_id );
    197197                }
    198198
    199                 // Update blog last activity timestamp
     199                // Update blog last activity timestamp.
    200200                if ( ! empty( $blog->last_updated ) && false !== strtotime( $blog->last_updated ) ) {
    201201                        bp_blogs_update_blogmeta( $blog->blog_id, 'last_activity', $blog->last_updated );
    202202                }
    203203        }
    204204
    205         // See if we need to do this again
     205        // See if we need to do this again.
    206206        if ( is_multisite() && empty( $r['blog_ids'] ) ) {
    207207                $sql['offset'] = $wpdb->prepare( " OFFSET %d", $r['limit'] + $r['offset'] );
    208208
    209                 // Check if there are more blogs to record
     209                // Check if there are more blogs to record.
    210210                $blog_ids = $wpdb->get_results( implode( ' ', $sql ) );
    211211
    212                 // We have more blogs; record offset and re-run function
     212                // We have more blogs; record offset and re-run function.
    213213                if ( ! empty( $blog_ids  ) ) {
    214214                        bp_update_option( '_bp_record_blogs_offset', $r['limit'] + $r['offset'] );
    215215                        bp_blogs_record_existing_blogs( array(
     
    222222                        // Bail since we have more blogs to record.
    223223                        return;
    224224
    225                 // No more blogs; delete offset marker
     225                // No more blogs; delete offset marker.
    226226                } else {
    227227                        bp_delete_option( '_bp_record_blogs_offset' );
    228228                }
     
    726726        // Set the current blog id.
    727727        $blog_id = get_current_blog_id();
    728728
    729         // These activity metadatas are used to build the new_blog_comment action string
     729        // These activity metadatas are used to build the new_blog_comment action string.
    730730        if ( ! empty( $activity_id ) && ! empty( $activity_args['item_id'] ) && 'new_blog_comment' === $activity_post_object->comment_action_id ) {
    731                 // add some post info in activity meta
     731                // Add some post info in activity meta.
    732732                bp_activity_update_meta( $activity_id, 'post_title', $comment->post->post_title );
    733733                bp_activity_update_meta( $activity_id, 'post_url',   esc_url_raw( add_query_arg( 'p', $comment->post->ID, home_url( '/' ) ) ) );
    734734        }
    735735
    736         // Sync comment - activity comment
     736        // Sync comment - activity comment.
    737737        if ( ! bp_disable_blogforum_comments() ) {
    738738
    739739                if ( ! empty( $_REQUEST['action'] ) ) {
     
    749749                }
    750750
    751751                if ( isset( $activity_post_object->action_id ) && isset( $activity_post_object->component_id ) ) {
    752                         // find the parent 'new_post_type' activity entry
     752                        // Find the parent 'new_post_type' activity entry.
    753753                        $parent_activity_id = bp_activity_get_activity_id( array(
    754754                                'component'         => $activity_post_object->component_id,
    755755                                'type'              => $activity_post_object->action_id,
     
    763763                        }
    764764                }
    765765
    766                 // we found the parent activity entry
    767                 // so let's go ahead and reconfigure some activity args
     766                // We found the parent activity entry
     767                // so let's go ahead and reconfigure some activity args.
    768768                if ( ! empty( $parent_activity_id ) ) {
    769                         // set the parent activity entry ID
     769                        // Set the parent activity entry ID.
    770770                        $activity_args['activity_id'] = $parent_activity_id;
    771771
    772                         // now see if the WP parent comment has a BP activity ID
     772                        // Now see if the WP parent comment has a BP activity ID.
    773773                        $comment_parent = 0;
    774774                        if ( ! empty( $comment->comment_parent ) ) {
    775775                                $comment_parent = get_comment_meta( $comment->comment_parent, 'bp_activity_comment_id', true );
     
    776776                        }
    777777
    778778                        // WP parent comment does not have a BP activity ID
    779                         // so set to 'new_' . post_type activity ID
     779                        // so set to 'new_' . post_type activity ID.
    780780                        if ( empty( $comment_parent ) ) {
    781781                                $comment_parent = $parent_activity_id;
    782782                        }
     
    784784                        $activity_args['parent_id']         = $comment_parent;
    785785                        $activity_args['skip_notification'] = true;
    786786
    787                 // could not find corresponding parent activity entry
    788                 // so wipe out $args array
     787                // Could not find corresponding parent activity entry
     788                // so wipe out $args array.
    789789                } else {
    790790                        $activity_args = array();
    791791                }
    792792
    793                 // Record in activity streams
     793                // Record in activity streams.
    794794                if ( ! empty( $activity_args ) ) {
    795795                        $activity_id = bp_activity_new_comment( $activity_args );
    796796
    797797                        if ( empty( $activity_args['id'] ) ) {
    798                                 // The activity metadata to inform about the corresponding comment ID
     798                                // The activity metadata to inform about the corresponding comment ID.
    799799                                bp_activity_update_meta( $activity_id, "bp_blogs_{$comment->post->post_type}_comment_id", $comment->comment_ID );
    800800
    801                                 // The comment metadata to inform about the corresponding activity ID
     801                                // The comment metadata to inform about the corresponding activity ID.
    802802                                add_comment_meta( $comment->comment_ID, 'bp_activity_comment_id', $activity_id );
    803803
    804                                 // These activity metadatas are used to build the new_blog_comment action string
     804                                // These activity metadatas are used to build the new_blog_comment action string.
    805805                                if ( 'new_blog_comment' === $activity_post_object->comment_action_id ) {
    806806                                        bp_activity_update_meta( $activity_id, 'post_title', $comment->post->post_title );
    807807                                        bp_activity_update_meta( $activity_id, 'post_url', esc_url_raw( add_query_arg( 'p', $comment->post->ID, home_url( '/' ) ) ) );
     
    10541054                 * child post comments and associated activity comments.
    10551055                 */
    10561056                if ( ! empty( $activity_id ) ) {
    1057                         // fetch the activity comments for the activity item
     1057                        // Fetch the activity comments for the activity item.
    10581058                        $activity = bp_activity_get( array(
    10591059                                'in'               => $activity_id,
    10601060                                'display_comments' => 'stream',
     
    10611061                                'spam'             => 'all',
    10621062                        ) );
    10631063
    1064                         // get all activity comment IDs for the pending deleted item
     1064                        // Get all activity comment IDs for the pending deleted item.
    10651065                        if ( ! empty( $activity['activities'] ) ) {
    10661066                                $activity_ids   = bp_activity_recurse_comments_activity_ids( $activity );
    10671067                                $activity_ids[] = $activity_id;
    10681068
    1069                                 // delete activity items
     1069                                // Delete activity items.
    10701070                                foreach ( $activity_ids as $activity_id ) {
    10711071                                        bp_activity_delete( array(
    10721072                                                'id' => $activity_id
     
    10731073                                        ) );
    10741074                                }
    10751075
    1076                                 // remove associated blog comments
     1076                                // Remove associated blog comments.
    10771077                                bp_blogs_remove_associated_blog_comments( $activity_ids );
    10781078
    1079                                 // rebuild activity comment tree
     1079                                // Rebuild activity comment tree.
    10801080                                BP_Activity_Activity::rebuild_activity_comment_tree( $activity['activities'][0]->item_id );
    10811081
    1082                                 // Set the result
     1082                                // Set the result.
    10831083                                $deleted = true;
    10841084                        }
    10851085                }
  • src/bp-blogs/classes/class-bp-blogs-blog.php

     
    8686                $this->user_id = apply_filters( 'bp_blogs_blog_user_id_before_save', $this->user_id, $this->id );
    8787
    8888                /**
    89                  * Filters the blog blog ID before save.
     89                 * Filters the blog ID before save.
    9090                 *
    9191                 * @since 1.0.0
    9292                 *