From a0e60513605fd5dac417668278b9d2aa4b626689 Mon Sep 17 00:00:00 2001 From: Utsav-Ladani <201901076@daiict.ac.in> Date: Fri, 29 Dec 2023 11:32:01 +0530 Subject: [PATCH 1/4] Bind correct context for Nouveau inject method --- app/assets/js/rtMedia.activity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/js/rtMedia.activity.js b/app/assets/js/rtMedia.activity.js index 207ec90bd..0fea0c6dd 100644 --- a/app/assets/js/rtMedia.activity.js +++ b/app/assets/js/rtMedia.activity.js @@ -4,7 +4,7 @@ // Overwrite the inject function and apply mediaelement library player after adding activity. bp.Nouveau.inject = function( selector, content, method ) { - callback( selector, content, method ); + callback.bind(this)( selector, content, method ); if ( 'function' === typeof rtmedia_on_activity_add ) { rtmedia_on_activity_add(); From 999233ca0eabc9cc88c3d24d03e1ab3487eede55 Mon Sep 17 00:00:00 2001 From: Utsav-Ladani <201901076@daiict.ac.in> Date: Fri, 29 Dec 2023 17:06:01 +0530 Subject: [PATCH 2/4] Update release date --- README.md | 3 ++- readme.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 63f135eea..1aab7645b 100755 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ https://www.youtube.com/watch?v=dJrykKQGDcs ## Changelog ## -### 4.6.17 [December 28, 2023] ### +### 4.6.17 [January 2, 2024] ### * Enhancement @@ -163,6 +163,7 @@ https://www.youtube.com/watch?v=dJrykKQGDcs * Fixed PHP compatibility issue. * Fixed issues related to Twenty Twenty Four theme. + * Fix BuddyPress nouveau template issue. ### 4.6.16 [November 16, 2023] ### diff --git a/readme.txt b/readme.txt index 68ba83ba5..921aff7ed 100755 --- a/readme.txt +++ b/readme.txt @@ -133,7 +133,7 @@ http://www.youtube.com/watch?v=dJrykKQGDcs == Changelog == -= 4.6.17 [December 28, 2023] = += 4.6.17 [January 2, 2024] = * Enhancement @@ -144,6 +144,7 @@ http://www.youtube.com/watch?v=dJrykKQGDcs * Fixed PHP compatibility issue. * Fixed issues related to Twenty Twenty Four theme. + * Fix BuddyPress nouveau template issue. = 4.6.16 [November 16, 2023] = From b3ca59124e488f384462cf5c90712d7a051cbfc1 Mon Sep 17 00:00:00 2001 From: Utsav-Ladani <201901076@daiict.ac.in> Date: Tue, 2 Jan 2024 11:58:44 +0530 Subject: [PATCH 3/4] Remove   flow and allow to upload media only in activity --- app/assets/js/rtMedia.backbone.js | 17 ++--------- .../activity/RTMediaBuddyPressActivity.php | 25 +++++++++++++++++ languages/buddypress-media.po | 28 +++++++++---------- 3 files changed, 41 insertions(+), 29 deletions(-) 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('

' + rtmedia_empty_activity_msg + '

') 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('

' + rtmedia_empty_activity_msg + '

') jQuery( '#whats-new' ).removeAttr( 'disabled' ); return false; 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/languages/buddypress-media.po b/languages/buddypress-media.po index 984e2a575..ede83ecea 100644 --- a/languages/buddypress-media.po +++ b/languages/buddypress-media.po @@ -1,14 +1,14 @@ -# Copyright (C) 2023 rtCamp +# Copyright (C) 2024 rtCamp # This file is distributed under the same license as the rtMedia for WordPress, BuddyPress and bbPress package. msgid "" msgstr "" "Project-Id-Version: rtMedia for WordPress, BuddyPress and bbPress 4.6.17\n" "Report-Msgid-Bugs-To: https://rtmedia.io/support/\n" -"POT-Creation-Date: 2023-12-28 10:36:32+00:00\n" +"POT-Creation-Date: 2024-01-02 06:22:56+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"PO-Revision-Date: 2023-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2024-MO-DA HO:MI+ZONE\n" "Last-Translator: rtMedia \n" "Language-Team: rtMedia \n" "Language: en\n" @@ -2312,7 +2312,7 @@ msgid "rtMedia: Import Media Size" msgstr "" #: app/main/RTMedia.php:163 app/main/RTMedia.php:1530 app/main/RTMedia.php:1623 -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:760 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:763 #: app/main/controllers/shortcodes/RTMediaGalleryShortcode.php:113 #: app/main/controllers/upload/processors/RTMediaUploadFile.php:246 msgid "Media Files" @@ -2581,28 +2581,28 @@ msgstr "" msgid "Adding media in Comments is not allowed" msgstr "" -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:490 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:493 #: app/main/controllers/upload/RTMediaUploadEndpoint.php:60 #: app/main/controllers/upload/RTMediaUploadEndpoint.php:74 msgid "Terms and Conditions checkbox not found!" msgstr "" -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:819 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:822 #: app/main/controllers/media/RTMediaComment.php:219 #: app/main/controllers/shortcodes/RTMediaUploadShortcode.php:135 #: app/main/controllers/template/rtmedia-functions.php:2265 msgid "You are not allowed to upload/attach media." msgstr "" -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:975 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:978 #: app/main/controllers/media/RTMediaMedia.php:797 #. translators: 1: user link, 2: media. #. translators: 1: username, 2: media type, 3: media name, 4: total media. msgid "%1$s added a %2$s" msgstr "" -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:982 #: app/main/controllers/activity/RTMediaBuddyPressActivity.php:985 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:988 #: app/main/controllers/upload/RTMediaUploadEndpoint.php:283 #. translators: 1: user link, 2: media count, 3: media. #. translators: 1: user link, 2: media count, 3: rtMedia slug. @@ -2610,32 +2610,32 @@ msgstr "" msgid "%1$s added %2$d %3$s" msgstr "" -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1057 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1060 #. translators: 1: username, 2: media, 3: group name. msgid "%1$s liked a %2$s in the group %3$s" msgstr "" -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1060 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1063 #. translators: 1: username, 2: media. msgid "%1$s liked their %2$s" msgstr "" -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1069 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1072 #. translators: 1: username, 2: author, 3: media. msgid "%1$s liked %2$s's %3$s" msgstr "" -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1178 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1181 #. translators: 1: username, 2: media, 3: group name. msgid "%1$s commented on a %2$s in the group %3$s" msgstr "" -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1181 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1184 #. translators: 1: username, 2: media. msgid "%1$s commented on their %2$s" msgstr "" -#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1190 +#: app/main/controllers/activity/RTMediaBuddyPressActivity.php:1193 #. translators: 1: username, 2: author, 3: media. msgid "%1$s commented on %2$s's %3$s" msgstr "" From da73b7e572547b128b025702122c6b7e246b1161 Mon Sep 17 00:00:00 2001 From: Utsav-Ladani <201901076@daiict.ac.in> Date: Tue, 2 Jan 2024 12:46:51 +0530 Subject: [PATCH 4/4] Allow media upload without text from group activity --- app/main/RTMedia.php | 3 +- .../group/RTMediaBuddyPressGroupActivity.php | 43 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 app/main/controllers/group/RTMediaBuddyPressGroupActivity.php 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/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 @@ +