Example #1
0
 /**
  * @ticket BP5625
  */
 public function test_bp_xprofie_is_richtext_enabled_for_field_should_default_to_false_for_non_textareas()
 {
     $g = $this->factory->xprofile_group->create();
     $f = $this->factory->xprofile_field->create(array('field_group_id' => $g, 'type' => 'radio'));
     $this->assertFalse(bp_xprofile_is_richtext_enabled_for_field($f));
 }
/**
 * Escape field value for display.
 *
 * Most field values are simply run through esc_html(). Those that support rich text (by default, `textarea` only)
 * are sanitized using kses, which allows a whitelist of HTML tags.
 *
 * @since 2.4.0
 *
 * @param string $value      Field value.
 * @param string $field_type Field type.
 * @param int    $field_id   Field ID.
 * @return string
 */
function bp_xprofile_escape_field_data($value, $field_type, $field_id)
{
    if (bp_xprofile_is_richtext_enabled_for_field($field_id)) {
        // The xprofile_filter_kses() expects a BP_XProfile_ProfileData object.
        $data_obj = null;
        if (bp_is_user()) {
            $data_obj = new BP_XProfile_ProfileData($field_id, bp_displayed_user_id());
        }
        $value = xprofile_filter_kses($value, $data_obj);
    } else {
        $value = esc_html($value);
    }
    return $value;
}
    /**
     * Output HTML for this field type on the wp-admin Profile Fields screen.
     *
     * Must be used inside the {@link bp_profile_fields()} template loop.
     *
     * @since 2.0.0
     *
     * @param array $raw_properties Optional key/value array of permitted attributes that you want to add.
     */
    public function admin_field_html(array $raw_properties = array())
    {
        $richtext_enabled = bp_xprofile_is_richtext_enabled_for_field();
        if (!$richtext_enabled) {
            $r = bp_parse_args($raw_properties, array('cols' => 40, 'rows' => 5));
            ?>

			<textarea <?php 
            echo $this->get_edit_field_html_elements($r);
            ?>
></textarea>

			<?php 
        } else {
            /** This filter is documented in bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php */
            $editor_args = apply_filters('bp_xprofile_field_type_textarea_editor_args', array('teeny' => true, 'media_buttons' => false, 'quicktags' => true, 'textarea_rows' => 1), 'admin');
            wp_editor('', 'xprofile_textarea_' . bp_get_the_profile_field_id(), $editor_args);
        }
    }