Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/12/2015 05:50:45 PM (4 years ago)
Author:
boonebgorges
Message:

Enable richtext editing for xProfile textarea fields.

Profile fields of the 'textarea' type are now edited using wp_editor().
Output escaping has been modified to whitelist all tags permitted by the
"teeny" version of the wp_editor() interface.

Richtext is enabled for all and only 'textarea' fields:

  • To enable richtext editing for a custom field type, set the supports_richtext property of your BP_XProfile_Field_Type class to true. In these cases, you'll need to provide your own editing markup as well; see the edit_field_html() and admin_field_html() methods of BP_XProfile_Field_Type_Textarea for inspiration.
  • To disable richtext editing for specific 'textarea' fields, filter bp_xprofile_is_richtext_enabled_for_field.

Props needle, boonebgorges.
Fixes #5625.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-functions.php

    r10233 r10254  
    10211021
    10221022/**
     1023 * Is rich text enabled for this profile field?
     1024 *
     1025 * By default, rich text is enabled for textarea fields and disabled for all other field types.
     1026 *
     1027 * @since 2.4.0
     1028 *
     1029 * @param int $field_id Optional. Default current field ID.
     1030 * @return bool
     1031 */
     1032function bp_xprofile_is_richtext_enabled_for_field( $field_id = null ) {
     1033    if ( ! $field_id ) {
     1034        $field_id = bp_get_the_profile_field_id();
     1035    }
     1036
     1037    $field = xprofile_get_field( $field_id );
     1038
     1039    $enabled = false;
     1040    if ( $field instanceof BP_XProfile_Field ) {
     1041        $enabled = (bool) $field->type_obj->supports_richtext;
     1042    }
     1043
     1044    /**
     1045     * Filters whether richtext is enabled for the given field.
     1046     *
     1047     * @since 2.4.0
     1048     *
     1049     * @param bool $enabled  True if richtext is enabled for the field, otherwise false.
     1050     * @param int  $field_id ID of the field.
     1051     */
     1052    return apply_filters( 'bp_xprofile_is_richtext_enabled_for_field', $enabled, $field_id );
     1053}
     1054
     1055/**
    10231056 * Get visibility levels out of the $bp global.
    10241057 *
Note: See TracChangeset for help on using the changeset viewer.