Skip to:
Content

BuddyPress.org

Changeset 10374


Ignore:
Timestamp:
11/23/2015 03:55:00 AM (9 years ago)
Author:
tw2113
Message:

More documentation cleanup for BP-Blogs component.

See #6397.

Location:
trunk/src/bp-blogs
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-actions.php

    r10100 r10374  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    1717function bp_blogs_redirect_to_random_blog() {
    1818
    19     // Bail if not looking for a random blog
     19    // Bail if not looking for a random blog.
    2020    if ( ! bp_is_blogs_component() || ! isset( $_GET['random-blog'] ) )
    2121        return;
    2222
    23     // Multisite is active so find a random blog
     23    // Multisite is active so find a random blog.
    2424    if ( is_multisite() ) {
    2525        $blog = bp_blogs_get_random_blogs( 1, 1 );
    2626        bp_core_redirect( get_home_url( $blog['blogs'][0]->blog_id ) );
    2727
    28     // No multisite and still called, always redirect to root
     28    // No multisite and still called, always redirect to root.
    2929    } else {
    3030        bp_core_redirect( bp_core_get_root_domain() );
  • trunk/src/bp-blogs/bp-blogs-activity.php

    r10253 r10374  
    2020    $bp = buddypress();
    2121
    22     // Bail if activity is not active
     22    // Bail if activity is not active.
    2323    if ( ! bp_is_active( 'activity' ) ) {
    2424        return false;
     
    3737    }
    3838
    39     // Only add the comment type if the 'post' post type is trackable
     39    // Only add the comment type if the 'post' post type is trackable.
    4040    if ( post_type_supports( 'post', 'buddypress-activity' ) ) {
    4141        bp_activity_set_action(
     
    6666 * @param string $action   Static activity action.
    6767 * @param object $activity Activity data object.
    68  *
    6968 * @return string
    7069 */
     
    7574    $action = sprintf( __( '%s created the site %s', 'buddypress' ), bp_core_get_userlink( $activity->user_id ), '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>' );
    7675
    77     // Legacy filter - requires the BP_Blogs_Blog object
     76    // Legacy filter - requires the BP_Blogs_Blog object.
    7877    if ( has_filter( 'bp_blogs_activity_created_blog_action' ) ) {
    7978        $user_blog = BP_Blogs_Blog::get_user_blog( $activity->user_id, $activity->item_id );
     
    105104 * @param string $action   Static activity action.
    106105 * @param object $activity Activity data object.
    107  *
    108106 * @return string Constructed activity action.
    109107 */
     
    141139    }
    142140
    143     // Should be the case when the post has just been published
     141    // Should be the case when the post has just been published.
    144142    if ( isset( $activity->post_title ) ) {
    145143        $post_title = $activity->post_title;
    146144
    147     // If activity already exists try to get the post title from activity meta
     145    // If activity already exists try to get the post title from activity meta.
    148146    } else if ( ! empty( $activity->id ) ) {
    149147        $post_title = bp_activity_get_meta( $activity->id, 'post_title' );
     
    152150    /**
    153151     * In case the post was published without a title
    154      * or the activity meta was not found
     152     * or the activity meta was not found.
    155153     */
    156154    if ( empty( $post_title ) ) {
    157         // Defaults to no title
     155        // Defaults to no title.
    158156        $post_title = esc_html__( '(no title)', 'buddypress' );
    159157
     
    167165            }
    168166
    169             // Make sure the activity exists before saving the post title in activity meta
     167            // Make sure the activity exists before saving the post title in activity meta.
    170168            if ( ! empty( $activity->id ) ) {
    171169                bp_activity_update_meta( $activity->id, 'post_title', $post_title );
     
    176174    }
    177175
    178     // Build the 'post link' part of the activity action string
     176    // Build the 'post link' part of the activity action string.
    179177    $post_link  = '<a href="' . esc_url( $post_url ) . '">' . $post_title . '</a>';
    180178
    181179    $user_link = bp_core_get_userlink( $activity->user_id );
    182180
    183     // Build the complete activity action string
     181    // Build the complete activity action string.
    184182    if ( is_multisite() ) {
    185183        $action  = sprintf( __( '%1$s wrote a new post, %2$s, on the site %3$s', 'buddypress' ), $user_link, $post_link, '<a href="' . esc_url( $blog_url ) . '">' . esc_html( $blog_name ) . '</a>' );
     
    188186    }
    189187
    190     // Legacy filter - requires the post object
     188    // Legacy filter - requires the post object.
    191189    if ( has_filter( 'bp_blogs_activity_new_post_action' ) ) {
    192190        switch_to_blog( $activity->item_id );
     
    217215 * @param string $action   Static activity action.
    218216 * @param object $activity Activity data object.
    219  *
    220217 * @return string Constructed activity action.
    221218 */
     
    235232    $post_title = bp_activity_get_meta( $activity->id, 'post_title' );
    236233
    237     // Should only be empty at the time of post creation
     234    // Should only be empty at the time of post creation.
    238235    if ( empty( $post_url ) || empty( $post_title ) ) {
    239236        switch_to_blog( $activity->item_id );
     
    265262    }
    266263
    267     // Legacy filter - requires the comment object
     264    // Legacy filter - requires the comment object.
    268265    if ( has_filter( 'bp_blogs_activity_new_comment_action' ) ) {
    269266        switch_to_blog( $activity->item_id );
     
    295292 *
    296293 * @param array $activities Array of activity items.
    297  *
    298294 * @return array
    299295 */
     
    338334function bp_blogs_record_activity( $args = '' ) {
    339335
    340     // Bail if activity is not active
     336    // Bail if activity is not active.
    341337    if ( ! bp_is_active( 'activity' ) ) {
    342338        return false;
     
    415411function bp_blogs_delete_activity( $args = '' ) {
    416412
    417     // Bail if activity is not active
     413    // Bail if activity is not active.
    418414    if ( ! bp_is_active( 'activity' ) ) {
    419415        return false;
     
    444440 * @since 2.0.0
    445441 *
    446  * @param object $activity The BP_Activity_Activity object
    447  *
     442 * @param object $activity The BP_Activity_Activity object.
    448443 * @return bool
    449444 */
     
    453448    $blog_id = $activity->item_id;
    454449
    455     // see if we've mirrored the close comments option before
     450    // See if we've mirrored the close comments option before.
    456451    $days_old = bp_blogs_get_blogmeta( $blog_id, 'close_comments_days_old' );
    457452
    458     // we've never cached these items before, so do it now
     453    // We've never cached these items before, so do it now.
    459454    if ( '' === $days_old ) {
    460455        switch_to_blog( $blog_id );
    461456
    462         // use comments_open()
     457        // Use comments_open().
    463458        remove_filter( 'comments_open', 'bp_comments_open', 10, 2 );
    464459        $open = comments_open( $activity->secondary_item_id );
    465460        add_filter( 'comments_open', 'bp_comments_open', 10, 2 );
    466461
    467         // might as well mirror values to blogmeta since we're here!
     462        // Might as well mirror values to blogmeta since we're here!
    468463        $thread_depth = get_option( 'thread_comments' );
    469464        if ( ! empty( $thread_depth ) ) {
    470465            $thread_depth = get_option( 'thread_comments_depth' );
    471466        } else {
    472             // perhaps filter this?
     467            // Perhaps filter this?
    473468            $thread_depth = 1;
    474469        }
     
    480475        restore_current_blog();
    481476
    482     // check blogmeta and manually check activity item
    483     // basically a copy of _close_comments_for_old_post()
     477    // Check blogmeta and manually check activity item.
     478    // Basically a copy of _close_comments_for_old_post().
    484479    } else {
    485480
    486         // comments are closed
     481        // Comments are closed.
    487482        if ( 'closed' == bp_activity_get_meta( $activity->id, 'post_comment_status' ) ) {
    488483            return false;
     
    498493        }
    499494
    500         /* commenting out for now - needs some more thought...
     495        /*
     496           Commenting out for now - needs some more thought...
    501497           should we add the post type to activity meta?
    502498
     
    535531 */
    536532function bp_blogs_sync_add_from_activity_comment( $comment_id, $params, $parent_activity ) {
    537     // if parent activity isn't a blog post, stop now!
     533    // If parent activity isn't a blog post, stop now!
    538534    if ( $parent_activity->type != 'new_blog_post' ) {
    539535        return;
    540536    }
    541537
    542     // if activity comments are disabled for blog posts, stop now!
     538    // If activity comments are disabled for blog posts, stop now!
    543539    if ( bp_disable_blogforum_comments() ) {
    544540        return;
    545541    }
    546542
    547     // get userdata
     543    // Get userdata.
    548544    if ( $params['user_id'] == bp_loggedin_user_id() ) {
    549545        $user = buddypress()->loggedin_user->userdata;
     
    552548    }
    553549
    554     // see if a parent WP comment ID exists
     550    // See if a parent WP comment ID exists.
    555551    if ( ! empty( $params['parent_id'] ) ) {
    556552        $comment_parent = bp_activity_get_meta( $params['parent_id'], 'bp_blogs_post_comment_id' );
     
    559555    }
    560556
    561     // comment args
     557    // Comment args.
    562558    $args = array(
    563559        'comment_post_ID'      => $parent_activity->secondary_item_id,
     
    566562        'comment_author_url'   => bp_core_get_user_domain( $params['user_id'], $user->user_nicename, $user->user_login ),
    567563        'comment_content'      => $params['content'],
    568         'comment_type'         => '', // could be interesting to add 'buddypress' here...
     564        'comment_type'         => '', // Could be interesting to add 'buddypress' here...
    569565        'comment_parent'       => (int) $comment_parent,
    570566        'user_id'              => $params['user_id'],
    571567
    572         // commenting these out for now
    573         //'comment_author_IP'    => '127.0.0.1',
    574         //'comment_agent'        => '',
    575 
     568        // Commenting these out for now
     569        // 'comment_author_IP'    => '127.0.0.1',
     570        // 'comment_agent'        => '', .
    576571        'comment_approved'     => 1
    577572    );
    578573
    579     // prevent separate activity entry being made
     574    // Prevent separate activity entry being made.
    580575    remove_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
    581576
    582     // handle multisite
     577    // Handle multisite.
    583578    switch_to_blog( $parent_activity->item_id );
    584579
    585     // handle timestamps for the WP comment after we've switched to the blog
     580    // Handle timestamps for the WP comment after we've switched to the blog.
    586581    $args['comment_date']     = current_time( 'mysql' );
    587582    $args['comment_date_gmt'] = current_time( 'mysql', 1 );
    588583
    589     // post the comment
     584    // Post the comment.
    590585    $post_comment_id = wp_insert_comment( $args );
    591586
    592     // add meta to comment
     587    // Add meta to comment.
    593588    add_comment_meta( $post_comment_id, 'bp_activity_comment_id', $comment_id );
    594589
    595     // add meta to activity comment
     590    // Add meta to activity comment.
    596591    bp_activity_update_meta( $comment_id, 'bp_blogs_post_comment_id', $post_comment_id );
    597592
    598     // resave activity comment with WP comment permalink
     593    // Resave activity comment with WP comment permalink.
    599594    //
    600595    // in bp_blogs_activity_comment_permalink(), we change activity comment
     
    602597    //
    603598    // @todo since this is done after AJAX posting, the activity comment permalink
    604     //       doesn't change on the frontend until the next page refresh.
     599    // doesn't change on the frontend until the next page refresh.
    605600    $resave_activity = new BP_Activity_Activity( $comment_id );
    606601    $resave_activity->primary_link = get_comment_link( $post_comment_id );
     
    614609    $resave_activity->save();
    615610
    616     // add the edit activity comment hook back
     611    // Add the edit activity comment hook back.
    617612    add_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 );
    618613
    619     // multisite again!
     614    // Multisite again!
    620615    restore_current_blog();
    621616
    622     // add the comment hook back
     617    // Add the comment hook back.
    623618    add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
    624619
     
    646641 * @since 2.0.0
    647642 *
    648  * @param bool $retval
     643 * @param bool $retval             Whether BuddyPress should continue or not.
    649644 * @param int  $parent_activity_id The parent activity ID for the activity comment.
    650645 * @param int  $activity_id        The activity ID for the pending deleted activity comment.
    651  *
    652646 * @return bool
    653647 */
    654648function bp_blogs_sync_delete_from_activity_comment( $retval, $parent_activity_id, $activity_id ) {
    655     // check if parent activity is a blog post
     649    // Check if parent activity is a blog post.
    656650    $parent_activity = new BP_Activity_Activity( $parent_activity_id );
    657651    if ( 'new_blog_post' != $parent_activity->type ) {
     
    659653    }
    660654
    661     // fetch the activity comments for the activity item
     655    // Fetch the activity comments for the activity item.
    662656    $activity = bp_activity_get( array(
    663657        'in'               => $activity_id,
     
    665659    ) );
    666660
    667     // get all activity comment IDs for the pending deleted item
     661    // Get all activity comment IDs for the pending deleted item.
    668662    $activity_ids   = bp_activity_recurse_comments_activity_ids( $activity );
    669663    $activity_ids[] = $activity_id;
    670664
    671     // handle multisite
    672     // switch to the blog where the comment was made
     665    // Handle multisite
     666    // switch to the blog where the comment was made.
    673667    switch_to_blog( $parent_activity->item_id );
    674668
    675     // remove associated blog comments
     669    // Remove associated blog comments.
    676670    bp_blogs_remove_associated_blog_comments( $activity_ids, current_user_can( 'moderate_comments' ) );
    677671
    678     // multisite again!
     672    // Multisite again!
    679673    restore_current_blog();
    680674
    681     // rebuild activity comment tree
    682     // emulate bp_activity_delete_comment()
     675    // Rebuild activity comment tree
     676    // emulate bp_activity_delete_comment().
    683677    BP_Activity_Activity::rebuild_activity_comment_tree( $parent_activity_id );
    684678
    685     // we're overriding the default bp_activity_delete_comment() functionality
    686     // so we need to return false
     679    // We're overriding the default bp_activity_delete_comment() functionality
     680    // so we need to return false.
    687681    return false;
    688682}
     
    697691 */
    698692function bp_blogs_sync_activity_edit_to_post_comment( BP_Activity_Activity $activity ) {
    699     // not an activity comment? stop now!
     693    // Not an activity comment? stop now!
    700694    if ( 'activity_comment' !== $activity->type ) {
    701695        return;
    702696    }
    703697
    704     // this is a new entry, so stop!
    705     // we only want edits!
     698    // This is a new entry, so stop!
     699    // We only want edits!
    706700    if ( empty( $activity->id ) ) {
    707701        return;
    708702    }
    709703
    710     // prevent recursion
     704    // Prevent recursion.
    711705    remove_action( 'bp_activity_before_save', 'bp_blogs_sync_activity_edit_to_post_comment', 20 );
    712706
    713     // Try to see if a corresponding blog comment exists
     707    // Try to see if a corresponding blog comment exists.
    714708    $post_comment_id = bp_activity_get_meta( $activity->id, 'bp_blogs_post_comment_id' );
    715709
     
    718712    }
    719713
    720     // fetch parent activity item
     714    // Fetch parent activity item.
    721715    $parent_activity = new BP_Activity_Activity( $activity->item_id );
    722716
    723     // sanity check
     717    // Sanity check.
    724718    if ( 'new_blog_post' !== $parent_activity->type ) {
    725719        return;
    726720    }
    727721
    728     // handle multisite
     722    // Handle multisite.
    729723    switch_to_blog( $parent_activity->item_id );
    730724
    731     // update the blog post comment
     725    // Update the blog post comment.
    732726    wp_update_comment( array(
    733727        'comment_ID'      => $post_comment_id,
     
    783777 *
    784778 * @param array $args Arguments passed from bp_parse_args() in bp_has_activities().
    785  *
    786779 * @return array $args
    787780 */
     
    790783    $bp = buddypress();
    791784
    792     // Bail if this is not a 'new_blog_comment' query
     785    // Bail if this is not a 'new_blog_comment' query.
    793786    if ( 'new_blog_comment' !== $args['action'] ) {
    794787        return $args;
     
    802795    }
    803796
    804     // Init the filter query
     797    // Init the filter query.
    805798    $filter_query = array();
    806799
     
    833826    $args['filter_query'] = $filter_query;
    834827
    835     // Make sure to have comment in stream mode && avoid duplicate content
     828    // Make sure to have comment in stream mode && avoid duplicate content.
    836829    $args['display_comments'] = 'stream';
    837830
    838     // Finally reset the action
     831    // Finally reset the action.
    839832    $args['action'] = '';
    840833
    841     // Return the original arguments
     834    // Return the original arguments.
    842835    return $args;
    843836}
     
    864857    }
    865858
    866     // parent not a blog post? stop now!
     859    // Parent not a blog post? stop now!
    867860    if ( 'new_blog_post' !== $activity->type ) {
    868861        return;
     
    873866    }
    874867
    875     // if we've already done this before, stop now!
     868    // If we've already done this before, stop now!
    876869    if ( isset( buddypress()->blogs->allow_comments[ $activity->id ] ) ) {
    877870        return;
     
    881874    $thread_depth   = bp_blogs_get_blogmeta( $activity->item_id, 'thread_comments_depth' );
    882875
    883     // initialize a local object so we won't have to query this again in the
    884     // comment loop
     876    // Initialize a local object so we won't have to query this again in the
     877    // comment loop.
    885878    if ( empty( buddypress()->blogs->allow_comments ) ) {
    886879        buddypress()->blogs->allow_comments = array();
     
    890883    }
    891884
    892     // cache comment settings in the buddypress() singleton to reference later in
     885    // Cache comment settings in the buddypress() singleton to reference later in
    893886    // the activity comment loop
    894887    // @see bp_blogs_disable_activity_replies()
     
    909902 */
    910903function bp_blogs_setup_comment_loop_globals_on_ajax() {
    911     // not AJAX? stop now!
     904    // Not AJAX? stop now!
    912905    if ( ! defined( 'DOING_AJAX' ) ) {
    913906        return;
     
    917910    }
    918911
    919     // get the parent activity item
     912    // Get the parent activity item.
    920913    $comment         = bp_activity_current_comment();
    921914    $parent_activity = new BP_Activity_Activity( $comment->item_id );
    922915
    923     // setup the globals
     916    // Setup the globals.
    924917    bp_blogs_setup_activity_loop_globals( $parent_activity );
    925918}
     
    938931 * @since 2.0.0
    939932 *
    940  * @param bool $retval Is activity commenting enabled for this activity entry?
    941  *
     933 * @param bool $retval Is activity commenting enabled for this activity entry.
    942934 * @return bool
    943935 */
    944936function bp_blogs_disable_activity_commenting( $retval ) {
    945     // if activity commenting is disabled, return current value
     937    // If activity commenting is disabled, return current value.
    946938    if ( bp_disable_blogforum_comments() ) {
    947939        return $retval;
    948940    }
    949941
    950     // activity commenting is enabled for blog posts
     942    // Activity commenting is enabled for blog posts.
    951943    switch ( bp_get_activity_action_name() ) {
    952944
    953         // we still have to disable activity commenting for 'new_blog_comment' items
    954         // commenting should only be done on the parent 'new_blog_post' item
     945        // We still have to disable activity commenting for 'new_blog_comment' items
     946        // commenting should only be done on the parent 'new_blog_post' item.
    955947        case 'new_blog_comment' :
    956948            $retval = false;
     
    958950            break;
    959951
    960         // check if commenting is disabled for the WP blog post
    961         // we should extrapolate this and automate this for plugins... or not
     952        // Check if commenting is disabled for the WP blog post
     953        // we should extrapolate this and automate this for plugins... or not.
    962954        case 'new_blog_post' :
    963955            global $activities_template;
    964956
    965             // setup some globals we'll need to reference later
     957            // Setup some globals we'll need to reference later.
    966958            bp_blogs_setup_activity_loop_globals( $activities_template->activity );
    967959
    968             // if comments are closed for the WP blog post, we should disable
    969             // activity comments for this activity entry
     960            // If comments are closed for the WP blog post, we should disable
     961            // activity comments for this activity entry.
    970962            if ( empty( buddypress()->blogs->allow_comments[bp_get_activity_id()] ) ) {
    971963                $retval = false;
     
    990982 * @since 2.0.0
    991983 *
    992  * @param bool         $retval  Are replies allowed for this activity reply?
     984 * @param bool         $retval  Are replies allowed for this activity reply.
    993985 * @param object|array $comment The activity comment object.
    994986 *
     
    1000992    }
    1001993
    1002     // check comment depth and disable if depth is too large
     994    // Check comment depth and disable if depth is too large.
    1003995    if ( isset( buddypress()->blogs->thread_depth[$comment->item_id] ) ){
    1004996        if ( $comment->mptt_left > buddypress()->blogs->thread_depth[$comment->item_id] ) {
     
    1007999    }
    10081000
    1009     // check if we should disable activity replies based on the parent activity
     1001    // Check if we should disable activity replies based on the parent activity.
    10101002    if ( isset( buddypress()->blogs->allow_comments[$comment->item_id] ) ){
    1011         // the blog post has closed off commenting, so we should disable all activity
    1012         // comments under the parent 'new_blog_post' activity entry
     1003        // The blog post has closed off commenting, so we should disable all activity
     1004        // comments under the parent 'new_blog_post' activity entry.
    10131005        if ( empty( buddypress()->blogs->allow_comments[$comment->item_id] ) ) {
    10141006            $retval = false;
     
    10301022 *
    10311023 * @param string $retval The activity comment permalink.
    1032  *
    10331024 * @return string
    10341025 */
     
    10361027    global $activities_template;
    10371028
    1038     // Get the current comment ID
     1029    // Get the current comment ID.
    10391030    $item_id = isset( $activities_template->activity->current_comment->item_id )
    10401031        ? $activities_template->activity->current_comment->item_id
    10411032        : false;
    10421033
    1043     // Maybe adjust the link if item ID exists
     1034    // Maybe adjust the link if item ID exists.
    10441035    if ( ( false !== $item_id ) && isset( buddypress()->blogs->allow_comments[ $item_id ] ) ) {
    10451036        $retval = $activities_template->activity->current_comment->primary_link;
     
    10581049 *
    10591050 * @param string               $retval   The activity permalink.
    1060  * @param BP_Activity_Activity $activity
    1061  *
     1051 * @param BP_Activity_Activity $activity Activity object.
    10621052 * @return string
    10631053 */
     
    10851075 *
    10861076 * @param string               $retval   The activity action.
    1087  * @param BP_Activity_Activity $activity
    1088  *
     1077 * @param BP_Activity_Activity $activity Activity object.
    10891078 * @return string
    10901079 */
     
    10971086
    10981087    if ( ! empty( $blog_comment_id ) ) {
    1099         // fetch the parent blog post activity item
     1088        // Fetch the parent blog post activity item.
    11001089        $parent_blog_post_activity = new BP_Activity_Activity( $activity->item_id );
    11011090
    1102         // fake a 'new_blog_comment' activity object
     1091        // Fake a 'new_blog_comment' activity object.
    11031092        $object = $activity;
    11041093
    1105         // override 'item_id' to use blog ID
     1094        // Override 'item_id' to use blog ID.
    11061095        $object->item_id = $parent_blog_post_activity->item_id;
    11071096
    1108         // override 'secondary_item_id' to use comment ID
     1097        // Override 'secondary_item_id' to use comment ID.
    11091098        $object->secondary_item_id = $blog_comment_id;
    11101099
    1111         // now format the activity action using the 'new_blog_comment' action callback
     1100        // Now format the activity action using the 'new_blog_comment' action callback.
    11121101        $retval = bp_blogs_format_activity_action_new_blog_comment( '', $object );
    11131102    }
  • trunk/src/bp-blogs/bp-blogs-cache.php

    r10100 r10374  
    2525function bp_blogs_update_meta_cache( $blog_ids = false ) {
    2626    $cache_args = array(
    27         'object_ids'       => $blog_ids,
    28         'object_type'      => buddypress()->blogs->id,
    29         'object_column'    => 'blog_id',
    30         'cache_group'      => 'blog_meta',
    31         'meta_table'       => buddypress()->blogs->table_name_blogmeta,
     27        'object_ids'    => $blog_ids,
     28        'object_type'   => buddypress()->blogs->id,
     29        'object_column' => 'blog_id',
     30        'cache_group'   => 'blog_meta',
     31        'meta_table'    => buddypress()->blogs->table_name_blogmeta,
    3232    );
    3333
  • trunk/src/bp-blogs/bp-blogs-filters.php

    r10100 r10374  
    3030 *
    3131 * @param string $url The original URL (points to wp-signup.php by default).
    32  *
    3332 * @return string The new URL.
    3433 */
     
    5453 *
    5554 * @param array $retval Current SQL clauses in array format.
    56  *
    5755 * @return array
    5856 */
     
    7068 * @since 2.2.0
    7169 *
    72  * @param  bool $return  Whether the post should be published.
    73  * @param  int  $blog_id ID of the blog.
    74  * @param  int  $post_id ID of the post.
    75  * @param  int  $user_id ID of the post author.
    76  *
     70 * @param bool $return  Whether the post should be published.
     71 * @param int  $blog_id ID of the blog.
     72 * @param int  $post_id ID of the post.
     73 * @param int  $user_id ID of the post author.
    7774 * @return bool True to authorize the post to be published, otherwise false.
    7875 */
  • trunk/src/bp-blogs/bp-blogs-functions.php

    r10277 r10374  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    4343function bp_blogs_get_blogs( $args = '' ) {
    4444
    45     // Parse query arguments
     45    // Parse query arguments.
    4646    $r = bp_parse_args( $args, array(
    4747        'type'              => 'active', // 'active', 'alphabetical', 'newest', or 'random'
     
    5454    ), 'blogs_get_blogs' );
    5555
    56     // Get the blogs
     56    // Get the blogs.
    5757    $blogs = BP_Blogs_Blog::get(
    5858        $r['type'],
     
    6565    );
    6666
    67     // Filter and return
     67    // Filter and return.
    6868    return apply_filters( 'bp_blogs_get_blogs', $blogs, $r );
    6969}
     
    8383    global $wpdb;
    8484
    85     // Query for all sites in network
     85    // Query for all sites in network.
    8686    if ( is_multisite() ) {
    8787
    88         // Get blog ID's if not a large network
     88        // Get blog ID's if not a large network.
    8989        if ( ! wp_is_large_network() ) {
    9090            $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE mature = 0 AND spam = 0 AND deleted = 0 AND site_id = %d", $wpdb->siteid ) );
    9191
    92             // If error running this query, set blog ID's to false
     92            // If error running this query, set blog ID's to false.
    9393            if ( is_wp_error( $blog_ids ) ) {
    9494                $blog_ids = false;
    9595            }
    9696
    97         // Large networks are not currently supported
     97        // Large networks are not currently supported.
    9898        } else {
    9999            $blog_ids = false;
    100100        }
    101101
    102     // Record a single site
     102    // Record a single site.
    103103    } else {
    104104        $blog_ids = $wpdb->blogid;
    105105    }
    106106
    107     // Bail if there are no blogs in the network
     107    // Bail if there are no blogs in the network.
    108108    if ( empty( $blog_ids ) ) {
    109109        return false;
    110110    }
    111111
    112     // Get BuddyPress
     112    // Get BuddyPress.
    113113    $bp = buddypress();
    114114
    115     // Truncate user blogs table
     115    // Truncate user blogs table.
    116116    $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name}" );
    117117    if ( is_wp_error( $truncate ) ) {
     
    119119    }
    120120
    121     // Truncate user blogsmeta table
     121    // Truncate user blogsmeta table.
    122122    $truncate = $wpdb->query( "TRUNCATE {$bp->blogs->table_name_blogmeta}" );
    123123    if ( is_wp_error( $truncate ) ) {
     
    125125    }
    126126
    127     // Loop through users of blogs and record the relationship
     127    // Loop through users of blogs and record the relationship.
    128128    foreach ( (array) $blog_ids as $blog_id ) {
    129129
    130         // Ensure that the cache is clear after the table TRUNCATE above
     130        // Ensure that the cache is clear after the table TRUNCATE above.
    131131        wp_cache_delete( $blog_id, 'blog_meta' );
    132132
    133         // Get all users
     133        // Get all users.
    134134        $users = get_users( array(
    135135            'blog_id' => $blog_id
    136136        ) );
    137137
    138         // Continue on if no users exist for this site (how did this happen?)
     138        // Continue on if no users exist for this site (how did this happen?).
    139139        if ( empty( $users ) ) {
    140140            continue;
    141141        }
    142142
    143         // Loop through users and record their relationship to this blog
     143        // Loop through users and record their relationship to this blog.
    144144        foreach ( (array) $users as $user ) {
    145145            bp_blogs_add_user_to_blog( $user->ID, false, $blog_id );
     
    154154    do_action( 'bp_blogs_recorded_existing_blogs' );
    155155
    156     // No errors
     156    // No errors.
    157157    return true;
    158158}
     
    170170 * @param int $blog_id ID of the blog being checked.
    171171 * @param int $user_id Optional. ID of the user for whom access is being checked.
    172  *
    173172 * @return bool True if blog is recordable, otherwise false.
    174173 */
     
    203202 * @param int $blog_id ID of the blog being checked.
    204203 * @param int $user_id Optional. ID of the user for whom access is being checked.
    205  *
    206204 * @return bool True if blog is trackable, otherwise false.
    207205 */
     
    234232 * @param bool $no_activity Optional. Whether to skip recording an activity
    235233 *                          item about this blog creation. Default: false.
    236  *
    237234 * @return bool|null Returns false on failure.
    238235 */
     
    261258        $thread_depth = get_blog_option( $blog_id, 'thread_comments_depth' );
    262259    } else {
    263         // perhaps filter this?
     260        // Perhaps filter this?
    264261        $thread_depth = 1;
    265262    }
     
    282279    $is_private = !apply_filters( 'bp_is_new_blog_public', !$is_private );
    283280
    284     // Only record this activity if the blog is public
     281    // Only record this activity if the blog is public.
    285282    if ( !$is_private && !$no_activity && bp_blogs_is_blog_trackable( $blog_id, $user_id ) ) {
    286283
    287         // Record this in activity streams
     284        // Record this in activity streams.
    288285        bp_blogs_record_activity( array(
    289286            'user_id'      => $recorded_blog->user_id,
     
    565562 * @param bool|string $is_approved Optional. The $is_approved value passed to
    566563 *                                 the 'comment_post' action. Default: true.
    567  *
    568564 * @return bool|object Returns false on failure, the comment object on success.
    569565 */
    570566function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
    571     // bail if activity component is not active
     567    // Bail if activity component is not active.
    572568    if ( ! bp_is_active( 'activity' ) ) {
    573569        return;
    574570    }
    575571
    576     // Get the users comment
     572    // Get the users comment.
    577573    $recorded_comment = get_comment( $comment_id );
    578574
    579     // Don't record activity if the comment hasn't been approved
     575    // Don't record activity if the comment hasn't been approved.
    580576    if ( empty( $is_approved ) )
    581577        return false;
    582578
    583     // Don't record activity if no email address has been included
     579    // Don't record activity if no email address has been included.
    584580    if ( empty( $recorded_comment->comment_author_email ) )
    585581        return false;
    586582
    587     // Don't record activity if the comment has already been marked as spam
     583    // Don't record activity if the comment has already been marked as spam.
    588584    if ( 'spam' === $is_approved )
    589585        return false;
     
    592588    $user = get_user_by( 'email', $recorded_comment->comment_author_email );
    593589
    594     // If user isn't registered, don't record activity
     590    // If user isn't registered, don't record activity.
    595591    if ( empty( $user ) )
    596592        return false;
    597593
    598     // Get the user_id
     594    // Get the user_id.
    599595    $user_id = (int) $user->ID;
    600596
    601     // Get blog and post data
     597    // Get blog and post data.
    602598    $blog_id = get_current_blog_id();
    603599
     
    611607        return false;
    612608
    613     // If this is a password protected post, don't record the comment
     609    // If this is a password protected post, don't record the comment.
    614610    if ( !empty( $recorded_comment->post->post_password ) )
    615611        return false;
    616612
    617     // Don't record activity if the comment's associated post isn't a WordPress Post
     613    // Don't record activity if the comment's associated post isn't a WordPress Post.
    618614    if ( !in_array( $recorded_comment->post->post_type, apply_filters( 'bp_blogs_record_comment_post_types', array( 'post' ) ) ) )
    619615        return false;
     
    621617    $is_blog_public = apply_filters( 'bp_is_blog_public', (int)get_blog_option( $blog_id, 'blog_public' ) );
    622618
    623     // If blog is public allow activity to be posted
     619    // If blog is public allow activity to be posted.
    624620    if ( $is_blog_public ) {
    625621
    626         // Get activity related links
     622        // Get activity related links.
    627623        $post_permalink = get_permalink( $recorded_comment->comment_post_ID );
    628624        $comment_link   = get_comment_link( $recorded_comment->comment_ID );
    629625
    630         // Setup activity args
     626        // Setup activity args.
    631627        $args = array();
    632628
     
    637633
    638634        // Setup some different activity args depending if activity commenting is
    639         // enabled or not
    640 
     635        // enabled or not.
    641636        // if cannot comment, record separate activity entry
    642         // this is the old way of doing things
     637        // this is the old way of doing things.
    643638        if ( bp_disable_blogforum_comments() ) {
    644639            $args['type']              = 'new_blog_comment';
     
    646641            $args['secondary_item_id'] = $comment_id;
    647642
    648             // record the activity entry
     643            // Record the activity entry.
    649644            $activity_id = bp_blogs_record_activity( $args );
    650645
    651             // add some post info in activity meta
     646            // Add some post info in activity meta.
    652647            bp_activity_update_meta( $activity_id, 'post_title', $recorded_comment->post->post_title );
    653648            bp_activity_update_meta( $activity_id, 'post_url',   add_query_arg( 'p', $recorded_comment->post->ID, home_url( '/' ) ) );
    654649
    655         // record comment as BP activity comment under the parent 'new_blog_post'
    656         // activity item
     650        // Record comment as BP activity comment under the parent 'new_blog_post'
     651        // activity item.
    657652        } else {
    658             // this is a comment edit
    659             // check to see if corresponding activity entry already exists
     653            // This is a comment edit
     654            // check to see if corresponding activity entry already exists.
    660655            if ( ! empty( $_REQUEST['action'] ) ) {
    661656                $existing_activity_id = get_comment_meta( $comment_id, 'bp_activity_comment_id', true );
     
    666661            }
    667662
    668             // find the parent 'new_blog_post' activity entry
     663            // Find the parent 'new_blog_post' activity entry.
    669664            $parent_activity_id = bp_activity_get_activity_id( array(
    670665                'component'         => 'blogs',
     
    674669            ) );
    675670
    676             // Try to create a new activity item for the parent blog post
     671            // Try to create a new activity item for the parent blog post.
    677672            if ( empty( $parent_activity_id ) ) {
    678673                $parent_activity_id = bp_activity_post_type_publish( $recorded_comment->comment_post_ID, $recorded_comment->post );
    679674            }
    680675
    681             // we found the parent activity entry
    682             // so let's go ahead and reconfigure some activity args
     676            // We found the parent activity entry
     677            // so let's go ahead and reconfigure some activity args.
    683678            if ( ! empty( $parent_activity_id ) ) {
    684                 // set the 'item_id' with the parent activity entry ID
     679                // Set the 'item_id' with the parent activity entry ID.
    685680                $args['item_id'] = $parent_activity_id;
    686681
    687                 // now see if the WP parent comment has a BP activity ID
     682                // Now see if the WP parent comment has a BP activity ID.
    688683                $comment_parent = 0;
    689684                if ( ! empty( $recorded_comment->comment_parent ) ) {
     
    692687
    693688                // WP parent comment does not have a BP activity ID
    694                 // so set to 'new_blog_post' activity ID
     689                // so set to 'new_blog_post' activity ID.
    695690                if ( empty( $comment_parent ) ) {
    696691                    $comment_parent = $parent_activity_id;
     
    701696                $args['type']              = 'activity_comment';
    702697
    703             // could not find corresponding parent activity entry
    704             // so wipe out $args array
     698            // Could not find corresponding parent activity entry
     699            // so wipe out $args array.
    705700            } else {
    706701                $args = array();
    707702            }
    708703
    709             // Record in activity streams
     704            // Record in activity streams.
    710705            if ( ! empty( $args ) ) {
    711706                // @todo should we use bp_activity_new_comment()? that function will also send
    712                 // an email to people in the activity comment thread
     707                // an email to people in the activity comment thread.
    713708                //
    714                 // what if a site already has some comment email notification plugin setup?
     709                // What if a site already has some comment email notification plugin setup?
    715710                // this is why I decided to go with bp_activity_add() to avoid any conflict
    716                 // with existing comment email notification plugins
     711                // with existing comment email notification plugins.
    717712                $comment_activity_id = bp_activity_add( $args );
    718713
    719714                if ( empty( $args['id'] ) ) {
    720                     // add meta to activity comment
     715                    // Add meta to activity comment.
    721716                    bp_activity_update_meta( $comment_activity_id, 'bp_blogs_post_comment_id', $comment_id );
    722717                    bp_activity_update_meta( $comment_activity_id, 'post_title', $recorded_comment->post->post_title );
    723718                    bp_activity_update_meta( $comment_activity_id, 'post_url', add_query_arg( 'p', $recorded_comment->post->ID, home_url( '/' ) ) );
    724719
    725                     // add meta to comment
     720                    // Add meta to comment.
    726721                    add_comment_meta( $comment_id, 'bp_activity_comment_id', $comment_activity_id );
    727722                }
     
    729724        }
    730725
    731         // Update the blogs last active date
     726        // Update the blogs last active date.
    732727        bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() );
    733728    }
     
    752747 * @param string|bool $role    User's WordPress role for this blog ID.
    753748 * @param int         $blog_id Blog ID user is being added to.
    754  *
    755749 * @return bool|null False on failure.
    756750 */
     
    758752    global $wpdb;
    759753
    760     // If no blog ID was passed, use the root blog ID
     754    // If no blog ID was passed, use the root blog ID.
    761755    if ( empty( $blog_id ) ) {
    762756        $blog_id = isset( $wpdb->blogid ) ? $wpdb->blogid : bp_get_root_blog_id();
    763757    }
    764758
    765     // If no role was passed, try to find the blog role
     759    // If no role was passed, try to find the blog role.
    766760    if ( empty( $role ) ) {
    767761
    768         // Get user capabilities
     762        // Get user capabilities.
    769763        $key        = $wpdb->get_blog_prefix( $blog_id ). 'capabilities';
    770764        $user_roles = array_keys( (array) bp_get_user_meta( $user_id, $key, true ) );
    771765
    772         // User has roles so lets
     766        // User has roles so lets.
    773767        if ( ! empty( $user_roles ) ) {
    774768
    775             // Get blog roles
     769            // Get blog roles.
    776770            $blog_roles      = array_keys( bp_get_current_blog_roles() );
    777771
    778             // Look for blog only roles of the user
     772            // Look for blog only roles of the user.
    779773            $intersect_roles = array_intersect( $user_roles, $blog_roles );
    780774
     
    789783    }
    790784
    791     // Bail if no role was found or role is not in the allowed roles array
     785    // Bail if no role was found or role is not in the allowed roles array.
    792786    if ( empty( $role ) || ! in_array( $role, bp_blogs_get_allowed_roles() ) ) {
    793787        return false;
    794788    }
    795789
    796     // Record the blog activity for this user being added to this blog
     790    // Record the blog activity for this user being added to this blog.
    797791    bp_blogs_record_blog( $blog_id, $user_id, true );
    798792}
     
    873867    BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    874868
    875     // Delete activity stream item
     869    // Delete activity stream item.
    876870    bp_blogs_delete_activity( array(
    877871        'item_id'   => $blog_id,
     
    915909    BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id );
    916910
    917     // Delete activity stream item
     911    // Delete activity stream item.
    918912    bp_blogs_delete_activity( array(
    919913        'item_id'   => $blog_id,
     
    941935 * @param int $user_id Optional. Defaults to the logged-in user ID. This param
    942936 *                     is currently unused in the function (but is passed to hooks).
    943  *
    944937 * @return bool
    945938 */
     
    969962    do_action( 'bp_blogs_before_remove_post', $blog_id, $post_id, $user_id );
    970963
    971     // Delete activity stream item
     964    // Delete activity stream item.
    972965    bp_blogs_delete_activity( array(
    973966        'item_id'           => $blog_id,
     
    998991    global $wpdb;
    999992
    1000     // activity comments are disabled for blog posts
    1001     // which means that individual activity items exist for blog comments
     993    // Activity comments are disabled for blog posts
     994    // which means that individual activity items exist for blog comments.
    1002995    if ( bp_disable_blogforum_comments() ) {
    1003         // Delete the individual activity stream item
     996        // Delete the individual activity stream item.
    1004997        bp_blogs_delete_activity( array(
    1005998            'item_id'           => $wpdb->blogid,
     
    10081001        ) );
    10091002
    1010     // activity comments are enabled for blog posts
    1011     // remove the associated activity item
     1003    // Activity comments are enabled for blog posts
     1004    // remove the associated activity item.
    10121005    } else {
    1013         // get associated activity ID from comment meta
     1006        // Get associated activity ID from comment meta.
    10141007        $activity_id = get_comment_meta( $comment_id, 'bp_activity_comment_id', true );
    10151008
    1016         // delete the associated activity comment
     1009        // Delete the associated activity comment.
    10171010        //
    1018         // also removes child post comments and associated activity comments
     1011        // Also removes child post comments and associated activity comments.
    10191012        if ( ! empty( $activity_id ) && bp_is_active( 'activity' ) ) {
    1020             // fetch the activity comments for the activity item
     1013            // Fetch the activity comments for the activity item.
    10211014            $activity = bp_activity_get( array(
    10221015                'in'               => $activity_id,
     
    10251018            ) );
    10261019
    1027             // get all activity comment IDs for the pending deleted item
     1020            // Get all activity comment IDs for the pending deleted item.
    10281021            if ( ! empty( $activity['activities'] ) ) {
    10291022                $activity_ids   = bp_activity_recurse_comments_activity_ids( $activity );
    10301023                $activity_ids[] = $activity_id;
    10311024
    1032                 // delete activity items
     1025                // Delete activity items.
    10331026                foreach ( $activity_ids as $activity_id ) {
    10341027                    bp_activity_delete( array(
     
    10371030                }
    10381031
    1039                 // remove associated blog comments
     1032                // Remove associated blog comments.
    10401033                bp_blogs_remove_associated_blog_comments( $activity_ids );
    10411034
    1042                 // rebuild activity comment tree
     1035                // Rebuild activity comment tree.
    10431036                BP_Activity_Activity::rebuild_activity_comment_tree( $activity['activities'][0]->item_id );
    10441037            }
     
    10691062 * @param array $activity_ids The activity IDs to check association with blog
    10701063 *                            comments.
    1071  * @param bool $force_delete  Whether to force delete the comments. If false,
     1064 * @param bool  $force_delete  Whether to force delete the comments. If false,
    10721065 *                            comments are trashed instead.
    10731066 */
    10741067function bp_blogs_remove_associated_blog_comments( $activity_ids = array(), $force_delete = true ) {
    1075     // query args
     1068    // Query args.
    10761069    $query_args = array(
    10771070        'meta_query' => array(
     
    10841077    );
    10851078
    1086     // get comment
     1079    // Get comment.
    10871080    $comment_query = new WP_Comment_Query;
    10881081    $comments = $comment_query->query( $query_args );
    10891082
    1090     // found the corresponding comments
     1083    // Found the corresponding comments
    10911084    // let's delete them!
    10921085    foreach ( $comments as $comment ) {
    10931086        wp_delete_comment( $comment->comment_ID, $force_delete );
    10941087
    1095         // if we're trashing the comment, remove the meta key as well
     1088        // If we're trashing the comment, remove the meta key as well.
    10961089        if ( empty( $force_delete ) ) {
    10971090            delete_comment_meta( $comment->comment_ID, 'bp_activity_comment_id' );
     
    11111104function bp_blogs_transition_activity_status( $new_status, $old_status, $comment ) {
    11121105
    1113     // Check the Activity component is active
     1106    // Check the Activity component is active.
    11141107    if ( ! bp_is_active( 'activity' ) )
    11151108        return;
     
    11361129    }
    11371130
    1138     // Get the activity
     1131    // Get the activity.
    11391132    if ( bp_disable_blogforum_comments() ) {
    11401133        $activity_id = bp_activity_get_activity_id( array(
     
    11481141    }
    11491142
    1150     // Check activity item exists
     1143    // Check activity item exists.
    11511144    if ( empty( $activity_id ) ) {
    11521145        // If no activity exists, but the comment has been approved, record it into the activity table.
     
    11581151    }
    11591152
    1160     // Create an activity object
     1153    // Create an activity object.
    11611154    $activity = new BP_Activity_Activity( $activity_id );
    11621155    if ( empty( $activity->component ) )
    11631156        return;
    11641157
    1165     // Spam/ham the activity if it's not already in that state
     1158    // Spam/ham the activity if it's not already in that state.
    11661159    if ( 'spam_activity' == $action && ! $activity->is_spam ) {
    11671160        bp_activity_mark_as_spam( $activity );
     
    11701163    }
    11711164
    1172     // Add "new_blog_comment" to the whitelisted activity types, so that the activity's Akismet history is generated
     1165    // Add "new_blog_comment" to the whitelisted activity types, so that the activity's Akismet history is generated.
    11731166    $comment_akismet_history = create_function( '$t', '$t[] = "new_blog_comment"; return $t;' );
    11741167    add_filter( 'bp_akismet_get_activity_types', $comment_akismet_history );
    11751168
    1176     // Save the updated activity
     1169    // Save the updated activity.
    11771170    $activity->save();
    11781171
    1179     // Remove the "new_blog_comment" activity type whitelist so we don't break anything
     1172    // Remove the "new_blog_comment" activity type whitelist so we don't break anything.
    11801173    remove_filter( 'bp_akismet_get_activity_types', $comment_akismet_history );
    11811174}
     
    12051198 * @param int $user_id ID of the user being queried. Default: on a user page,
    12061199 *                     the displayed user. Otherwise, the logged-in user.
    1207  *
    12081200 * @return int $count Total blog count for the user.
    12091201 */
     
    12131205    }
    12141206
    1215     // no user ID? do not attempt to look at cache
     1207    // No user ID? do not attempt to look at cache.
    12161208    if ( empty( $user_id ) ) {
    12171209        return 0;
     
    12471239    BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    12481240
    1249     // Delete activity stream item
     1241    // Delete activity stream item.
    12501242    bp_blogs_delete_activity( array(
    12511243        'item_id'   => $blog_id,
     
    12741266 * @param int  $user_id     See {@BP_Blogs_Blog::get_blogs_for_user()}.
    12751267 * @param bool $show_hidden See {@BP_Blogs_Blog::get_blogs_for_user()}.
    1276  *
    12771268 * @return array See {@BP_Blogs_Blog::get_blogs_for_user()}.
    12781269 */
     
    12881279 * @param int $limit See {@BP_Blogs_Blog::get_all()}.
    12891280 * @param int $page  See {@BP_Blogs_Blog::get_all()}.
    1290  *
    12911281 * @return array See {@BP_Blogs_Blog::get_all()}.
    12921282 */
     
    13021292 * @param int $limit See {@BP_Blogs_Blog::get()}.
    13031293 * @param int $page  See {@BP_Blogs_Blog::get()}.
    1304  *
    13051294 * @return array See {@BP_Blogs_Blog::get()}.
    13061295 */
     
    13151304 *
    13161305 * @param int $blog_id See {@BP_Blogs_Blog::is_hidden()}.
    1317  *
    13181306 * @return bool See {@BP_Blogs_Blog::is_hidden()}.
    13191307 */
     
    13221310}
    13231311
    1324 /*******************************************************************************
     1312/*
    13251313 * Blog meta functions
    13261314 *
     
    13431331 *                                deleted if the meta_value matches this parameter.
    13441332 * @param bool        $delete_all Optional. If true, delete matching metadata entries for
    1345  *                               all objects, ignoring the specified blog_id. Otherwise, only
    1346  *                               delete matching metadata entries for the specified blog.
    1347  *                               Default: false.
    1348  *
     1333 *                                all objects, ignoring the specified blog_id. Otherwise, only
     1334 *                                delete matching metadata entries for the specified blog.
     1335 *                                Default: false.
    13491336 * @return bool True on success, false on failure.
    13501337 */
     
    13521339    global $wpdb;
    13531340
    1354     // Legacy - if no meta_key is passed, delete all for the blog_id
     1341    // Legacy - if no meta_key is passed, delete all for the blog_id.
    13551342    if ( empty( $meta_key ) ) {
    13561343        $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->blogmeta} WHERE blog_id = %d", $blog_id ) );
     
    13841371 *                         metadata for the blog will be fetched.
    13851372 * @param bool   $single   Optional. If true, return only the first value of the
    1386  *                          specified meta_key. This parameter has no effect if
    1387  *                          meta_key is not specified. Default: true.
    1388  *
     1373 *                         specified meta_key. This parameter has no effect if
     1374 *                         meta_key is not specified. Default: true.
    13891375 * @return mixed The meta value(s) being requested.
    13901376 */
     
    14081394 *                           metadata entries with the specified value.
    14091395 *                           Otherwise, update all entries.
    1410  *
    14111396 * @return bool|int Returns false on failure. On successful update of existing
    14121397 *                  metadata, returns true. On successful creation of new metadata,
     
    14321417 *                           for the given key. If true, and the object already has a value for
    14331418 *                           the key, no change will be made. Default: false.
    1434  *
    14351419 * @return int|bool The meta ID on successful update, false on failure.
    14361420 */
     
    14461430 *
    14471431 * @param int $user_id ID whose blog data should be removed.
    1448  *
    1449  * @return bool|null Returns false on failure.
     1432 * @return bool Returns false on failure.
    14501433 */
    14511434function bp_blogs_remove_data( $user_id ) {
     
    14901473    }
    14911474
    1492     // Get the user's blogs
     1475    // Get the user's blogs.
    14931476    $user_blogs = get_blogs_of_user( $user_id );
    14941477    if ( empty( $user_blogs ) ) {
  • trunk/src/bp-blogs/bp-blogs-loader.php

    r10110 r10374  
    1111 */
    1212
    13 // Exit if accessed directly
     13// Exit if accessed directly.
    1414defined( 'ABSPATH' ) || exit;
    1515
     16/**
     17 * Creates our Blogs component.
     18 */
    1619class BP_Blogs_Component extends BP_Component {
    1720
     
    5255        }
    5356
    54         // Global tables for messaging component
     57        // Global tables for messaging component.
    5558        $global_tables = array(
    5659            'table_name'          => $bp->table_prefix . 'bp_user_blogs',
     
    6669            'slug'                  => BP_BLOGS_SLUG,
    6770            'root_slug'             => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
    68             'has_directory'         => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site
     71            'has_directory'         => is_multisite(), // Non-multisite installs don't need a top-level Sites directory, since there's only one site.
    6972            'directory_title'       => _x( 'Sites', 'component directory title', 'buddypress' ),
    7073            'notification_callback' => 'bp_blogs_format_notifications',
     
    7578        );
    7679
    77         // Setup the globals
     80        // Setup the globals.
    7881        parent::setup_globals( $args );
    7982
    80         /*
     83        /**
    8184         * Filters if a blog is public.
    8285         *
     
    8588         * @since 2.3.0
    8689         *
    87          * @oaram int $value Whether or not the blog is public.
     90         * @param int $value Whether or not the blog is public.
    8891         */
    8992        if ( 0 !== apply_filters( 'bp_is_blog_public', (int) get_option( 'blog_public' ) ) || ! is_multisite() ) {
     
    117120    public function includes( $includes = array() ) {
    118121
    119         // Files to include
     122        // Files to include.
    120123        $includes = array(
    121124            'cache',
     
    133136        }
    134137
    135         // Include the files
     138        // Include the files.
    136139        parent::includes( $includes );
    137140    }
     
    158161        }
    159162
    160         // Determine user to use
     163        // Determine user to use.
    161164        if ( bp_displayed_user_domain() ) {
    162165            $user_domain = bp_displayed_user_domain();
     
    170173        $parent_url = trailingslashit( $user_domain . $slug );
    171174
    172         // Add 'Sites' to the main navigation
     175        // Add 'Sites' to the main navigation.
    173176        $count    = (int) bp_get_total_blog_count_for_user();
    174177        $class    = ( 0 === $count ) ? 'no-count' : 'count';
     
    192195        );
    193196
    194         // Setup navigation
     197        // Setup navigation.
    195198        parent::setup_nav( $main_nav, $sub_nav );
    196199    }
     
    205208     * @param array $wp_admin_nav See BP_Component::setup_admin_bar()
    206209     *                            for description.
    207      *
    208210     * @return bool
    209211     */
     
    219221        }
    220222
    221         // Menus for logged in user
     223        // Menus for logged in user.
    222224        if ( is_user_logged_in() ) {
    223225
    224             // Setup the logged in user variables
     226            // Setup the logged in user variables.
    225227            $blogs_link = trailingslashit( bp_loggedin_user_domain() . bp_get_blogs_slug() );
    226228
    227             // Add the "Sites" sub menu
     229            // Add the "Sites" sub menu.
    228230            $wp_admin_nav[] = array(
    229231                'parent' => buddypress()->my_account_menu_id,
     
    233235            );
    234236
    235             // My Sites
     237            // My Sites.
    236238            $wp_admin_nav[] = array(
    237239                'parent' => 'my-account-' . $this->id,
     
    241243            );
    242244
    243             // Create a Site
     245            // Create a Site.
    244246            if ( bp_blog_signup_enabled() ) {
    245247                $wp_admin_nav[] = array(
     
    256258
    257259    /**
    258      * Set up the title for pages and <title>
     260     * Set up the title for pages and <title>.
    259261     */
    260262    public function setup_title() {
    261263
    262         // Set up the component options navigation for Site
     264        // Set up the component options navigation for Site.
    263265        if ( bp_is_blogs_component() ) {
    264266            $bp = buddypress();
     
    270272
    271273            // If we are not viewing the logged in user, set up the current
    272             // users avatar and name
     274            // users avatar and name.
    273275            } else {
    274276                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
     
    291293    public function setup_cache_groups() {
    292294
    293         // Global groups
     295        // Global groups.
    294296        wp_cache_add_global_groups( array(
    295297            'blog_meta'
     
    306308     * @see bp_activity_get_post_type_tracking_args() for information on parameters.
    307309     *
    308      * @param object|null $params
    309      * @param string|int  $post_type
    310      *
     310     * @param object|null $params    Tracking arguments.
     311     * @param string|int  $post_type Post type to track.
    311312     * @return object
    312313     */
  • trunk/src/bp-blogs/bp-blogs-screens.php

    r10100 r10374  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    9696    public function is_blogs() {
    9797
    98         // Bail if not looking at a group
     98        // Bail if not looking at a group.
    9999        if ( ! bp_is_blogs_component() )
    100100            return;
    101101
    102         // Bail if looking at a users sites
     102        // Bail if looking at a users sites.
    103103        if ( bp_is_user() )
    104104            return;
    105105
    106         // Blog Directory
     106        // Blog Directory.
    107107        if ( is_multisite() && ! bp_current_action() ) {
    108108            bp_update_is_directory( true, 'blogs' );
     
    120120            add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
    121121
    122         // Create blog
     122        // Create blog.
    123123        } elseif ( is_user_logged_in() && bp_blog_signup_enabled() ) {
    124124            add_filter( 'bp_get_buddypress_template',                array( $this, 'create_template_hierarchy' ) );
     
    139139     *
    140140     * @param string $templates The templates from bp_get_theme_compat_templates().
    141      *
    142141     * @return array $templates Array of custom templates to look for.
    143142     */
     
    156155
    157156        // Merge new templates with existing stack
    158         // @see bp_get_theme_compat_templates()
     157        // @see bp_get_theme_compat_templates().
    159158        $templates = array_merge( (array) $new_templates, $templates );
    160159
     
    202201     *
    203202     * @param string $templates The templates from bp_get_theme_compat_templates().
    204      *
    205203     * @return array $templates Array of custom templates to look for.
    206204     */
     
    219217
    220218        // Merge new templates with existing stack
    221         // @see bp_get_theme_compat_templates()
     219        // @see bp_get_theme_compat_templates().
    222220        $templates = array_merge( (array) $new_templates, $templates );
    223221
     
    232230    public function create_dummy_post() {
    233231
    234         // Title based on ability to create blogs
     232        // Title based on ability to create blogs.
    235233        if ( is_user_logged_in() && bp_blog_signup_enabled() ) {
    236234            $title = __( 'Create a Site', 'buddypress' );
  • trunk/src/bp-blogs/bp-blogs-template.php

    r10248 r10374  
    195195        $this->pag_num  = bp_sanitize_pagination_arg( 'num',          $per_page );
    196196
    197         // Backwards compatibility support for blogs by first letter
     197        // Backwards compatibility support for blogs by first letter.
    198198        if ( ! empty( $_REQUEST['letter'] ) ) {
    199199            $this->blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
    200200
    201         // Typical blogs query
     201        // Typical blogs query.
    202202        } else {
    203203            $this->blogs = bp_blogs_get_blogs( array(
     
    212212        }
    213213
    214         // Set the total blog count
     214        // Set the total blog count.
    215215        if ( empty( $max ) || ( $max >= (int) $this->blogs['total'] ) ) {
    216216            $this->total_blog_count = (int) $this->blogs['total'];
     
    219219        }
    220220
    221         // Set the blogs array (to loop through later
     221        // Set the blogs array (to loop through later.
    222222        $this->blogs = $this->blogs['blogs'];
    223223
    224         // Get the current blog count to compare maximum against
     224        // Get the current blog count to compare maximum against.
    225225        $blog_count = count( $this->blogs );
    226226
    227         // Set the current blog count
     227        // Set the current blog count.
    228228        if ( empty( $max ) || ( $max >= (int) $blog_count ) ) {
    229229            $this->blog_count = (int) $blog_count;
     
    232232        }
    233233
    234         // Build pagination links based on total blogs and current page number
     234        // Build pagination links based on total blogs and current page number.
    235235        if ( ! empty( $this->total_blog_count ) && ! empty( $this->pag_num ) ) {
    236236            $this->pag_links = paginate_links( array(
     
    302302             */
    303303            do_action( 'blog_loop_end' );
    304             // Do some cleaning up after the loop
     304            // Do some cleaning up after the loop.
    305305            $this->rewind_blogs();
    306306        }
     
    324324        $this->blog        = $this->next_blog();
    325325
    326         // loop has just started
     326        // Loop has just started.
    327327        if ( 0 === $this->current_blog ) {
    328328
     
    396396    }
    397397
    398     // Parse arguments
     398    // Parse arguments.
    399399    $r = bp_parse_args( $args, array(
    400400        'type'              => 'active',
    401         'page_arg'          => 'bpage',                // See https://buddypress.trac.wordpress.org/ticket/3679
     401        'page_arg'          => 'bpage', // See https://buddypress.trac.wordpress.org/ticket/3679.
    402402        'page'              => 1,
    403403        'per_page'          => 20,
    404404        'max'               => false,
    405         'user_id'           => bp_displayed_user_id(), // Pass a user_id to limit to only blogs this user is a member of
     405        'user_id'           => bp_displayed_user_id(), // Pass a user_id to limit to only blogs this user is a member of.
    406406        'include_blog_ids'  => false,
    407407        'search_terms'      => $search_terms_default,
     
    409409    ), 'has_blogs' );
    410410
    411     // Set per_page to maximum if max is enforced
     411    // Set per_page to maximum if max is enforced.
    412412    if ( ! empty( $r['max'] ) && ( (int) $r['per_page'] > (int) $r['max'] ) ) {
    413413        $r['per_page'] = (int) $r['max'];
    414414    }
    415415
    416     // Get the blogs
     416    // Get the blogs.
    417417    $blogs_template = new BP_Blogs_Template( $r['type'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['search_terms'], $r['page_arg'], $r['update_meta_cache'], $r['include_blog_ids'] );
    418418
     
    550550        $author_displayname = bp_core_get_user_displayname( $blogs_template->blog->admin_user_id );
    551551
    552         // Parse the arguments
     552        // Parse the arguments.
    553553        $r = bp_parse_args( $args, array(
    554554            'type'    => 'full',
     
    562562        ) );
    563563
    564         // Fetch the avatar
     564        // Fetch the avatar.
    565565        $avatar = bp_core_fetch_avatar( array(
    566566            'item_id'    => $blogs_template->blog->admin_user_id,
    567567            'title'      => $r['title'],
    568             //'avatar_dir' => 'blog-avatars',
    569             //'object'     => 'blog',
     568            // 'avatar_dir' => 'blog-avatars',
     569            // 'object'     => 'blog',
    570570            'type'       => $r['type'],
    571571            'alt'        => $r['alt'],
     
    576576        ) );
    577577
    578         /***
     578        /**
    579579         * In future BuddyPress versions you will be able to set the avatar for a blog.
    580580         * Right now you can use a filter with the ID of the blog to change it if you wish.
     
    714714 * @since 1.7.0
    715715 *
    716  * @param array $classes Array of custom classes
     716 * @param array $classes Array of custom classes.
    717717 */
    718718function bp_blog_class( $classes = array() ) {
     
    725725     *
    726726     * @global BP_Blogs_Template $blogs_template
    727      * @param array $classes Array of custom classes
    728      *
     727     *
     728     * @param array $classes Array of custom classes.
    729729     * @return string Row class of the site.
    730730     */
     
    732732        global $blogs_template;
    733733
    734         // Add even/odd classes, but only if there's more than 1 group
     734        // Add even/odd classes, but only if there's more than 1 group.
    735735        if ( $blogs_template->blog_count > 1 ) {
    736736            $pos_in_loop = (int) $blogs_template->current_blog;
    737737            $classes[]   = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
    738738
    739         // If we've only one site in the loop, don't bother with odd and even
     739        // If we've only one site in the loop, don't bother with odd and even.
    740740        } else {
    741741            $classes[] = 'bp-single-blog';
     
    778778        global $blogs_template;
    779779
    780         // Parse the activity format
     780        // Parse the activity format.
    781781        $r = bp_parse_args( $args, array(
    782782            'active_format' => true
    783783        ) );
    784784
    785         // Backwards compatibility for anyone forcing a 'true' active_format
     785        // Backwards compatibility for anyone forcing a 'true' active_format.
    786786        if ( true === $r['active_format'] ) {
    787787            $r['active_format'] = __( 'active %s', 'buddypress' );
    788788        }
    789789
    790         // Blog has been posted to at least once
     790        // Blog has been posted to at least once.
    791791        if ( isset( $blogs_template->blog->last_activity ) ) {
    792792
    793             // Backwards compatibility for pre 1.5 'ago' strings
     793            // Backwards compatibility for pre 1.5 'ago' strings.
    794794            $last_activity = ! empty( $r['active_format'] )
    795795                ? bp_core_get_last_activity( $blogs_template->blog->last_activity, $r['active_format'] )
    796796                : bp_core_time_since( $blogs_template->blog->last_activity );
    797797
    798         // Blog has never been posted to
     798        // Blog has never been posted to.
    799799        } else {
    800800            $last_activity = __( 'Never active', 'buddypress' );
     
    10001000     * @param string $size Image version to return. 'thumbnail', 'medium',
    10011001     *                     'large', or 'post-thumbnail'. Default: 'thumbnail'.
    1002      *
    10031002     * @return string URL of the image.
    10041003     */
     
    10281027 * @param string $thumbnail Image version to return. 'thumbnail', 'medium', 'large',
    10291028 *                          or 'post-thumbnail'. Default: 'thumbnail'.
    1030  *
    10311029 * @return bool True if the latest blog post from the current blog has a
    10321030 *              featured image of the given size.
     
    11011099     *
    11021100     * @param int $user_id ID of the user.
    1103      *
    11041101     * @return int Total number of blogs for the user.
    11051102     */
     
    11381135     * Filters whether or not blog creation is enabled.
    11391136     *
     1137     * Return "all", "none", "blog" or "user".
     1138     *
    11401139     * @since 1.0.0
    11411140     *
    11421141     * @param string $active_signup Value of the registration site option creation status.
    11431142     */
    1144     $active_signup = apply_filters( 'wpmu_active_signup', $active_signup ); // return "all", "none", "blog" or "user"
     1143    $active_signup = apply_filters( 'wpmu_active_signup', $active_signup );
    11451144
    11461145    if ( 'none' == $active_signup || 'user' == $active_signup )
     
    12261225    global $current_site;
    12271226
    1228     // Blog name
     1227    // Blog name.
    12291228    if( !is_subdomain_install() )
    12301229        echo '<label for="blogname">' . __('Site Name:', 'buddypress') . '</label>';
     
    12551254    }
    12561255
    1257     // Blog Title
     1256    // Blog Title.
    12581257    ?>
    12591258
     
    13231322    $public = (int) $_POST['blog_public'];
    13241323
    1325     $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) ); // depreciated
     1324    // Depreciated.
     1325    $meta = apply_filters( 'signup_create_blog_meta', array( 'lang_id' => 1, 'public' => $public ) );
    13261326
    13271327    /**
     
    13981398function bp_create_blog_link() {
    13991399
    1400     // Don't show this link when not on your own profile
     1400    // Don't show this link when not on your own profile.
    14011401    if ( ! bp_is_my_profile() ) {
    14021402        return;
     
    14201420function bp_blogs_blog_tabs() {
    14211421
    1422     // Don't show these tabs on a user's own profile
     1422    // Don't show these tabs on a user's own profile.
    14231423    if ( bp_is_my_profile() ) {
    14241424        return false;
     
    15311531     */
    15321532    function bp_get_blog_create_nav_item() {
    1533         // Get the create a site button
     1533        // Get the create a site button.
    15341534        $create_blog_button = bp_get_blog_create_button();
    15351535
    1536         // Make sure the button is available
     1536        // Make sure the button is available.
    15371537        if ( empty( $create_blog_button ) ) {
    15381538            return;
     
    15551555 */
    15561556function bp_blog_backcompat_create_nav_item() {
    1557     // Bail if Blogs nav item is already used by bp-legacy
     1557    // Bail if Blogs nav item is already used by bp-legacy.
    15581558    if ( has_action( 'bp_blogs_directory_blog_types', 'bp_legacy_theme_blog_create_nav', 999 ) ) {
    15591559        return;
    15601560    }
    15611561
    1562     // Bail if the theme is not filtering the Blogs directory title
     1562    // Bail if the theme is not filtering the Blogs directory title.
    15631563    if ( ! has_filter( 'bp_blogs_directory_header' ) ) {
    15641564        return;
     
    16341634 * @uses bp_blogs_admin_get_profile_stats() to get the stats.
    16351635 *
    1636  * @param array|string $args before|after|user_id
     1636 * @param array|string $args Before|after|user_id.
    16371637 */
    16381638function bp_blogs_profile_stats( $args = '' ) {
     
    16461646 * @since 2.0.0
    16471647 *
    1648  * @param array|string $args before|after|user_id
    1649  *
     1648 * @param array|string $args Before|after|user_id.
    16501649 * @return string HTML for stats output.
    16511650 */
    16521651function bp_blogs_get_profile_stats( $args = '' ) {
    16531652
    1654     // Parse the args
     1653    // Parse the args.
    16551654    $r = bp_parse_args( $args, array(
    16561655        'before'  => '<li class="bp-blogs-profile-stats">',
     
    16611660    ), 'blogs_get_profile_stats' );
    16621661
    1663     // Allow completely overloaded output
     1662    // Allow completely overloaded output.
    16641663    if ( is_multisite() && empty( $r['output'] ) ) {
    16651664
    1666         // Only proceed if a user ID was passed
     1665        // Only proceed if a user ID was passed.
    16671666        if ( ! empty( $r['user_id'] ) ) {
    16681667
    1669             // Get the user's blogs
     1668            // Get the user's blogs.
    16701669            if ( empty( $r['blogs'] ) ) {
    16711670                $r['blogs'] = absint( bp_blogs_total_blogs_for_user( $r['user_id'] ) );
    16721671            }
    16731672
    1674             // If blogs exist, show some formatted output
     1673            // If blogs exist, show some formatted output.
    16751674            $r['output'] = $r['before'] . sprintf( _n( '%s site', '%s sites', $r['blogs'], 'buddypress' ), '<strong>' . $r['blogs'] . '</strong>' ) . $r['after'];
    16761675        }
  • trunk/src/bp-blogs/bp-blogs-widgets.php

    r10215 r10374  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    7777        $after_widget = $args['after_widget'];
    7878
    79         // Override some of the contextually set parameters for bp_has_activities()
     79        // Override some of the contextually set parameters for bp_has_activities().
    8080        $args = array(
    8181            'action'     => 'new_blog_post',
     
    128128     * @param array $new_instance The new instance options.
    129129     * @param array $old_instance The old instance options.
    130      *
    131130     * @return array $instance The parsed options to be saved.
    132131     */
     
    145144     * @param array $instance Settings for this widget.
    146145     *
    147      * @return string
     146     * @return void
    148147     */
    149148    public function form( $instance ) {
  • trunk/src/bp-blogs/classes/class-bp-blogs-blog.php

    r10100 r10374  
    77 */
    88
    9 // Exit if accessed directly
     9// Exit if accessed directly.
    1010defined( 'ABSPATH' ) || exit;
    1111
     
    1919 */
    2020class BP_Blogs_Blog {
     21
     22    /**
     23     * Site ID.
     24     *
     25     * @var int|null
     26     */
    2127    public $id;
     28
     29    /**
     30     * User ID.
     31     *
     32     * @var int
     33     */
    2234    public $user_id;
     35
     36    /**
     37     * Blog ID.
     38     *
     39     * @var int
     40     */
    2341    public $blog_id;
    2442
     
    82100
    83101        if ( $this->id ) {
    84             // Update
     102            // Update.
    85103            $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name} SET user_id = %d, blog_id = %d WHERE id = %d", $this->user_id, $this->blog_id, $this->id );
    86104        } else {
    87             // Save
     105            // Save.
    88106            $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name} ( user_id, blog_id ) VALUES ( %d, %d )", $this->user_id, $this->blog_id );
    89107        }
     
    141159     *                                       blogs. Default: true.
    142160     * @param array|bool  $include_blog_ids  Array of blog IDs to include.
    143      *
    144161     * @return array Multidimensional results array, structured as follows:
    145162     *               'blogs' - Array of located blog objects
     
    255272     * @param int $user_id Optional. The ID of the user from whom the blog is
    256273     *                     being removed. If absent, defaults to the logged-in user ID.
    257      *
    258274     * @return int|bool Number of rows deleted on success, false on failure.
    259275     */
     
    274290     * @param int $user_id Optional. The ID of the user whose blog associations
    275291     *                     are being deleted. If absent, defaults to logged-in user ID.
    276      *
    277292     * @return int|bool Number of rows deleted on success, false on failure.
    278293     */
     
    300315     * @param bool $show_hidden Optional. Whether to include blogs that are not marked
    301316     *                          public. Defaults to true when viewing one's own profile.
    302      *
    303317     * @return array Multidimensional results array, structured as follows:
    304318     *               'blogs' - Array of located blog objects.
     
    340354     * @param int $user_id Optional. ID of the user whose blogs are being
    341355     *                     queried. Defaults to logged-in user.
    342      *
    343356     * @return int The number of blogs associated with the user.
    344357     */
     
    358371     *
    359372     * @param int $blog_id ID of the blog being queried.
    360      *
    361373     * @return int|null The ID of the first located entry in the BP table
    362374     *                  on success, otherwise null.
     
    379391     * @param int $user_id Optional. ID of the user whose blogs are being
    380392     *                     queried. Defaults to logged-in user.
    381      *
    382393     * @return int Blog count for the user.
    383394     */
     
    409420     * @param int    $page   Optional. The page of results to return. Default:
    410421     *                       null (no limit).
    411      *
    412422     * @return array Multidimensional results array, structured as follows:
    413423     *               'blogs' - Array of located blog objects.
     
    447457     * @param int $page  Optional. The page of results to return. Default:
    448458     *                   null (no limit).
    449      *
    450459     * @return array Multidimensional results array, structured as follows:
    451460     *               'blogs' - Array of located blog objects.
     
    472481     * 'bp_moderate' cap.
    473482     *
    474      * @param string $letter. The letter you're looking for.
    475      * @param int    $limit   Optional. The maximum number of items to return.
    476      *                        Default: null (no limit).
    477      * @param int    $page    Optional. The page of results to return. Default:
    478      *                        null (no limit).
    479      *
     483     * @param string $letter The letter you're looking for.
     484     * @param int    $limit  Optional. The maximum number of items to return.
     485     *                       Default: null (no limit).
     486     * @param int    $page   Optional. The page of results to return. Default:
     487     *                       null (no limit).
    480488     * @return array Multidimensional results array, structured as follows:
    481489     *               'blogs' - Array of located blog objects.
     
    516524     * @param array       $blog_ids    Array of IDs returned from the original query.
    517525     * @param string|bool $type        Not currently used. Default: false.
    518      *
    519526     * @return array $paged_blogs The located blogs array, with the extras added.
    520527     */
     
    534541            $images = array();
    535542
    536             // Add URLs to any Featured Image this post might have
     543            // Add URLs to any Featured Image this post might have.
    537544            if ( ! empty( $paged_blogs[$i]->latest_post ) && has_post_thumbnail( $paged_blogs[$i]->latest_post->ID ) ) {
    538545
     
    542549                    $images['thumbnail'] = $image[0];
    543550
    544                 // Medium
     551                // Medium.
    545552                $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'medium', false );
    546553                if ( ! empty( $image ) )
    547554                    $images['medium'] = $image[0];
    548555
    549                 // Large
     556                // Large.
    550557                $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'large', false );
    551558                if ( ! empty( $image ) )
    552559                    $images['large'] = $image[0];
    553560
    554                 // Post thumbnail
     561                // Post thumbnail.
    555562                $image = wp_get_attachment_image_src( get_post_thumbnail_id( $paged_blogs[$i]->latest_post->ID ), 'post-thumbnail', false );
    556563                if ( ! empty( $image ) )
    557564                    $images['post-thumbnail'] = $image[0];
    558565
    559                 // Add the images to the latest_post object
     566                // Add the images to the latest_post object.
    560567                $paged_blogs[$i]->latest_post->images = $images;
    561568            }
     
    581588     *
    582589     * @param int $blog_id The ID of the blog being checked.
    583      *
    584590     * @return bool True if hidden (public = 0), false otherwise.
    585591     */
     
    599605     * @param int $user_id ID of user.
    600606     * @param int $blog_id ID of blog.
    601      *
    602607     * @return int|bool ID of user-blog link, or false if not found.
    603608     */
Note: See TracChangeset for help on using the changeset viewer.