Skip to:
Content

BuddyPress.org

Changeset 9110


Ignore:
Timestamp:
10/30/2014 11:55:04 PM (10 years ago)
Author:
boonebgorges
Message:

Hook documentation for bp-activity-classes.php.

Props tw2113.
See #5938.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-classes.php

    r9087 r9110  
    202202        $this->is_spam           = apply_filters_ref_array( 'bp_activity_is_spam_before_save',           array( $this->is_spam,           &$this ) );
    203203
    204         // Use this, not the filters above
     204        /**
     205         * Fires before the current activity item gets saved.
     206         *
     207         * Please use this hook to filter the properties above. Each part will be passed in.
     208         *
     209         * @since BuddyPress (1.0.0)
     210         *
     211         * @param BP_Activity_Activity Current instance of the activity item being saved.
     212         */
    205213        do_action_ref_array( 'bp_activity_before_save', array( &$this ) );
    206214
     
    228236            add_filter( 'bp_activity_at_name_do_notifications', '__return_false' );
    229237
     238        /**
     239         * Fires after an activity item has been saved to the database.
     240         *
     241         * @since BuddyPress (1.0.0)
     242         *
     243         * @param BP_Activity_Activity Reference to current instance of activity being saved.
     244         */
    230245        do_action_ref_array( 'bp_activity_after_save', array( &$this ) );
    231246
     
    415430        }
    416431
    417         // Filter the where conditions
     432        /**
     433         * Filters the MySQL WHERE conditions for the Activity items get method.
     434         *
     435         * @since BuddyPress (1.9.0)
     436         *
     437         * @param array  $where_conditions Current conditions for MySQL WHERE statement.
     438         * @param array  $r Parsed arguments passed into method.
     439         * @param string $select_sql Current SELECT MySQL statement at point of execution.
     440         * @param string $from_sql Current FROM MySQL statement at point of execution.
     441         * @param string $join_sql Current INNER JOIN MySQL statement at point of execution.
     442         */
    418443        $where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
    419444
     
    421446        $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
    422447
    423         // Define the preferred order for indexes
     448        /**
     449         * Filters the preferred order of indexes for activity item.
     450         *
     451         * @since Buddypress (1.6.0)
     452         *
     453         * @param array Array of indexes in preferred order.
     454         */
    424455        $indexes = apply_filters( 'bp_activity_preferred_index_order', array( 'user_id', 'item_id', 'secondary_item_id', 'date_recorded', 'component', 'type', 'hide_sitewide', 'is_spam' ) );
    425456
     
    447478        );
    448479
    449         // Filter and return true to use the legacy query structure (not recommended)
     480        /**
     481         * Filters if BuddyPress should use legacy query structure over current structure for version 2.0+.
     482         *
     483         * It is not recommended to use the legacy structure, but allowed to if needed.
     484         *
     485         * @since BuddyPress (2.0.0)
     486         *
     487         * @param bool                 Whether to use legacy structure or not.
     488         * @param BP_Activity_Activity Current method being called.
     489         * @param array                $r Parsed arguments pased into method.
     490         */
    450491        if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $r ) ) {
    451492
     
    456497            if ( ! empty( $page ) && ! empty( $per_page ) ) {
    457498                $pag_sql    = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
     499
     500                /** this filter is documented in bp-activity/bp-activity-classes.php */
    458501                $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
    459502            } else {
    460503                $pag_sql    = '';
     504
     505                /**
     506                 * Filters the legacy MySQL query statement so plugins can alter before results are fetched.
     507                 *
     508                 * @since BuddyPress (1.5.0)
     509                 *
     510                 * @param string Concatenated MySQL statement pieces to be query results with for legacy query.
     511                 * @param string $select_sql Final SELECT MySQL statement portion for legacy query.
     512                 * @param string $from_sql Final FROM MySQL statement portion for legacy query.
     513                 * @param string $where_sql Final WHERE MySQL statement portion for legacy query.
     514                 * @param string $sort Final sort direction for legacy query.
     515                 */
    461516                $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
    462517            }
     
    473528            }
    474529
     530            /**
     531             * Filters the paged activities MySQL statement.
     532             *
     533             * @since BuddyPress (2.0.0)
     534             *
     535             * @param string $activity_ids_sql MySQL statement used to query for Activity IDs.
     536             * @param array  $r Array of arguments passed into method.
     537             */
    475538            $activity_ids_sql = apply_filters( 'bp_activity_paged_activities_sql', $activity_ids_sql, $r );
    476539
     
    515578        if ( ! empty( $r['count_total'] ) ) {
    516579
     580            /**
     581             * Filters the total activities MySQL statement.
     582             *
     583             * @since BuddyPress (1.5.0)
     584             *
     585             * @param string MySQL statement used to query for total activities.
     586             * @param string $where_sql MySQL WHERE statement portion.
     587             * @param string $sort sort direction for query.
     588             */
    517589            $total_activities_sql = apply_filters( 'bp_activity_total_activities_sql', "SELECT count(DISTINCT a.id) FROM {$bp->activity->table_name} a {$join_sql} {$where_sql}", $where_sql, $sort );
    518590            $total_activities     = $wpdb->get_var( $total_activities_sql );
     
    641713     */
    642714    protected static function prefetch_object_data( $activities ) {
     715
     716        /**
     717         * Filters inside prefetch_object_data method to aid in pre-fetching object data associated with activity item.
     718         *
     719         * @since BuddyPress (2.0.0)
     720         *
     721         * @param array $activities Array of activities.
     722         */
    643723        return apply_filters( 'bp_activity_prefetch_object_data', $activities );
    644724    }
     
    10551135            // Legacy query - not recommended
    10561136            $func_args = func_get_args();
     1137
     1138            /**
     1139             * Filters if BuddyPress should use the legacy activity query.
     1140             *
     1141             * @since BuddyPress (2.0.0)
     1142             *
     1143             * @param bool                 Whether or not to use the legacy query.
     1144             * @param BP_Activity_Activity Magic method referring to currently called method.
     1145             * @param array $func_args     Array of the method's argument list.
     1146             */
    10571147            if ( apply_filters( 'bp_use_legacy_activity_query', false, __METHOD__, $func_args ) ) {
     1148
     1149                /**
     1150                 * Filters the MySQL prepared statement for the legacy activity query.
     1151                 *
     1152                 * @since BuddyPress (1.5.0)
     1153                 *
     1154                 * @param string Prepared statement for the activity query.
     1155                 * @param int    $activity_id Activity ID to fetch comments for.
     1156                 * @param int    $left Left-most node boundary.
     1157                 * @param int    $right Right-most node boundary.
     1158                 * @param string $spam_sql SQL Statement portion to differentiate between ham or spam.
     1159                 */
    10581160                $sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d AND a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right ), $activity_id, $left, $right, $spam_sql );
    10591161
     
    14511553     */
    14521554    public function __construct( $args = array() ) {
    1453         // If feeds are disabled, stop now!
     1555
     1556        /**
     1557         * Filters if BuddyPress should consider feeds enabled. If disabled, it will return early.
     1558         *
     1559         * @since BuddyPress (1.8.0)
     1560         *
     1561         * @param bool true Default true aka feeds are enabled.
     1562         */
    14541563        if ( false === (bool) apply_filters( 'bp_activity_enable_feeds', true ) ) {
    14551564            global $wp_query;
     
    14971606        ) );
    14981607
    1499         // Plugins can use this filter to modify the feed before it is setup
     1608        /**
     1609         * Fires before the feed is setup so plugins can modify.
     1610         *
     1611         * @since BuddyPress (1.8.0)
     1612         *
     1613         * @param BP_Activity_Feed Reference to current instance of activity feed.
     1614         */
    15001615        do_action_ref_array( 'bp_activity_feed_prefetch', array( &$this ) );
    15011616
     
    15091624        }
    15101625
    1511         // Plugins can use this filter to modify the feed after it's setup
     1626        /**
     1627         * Fires after the feed is setup so plugins can modify.
     1628         *
     1629         * @since BuddyPress (1.8.0)
     1630         *
     1631         * @param BP_Activity_Feed Reference to current instance of activity feed.
     1632         */
    15121633        do_action_ref_array( 'bp_activity_feed_postfetch', array( &$this ) );
    15131634
     
    15661687     */
    15671688    public function backpat_rss_attributes() {
     1689
     1690        /**
     1691         * Fires inside backpat_rss_attributes method for backwards compatibility related to RSS attributes.
     1692         *
     1693         * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
     1694         *
     1695         * @since BuddyPress (1.0.0)
     1696         */
    15681697        do_action( 'bp_activity_' . $this->id . '_feed' );
    15691698    }
     
    15731702     */
    15741703    public function backpat_channel_elements() {
     1704
     1705        /**
     1706         * Fires inside backpat_channel_elements method for backwards compatibility related to RSS channel elements.
     1707         *
     1708         * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
     1709         *
     1710         * @since BuddyPress (1.0.0)
     1711         */
    15751712        do_action( 'bp_activity_' . $this->id . '_feed_head' );
    15761713    }
     
    15951732        }
    15961733
     1734        /**
     1735         * Fires inside backpat_item_elements method for backwards compatibility related to RSS item elements.
     1736         *
     1737         * This hook was originally separated out for individual components but has since been abstracted into the BP_Activity_Feed class.
     1738         *
     1739         * @since BuddyPress (1.0.0)
     1740         */
    15971741        do_action( 'bp_activity_' . $id . '_feed_item' );
    15981742    }
     
    17201864    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    17211865    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    1722     <?php do_action( 'bp_activity_feed_rss_attributes' ); ?>
     1866    <?php
     1867
     1868    /**
     1869     * Fires at the end of the opening RSS tag for feed output so plugins can add extra attributes.
     1870     *
     1871     * @since BuddyPress (1.8.0)
     1872     */
     1873    do_action( 'bp_activity_feed_rss_attributes' ); ?>
    17231874>
    17241875
     
    17341885    <sy:updatePeriod><?php echo $this->update_period; ?></sy:updatePeriod>
    17351886    <sy:updateFrequency><?php echo $this->update_frequency; ?></sy:updateFrequency>
    1736     <?php do_action( 'bp_activity_feed_channel_elements' ); ?>
     1887    <?php
     1888
     1889    /**
     1890     * Fires at the end of channel elements list in RSS feed so plugins can add extra channel elements.
     1891     *
     1892     * @since BuddyPress (1.8.0)
     1893     */
     1894    do_action( 'bp_activity_feed_channel_elements' ); ?>
    17371895
    17381896    <?php if ( bp_has_activities( $this->activity_args ) ) : ?>
     
    17521910                <?php endif; ?>
    17531911
    1754                 <?php do_action( 'bp_activity_feed_item_elements' ); ?>
     1912                <?php
     1913
     1914                /**
     1915                 * Fires at the end of the individual RSS Item list in RSS feed so plugins can add extra item elements.
     1916                 *
     1917                 * @since BuddyPress (1.8.0)
     1918                 */
     1919                do_action( 'bp_activity_feed_item_elements' ); ?>
    17551920            </item>
    17561921        <?php endwhile; ?>
Note: See TracChangeset for help on using the changeset viewer.