Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/28/2021 11:50:34 PM (9 months ago)
Author:
dcavins
Message:

Member Invites: Add core template functions.

Add class BP_Members_Invitations_Template and
template functions in BP_Members_Template.

See #8139.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-filters.php

    r12917 r12919  
    173173}
    174174add_filter( 'bp_user_can', 'bp_members_user_can_filter', 10, 5 );
     175/**
     176 * Sanitize the invitation property output.
     177 *
     178 * @since 8.0.0
     179 *
     180 * @param int|string $value    The value for the requested property.
     181 * @param string     $property The name of the requested property.
     182 * @param string     $context  The context of display.
     183 * @return int|string          The sanitized value.
     184 */
     185function bp_members_sanitize_invitation_property( $value = '', $property = '', $context = 'html' ) {
     186    if ( ! $property ) {
     187        return '';
     188    }
     189
     190    switch ( $property ) {
     191        case 'id':
     192        case 'user_id':
     193        case 'item_id':
     194        case 'secondary_item_id':
     195            $value = absint( $value );
     196            break;
     197        case 'invite_sent':
     198        case 'accepted':
     199            $value = absint( $value ) ? __( 'Yes', 'buddypress' ) : __( 'No', 'buddypress' );
     200            $value = 'attribute' === $context ? esc_attr( $value ) : esc_html( $value );
     201            break;
     202        case 'invitee_email':
     203            $value = sanitize_email( $value );
     204            break;
     205        case 'content':
     206            $value = wp_kses( $value, array() );
     207            $value = wptexturize( $value );
     208            break;
     209        case 'date_modified':
     210            $value = mysql2date( 'Y/m/d g:i:s a', $value );
     211            $value = 'attribute' === $context ? esc_attr( $value ) : esc_html( $value );
     212            break;
     213
     214        default:
     215            $value = 'attribute' === $context ? esc_attr( $value ) : esc_html( $value );
     216            break;
     217    }
     218
     219    return $value;
     220}
     221add_filter( 'bp_the_members_invitation_property', 'bp_members_sanitize_invitation_property', 10, 3 );
Note: See TracChangeset for help on using the changeset viewer.