Skip to content

Commit 7ab210f

Browse files
authored
Merge pull request #1561 from rtMediaWP/develop
Version update v4.6.0
2 parents 74b9721 + 5244101 commit 7ab210f

File tree

95 files changed

+1560
-876
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1560
-876
lines changed

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,20 @@ https://www.youtube.com/watch?v=dJrykKQGDcs
147147

148148
## Changelog ##
149149

150+
### 4.6.0 [February 17, 2020] ###
151+
152+
* Enhancement
153+
* Show long text truncated with read more option and image displayed below the truncated text on activity
154+
155+
* FIXED
156+
* Error uploading media in comments with Kleo theme
157+
* JavaScript errors
158+
* Album styling when masonry style is disabled
159+
* The template loaded on media page when nouveau template is set
160+
* Compatibility issues with PHP 7.4.1
161+
* UI related bugs
162+
* Notices and Warnings
163+
150164
### 4.5.11 [December 26, 2019] ###
151165

152166
* Enhancement
@@ -1648,8 +1662,8 @@ https://www.youtube.com/watch?v=dJrykKQGDcs
16481662
* HTML5 Audio Tag Support (with fallback)
16491663
* HTML5 Video Tag Support (with fallback)
16501664

1651-
#### 4.5.11 ####
1652-
rtMedia 4.5.11, with improved styling for albums and improved UX on BuddyPress Activity Wall.
1665+
#### 4.6.0 ####
1666+
rtMedia 4.6.0, with improved activity content preview and JavaScript and Nouveau template related fixes.
16531667

16541668
## Sponsors ##
16551669

app/assets/css/rtmedia.css

+10-1
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ button#rtmedia-add-media-button-post-update .dashicons {
347347
.rtm-form .rtm-field-wrap {
348348
margin-bottom: 20px;
349349
}
350+
.rtm-form .rtm-field-wrap .rtmedia-title-editor {
351+
width: 100%;
352+
}
350353

351354
#buddypress a.rtm-button-back {
352355
padding: 3px 10px;
@@ -651,7 +654,12 @@ input.imgedit-submit-btn {
651654
}
652655
.rtm-tabs a {
653656
border: 0;
654-
display: block;
657+
display: -webkit-box;
658+
display: -ms-flexbox;
659+
display: flex;
660+
-webkit-box-align: center;
661+
-ms-flex-align: center;
662+
align-items: center;
655663
padding: 5px 15px;
656664
text-decoration: none;
657665
}
@@ -1919,6 +1927,7 @@ a.rtmedia-comment-link.rtmedia-comments-link {
19191927
border: 1px solid #ddd;
19201928
padding: 5px;
19211929
border-radius: 5px;
1930+
width: auto;
19221931
}
19231932

19241933
/*------------------------------------------------------------------------------

app/assets/css/rtmedia.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/css/sass/_album.scss

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
border: 1px solid #ddd;
3636
padding: 5px;
3737
border-radius: 5px;
38+
width: auto;
3839
}
3940
}
4041
}

app/assets/css/sass/_rtm.scss

+4
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ button#rtmedia-add-media-button-post-update {
197197
.rtm-form {
198198
.rtm-field-wrap {
199199
margin-bottom: 20px;
200+
201+
.rtmedia-title-editor {
202+
width: 100%;
203+
}
200204
}
201205
}
202206

app/assets/css/sass/_tabs.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
a {
2020
border: 0;
21-
display: block;
21+
display: flex;
22+
align-items: center;
2223
padding: 5px 15px;
2324
text-decoration: none; //2012
2425

app/assets/js/rtMedia.backbone.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,7 @@ function renderUploadercomment_media( widget_id, parent_id_type ) {
24432443
jQuery( input_file_el ).click();
24442444
file_dialog_open = false;
24452445
}
2446-
$(this).blur();
2446+
jQuery(this).blur();
24472447
} );
24482448

24492449
var form_html = jQuery( "."+comment_media_wrapper+widget_id );
@@ -2621,15 +2621,15 @@ function renderUploadercomment_media( widget_id, parent_id_type ) {
26212621

26222622
if ( 'undefined' != typeof rtmedia_direct_upload_enabled && '1' == rtmedia_direct_upload_enabled ) {
26232623

2624-
$( '.rtmedia-comment-media-submit-' + widget_id ).focus();
2624+
jQuery( '.rtmedia-comment-media-submit-' + widget_id ).focus();
26252625
/* when direct upload is enable */
26262626
jQuery( '.'+rtmedia_comment_media_submit+widget_id ).trigger( 'click' );
26272627
}
26282628

