From 2684725f1e8d67284ef799562ef36a2c3ff4e646 Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Mon, 19 Aug 2019 20:13:09 +0530 Subject: [PATCH 01/10] Increase comment_max_links count to fix issue with media comment in activity comment --- app/main/controllers/activity/RTMediaActivity.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/main/controllers/activity/RTMediaActivity.php b/app/main/controllers/activity/RTMediaActivity.php index 659802b52..7983a1198 100755 --- a/app/main/controllers/activity/RTMediaActivity.php +++ b/app/main/controllers/activity/RTMediaActivity.php @@ -169,15 +169,17 @@ public function create_activity_html( $type = 'activity' ) { $activity .= $activity_content; $activity .= $activity_container_end; + $current_max_links = absint( get_option( 'comment_max_links' ) ); // get current number of allowed links. + // Bypass comment links limit. add_filter( 'option_comment_max_links', - function ( $values ) { + function ( $values ) use ( $current_max_links ) { $rtmedia_attached_files = filter_input( INPUT_POST, 'rtMedia_attached_files', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); // Check if files available. if ( is_array( $rtmedia_attached_files ) && ! empty( $rtmedia_attached_files[0] ) ) { // One url of image and other for anchor tag. - $values = count( $rtmedia_attached_files ) * 3; + $values = ( count( $rtmedia_attached_files ) * 3 ) + $current_max_links; } return $values; } From b71c3375c16f0a1119a028266b557c0d15dae084 Mon Sep 17 00:00:00 2001 From: Thrijith Thankachan Date: Tue, 10 Sep 2019 13:00:08 +0530 Subject: [PATCH 02/10] Add new class on activity ul, based on media type --- .../controllers/activity/RTMediaActivity.php | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/app/main/controllers/activity/RTMediaActivity.php b/app/main/controllers/activity/RTMediaActivity.php index 7983a1198..3ff065dfe 100755 --- a/app/main/controllers/activity/RTMediaActivity.php +++ b/app/main/controllers/activity/RTMediaActivity.php @@ -76,6 +76,25 @@ public function create_activity_html( $type = 'activity' ) { } $rtmedia_activity_ul_class = apply_filters( 'rtmedia_' . $type . '_ul_class', 'rtm-activity-media-list' ); + $uploaded_media_types = []; + $rtmedia_activity_ul_list_class = 'rtm-activity-mixed-list'; + + // Loop through each media and check media type. + $uploaded_media_types = array_map( function ( $current_media ) { + return is_object( $current_media ) ? $current_media->media_type : ''; + }, $media_details ); + + // Remove empty values from media type list. + $media_type_list = array_filter( $uploaded_media_types, 'strlen' ); + + // Update activity class based on media type. + if ( ! empty( $media_type_list ) ) { + if ( count( array_unique( $uploaded_media_types ) ) === 1 ) { + $current_media_type = end( $uploaded_media_types ); + $rtmedia_activity_ul_list_class = "rtm-activity-{$current_media_type}-list"; + } + } + $media_content = ''; $count = 0; foreach ( $media_details as $media ) { @@ -144,10 +163,11 @@ public function create_activity_html( $type = 'activity' ) { } $media_container_start = sprintf( - '