Skip to content

Commit

Permalink
Merge pull request #2027 from rtCamp/develop
Browse files Browse the repository at this point in the history
Release version 4.6.17
  • Loading branch information
pavanpatil1 authored Dec 28, 2023
2 parents 8639be4 + 2635347 commit 0ed2115
Show file tree
Hide file tree
Showing 26 changed files with 573 additions and 628 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ https://www.youtube.com/watch?v=dJrykKQGDcs

## Changelog ##

### 4.6.17 [December 28, 2023] ###

* Enhancement

* Compatible with WordPress latest version 6.4.2
* Compatible with BuddyPress latest version 12.0.0

* Fixed

* Fixed PHP compatibility issue.
* Fixed issues related to Twenty Twenty Four theme.

### 4.6.16 [November 16, 2023] ###

* Enhancement
Expand Down
16 changes: 9 additions & 7 deletions app/admin/RTMediaFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,12 @@ public static function types_render_options( $options ) {
}

foreach ( $options as $key => $value ) {
$data = explode( '_', $key );
$data = explode( '_', $key );

if ( false === $render[ $data[1] ] ) {
$render[ $data[1] ] = array();
}

$render[ $data[1] ][ $data[2] ] = $value;
}

Expand Down Expand Up @@ -1227,7 +1232,6 @@ public static function buddypress_content() {
</script>
<?php
}

}