26292629
/**
26302630
* Uploader improper enter behavior issue(124) fixed
26312631
*/
2632-
$('.rtmedia-comment-media-submit-'+widget_id).focus();
2632+
jQuery('.rtmedia-comment-media-submit-'+widget_id).focus();
26332633
/**
26342634
* End of issue 124
26352635
*/
@@ -2739,7 +2739,7 @@ function renderUploadercomment_media( widget_id, parent_id_type ) {
27392739
'class': 'plupload_file_progress ui-widget-header',
27402740
});
27412741
progressBar.css( 'width', file.percent + '%' );
2742-
$( '#' + file.id + ' .plupload_file_status' ).html( progressBar );
2742+
jQuery( '#' + file.id + ' .plupload_file_status' ).html( progressBar );
27432743
// filter to customize existing progress bar can be used to display
27442744
// '%' of upload completed.
27452745
rtMediaHook.call( 'rtm_custom_progress_bar_content', [ file ] );

app/assets/js/rtm-upload-terms.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ if ( 'object' === typeof rtMediaHook ) {
7777
});
7878

7979
rtMediaHook.register( 'rtmedia_js_after_activity_added', function() {
80-
var rtmedia_terms_conditions = $( '#rtmedia_upload_terms_conditions' );
80+
var rtmedia_terms_conditions = jQuery( '#rtmedia_upload_terms_conditions' );
8181
if ( rtmedia_terms_conditions && rtmedia_terms_conditions.is(':checked') ) {
8282
rtmedia_terms_conditions.prop( 'checked', false );
8383
}

app/assets/js/rtm-upload-terms.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/main/RTMedia.php

+1-16
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ public function init_site_options() {
684684
break;
685685
case 'video':
686686
case 'music':
687-
$old = ( 'video' === $type ) ? 'video' : ( 'music' === $type ) ? 'audio' : '';
687+
$old = ( 'video' === $type ) ? 'video' : ( ( 'music' === $type ) ? 'audio' : '' );
688688
switch ( $size ) {
689689
case 'activityPlayer':
690690
if ( isset( $bp_media_options['sizes'][ $old ]['medium'][ $dimension ] ) && ! empty( $bp_media_options['sizes'][ $old ]['medium'][ $dimension ] ) ) {
@@ -1337,21 +1337,6 @@ function enqueue_scripts_styles() {
13371337
if ( empty( $is_buddypress_activate ) ) {
13381338
wp_localize_script( 'rtmedia-main', 'ajaxurl', admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ) );
13391339
}
1340-
1341-
// Only Applay if BP Template Nouveau is activate.
1342-
if ( ! empty( $bp_template ) && 'nouveau' === $bp_template && ( 'group' === $rtmedia_interaction->context->type || 'profile' === $rtmedia_interaction->context->type ) ) {
1343-
$rtmedia_router = new RTMediaRouter();
1344-
if ( ! empty( $rtmedia_router->query_vars ) ) {
1345-
$wp_current_stylesheet = get_stylesheet();
1346-
1347-
// If file is already exists in buddypress then enqueue it.
1348-
if ( file_exists( sprintf( '%sbp-templates/bp-legacy/css/%s.min.css', BP_PLUGIN_DIR, $wp_current_stylesheet ) ) ) {
1349-
wp_enqueue_style( 'bp-nouveau-stylesheet-theme', BP_PLUGIN_URL . 'bp-templates/bp-legacy/css/' . $wp_current_stylesheet . '.min.css' );
1350-
}
1351-
1352-
wp_enqueue_style( 'bp-nouveau-stylesheet-buddypress', BP_PLUGIN_URL . 'bp-templates/bp-legacy/css/buddypress.min.css', '' );
1353-
}
1354-
}
13551340
}
13561341

13571342
function set_bp_bar() {

app/main/controllers/activity/RTMediaBuddyPressActivity.php

+170
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ function __construct() {
2121
// manage user's last activity update.
2222
add_action( 'bp_activity_posted_update', array( &$this, 'manage_user_last_activity_update' ), 999, 3 );
2323
add_action( 'bp_groups_posted_update', array( &$this, 'bp_groups_posted_update' ), 99, 4 );
24+
25+
/**
26+
* Filter to disable bp_activity_truncate_entry override function.
27+
*
28+
* @param boolean By default its enabled.
29+
*/
30+
if ( apply_filters( 'rtmedia_disable_truncate_entry_override', true ) ) {
31+
// Code to show media with read more option.
32+
add_filter( 'bp_activity_truncate_entry', array( $this, 'bp_activity_truncate_entry' ), 10, 3 );
33+
}
2434
}
2535
add_action( 'bp_init', array( $this, 'non_threaded_comments' ) );
2636
add_action( 'bp_activity_comment_posted', array( $this, 'comment_sync' ), 10, 2 );
@@ -64,6 +74,166 @@ function __construct() {
6474
}
6575
}
6676

77+
/**
78+
* Show media even if the text is long with read more option.
79+
*
80+
* @param string $excerpt Excerpt of the activity text.
81+
* @param string $text Actual text of activity.
82+
* @param string $readmore Read more text.
83+
*
84+
* @return string Custom excerpt if conditions are match.
85+
*/
86+
public function bp_activity_truncate_entry( $excerpt, $text, $readmore ) {
87+
// Return if class doesn't exist.
88+
if ( ! class_exists( 'DOMDocument' ) ) {
89+
return $excerpt;
90+
}
91+
92+
global $activities_template;
93+
94+
$excerpt_length = bp_activity_get_excerpt_length();
95+
// Run the text through the excerpt function. If it's too short, the original text will be returned.
96+
$temp_excerpt = bp_create_excerpt( $text, $excerpt_length, array() );
97+
if ( strlen( $temp_excerpt ) >= strlen( strip_shortcodes( $text ) ) ) {
98+
return $excerpt;
99+
}
100+
101+
// Get current activity id.
102+
$activity_id = bp_get_activity_id();
103+
104+
// We need to separate text and rtMedia images, for this we need DOM manipulation.
105+
$dom = new DOMDocument();
106+
// DOMDocument gives error on html5 tags, so we need to disable errors.
107+
libxml_use_internal_errors( true );
108+
$dom->loadHTML( $text );
109+
// DOMDocument gives error on html5 tags, so we need to disable errors.
110+
libxml_clear_errors();
111+
// We need to find div having rtmedia-activity-text class, but no direct method for it.
112+
// So we need to iterate.
113+
$div_list = $dom->getElementsByTagName( 'div' );
114+
115+
// Return if no divs found.
116+
if ( empty( $div_list ) ) {
117+
return $excerpt;
118+
}
119+
120+
// We're storing first div to create final markup.
121+
// If we create markup from dom object, it'll create whole HTML which we don't want.
122+
$first_div = '';
123+
124+
foreach ( $div_list as $div ) {
125+
// Set first div.
126+
if ( empty( $first_div ) ) {
127+
$first_div = $div;
128+
}
129+
130+
// We need div with class attribute.
131+
if ( empty( $div->attributes ) ) {
132+
continue;
133+
}
134+
135+
$atts = $div->attributes;
136+
// Check attributes by iterating them.
137+
foreach ( $atts as $att ) {
138+
if ( empty( $att->name ) || empty( $att->value ) ) {
139+
continue;
140+
}
141+
142+
// Condition to find text div.
143+
if ( 'class' === $att->name && strpos( $att->value, 'rtmedia-activity-text' ) !== false ) {
144+
// Create excerpt only on text and then set it to div text.
145+
// We're using actual length / 2 to make space for image.
146+
$custom_excerpt = bp_create_excerpt( $div->textContent, (int) $excerpt_length / 2, array( 'ending' => '...' ) ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Can't change property name.
147+
$div->textContent = trim( $custom_excerpt ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Can't change property name.
148+
149+
// Show 4 images if text is less, else show 2 images.
150+
$images_to_show = 4;
151+
if ( strlen( $div->textContent ) > 20 ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Can't change property name.
152+
$images_to_show = 2;
153+
}
154+
155+
// Set number of images to show in excerpt.
156+
$dom = $this->get_bp_activity_media_html( $dom, $images_to_show );
157+
158+
// Code copied from buddypress.
159+
$id = ( ! empty( $activities_template->activity->current_comment->id ) ? 'acomment-read-more-' . $activities_template->activity->current_comment->id : 'activity-read-more-' . $activity_id );
160+
161+
// Get final HTML.
162+
$content = $first_div->ownerDocument->saveHTML( $first_div ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Can't change property name.
163+
164+
// Append read more link and text.
165+
$return = sprintf( '%1$s<span class="activity-read-more" id="%2$s"><a href="%3$s" rel="nofollow">%4$s</a></span>', $content, $id, bp_get_activity_thread_permalink(), $readmore );
166+
167+
return $return;
168+
}
169+
}
170+
}
171+
172+
return $excerpt;
173+
}
174+
175+
/**
176+
* Set number of images to show in activity excerpt.
177+
*
178+
* @param object $dom DOMDocument object for DOM manipulation.
179+
* @param int $images_to_show Number of images to show.
180+
*
181+
* @return object Modified DOMDocument object.
182+
*/
183+
private function get_bp_activity_media_html( $dom, $images_to_show ) {
184+
// Get media list which is inside <ul>.
185+
$ul_list = $dom->getElementsByTagName( 'ul' );
186+
187+
// Return if no ul element.
188+
if ( empty( $ul_list ) ) {
189+
return $dom;
190+
}
191+
192+
// Iterate to find out media-list ul.
193+
foreach ( $ul_list as $ul ) {
194+
// We need ul having class 'rtm-activity-media-list'.
195+
if ( empty( $ul->attributes ) ) {
196+
continue;
197+
}
198+
199+
// Iterate attributes.
200+
foreach ( $ul->attributes as $att ) {
201+
if ( empty( $att->name ) || empty( $att->value ) ) {
202+
continue;
203+
}
204+
205+
// Conditions to match required class.
206+
if ( 'class' === $att->name && strpos( $att->value, 'rtm-activity-media-list' ) !== false && count( $ul->childNodes ) > 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Can't change property name.
207+
208+
// Number of li (images) allowed to show.
209+
$count = 1;
210+
// Array where items to remove will be stored.
211+
$items_to_remove = array();
212+
// Iterate all children of ul which are images (li).
213+
foreach ( $ul->childNodes as $li ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Can't change property name.
214+
215+
// If max number of images reached, add li to items_to_remove array.
216+
if ( $count > $images_to_show ) {
217+
$items_to_remove[] = $li;
218+
}
219+
220+
$count++;
221+
}
222+
223+
// Remove images.
224+
foreach ( $items_to_remove as $item ) {
225+
$ul->removeChild( $item );
226+
}
227+
228+
return $dom;
229+
}
230+
}
231+
}
232+
233+
return $dom;
234+
}
235+
236+
67237
/**
68238
* For adding secondary avatar in the activity header.
69239
*

0 commit comments

Comments
 (0)