Skip to:
Content

bbPress.org


Ignore:
Timestamp:
01/18/2018 05:10:13 PM (3 years ago)
Author:
johnjamesjacoby
Message:

Engagements: Add relationship key and type to bbp_user_engagements_interface().

This allows for per-feature overloading of the engagement relationship type – useful if you want to store some data as a taxonomy, some data as meta, and other data in custom storage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/engagements.php

    r6747 r6768  
    2727 */
    2828function bbp_add_user_to_object( $object_id = 0, $user_id = 0, $rel_key = '', $rel_type = 'post', $unique = false ) {
    29     $retval = bbp_user_engagements_interface()->add_user_to_object( $object_id, $user_id, $rel_key, $rel_type, $unique );
     29    $retval = bbp_user_engagements_interface( $rel_key, $rel_type )->add_user_to_object( $object_id, $user_id, $rel_key, $rel_type, $unique );
    3030
    3131    // Filter & return
     
    4646 */
    4747function bbp_remove_user_from_object( $object_id = 0, $user_id = 0, $rel_key = '', $rel_type = 'post' ) {
    48     $retval = bbp_user_engagements_interface()->remove_user_from_object( $object_id, $user_id, $rel_key, $rel_type );
     48    $retval = bbp_user_engagements_interface( $rel_key, $rel_type )->remove_user_from_object( $object_id, $user_id, $rel_key, $rel_type );
    4949
    5050    // Filter & return
     
    6464 */
    6565function bbp_remove_user_from_all_objects( $user_id = 0, $rel_key = '', $rel_type = 'post' ) {
    66     $retval = bbp_user_engagements_interface()->remove_user_from_all_objects( $user_id, $rel_key, $rel_type );
     66    $retval = bbp_user_engagements_interface( $rel_key, $rel_type )->remove_user_from_all_objects( $user_id, $rel_key, $rel_type );
    6767
    6868    // Filter & return
     
    8383 */
    8484function bbp_remove_object_from_all_users( $object_id = 0, $rel_key = '', $rel_type = 'post' ) {
    85     $retval = bbp_user_engagements_interface()->remove_object_from_all_users( $object_id, $rel_key, $rel_type );
     85    $retval = bbp_user_engagements_interface( $rel_key, $rel_type )->remove_object_from_all_users( $object_id, $rel_key, $rel_type );
    8686
    8787    // Filter & return
     
    100100 */
    101101function bbp_remove_all_users_from_all_objects( $rel_key = '', $rel_type = 'post' ) {
    102     $retval = bbp_user_engagements_interface()->remove_all_users_from_all_objects( $rel_key, $rel_type );
     102    $retval = bbp_user_engagements_interface( $rel_key, $rel_type )->remove_all_users_from_all_objects( $rel_key, $rel_type );
    103103
    104104    // Filter & return
     
    118118 */
    119119function bbp_get_users_for_object( $object_id = 0, $rel_key = '', $rel_type = 'post' ) {
    120     $retval = bbp_user_engagements_interface()->get_users_for_object( $object_id, $rel_key, $rel_type );
     120    $retval = bbp_user_engagements_interface( $rel_key, $rel_type )->get_users_for_object( $object_id, $rel_key, $rel_type );
    121121
    122122    // Filter & return
     
    149149 * @since 2.6.0 bbPress (r6747)
    150150 *
    151  * @param array  $args
    152  * @param string $context
    153  * @param string $meta_key
    154  * @param string $meta_type
     151 * @param array  $args      Default query arguments
     152 * @param string $context   Additional context
     153 * @param string $rel_key   The relationship key
     154 * @param string $rel_type  The relationship type (usually 'post')
    155155 *
    156156 * @return array
    157157 */
    158 function bbp_get_user_object_query( $args = array(), $context = '', $meta_key = '', $meta_type = 'post' ) {
    159     $retval = bbp_user_engagements_interface()->get_query( $args, "get_user_{$context}", $meta_key, $meta_type );
    160 
    161     // Filter & return
    162     return (array) apply_filters( 'bbp_get_user_object_query', $retval, $args, $context, $meta_key, $meta_type );
     158function bbp_get_user_object_query( $args = array(), $context = '', $rel_key = '', $rel_type = 'post' ) {
     159    $retval = bbp_user_engagements_interface( $rel_key, $rel_type )->get_query( $args, "get_user_{$context}", $rel_key, $rel_type );
     160
     161    // Filter & return
     162    return (array) apply_filters( 'bbp_get_user_object_query', $retval, $args, $context, $rel_key, $rel_type );
    163163}
    164164
Note: See TracChangeset for help on using the changeset viewer.