Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/12/2015 05:50:45 PM (9 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/tests/phpunit/testcases/xprofile/functions.php

    r10198 r10254  
    914914        $this->assertSame( $num_queries, $wpdb->num_queries );
    915915    }
     916
     917    /**
     918     * @ticket BP5625
     919     */
     920    public function test_bp_xprofie_is_richtext_enabled_for_field_should_default_to_true_for_textareas() {
     921        $g = $this->factory->xprofile_group->create();
     922        $f = $this->factory->xprofile_field->create( array(
     923            'field_group_id' => $g,
     924            'type' => 'textarea',
     925        ) );
     926
     927        $this->assertTrue( bp_xprofile_is_richtext_enabled_for_field( $f ) );
     928    }
     929
     930    /**
     931     * @ticket BP5625
     932     */
     933    public function test_bp_xprofie_is_richtext_enabled_for_field_should_default_to_false_for_non_textareas() {
     934        $g = $this->factory->xprofile_group->create();
     935        $f = $this->factory->xprofile_field->create( array(
     936            'field_group_id' => $g,
     937            'type' => 'radio',
     938        ) );
     939
     940        $this->assertFalse( bp_xprofile_is_richtext_enabled_for_field( $f ) );
     941    }
    916942}
Note: See TracChangeset for help on using the changeset viewer.