Skip to:
Content

BuddyPress.org

Changeset 9165


Ignore:
Timestamp:
11/22/2014 01:49:35 AM (6 years ago)
Author:
boonebgorges
Message:

Add some actions and filters to BP_Messages_Thread.

Props slaFFik.
See #5193.

File:
1 edited

Legend:

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

    r9164 r9165  
    155155            $this->unread_count = $this->recipients[bp_loggedin_user_id()]->unread_count;
    156156        }
     157
     158        /**
     159         * Fires after a BP_Messages_Thread object has been populated.
     160         *
     161         * @since BuddyPress (2.2.0)
     162         *
     163         * @param BP_Messages_Thread Message thread object.
     164         */
     165        do_action( 'bp_messages_thread_post_populate', $this );
    157166    }
    158167
     
    184193     * @since BuddyPress (1.0.0)
    185194     *
    186      * @return object
     195     * @return array
    187196     */
    188197    public function get_recipients() {
     
    192201        $results    = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
    193202
    194         foreach ( (array) $results as $recipient )
     203        foreach ( (array) $results as $recipient ) {
    195204            $recipients[$recipient->user_id] = $recipient;
    196 
    197         return $recipients;
     205        }
     206
     207        /**
     208         * Filters the recipients of a message thread.
     209         *
     210         * @since BuddyPress (2.2.0)
     211         *
     212         * @param array $recipients Array of recipient objects.
     213         * @param int   $thread_id  ID of the current thread.
     214                 */
     215        return apply_filters( 'bp_messages_thread_get_recipients', $recipients, $this->thread_id );
    198216    }
    199217
     
    210228    public static function delete( $thread_id ) {
    211229        global $wpdb, $bp;
     230
     231        /**
     232         * Fires before a message thread is deleted.
     233         *
     234         * @since BuddyPress (2.2.0)
     235         *
     236         * @param int $thread_id ID of the thread being deleted.
     237         */
     238        do_action( 'bp_messages_thread_before_delete', $thread_id );
    212239
    213240        // Mark messages as deleted
     
    229256        }
    230257
    231         do_action( 'messages_thread_deleted_thread', $message_id );
     258        /**
     259         * Fires after a message thread is deleted.
     260         *
     261         * @since BuddyPress (2.2.0)
     262         *
     263         * @param int $thread_id ID of the thread being deleted.
     264         */
     265        do_action( 'bp_messages_thread_after_delete', $message_id );
    232266
    233267        return true;
     
    295329        }
    296330
    297         return array( 'threads' => &$threads, 'total' => (int) $total_threads );
     331        /**
     332         * Filters the results of the query for a user's message threads.
     333         *
     334         * @since BuddyPress (2.2.0)
     335         *
     336         * @param array $value {
     337         *     @type array $threads       Array of threads. Passed by reference.
     338         *     @type int   $total_threads Number of threads found by the query.
     339         * }
     340         */
     341        return apply_filters( 'bp_messages_thread_current_threads', array( 'threads' => &$threads, 'total' => (int) $total_threads ) );
    298342    }
    299343
     
    418462        }
    419463
    420         return (int) $unread_count;
     464        /**
     465         * Filters a user's unread message count.
     466         *
     467         * @since BuddyPress (2.2.0)
     468         *
     469         * @param int $unread_count Unread message count.
     470         * @param int $user_id      ID of the user.
     471         */
     472        return apply_filters( 'messages_thread_get_inbox_count', (int) $unread_count, $user_id );
    421473    }
    422474
Note: See TracChangeset for help on using the changeset viewer.