From 396044487d00d24c903bee271be2b6c7ff8a75db Mon Sep 17 00:00:00 2001 From: rajinsharwar2 Date: Sat, 16 Mar 2024 13:21:00 -0400 Subject: [PATCH 1/4] Only allow 'text-align' property for non-capable users --- src/bp-xprofile/bp-xprofile-filters.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bp-xprofile/bp-xprofile-filters.php b/src/bp-xprofile/bp-xprofile-filters.php index 8cddd0385b..09902497b3 100644 --- a/src/bp-xprofile/bp-xprofile-filters.php +++ b/src/bp-xprofile/bp-xprofile-filters.php @@ -223,18 +223,20 @@ function xprofile_filter_kses( $content, $data_obj = null, $field_id = null ) { 'id' => 1, 'class' => 1, ), - 'span' => array(), - 'p' => array(), + 'span' => array( "style" => 1 ), + 'p' => array( "style" => 1 ), 'a' => array( 'href' => 1, 'target' => 1, ), ); - // Allow style attributes on certain elements for capable users - if ( bp_current_user_can( 'unfiltered_html' ) ) { - $richtext_tags['span'] = array( 'style' => 1 ); - $richtext_tags['p'] = array( 'style' => 1 ); + // Only allow 'text-align' property for non-capable users + if ( ! bp_current_user_can( 'unfiltered_html' ) ) { + add_filter( 'safe_style_css', function( $styles ) { + $styles = array( 'text-align' ); + return $styles; + } ); } $xprofile_allowedtags = array_merge( $allowedtags, $richtext_tags ); From d637ac5ddfe61a266a6c93daf1e8433f1fdc0ab6 Mon Sep 17 00:00:00 2001 From: rajinsharwar Date: Fri, 7 Jun 2024 16:09:00 -0400 Subject: [PATCH 2/4] PROD-6998 - Revert prev changes, and remove align buttons for non-admins --- src/bp-xprofile/bp-xprofile-filters.php | 14 ++++++-------- .../class-bp-xprofile-field-type-textarea.php | 3 +++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bp-xprofile/bp-xprofile-filters.php b/src/bp-xprofile/bp-xprofile-filters.php index 0fc87de78b..06b09f5b21 100644 --- a/src/bp-xprofile/bp-xprofile-filters.php +++ b/src/bp-xprofile/bp-xprofile-filters.php @@ -223,20 +223,18 @@ function xprofile_filter_kses( $content, $data_obj = null, $field_id = null ) { 'id' => 1, 'class' => 1, ), - 'span' => array( "style" => 1 ), - 'p' => array( "style" => 1 ), + 'span' => array(), + 'p' => array(), 'a' => array( 'href' => 1, 'target' => 1, ), ); - // Only allow 'text-align' property for non-capable users - if ( ! bp_current_user_can( 'unfiltered_html' ) ) { - add_filter( 'safe_style_css', function( $styles ) { - $styles = array( 'text-align' ); - return $styles; - } ); + // Allow style attributes on certain elements for capable users + if ( bp_current_user_can( 'unfiltered_html' ) ) { + $richtext_tags['span'] = array( 'style' => 1 ); + $richtext_tags['p'] = array( 'style' => 1 ); } $xprofile_allowedtags = array_merge( $allowedtags, $richtext_tags ); diff --git a/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php b/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php index 9ac8298eb4..4b5850e6cf 100644 --- a/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php +++ b/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php @@ -120,6 +120,9 @@ public function edit_field_html( array $raw_properties = array() ) { 'media_buttons' => false, 'quicktags' => true, 'textarea_rows' => 10, + 'tinymce' => array( + 'toolbar1' => bp_current_user_can('unfiltered_html') ? 'bold,italic,underline,blockquote,strikethrough,bullist,numlist,alignleft,aligncenter,alignright,undo,redo,link,fullscreen' : 'bold,italic,underline,blockquote,strikethrough,bullist,numlist,undo,redo,link,fullscreen', + ), ), 'edit' ); From b589e8dfddb403a586df86b814ea6a689bf85afb Mon Sep 17 00:00:00 2001 From: rajinsharwar Date: Sun, 23 Jun 2024 21:40:54 -0400 Subject: [PATCH 3/4] PROD-6998 - Updating code for better readability --- .../class-bp-xprofile-field-type-textarea.php | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php b/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php index 4b5850e6cf..2a46422c45 100644 --- a/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php +++ b/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php @@ -70,7 +70,7 @@ public function edit_field_html( array $raw_properties = array() ) { - +

true, 'textarea_rows' => 10, 'tinymce' => array( - 'toolbar1' => bp_current_user_can('unfiltered_html') ? 'bold,italic,underline,blockquote,strikethrough,bullist,numlist,alignleft,aligncenter,alignright,undo,redo,link,fullscreen' : 'bold,italic,underline,blockquote,strikethrough,bullist,numlist,undo,redo,link,fullscreen', + 'toolbar1' => implode( ',', $toolbar_buttons ), ), ), 'edit' From 739cb70a5cb4602c8c0804bd30758a9b1c40febe Mon Sep 17 00:00:00 2001 From: Jitendra Banjara Date: Mon, 24 Jun 2024 08:31:31 +0530 Subject: [PATCH 4/4] PROD-6998 - Support - Remove align button for non-admin members --- .../classes/class-bp-xprofile-field-type-textarea.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php b/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php index 2a46422c45..adf10b9851 100644 --- a/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php +++ b/src/bp-xprofile/classes/class-bp-xprofile-field-type-textarea.php @@ -126,6 +126,8 @@ public function edit_field_html( array $raw_properties = array() ) { * Filters the arguments passed to `wp_editor()` in richtext xprofile fields. * * @since BuddyPress 2.4.0 + * @since BuddyBoss [BBVERSION] + * Remove align button for non-admin members. * * @param array $args { * Array of optional arguments. See `wp_editor()`. @@ -134,6 +136,10 @@ public function edit_field_html( array $raw_properties = array() ) { * @type bool $quicktags Whether to show the quicktags buttons. Default true. * @type int $textarea_rows Number of rows to display in the editor. Defaults to 1 in the * 'admin' context, and 10 in the 'edit' context. + * @type array $tinymce { + * Array of TinyMCE arguments. + * @type string $toolbar1 Comma-separated list of buttons to display in the first row of the toolbar. + * } * } * @param string $context The display context. 'edit' when the markup is intended for the * profile edit screen, 'admin' when intended for the Profile Fields