Skip to content

Commit

Permalink
fix: Docs Media Count when uploading docs
Browse files Browse the repository at this point in the history
  • Loading branch information
the-hercules committed Sep 17, 2024
1 parent 447369f commit 77f6d2b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/assets/js/rtMedia.backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ jQuery( function( $ ) {
jQuery( '#rtmedia-nav-item-photo span' ).text( response.media_count.photos_count );
jQuery( '#rtmedia-nav-item-music span' ).text( response.media_count.music_count );
jQuery( '#rtmedia-nav-item-video span' ).text( response.media_count.videos_count );
jQuery( '#rtmedia-nav-item-document span' ).text( response.media_count.docs_count );


if ( jQuery( 'li#rtm-url-upload' ).length === 0 ) {
jQuery( '#' + current_gallery_id + ' .rtmedia-list' ).css( { 'opacity': 1, 'height': 'auto', 'overflow': 'auto' } );
Expand Down
3 changes: 3 additions & 0 deletions app/helper/RTMediaModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ public function get_media_count() {
$remaining_music = 0;
$remaining_videos = 0;
$remaining_all_media = 0;
$remaining_docs = 0;

// Fetch the remaining media count.
if ( class_exists( 'RTMediaNav' ) ) {
Expand All @@ -512,6 +513,7 @@ public function get_media_count() {
$remaining_photos = ( ! empty( $counts['total']['photo'] ) ) ? $counts['total']['photo'] : 0;
$remaining_videos = ( ! empty( $counts['total']['video'] ) ) ? $counts['total']['video'] : 0;
$remaining_music = ( ! empty( $counts['total']['music'] ) ) ? $counts['total']['music'] : 0;
$remaining_docs = ( ! empty( $counts['total']['document'] ) ) ? $counts['total']['document'] : 0;
}

$media_counts = array(
Expand All @@ -520,6 +522,7 @@ public function get_media_count() {
'music_count' => $remaining_music,
'videos_count' => $remaining_videos,
'albums_count' => $remaining_album,
'docs_count' => $remaining_docs,
);

return $media_counts;
Expand Down
2 changes: 2 additions & 0 deletions app/main/controllers/template/rtmedia-ajax-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function rtmedia_delete_uploaded_media() {
$remaining_photos = ( ! empty( $counts['total']['photo'] ) ) ? $counts['total']['photo'] : 0;
$remaining_videos = ( ! empty( $counts['total']['video'] ) ) ? $counts['total']['video'] : 0;
$remaining_music = ( ! empty( $counts['total']['music'] ) ) ? $counts['total']['music'] : 0;
$remaining_docs = ( ! empty( $counts['total']['document'] ) ) ? $counts['total']['document'] : 0;
}

wp_send_json_success(
Expand All @@ -62,6 +63,7 @@ function rtmedia_delete_uploaded_media() {
'music_count' => $remaining_music,
'videos_count' => $remaining_videos,
'albums_count' => $remaining_album,
'docs_count' => $remaining_docs,
)
);

Expand Down

0 comments on commit 77f6d2b

Please sign in to comment.