diff --git a/app/assets/js/rtMedia.backbone.js b/app/assets/js/rtMedia.backbone.js index acd48e150..040f14324 100755 --- a/app/assets/js/rtMedia.backbone.js +++ b/app/assets/js/rtMedia.backbone.js @@ -1432,10 +1432,7 @@ jQuery( document ).ready( function( $ ) { * By: Yahil */ if ( '' === jQuery( '#whats-new' ).val().trim() ) { - if ( rtmedia_activity_text_with_attachment == 'disable' ) { - $( '#whats-new' ).css( 'color', 'transparent' ); - $( '#whats-new' ).val( ' ' ); - } else { + if ( rtmedia_activity_text_with_attachment != 'disable' ) { jQuery('#whats-new-form').prepend('
') jQuery( '#whats-new' ).removeAttr( 'disabled' ); return false; @@ -1588,13 +1585,6 @@ jQuery( document ).ready( function( $ ) { * Blank error display issue resolved */ if ( bp_template_pack && 'legacy' !== bp_template_pack ) { - - if ( 'disable' === rtmedia_activity_text_with_attachment && '' === jQuery.trim( jQuery( '#whats-new' ).val() ) ) { - let textarea = jQuery( '#whats-new' ); - textarea.css( 'color', 'transparent' ); - textarea.val( ' ' ); - } - jQuery( '#whats-new-form' ).submit(); } else { jQuery( '#aw-whats-new-submit' ).click(); @@ -1692,10 +1682,7 @@ jQuery( document ).ready( function( $ ) { * By: Yahil */ - if ( rtmedia_activity_text_with_attachment == 'disable') { - $( "#whats-new" ).css( 'color', 'transparent' ); - $( "#whats-new" ).val( ' ' ); - } else { + if ( rtmedia_activity_text_with_attachment != 'disable') { jQuery('#whats-new-form').prepend(' ') jQuery( '#whats-new' ).removeAttr( 'disabled' ); return false; diff --git a/app/main/RTMedia.php b/app/main/RTMedia.php index eaf4d2943..f3038cc5d 100755 --- a/app/main/RTMedia.php +++ b/app/main/RTMedia.php @@ -1050,8 +1050,9 @@ public function init() { $this->set_allowed_types(); // Define allowed types. - global $rtmedia_buddypress_activity; + global $rtmedia_buddypress_activity, $rtmedia_buddypress_group_activity; $rtmedia_buddypress_activity = new RTMediaBuddyPressActivity(); + $rtmedia_buddypress_group_activity = new RTMediaBuddyPressGroupActivity(); $media = new RTMediaMedia(); $media->delete_hook(); diff --git a/app/main/controllers/activity/RTMediaBuddyPressActivity.php b/app/main/controllers/activity/RTMediaBuddyPressActivity.php index 10168c994..3058e7fc6 100644 --- a/app/main/controllers/activity/RTMediaBuddyPressActivity.php +++ b/app/main/controllers/activity/RTMediaBuddyPressActivity.php @@ -81,6 +81,9 @@ public function __construct() { add_filter( 'bea_get_activity_content', array( $this, 'rtm_edit_activity_filter' ) ); add_filter( 'bea_activity_content', array( $this, 'rtm_save_activity_with_media_filter' ), 10, 2 ); } + + // Allow only media uploading without text in activity. + add_filter( 'bp_before_activity_post_update_parse_args', array( $this, 'bp_before_activity_post_update_parse_args' ) ); } /** @@ -1473,4 +1476,26 @@ public function rtm_save_activity_with_media_filter( $content_new, $activity_id } return $content; } + + + /** + * Filter content before processing in activity. + * It adds the ' ' if content is empty, when we are only uploading media from activity. + * + * @param array $args Activity arguments. + * + * @return array + */ + public function bp_before_activity_post_update_parse_args( $args ) { + // if content is non-breaking space then set it to empty. + if ( isset( $args['content'] ) && '' === $args['content'] ) { + + // Nonce verification is not required here as it is already done in previously. + if ( ! empty( $_POST['rtMedia_attached_files'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing + $args['content'] = ' '; + } + } + + return $args; + } } diff --git a/app/main/controllers/group/RTMediaBuddyPressGroupActivity.php b/app/main/controllers/group/RTMediaBuddyPressGroupActivity.php new file mode 100644 index 000000000..dc467a74e --- /dev/null +++ b/app/main/controllers/group/RTMediaBuddyPressGroupActivity.php @@ -0,0 +1,43 @@ +\n" "Language-Team: rtMedia