Skip to:
Content

BuddyPress.org

Changeset 9488


Ignore:
Timestamp:
02/17/2015 05:31:15 AM (11 years ago)
Author:
tw2113
Message:

Adds hooks documentation for bp-groups-forums.php.

See #5943.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-forums.php

    r9351 r9488  
    5050        groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
    5151
     52        /**
     53         * Fires after the creation of a new forum inside a specific BuddyPress group.
     54         *
     55         * @since BuddyPress (1.0.0)
     56         *
     57         * @param int $forum_id ID of the newly created forum.
     58         * @param int $group_id ID of the associated group.
     59         */
    5260        do_action( 'groups_new_group_forum', $forum_id, $group_id );
    5361}
     
    7583        }
    7684
     85        /**
     86         * Filters the group forum metadata value argument.
     87         *
     88         * @since BuddyPress (1.2.5)
     89         *
     90         * @param array $value Array of metadata values to update the group forum with.
     91         */
    7792        bp_forums_update_forum( apply_filters( 'groups_update_group_forum', array(
    7893                'forum_id'   => groups_get_groupmeta( $group_id, 'forum_id' ),
     
    103118        }
    104119
     120        /**
     121         * Filters the text for the forum post before save.
     122         *
     123         * @since BuddyPress (1.2.0)
     124         *
     125         * @param string $post_text Text for the forum post.
     126         */
    105127        $post_text = apply_filters( 'group_forum_post_text_before_save',     $post_text );
     128
     129        /**
     130         * Filters the ID for the forum post before save.
     131         *
     132         * @since BuddyPress (1.2.0)
     133         *
     134         * @param int $topic_id ID of the topic the post will be associated with.
     135         */
    106136        $topic_id  = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id  );
    107137        $post_id   = bp_forums_insert_post( array(
     
    123153        }
    124154
    125         // Record this in activity streams
     155        /**
     156         * Filters the new groups activity forum post action.
     157         *
     158         * @since BuddyPress (1.2.0)
     159         *
     160         * @param string $activity_action Formatted action related to group activity posting.
     161         * @param int    $post_id         ID of the newly created group forum post.
     162         * @param string $post_text       The text for the forum post.
     163         * @param object $topic           Object holding current topic details. Passed by reference.
     164         */
     165        $action = apply_filters_ref_array( 'groups_activity_new_forum_post_action',  array( $activity_action,  $post_id, $post_text, &$topic ) );
     166
     167        /**
     168         * Filters the new groups activity forum post content.
     169         *
     170         * @since BuddyPress (1.2.0)
     171         *
     172         * @param string $activity_content Excerpt-length activity content to be posted.
     173         * @param int    $post_id          ID of the newly created group forum post.
     174         * @param string $post_text        The text for the forum post.
     175         * @param object $topic            Object holding current topic details. Passed by reference.
     176         */
     177        $content = apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_id, $post_text, &$topic ) );
     178
     179        /**
     180         * Filters the new groups activity forum post primary link.
     181         *
     182         * @since BuddyPress (1.1.0)
     183         *
     184         * @param string $value URL to the newly posted forum post.
     185         */
     186        $filtered_primary_link = apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" );
     187
    126188        groups_record_activity( array(
    127                 'action'            => apply_filters_ref_array( 'groups_activity_new_forum_post_action',  array( $activity_action,  $post_id, $post_text, &$topic ) ),
    128                 'content'           => apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_id, $post_text, &$topic ) ),
    129                 'primary_link'      => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ),
     189                'action'            => $action,
     190                'content'           => $content,
     191                'primary_link'      => $filtered_primary_link,
    130192                'type'              => 'new_forum_post',
    131193                'item_id'           => bp_get_current_group_id(),
     
    133195        ) );
    134196
     197        /**
     198         * Fires after the creation of a new group forum topic post.
     199         *
     200         * @since BuddyPress (1.0.0)
     201         *
     202         * @param int $value   ID of the current group.
     203         * @param int $post_id ID of the new created forum topic post.
     204         */
    135205        do_action( 'groups_new_forum_topic_post', bp_get_current_group_id(), $post_id );
    136206
     
    155225                return false;
    156226
     227        /**
     228         * Filters the new groups forum topic title before saving.
     229         *
     230         * @since BuddyPress (1.2.0)
     231         *
     232         * @param string $topic_title The title for the forum topic.
     233         */
    157234        $topic_title = apply_filters( 'group_forum_topic_title_before_save',    $topic_title );
     235
     236        /**
     237         * Filters the new groups forum topic text before saving.
     238         *
     239         * @since BuddyPress (1.2.0)
     240         *
     241         * @param string $topic_text The text for the forum topic.
     242         */
    158243        $topic_text  = apply_filters( 'group_forum_topic_text_before_save',     $topic_text  );
     244
     245        /**
     246         * Filters the new groups forum topic tags before saving.
     247         *
     248         * @since BuddyPress (1.2.0)
     249         *
     250         * @param string $topic_tags A comma-delimited string of topic tags.
     251         */
    159252        $topic_tags  = apply_filters( 'group_forum_topic_tags_before_save',     $topic_tags  );
     253
     254        /**
     255         * Filters the forum ID this forum topic resides in.
     256         *
     257         * @since BuddyPress (1.2.0)
     258         *
     259         * @param string $forum_id The forum ID this forum topic resides in.
     260         */
    160261        $forum_id    = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id    );
    161262        $topic_id    = bp_forums_new_topic( array(
     
    174275        $activity_content = bp_create_excerpt( $topic_text );
    175276
    176         // Record this in activity streams
     277        /**
     278         * Filters the new groups activity forum topic action.
     279         *
     280         * @since BuddyPress (1.2.0)
     281         *
     282         * @param string $activity_action Formatted action related to forum topic.
     283         * @param string $topic_text      New topic text.
     284         * @param object $topic           Object holding current topic details. Passed by reference.
     285         */
     286        $action = apply_filters_ref_array( 'groups_activity_new_forum_topic_action',  array( $activity_action,  $topic_text, &$topic ) );
     287
     288        /**
     289         * Filters the new groups activity forum topic content.
     290         *
     291         * @since BuddyPress (1.2.0)
     292         *
     293         * @param string $activity_content Excerpt-length activity content to be posted.
     294         * @param string $topic_text       New topic text.
     295         * @param object $topic            Object holding current topic details. Passed by reference.
     296         */
     297        $content = apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) );
     298
     299        /**
     300         * Filters the new groups activity forum topic primary link.
     301         *
     302         * @since BuddyPress (1.1.0)
     303         *
     304         * @param string $value Concatenated primary link.
     305         */
     306        $primary_link = apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' );
     307
    177308        groups_record_activity( array(
    178                 'action'            => apply_filters_ref_array( 'groups_activity_new_forum_topic_action',  array( $activity_action,  $topic_text, &$topic ) ),
    179                 'content'           => apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) ),
    180                 'primary_link'      => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' ),
     309                'action'            => $action,
     310                'content'           => $content,
     311                'primary_link'      => $primary_link,
    181312                'type'              => 'new_forum_topic',
    182313                'item_id'           => bp_get_current_group_id(),
     
    184315        ) );
    185316
     317        /**
     318         * Fires after the creation of a new group forum topic.
     319         *
     320         * @since BuddyPress (1.0.0)
     321         *
     322         * @param int    $value ID of the current group.
     323         * @param object $topic Object holding current topic details. Passed by reference.
     324         */
    186325        do_action_ref_array( 'groups_new_forum_topic', array( bp_get_current_group_id(), &$topic ) );
    187326
     
    205344        $bp = buddypress();
    206345
     346        /** This filter is documented in bp-groups/bp-groups-forums.php */
    207347        $topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
     348
     349        /** This filter is documented in bp-groups/bp-groups-forums.php */
    208350        $topic_text  = apply_filters( 'group_forum_topic_text_before_save',  $topic_text  );
    209351        $topic       = bp_forums_update_topic( array(
     
    231373        $activity_content = bp_create_excerpt( $topic_text );
    232374
    233         // Record this in activity streams
     375        /** This filter is documented in bp-groups/bp-groups-forums.php */
     376        $action = apply_filters_ref_array( 'groups_activity_new_forum_topic_action',  array( $activity_action,  $topic_text, &$topic ) );
     377
     378        /** This filter is documented in bp-groups/bp-groups-forums.php */
     379        $content = apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) );
     380
     381        /** This filter is documented in bp-groups/bp-groups-forums.php */
     382        $primary_link = apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' );
     383
    234384        groups_record_activity( array(
    235385                'id'                => $id,
    236                 'action'            => apply_filters_ref_array( 'groups_activity_new_forum_topic_action',  array( $activity_action,  $topic_text, &$topic ) ),
    237                 'content'           => apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) ),
    238                 'primary_link'      => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' ),
     386                'action'            => $action,
     387                'content'           => $content,
     388                'primary_link'      => $primary_link,
    239389                'type'              => 'new_forum_topic',
    240390                'item_id'           => (int) bp_get_current_group_id(),
     
    244394        ) );
    245395
     396        /**
     397         * Fires after the update of a group forum topic.
     398         *
     399         * @since BuddyPress (1.1.0)
     400         *
     401         * @param object $topic Object holding current topic being updated. Passed by reference.
     402         */
    246403        do_action_ref_array( 'groups_update_group_forum_topic', array( &$topic ) );
    247404
     
    266423        $bp = buddypress();
    267424
     425        /** This filter is documented in bp-groups/bp-groups-forums.php */
    268426        $post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
     427
     428        /** This filter is documented in bp-groups/bp-groups-forums.php */
    269429        $topic_id  = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
    270430        $post      = bp_forums_get_post( $post_id );
     
    301461        }
    302462
    303         // Update the entry in activity streams
     463        /** This filter is documented in bp-groups/bp-groups-forums.php */
     464        $action = apply_filters_ref_array( 'groups_activity_new_forum_post_action',  array( $activity_action,  $post_text, &$topic, &$topic ) );
     465
     466        /** This filter is documented in bp-groups/bp-groups-forums.php */
     467        $content = apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_text, &$topic, &$topic ) );
     468
     469        /** This filter is documented in bp-groups/bp-groups-forums.php */
     470        $filtered_primary_link = apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id );
     471
    304472        groups_record_activity( array(
    305473                'id'                => $id,
    306                 'action'            => apply_filters_ref_array( 'groups_activity_new_forum_post_action',  array( $activity_action,  $post_text, &$topic, &$topic ) ),
    307                 'content'           => apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_text, &$topic, &$topic ) ),
    308                 'primary_link'      => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
     474                'action'            => $action,
     475                'content'           => $content,
     476                'primary_link'      => $filtered_primary_link,
    309477                'type'              => 'new_forum_post',
    310478                'item_id'           => (int) bp_get_current_group_id(),
     
    314482        ) );
    315483
     484        /**
     485         * Fires after the update of a group forum post.
     486         *
     487         * @since BuddyPress (1.1.0)
     488         *
     489         * @param object $post  Object holding current post being updated.
     490         * @param object $topic Object holding current topic details. Passed by reference.
     491         */
    316492        do_action_ref_array( 'groups_update_group_forum_post', array( $post, &$topic ) );
    317493
     
    337513
    338514        if ( !empty( $action ) ) {
     515
     516                /**
     517                 * Fires before the deletion of a group forum topic.
     518                 *
     519                 * @since BuddyPress (1.2.9)
     520                 *
     521                 * @param int $topic_id ID of the topic to be deleted.
     522                 */
    339523                do_action( 'groups_before_delete_group_forum_topic', $topic_id );
    340524
     
    361545                }
    362546
     547                /**
     548                 * Fires after the deletion of a group forum topic.
     549                 *
     550                 * @since BuddyPress (1.1.0)
     551                 *
     552                 * @param int $topic_id ID of the topic that was deleted.
     553                 */
    363554                do_action( 'groups_delete_group_forum_topic', $topic_id );
    364555        }
     
    385576
    386577        if ( !empty( $action ) ) {
     578
     579                /**
     580                 * Fires before the deletion of a group forum post.
     581                 *
     582                 * @since BuddyPress (1.5.0)
     583                 *
     584                 * @param int $post_id  ID of the post to be deleted.
     585                 * @param int $topic_id ID of the associated topic.
     586                 */
    387587                do_action( 'groups_before_delete_group_forum_post', $post_id, $topic_id );
    388588
     
    397597                }
    398598
     599                /**
     600                 * Fires after the deletion of a group forum post.
     601                 *
     602                 * @since BuddyPress (1.1.0)
     603                 *
     604                 * @param int $post_id  ID of the post that was deleted.
     605                 * @param int $topic_id ID of the associated topic.
     606                 */
    399607                do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
    400608        }
     
    413621 */
    414622function groups_total_public_forum_topic_count( $type = 'newest' ) {
     623
     624        /**
     625         * Filters the total count of all public topics of a given type, across groups/forums.
     626         *
     627         * @since BuddyPress (1.1.0)
     628         *
     629         * @param int $value Total count of all public topics.
     630         */
    415631        return apply_filters( 'groups_total_public_forum_topic_count', BP_Groups_Group::get_global_forum_topic_count( $type ) );
    416632}
     
    427643 */
    428644function groups_total_forum_topic_count( $status = 'public', $search_terms = false ) {
     645
     646        /**
     647         * Filters the total count of all topics of a given status, across groups/forums.
     648         *
     649         * @since BuddyPress (1.5.0)
     650         *
     651         * @param int $value Total count of all topics.
     652         */
    429653        return apply_filters( 'groups_total_forum_topic_count', BP_Groups_Group::get_global_topic_count( $status, $search_terms ) );
    430654}
Note: See TracChangeset for help on using the changeset viewer.