diff --git a/app/assets/js/rtMedia.backbone.js b/app/assets/js/rtMedia.backbone.js index cfbc7e26a..5ea033882 100755 --- a/app/assets/js/rtMedia.backbone.js +++ b/app/assets/js/rtMedia.backbone.js @@ -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' } ); diff --git a/app/helper/RTMediaModel.php b/app/helper/RTMediaModel.php index 0b5ed5f9a..cb2a6a68f 100755 --- a/app/helper/RTMediaModel.php +++ b/app/helper/RTMediaModel.php @@ -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' ) ) { @@ -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( @@ -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; diff --git a/app/main/controllers/template/RTMediaTemplate.php b/app/main/controllers/template/RTMediaTemplate.php index 4661967ec..05c01a462 100755 --- a/app/main/controllers/template/RTMediaTemplate.php +++ b/app/main/controllers/template/RTMediaTemplate.php @@ -367,16 +367,22 @@ public function save_single_edit() { $data = rtmedia_sanitize_object( $_POST, $data_array ); $media = new RTMediaMedia(); - $image_path = get_attached_file( $rtmedia_query->media[0]->media_id ); - - if ( $image_path && 'photo' === $rtmedia_query->media[0]->media_type ) { + if ( isset( $rtmedia_query->media[0]->media_id ) ) { + $image_path = get_attached_file( $rtmedia_query->media[0]->media_id ); + } else { + $image_path = ''; // or handle the error as needed + } + if ( isset( $rtmedia_query->media[0] ) && 'photo' === $rtmedia_query->media[0]->media_type ) { $image_meta_data = wp_generate_attachment_metadata( $rtmedia_query->media[0]->media_id, $image_path ); wp_update_attachment_metadata( $rtmedia_query->media[0]->media_id, $image_meta_data ); } - $state = $media->update( $rtmedia_query->action_query->id, $data, $rtmedia_query->media[0]->media_id ); - + if ( isset( $rtmedia_query->action_query->id ) && isset( $rtmedia_query->media[0]->media_id ) ) { + $state = $media->update( $rtmedia_query->action_query->id, $data, $rtmedia_query->media[0]->media_id ); + } else { + $state = false; // or handle the error as needed + } $rtmedia_filepath_old = sanitize_text_field( filter_input( INPUT_POST, 'rtmedia-filepath-old', FILTER_SANITIZE_FULL_SPECIAL_CHARS ) ); if ( isset( $rtmedia_filepath_old ) ) { $is_valid_url = preg_match( "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $rtmedia_filepath_old ); @@ -423,22 +429,24 @@ public function save_single_edit() { // refresh. $rtmedia_nav = new RTMediaNav(); - if ( 'group' === $rtmedia_query->media[0]->context ) { - $rtmedia_nav->refresh_counts( - $rtmedia_query->media[0]->context_id, - array( - 'context' => $rtmedia_query->media[0]->context, - 'context_id' => $rtmedia_query->media[0]->context_id, - ) - ); - } else { - $rtmedia_nav->refresh_counts( - $rtmedia_query->media[0]->media_author, - array( - 'context' => 'profile', - 'media_author' => $rtmedia_query->media[0]->media_author, - ) - ); + if ( isset( $rtmedia_query->media[0] ) && isset( $rtmedia_query->media[0]->context ) ) { + if ( 'group' === $rtmedia_query->media[0]->context ) { + $rtmedia_nav->refresh_counts( + $rtmedia_query->media[0]->context_id, + array( + 'context' => $rtmedia_query->media[0]->context, + 'context_id' => $rtmedia_query->media[0]->context_id, + ) + ); + } else { + $rtmedia_nav->refresh_counts( + $rtmedia_query->media[0]->media_author, + array( + 'context' => 'profile', + 'media_author' => $rtmedia_query->media[0]->media_author, + ) + ); + } } $state = apply_filters( 'rtmedia_single_edit_state', $state ); diff --git a/app/main/controllers/template/rtmedia-actions.php b/app/main/controllers/template/rtmedia-actions.php index c19e3b6d0..8bdb8833f 100644 --- a/app/main/controllers/template/rtmedia-actions.php +++ b/app/main/controllers/template/rtmedia-actions.php @@ -124,7 +124,7 @@ function rtmedia_add_album_selection_field( $media_type ) { } ?>