/**
Expand Down Expand Up @@ -1272,12 +1276,10 @@ public static function rtForm_do_settings_fields( $page, $section ) { // phpcs:i

if ( isset( $field['args']['label_for'] ) && ! empty( $field['args']['label_for'] ) ) {
call_user_func( $field['callback'], array_merge( $field['args'], array( 'label' => $field['args']['label_for'] ) ) );
} else {
if ( isset( $field['title'] ) && ! empty( $field['title'] ) ) {
} elseif ( isset( $field['title'] ) && ! empty( $field['title'] ) ) {
call_user_func( $field['callback'], array_merge( $field['args'], array( 'label' => $field['title'] ) ) );
} else {
call_user_func( $field['callback'], $field['args'] );
}
} else {
call_user_func( $field['callback'], $field['args'] );
}
echo '</div>';
echo '</div>';
Expand Down
10 changes: 10 additions & 0 deletions app/assets/css/rtmedia.css
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ body.media.buddypress {
align-items: center;
}

#buddypress.buddypress-wrap .bp-navs.bp-priority-nav {
overflow: unset;
}

.bp-priority-nav {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}

.rtmedia-container {
box-sizing: border-box;
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/css/rtmedia.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/css/rtmedia.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/css/rtmedia.min.css.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions app/assets/css/sass/_buddypress.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,12 @@ body.media.buddypress {
display: flex;
align-items: center;
}

// Fix BuddyPress Nouveau issue in 2024 theme
#buddypress.buddypress-wrap .bp-navs.bp-priority-nav {
overflow: unset;
}

.bp-priority-nav {
display: flex;
}
3 changes: 2 additions & 1 deletion app/assets/js/rtMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ var rtMediaHook = {
call: function( name, arguments ) {
if ( 'undefined' != typeof ( rtMediaHook.hooks[name] ) ) {
for ( i = 0; i < rtMediaHook.hooks[name].length; ++i ) {
if ( true != rtMediaHook.hooks[name][i]( arguments ) ) {
var result = rtMediaHook.hooks[name][i]( arguments );
if ( false === result || 0 === result ) {
rtMediaHook.is_break = true;
return false;
break;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/js/rtmedia.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/helper/RTMediaModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function get_group_albums( $group_id, $offset, $per_page, $order_by = 'me
}

$rtm_post_table = $wpdb->prefix . 'posts';
$where = $wpdb->prepare( " WHERE ( {$this->table_name}.id IN( $sub_sql ) OR (media_type = 'album' AND context_id = %d AND context = 'group') )", $group_id ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$where = $wpdb->prepare( " WHERE ( {$this->table_name}.id IN( $sub_sql ) OR (media_type = 'album' AND (context_id = %d OR context_id IS NULL) AND (context = 'group' OR context IS NULL) ) )", $group_id ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared

$where = apply_filters( 'rtmedia-get-group-album-where-query', $where, $this->table_name ); // phpcs:ignore
$sql = "SELECT * FROM $this->table_name INNER JOIN $rtm_post_table AS post_table ON post_table.id = $this->table_name.media_id and post_table.post_type = 'rtmedia_album'";
Expand Down
62 changes: 28 additions & 34 deletions app/importers/RTMediaMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,26 +278,26 @@ public function get_done_count( $flag = false ) {
if ( 5 === $state ) {
$album_count = intval( $_SESSION['migration_user_album'] );
$album_count += ( isset( $_SESSION['migration_group_album'] ) ) ? intval( $_SESSION['migration_group_album'] ) : 0;
} else {
if ( $state > 0 ) {
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
$bp_prefix = bp_core_get_table_prefix();
} else {
$bp_prefix = '';
}
$pending_count = "select count(*) from $wpdb->posts where post_type='bp_media_album' and ( ID in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') ";
if ( $this->table_exists( $bp_prefix . 'bp_groups_groupmeta' ) ) {
$pending_count .= " or ID in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album')";
}
} elseif ( $state > 0 ) {
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
$bp_prefix = bp_core_get_table_prefix();
} else {
$bp_prefix = '';
}

$pending_count = "select count(*) from $wpdb->posts where post_type='bp_media_album' and ( ID in (select meta_value FROM $wpdb->usermeta where meta_key ='bp-media-default-album') ";

if ( $this->table_exists( $bp_prefix . 'bp_groups_groupmeta' ) ) {
$pending_count .= " or ID in (select meta_value FROM {$bp_prefix}bp_groups_groupmeta where meta_key ='bp_media_default_album')";
}
$pending_count .= ')';
$pending_count = $wpdb->get_var( $pending_count ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared

$album_count = intval( $_SESSION['migration_user_album'] );
$album_count += ( isset( $_SESSION['migration_group_album'] ) ) ? intval( $_SESSION['migration_group_album'] ) : 0;
$album_count = $album_count - intval( $pending_count );
} else {
$album_count = 0;
}
} else {
$album_count = 0;
}

if ( isset( $_SESSION['migration_activity'] ) && intval( $_SESSION['migration_media'] ) === intval( $media_count ) ) {
Expand Down Expand Up @@ -815,18 +815,14 @@ public function migrate_single_media( $result, $album = false ) {
if ( 0 === strpos( $mime_type, 'image' ) ) {
$media_type = 'photo';
$old_type = 'photos';
} else {
if ( 0 === strpos( $mime_type, 'audio' ) ) {
} elseif ( 0 === strpos( $mime_type, 'audio' ) ) {
$media_type = 'music';
$old_type = 'music';
} else {
if ( 0 === strpos( $mime_type, 'video' ) ) {
$media_type = 'video';
$old_type = 'videos';
} else {
$media_type = 'other';
}
}
} elseif ( 0 === strpos( $mime_type, 'video' ) ) {
$media_type = 'video';
$old_type = 'videos';
} else {
$media_type = 'other';
}
}

Expand Down Expand Up @@ -900,7 +896,7 @@ public function migrate_single_media( $result, $album = false ) {

$last_id = $wpdb->insert_id;

if ( 'album' !== $media_type && function_exists( 'bp_core_get_user_domain' ) && $activity_data ) {
if ( 'album' !== $media_type && ( function_exists( 'bp_core_get_user_domain' ) || function_exists( 'bp_members_get_user_url' ) ) && $activity_data ) {
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
$bp_prefix = bp_core_get_table_prefix();
} else {
Expand Down Expand Up @@ -929,20 +925,18 @@ public function migrate_single_media( $result, $album = false ) {
),
array( 'id' => $activity_data->id )
);
} else {
if ( 'group' === $media_context ) {
} else if ( 'group' === $media_context ) {
$activity_data->old_primary_link = $activity_data->primary_link;
$parent_link = get_rtmedia_group_link( abs( intval( $result->context_id ) ) );
$parent_link = trailingslashit( $parent_link );
$activity_data->primary_link = trailingslashit( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id );
$this->search_and_replace( $activity_data->old_primary_link, $activity_data->primary_link );
} else {
$activity_data->old_primary_link = $activity_data->primary_link;
$parent_link = get_rtmedia_user_link( $activity_data->user_id );
$parent_link = trailingslashit( $parent_link );
$activity_data->primary_link = trailingslashit( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id );
$this->search_and_replace( $activity_data->old_primary_link, $activity_data->primary_link );
}
} else {
$activity_data->old_primary_link = $activity_data->primary_link;
$parent_link = get_rtmedia_user_link( $activity_data->user_id );
$parent_link = trailingslashit( $parent_link );
$activity_data->primary_link = trailingslashit( $parent_link . RTMEDIA_MEDIA_SLUG . '/' . $last_id );
$this->search_and_replace( $activity_data->old_primary_link, $activity_data->primary_link );
}
if ( '' !== $old_type ) {
if ( 'group' === $media_context ) {
Expand Down
71 changes: 40 additions & 31 deletions app/main/RTMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,13 @@ public function media_screen() {
*/
public function get_user_link( $user ) {

if ( function_exists( 'bp_core_get_user_domain' ) ) {
$parent_link = bp_core_get_user_domain( $user );
} else {
$parent_link = get_author_posts_url( $user );
if ( function_exists( 'bp_members_get_user_url' ) ) {
return bp_members_get_user_url( $user );
} else if ( function_exists( 'bp_core_get_user_domain' ) ) {
return bp_core_get_user_domain( $user );
}

return $parent_link;
return get_author_posts_url( $user );
}

/**
Expand Down Expand Up @@ -1273,7 +1273,7 @@ public function enqueue_scripts_styles() {
array(
'jquery',
'rt-mediaelement-wp',
'rtmedia-emoji-picker'
'rtmedia-emoji-picker',
),
RTMEDIA_VERSION,
true
Expand Down Expand Up @@ -1670,16 +1670,18 @@ public function enqueue_scripts_styles() {
wp_localize_script( 'rtmedia-backbone', 'rtMedia_update_plupload_config', $params );
}

wp_enqueue_script(
'rtmedia-activity',
RTMEDIA_URL . 'app/assets/js/rtMedia.activity.js',
array(
'bp-nouveau',
'rtmedia-backbone'
),
RTMEDIA_VERSION,
true
);
if ( function_exists( 'bp_nouveau' ) ) {
wp_enqueue_script(
'rtmedia-activity',
RTMEDIA_URL . 'app/assets/js/rtMedia.activity.js',
array(
'bp-nouveau',
'rtmedia-backbone',
),
RTMEDIA_VERSION,
true
);
}
}

/**
Expand Down Expand Up @@ -1976,7 +1978,7 @@ public static function allow_display_in_style( $styles ) {
*
* @return string
*/
function parentlink_global_album( $id ) {
function parentlink_global_album( $id ) { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed
$global_albums = RTMediaAlbum::get_globals();
$parent_link = '';

Expand Down Expand Up @@ -2025,15 +2027,13 @@ function get_rtmedia_permalink( $id ) {
$parent_link = get_rtmedia_user_link( $media[0]->media_author );
}
}
} else {
if ( isset( $media[0]->context ) && function_exists( 'bp_get_groups_root_slug' ) && 'group' === $media[0]->context ) {
} elseif ( isset( $media[0]->context ) && function_exists( 'bp_get_groups_root_slug' ) && 'group' === $media[0]->context ) {
$parent_link = get_rtmedia_group_link( $media[0]->context_id );
} else {
// check for global album.
$parent_link = parentlink_global_album( $id );
if ( '' === $parent_link && isset( $media[0]->media_author ) ) {
$parent_link = get_rtmedia_user_link( $media[0]->media_author );
}
} else {
// check for global album.
$parent_link = parentlink_global_album( $id );
if ( '' === $parent_link && isset( $media[0]->media_author ) ) {
$parent_link = get_rtmedia_user_link( $media[0]->media_author );
}
}

Expand Down Expand Up @@ -2065,13 +2065,14 @@ function get_rtmedia_permalink( $id ) {
* @return string
*/
function get_rtmedia_user_link( $id ) {
if ( function_exists( 'bp_core_get_user_domain' ) ) {
$parent_link = bp_core_get_user_domain( $id );
} else {
$parent_link = get_author_posts_url( $id );

if ( function_exists( 'bp_members_get_user_url' ) ) {
return bp_members_get_user_url( $id );
} else if ( function_exists( 'bp_core_get_user_domain' ) ) {
return bp_core_get_user_domain( $id );
}

return $parent_link;
return get_author_posts_url( $id );
}

/**
Expand All @@ -2098,9 +2099,17 @@ function rtmedia_update_site_option( $option_name, $option_value ) {
* @return mixed|void
*/
function get_rtmedia_group_link( $group_id ) {
global $bp;

$group = groups_get_group( array( 'group_id' => $group_id ) );

return apply_filters( 'rtmedia_get_group_link', bp_get_group_permalink( $group ) );
if ( isset( $bp->version ) && version_compare( $bp->version, '12.0.0', 'ge' ) ) {
$group_link = bp_get_group_url( $group );
} else {
$group_link = bp_get_group_permalink( $group );
}

return apply_filters( 'rtmedia_get_group_link', $group_link );
}

/**
Expand Down
Loading

0 comments on commit 0ed2115

Please sign in to comment.