diff --git src/bp-templates/bp-legacy/css/buddypress.css src/bp-templates/bp-legacy/css/buddypress.css
index 77b8e3a..d0a4a01 100644
|
|
|
a.bp-title-button {
|
| 840 | 840 | #buddypress .wp-editor-wrap input[type=submit], |
| 841 | 841 | #buddypress .wp-editor-wrap input[type=button], |
| 842 | 842 | #buddypress .wp-editor-wrap input[type=reset] { |
| 843 | | padding: 0 10px 1px; |
| | 843 | padding: 0 8px 1px; |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | /* Form classes & generic attr styling */ |
| … |
… |
body.register #buddypress div.page ul {
|
| 1584 | 1584 | #buddypress .field-visibility select { |
| 1585 | 1585 | margin: 0; |
| 1586 | 1586 | } |
| | 1587 | #buddypress .wp-editor-container { |
| | 1588 | border: 1px solid #dedede; |
| | 1589 | } |
| | 1590 | #buddypress .html-active button.switch-html { |
| | 1591 | border-bottom-color: transparent; |
| | 1592 | border-bottom-left-radius: 0; |
| | 1593 | border-bottom-right-radius: 0; |
| | 1594 | background: #f5f5f5; |
| | 1595 | } |
| | 1596 | #buddypress .tmce-active button.switch-tmce { |
| | 1597 | border-bottom-color: transparent; |
| | 1598 | border-bottom-left-radius: 0; |
| | 1599 | border-bottom-right-radius: 0; |
| | 1600 | background: #f5f5f5; |
| | 1601 | } |
| | 1602 | #buddypress .standard-form .wp-editor-container textarea { |
| | 1603 | width: 100%; |
| | 1604 | padding-top: 0; |
| | 1605 | padding-bottom: 0; |
| | 1606 | } |
| 1587 | 1607 | |
| 1588 | 1608 | /*-------------------------------------------------------------- |
| 1589 | 1609 | 3.11 - Widgets |
diff --git src/bp-templates/bp-legacy/css/twentyfifteen.css src/bp-templates/bp-legacy/css/twentyfifteen.css
index 331f0bb..c9908f8 100644
|
|
|
http://codex.buddypress.org/themes/buddypress-companion-stylesheets/
|
| 1708 | 1708 | border: 1px solid rgba(153, 153, 153, 0.5); |
| 1709 | 1709 | } |
| 1710 | 1710 | |
| | 1711 | #buddypress .wp-editor-wrap a.button, |
| | 1712 | #buddypress .wp-editor-wrap button, |
| | 1713 | #buddypress .wp-editor-wrap input[type=submit], |
| | 1714 | #buddypress .wp-editor-wrap input[type=button], |
| | 1715 | #buddypress .wp-editor-wrap input[type=reset] { |
| | 1716 | padding: 0 5px 1px; |
| | 1717 | } |
| | 1718 | |
| 1711 | 1719 | #buddypress .standard-form li, |
| 1712 | 1720 | #buddypress .group-create-form li { |
| 1713 | 1721 | float: none; |
diff --git src/bp-templates/bp-legacy/css/twentyfifteen.scss src/bp-templates/bp-legacy/css/twentyfifteen.scss
index cabcd0e..b1a0d57 100644
|
|
|
http://codex.buddypress.org/themes/buddypress-companion-stylesheets/
|
| 2040 | 2040 | |
| 2041 | 2041 | select {border: 1px solid rgba($border-color, 0.5);} |
| 2042 | 2042 | |
| | 2043 | // Overrides for embedded WP editors. |
| | 2044 | .wp-editor-wrap { |
| | 2045 | a.button, |
| | 2046 | button, |
| | 2047 | input[type=submit], |
| | 2048 | input[type=button], |
| | 2049 | input[type=reset] { |
| | 2050 | padding: 0 5px 1px; |
| | 2051 | } |
| | 2052 | } |
| | 2053 | |
| 2043 | 2054 | } // close #buddypress |
| 2044 | 2055 | |
| 2045 | 2056 | |
diff --git src/bp-xprofile/bp-xprofile-filters.php src/bp-xprofile/bp-xprofile-filters.php
index 639fd6c..e039a4c 100644
|
|
|
add_filter( 'bp_get_the_profile_field_value', 'convert_chars' );
|
| 23 | 23 | add_filter( 'bp_get_the_profile_field_value', 'wpautop' ); |
| 24 | 24 | add_filter( 'bp_get_the_profile_field_value', 'force_balance_tags' ); |
| 25 | 25 | add_filter( 'bp_get_the_profile_field_value', 'make_clickable' ); |
| 26 | | add_filter( 'bp_get_the_profile_field_value', 'esc_html', 8 ); |
| | 26 | add_filter( 'bp_get_the_profile_field_value', 'bp_xprofile_escape_field_data', 8, 3 ); |
| 27 | 27 | add_filter( 'bp_get_the_profile_field_value', 'convert_smilies', 9 ); |
| 28 | 28 | add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_format_field_value', 1, 2 ); |
| 29 | 29 | add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_format_field_value_by_type', 8, 3 ); |
| 30 | 30 | add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 3 ); |
| 31 | 31 | |
| 32 | 32 | add_filter( 'bp_get_the_profile_field_edit_value', 'force_balance_tags' ); |
| 33 | | add_filter( 'bp_get_the_profile_field_edit_value', 'esc_html' ); |
| | 33 | add_filter( 'bp_get_the_profile_field_edit_value', 'bp_xprofile_escape_field_data', 10, 3 ); |
| 34 | 34 | |
| 35 | 35 | add_filter( 'bp_get_the_profile_group_name', 'stripslashes' ); |
| 36 | 36 | add_filter( 'bp_get_the_profile_group_description', 'stripslashes' ); |
| … |
… |
add_filter( 'bp_get_the_profile_field_edit_value', 'stripslashes' );
|
| 39 | 39 | add_filter( 'bp_get_the_profile_field_name', 'stripslashes' ); |
| 40 | 40 | add_filter( 'bp_get_the_profile_field_description', 'stripslashes' ); |
| 41 | 41 | |
| 42 | | add_filter( 'xprofile_get_field_data', 'wp_filter_kses', 1 ); |
| | 42 | add_filter( 'xprofile_get_field_data', 'xprofile_filter_kses', 1 ); |
| 43 | 43 | add_filter( 'xprofile_field_name_before_save', 'wp_filter_kses', 1 ); |
| 44 | 44 | add_filter( 'xprofile_field_description_before_save', 'wp_filter_kses', 1 ); |
| 45 | 45 | |
| … |
… |
function xprofile_filter_kses( $content, $data_obj = null ) {
|
| 124 | 124 | $xprofile_allowedtags = $allowedtags; |
| 125 | 125 | $xprofile_allowedtags['a']['rel'] = array(); |
| 126 | 126 | |
| | 127 | // If the field supports rich text, we must allow tags that appear in wp_editor(). |
| | 128 | if ( $data_obj instanceof BP_XProfile_ProfileData && bp_xprofile_is_richtext_enabled_for_field( $data_obj->field_id ) ) { |
| | 129 | $richtext_tags = array( |
| | 130 | 'img' => array( 'id' => 1, 'class' => 1, 'src' => 1, 'alt' => 1, 'width' => 1, 'height' => 1 ), |
| | 131 | 'ul' => array( 'id' => 1, 'class' => 1 ), |
| | 132 | 'ol' => array( 'id' => 1, 'class' => 1 ), |
| | 133 | 'li' => array( 'id' => 1, 'class' => 1 ), |
| | 134 | 'span' => array( 'style' => 1 ), |
| | 135 | 'p' => array( 'style' => 1 ), |
| | 136 | ); |
| | 137 | |
| | 138 | $xprofile_allowedtags = array_merge( $allowedtags, $richtext_tags ); |
| | 139 | } |
| | 140 | |
| 127 | 141 | /** |
| 128 | 142 | * Filters the allowed tags for use within xprofile_filter_kses(). |
| 129 | 143 | * |
| … |
… |
function xprofile_filter_pre_validate_value_by_field_type( $value, $field, $fiel
|
| 280 | 294 | } |
| 281 | 295 | |
| 282 | 296 | /** |
| | 297 | * Escape field value for display. |
| | 298 | * |
| | 299 | * Most field values are simply run through esc_html(). Those that support rich text (by default, `textarea` only) |
| | 300 | * are sanitized using kses, which allows a whitelist of HTML tags. |
| | 301 | * |
| | 302 | * @since 2.4.0 |
| | 303 | * |
| | 304 | * @param string $value Field value. |
| | 305 | * @param string $field_type Field type. |
| | 306 | * @param int $field_id Field ID. |
| | 307 | * @return string |
| | 308 | */ |
| | 309 | function bp_xprofile_escape_field_data( $value, $field_type, $field_id ) { |
| | 310 | if ( bp_xprofile_is_richtext_enabled_for_field( $field_id ) ) { |
| | 311 | // xprofile_filter_kses() expects a BP_XProfile_ProfileData object. |
| | 312 | $data_obj = null; |
| | 313 | if ( bp_is_user() ) { |
| | 314 | $data_obj = new BP_XProfile_ProfileData( $field_id, bp_displayed_user_id() ); |
| | 315 | } |
| | 316 | |
| | 317 | $value = xprofile_filter_kses( $value, $data_obj ); |
| | 318 | } else { |
| | 319 | $value = esc_html( $value ); |
| | 320 | } |
| | 321 | |
| | 322 | return $value; |
| | 323 | } |
| | 324 | |
| | 325 | /** |
| 283 | 326 | * Filter an Extended Profile field value, and attempt to make clickable links |
| 284 | 327 | * to members search results out of them. |
| 285 | 328 | * |
diff --git src/bp-xprofile/bp-xprofile-functions.php src/bp-xprofile/bp-xprofile-functions.php
index a2004d8..a3d025d 100644
|
|
|
function bp_xprofile_fullname_field_name() {
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | /** |
| | 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 | */ |
| | 1032 | function 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 | /** |
| 1023 | 1056 | * Get visibility levels out of the $bp global. |
| 1024 | 1057 | * |
| 1025 | 1058 | * @return array |
diff --git src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php
index c480dd4..041e2e7 100644
|
|
|
class BP_XProfile_Field_Type_Textarea extends BP_XProfile_Field_Type {
|
| 26 | 26 | |
| 27 | 27 | $this->category = _x( 'Single Fields', 'xprofile field type category', 'buddypress' ); |
| 28 | 28 | $this->name = _x( 'Multi-line Text Area', 'xprofile field type', 'buddypress' ); |
| | 29 | $this->supports_richtext = true; |
| 29 | 30 | |
| 30 | 31 | $this->set_format( '/^.*$/m', 'replace' ); |
| 31 | 32 | |
| … |
… |
class BP_XProfile_Field_Type_Textarea extends BP_XProfile_Field_Type {
|
| 59 | 60 | unset( $raw_properties['user_id'] ); |
| 60 | 61 | } |
| 61 | 62 | |
| 62 | | $r = bp_parse_args( $raw_properties, array( |
| 63 | | 'cols' => 40, |
| 64 | | 'rows' => 5, |
| 65 | | ) ); ?> |
| | 63 | $richtext_enabled = bp_xprofile_is_richtext_enabled_for_field(); ?> |
| 66 | 64 | |
| 67 | 65 | <label for="<?php bp_the_profile_field_input_name(); ?>"> |
| 68 | 66 | <?php bp_the_profile_field_name(); ?> |
| … |
… |
class BP_XProfile_Field_Type_Textarea extends BP_XProfile_Field_Type {
|
| 72 | 70 | <?php |
| 73 | 71 | |
| 74 | 72 | /** This action is documented in bp-xprofile/bp-xprofile-classes */ |
| 75 | | do_action( bp_get_the_profile_field_errors_action() ); ?> |
| 76 | | |
| 77 | | <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?>><?php bp_the_profile_field_edit_value(); ?></textarea> |
| 78 | | |
| 79 | | <?php |
| | 73 | do_action( bp_get_the_profile_field_errors_action() ); |
| | 74 | |
| | 75 | if ( ! $richtext_enabled ) { |
| | 76 | $r = wp_parse_args( $raw_properties, array( |
| | 77 | 'cols' => 40, |
| | 78 | 'rows' => 5, |
| | 79 | ) ); |
| | 80 | |
| | 81 | ?> |
| | 82 | |
| | 83 | <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?>><?php bp_the_profile_field_edit_value(); ?></textarea> |
| | 84 | |
| | 85 | <?php |
| | 86 | |
| | 87 | } else { |
| | 88 | |
| | 89 | /** |
| | 90 | * Filters the arguments passed to `wp_editor()` in richtext xprofile fields. |
| | 91 | * |
| | 92 | * @since 2.4.0 |
| | 93 | * |
| | 94 | * @param array $args { |
| | 95 | * Array of optional arguments. See `wp_editor()`. |
| | 96 | * @type bool $teeny Whether to use the teeny version of TinyMCE. Default true. |
| | 97 | * @type bool $media_buttons Whether to show media buttons. Default false. |
| | 98 | * @type bool $quicktags Whether to show the quicktags buttons. Default true. |
| | 99 | * } |
| | 100 | */ |
| | 101 | $editor_args = apply_filters( 'bp_xprofile_field_type_textarea_editor_args', array( |
| | 102 | 'teeny' => true, |
| | 103 | 'media_buttons' => false, |
| | 104 | 'quicktags' => true, |
| | 105 | ) ); |
| | 106 | |
| | 107 | wp_editor( |
| | 108 | bp_get_the_profile_field_edit_value(), |
| | 109 | bp_get_the_profile_field_input_name(), |
| | 110 | $editor_args |
| | 111 | ); |
| | 112 | } |
| 80 | 113 | } |
| 81 | 114 | |
| 82 | 115 | /** |
| … |
… |
class BP_XProfile_Field_Type_Textarea extends BP_XProfile_Field_Type {
|
| 89 | 122 | * @param array $raw_properties Optional key/value array of permitted attributes that you want to add. |
| 90 | 123 | */ |
| 91 | 124 | public function admin_field_html( array $raw_properties = array() ) { |
| 92 | | $r = bp_parse_args( $raw_properties, array( |
| 93 | | 'cols' => 40, |
| 94 | | 'rows' => 5, |
| 95 | | ) ); ?> |
| | 125 | $richtext_enabled = bp_xprofile_is_richtext_enabled_for_field(); |
| 96 | 126 | |
| 97 | | <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?>></textarea> |
| | 127 | if ( ! $richtext_enabled ) { |
| 98 | 128 | |
| 99 | | <?php |
| | 129 | $r = bp_parse_args( $raw_properties, array( |
| | 130 | 'cols' => 40, |
| | 131 | 'rows' => 5, |
| | 132 | ) ); ?> |
| | 133 | |
| | 134 | <textarea <?php echo $this->get_edit_field_html_elements( $r ); ?>></textarea> |
| | 135 | |
| | 136 | <?php |
| | 137 | } else { |
| | 138 | |
| | 139 | /** This filter is documented in bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php */ |
| | 140 | $editor_args = apply_filters( 'bp_xprofile_field_type_textarea_editor_args', array( |
| | 141 | 'teeny' => true, |
| | 142 | 'media_buttons' => false, |
| | 143 | 'quicktags' => true, |
| | 144 | ) ); |
| | 145 | |
| | 146 | wp_editor( |
| | 147 | '', |
| | 148 | 'xprofile_textarea_' . bp_get_the_profile_field_id(), |
| | 149 | $editor_args |
| | 150 | ); |
| | 151 | } |
| 100 | 152 | } |
| 101 | 153 | |
| 102 | 154 | /** |
diff --git src/bp-xprofile/classes/class-bp-xprofile-field-type.php src/bp-xprofile/classes/class-bp-xprofile-field-type.php
index dda936a..1557c25 100644
|
|
|
abstract class BP_XProfile_Field_Type {
|
| 73 | 73 | public $supports_multiple_defaults = false; |
| 74 | 74 | |
| 75 | 75 | /** |
| | 76 | * If the field type supports rich text by default. |
| | 77 | * |
| | 78 | * @since 2.4.0 |
| | 79 | * @var bool |
| | 80 | */ |
| | 81 | public $supports_richtext = false; |
| | 82 | |
| | 83 | /** |
| 76 | 84 | * If object is created by an BP_XProfile_Field object. |
| 77 | 85 | * |
| 78 | 86 | * @since 2.0.0 |
diff --git tests/phpunit/testcases/xprofile/functions.php tests/phpunit/testcases/xprofile/functions.php
index 63256ea..f5f56e4 100644
|
|
|
Bar!';
|
| 913 | 913 | $this->assertEquals( $field_1, $field_2 ); |
| 914 | 914 | $this->assertSame( $num_queries, $wpdb->num_queries ); |
| 915 | 915 | } |
| | 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 | } |
| 916 | 942 | } |