Changeset 3307451
- Timestamp:
- 06/06/2025 09:58:10 AM (10 months ago)
- Location:
- buddypress-media
- Files:
-
- 12 edited
- 1 copied
-
tags/4.7.1 (copied) (copied from buddypress-media/trunk)
-
tags/4.7.1/app/assets/js/godam-integration.js (modified) (1 diff)
-
tags/4.7.1/app/assets/js/godam-integration.min.js (modified) (1 diff)
-
tags/4.7.1/app/main/RTMedia.php (modified) (1 diff)
-
tags/4.7.1/app/main/controllers/template/rtmedia-functions.php (modified) (13 diffs)
-
tags/4.7.1/index.php (modified) (2 diffs)
-
tags/4.7.1/readme.txt (modified) (3 diffs)
-
trunk/app/assets/js/godam-integration.js (modified) (1 diff)
-
trunk/app/assets/js/godam-integration.min.js (modified) (1 diff)
-
trunk/app/main/RTMedia.php (modified) (1 diff)
-
trunk/app/main/controllers/template/rtmedia-functions.php (modified) (13 diffs)
-
trunk/index.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
buddypress-media/tags/4.7.1/app/assets/js/godam-integration.js
r3305192 r3307451 63 63 } 64 64 65 if (node.classList?.contains('activity')) { 65 // Check for either 'activity' or 'groups' class. 66 if (node.classList?.contains('activity') || node.classList?.contains('groups')) { 66 67 setTimeout(() => safeGODAMPlayer(node), 100); 67 68 } -
buddypress-media/tags/4.7.1/app/assets/js/godam-integration.min.js
r3305192 r3307451 1 const safeGODAMPlayer=(e=null)=>{try{return e&&1===e.nodeType&&e.isConnected?GODAMPlayer(e):GODAMPlayer(),!0}catch(e){return!1}};safeGODAMPlayer();let popupInitTimeout=null;const initializePopupVideos=()=>{clearTimeout(popupInitTimeout),popupInitTimeout=setTimeout((()=>{const e=document.querySelector(".mfp-content");if(e){e.querySelectorAll("video").length>0&&(safeGODAMPlayer(e)||safeGODAMPlayer())}}),200)};document.addEventListener("DOMContentLoaded",(()=>{safeGODAMPlayer();new MutationObserver((e=>{for(const t of e)for(const e of t.addedNodes)if(1===e.nodeType){const t=e.classList?.contains("mfp-content")||e.querySelector?.(".mfp-content"),o="VIDEO"===e.tagName||e.querySelector?.("video");(t||o&&e.closest(".mfp-content"))&&initializePopupVideos(), e.classList?.contains("activity")&&setTimeout((()=>safeGODAMPlayer(e)),100)}})).observe(document.body,{childList:!0,subtree:!0}),"undefined"!=typeof $&&$.magnificPopup&&($(document).on("mfpOpen mfpChange",(()=>{initializePopupVideos()})),$(document).on("mfpOpen",(()=>{setTimeout(initializePopupVideos,500)})))}));1 const safeGODAMPlayer=(e=null)=>{try{return e&&1===e.nodeType&&e.isConnected?GODAMPlayer(e):GODAMPlayer(),!0}catch(e){return!1}};safeGODAMPlayer();let popupInitTimeout=null;const initializePopupVideos=()=>{clearTimeout(popupInitTimeout),popupInitTimeout=setTimeout((()=>{const e=document.querySelector(".mfp-content");if(e){e.querySelectorAll("video").length>0&&(safeGODAMPlayer(e)||safeGODAMPlayer())}}),200)};document.addEventListener("DOMContentLoaded",(()=>{safeGODAMPlayer();new MutationObserver((e=>{for(const t of e)for(const e of t.addedNodes)if(1===e.nodeType){const t=e.classList?.contains("mfp-content")||e.querySelector?.(".mfp-content"),o="VIDEO"===e.tagName||e.querySelector?.("video");(t||o&&e.closest(".mfp-content"))&&initializePopupVideos(),(e.classList?.contains("activity")||e.classList?.contains("groups"))&&setTimeout((()=>safeGODAMPlayer(e)),100)}})).observe(document.body,{childList:!0,subtree:!0}),"undefined"!=typeof $&&$.magnificPopup&&($(document).on("mfpOpen mfpChange",(()=>{initializePopupVideos()})),$(document).on("mfpOpen",(()=>{setTimeout(initializePopupVideos,500)})))})); -
buddypress-media/tags/4.7.1/app/main/RTMedia.php
r3305192 r3307451 1268 1268 ), 1269 1269 RTMEDIA_VERSION, 1270 args:true1270 true 1271 1271 ); 1272 1272 } else { -
buddypress-media/tags/4.7.1/app/main/controllers/template/rtmedia-functions.php
r3305192 r3307451 594 594 if ( defined( 'RTMEDIA_GODAM_ACTIVE' ) && RTMEDIA_GODAM_ACTIVE ) { 595 595 $html .= do_shortcode( '[godam_video id="' . esc_attr( $rtmedia_media->media_id ) . '"]' ); 596 } elseif ( empty( $youtube_url ) ) { 597 $html .= sprintf( 598 '<video poster="%1$s" src="%2$s"%3$s type="video/mp4" class="wp-video-shortcode" id="rt_media_video_%4$s" controls="controls" preload="metadata" playsinline></video>', 599 esc_url( ! empty( $rtmedia_media->cover_art ) ? $rtmedia_media->cover_art : '' ), 600 esc_url( wp_get_attachment_url( $rtmedia_media->media_id ) ), 601 $size_attr, 602 esc_attr( $rtmedia_media->id ) 603 ); 596 604 } else { 597 // Fallback to native or YouTube player. 598 if ( empty( $youtube_url ) ) { 599 $html .= sprintf( 600 '<video poster="%1$s" src="%2$s"%3$s type="video/mp4" class="wp-video-shortcode" id="rt_media_video_%4$s" controls="controls" preload="metadata" playsinline></video>', 601 esc_url( $rtmedia_media->cover_art ?: '' ), 602 esc_url( wp_get_attachment_url( $rtmedia_media->media_id ) ), 603 $size_attr, 604 esc_attr( $rtmedia_media->id ) 605 ); 606 } else { 607 $html .= sprintf( 608 '<video width="640" height="360" class="url-video" id="video-id-%1$s" preload="none" playsinline><source type="video/youtube" src="%2$s" /></video>', 609 esc_attr( $rtmedia_media->id ), 610 esc_url( $youtube_url ) 611 ); 612 } 605 $html .= sprintf( 606 '<video width="640" height="360" class="url-video" id="video-id-%1$s" preload="none" playsinline><source type="video/youtube" src="%2$s" /></video>', 607 esc_attr( $rtmedia_media->id ), 608 esc_url( $youtube_url ) 609 ); 613 610 } 614 611 … … 998 995 999 996 $flag = false; 1000 if ( $rtmedia_media !== null&& isset( $rtmedia_media->media_author ) ) {997 if ( null !== $rtmedia_media && isset( $rtmedia_media->media_author ) ) { 1001 998 $flag = intval( $rtmedia_media->media_author ) === get_current_user_id(); 1002 999 } … … 1026 1023 1027 1024 $flag = false; 1028 if ( $rtmedia_media !== null&& isset( $rtmedia_media->media_author ) ) {1025 if ( null !== $rtmedia_media && isset( $rtmedia_media->media_author ) ) { 1029 1026 $flag = intval( $rtmedia_media->media_author ) === get_current_user_id(); 1030 1027 } … … 1483 1480 global $wpdb; 1484 1481 1485 // Replace all <video> tags with ID pattern rt_media_video_{id} 1482 // Replace all <video> tags with ID pattern rt_media_video_{id}. 1486 1483 $html = preg_replace_callback( 1487 1484 '#<video[^>]*id="rt_media_video_(\d+)"[^>]*>.*?</video>#is', 1488 function ( $matches ) use ( $wpdb ) {1489 $extracted_id = intval( $matches[1] ); // Extract numeric ID from video tag 1490 1491 // Fetch media_id from rt_rtm_media table using the extracted ID 1485 function ( $matches ) use ( $wpdb ) { 1486 $extracted_id = intval( $matches[1] ); // Extract numeric ID from video tag. 1487 1488 // Fetch media_id from rt_rtm_media table using the extracted ID. 1492 1489 $media_id = $wpdb->get_var( 1493 1490 $wpdb->prepare( … … 1497 1494 ); 1498 1495 1499 // If media_id exists, return Godam video shortcode 1496 // If media_id exists, return Godam video shortcode. 1500 1497 if ( ! empty( $media_id ) ) { 1501 1498 return '<div style="max-width: 480px; width: 100%; overflow: hidden;">' … … 1505 1502 } 1506 1503 1507 // If no media_id found, return original video HTML 1504 // If no media_id found, return original video HTML. 1508 1505 return $matches[0]; 1509 1506 }, … … 5234 5231 add_action( 'wp_enqueue_scripts', 'enqueue_scripts_globally', 20 ); 5235 5232 5233 /** 5234 * Enqueues all necessary frontend scripts and styles globally for the Godam player. 5235 * 5236 * This includes the player script, analytics script, and both frontend and core styles. 5237 * Intended to be called on every page load where the player may be used. 5238 * 5239 * @return void 5240 */ 5236 5241 function enqueue_scripts_globally() { 5237 5242 wp_enqueue_script( 'godam-player-frontend-script' ); … … 5244 5249 * Enqueue frontend scripts for Godam integration and AJAX refresh. 5245 5250 */ 5246 add_action( 'wp_enqueue_scripts', function() { 5247 5248 // Enqueue integration script for rtMedia and Godam. 5249 wp_enqueue_script( 5250 'godam-rtmedia-integration', 5251 RTMEDIA_URL . 'app/assets/js/godam-integration.min.js', 5252 [ 'godam-player-frontend-script' ], 5253 null, 5254 true 5255 ); 5256 5257 // Enqueue the script responsible for AJAX-based comment refresh. 5258 wp_enqueue_script( 5259 'godam-ajax-refresh', 5260 RTMEDIA_URL . 'app/assets/js/godam-ajax-refresh.min.js', 5261 [], 5262 null, 5263 true 5264 ); 5265 5266 // Pass AJAX URL and nonce to the script. 5267 wp_localize_script( 'godam-ajax-refresh', 'GodamAjax', [ 5268 'ajax_url' => admin_url( 'admin-ajax.php' ), 5269 'nonce' => wp_create_nonce( 'godam-ajax-nonce' ), 5270 ]); 5271 } ); 5251 add_action( 5252 'wp_enqueue_scripts', 5253 function () { 5254 5255 // Enqueue integration script for rtMedia and Godam. 5256 wp_enqueue_script( 5257 'godam-rtmedia-integration', 5258 RTMEDIA_URL . 'app/assets/js/godam-integration.min.js', 5259 array( 'godam-player-frontend-script' ), 5260 null, 5261 true 5262 ); 5263 5264 // Enqueue the script responsible for AJAX-based comment refresh. 5265 wp_enqueue_script( 5266 'godam-ajax-refresh', 5267 RTMEDIA_URL . 'app/assets/js/godam-ajax-refresh.min.js', 5268 array(), 5269 null, 5270 true 5271 ); 5272 5273 // Pass AJAX URL and nonce to the script. 5274 wp_localize_script( 5275 'godam-ajax-refresh', 5276 'GodamAjax', 5277 array( 5278 'ajax_url' => admin_url( 'admin-ajax.php' ), 5279 'nonce' => wp_create_nonce( 'godam-ajax-nonce' ), 5280 ) 5281 ); 5282 } 5283 ); 5272 5284 5273 5285 /** … … 5275 5287 * with Godam player shortcodes. 5276 5288 */ 5277 add_filter( 'bp_get_activity_content_body', function( $content ) { 5278 global $activities_template; 5279 5280 // Bail early if activity object is not available 5281 if ( empty( $activities_template->activity ) || ! is_object( $activities_template->activity ) ) { 5282 return $content; 5283 } 5284 5285 $activity = $activities_template->activity; 5286 5287 // Allow only certain activity types 5288 $valid_types = [ 'rtmedia_update', 'activity_update', 'activity_comment' ]; 5289 if ( ! isset( $activity->type ) || ! in_array( $activity->type, $valid_types, true ) ) { 5290 return $content; 5291 } 5292 5293 // Ensure RTMediaModel class exists 5294 if ( ! class_exists( 'RTMediaModel' ) ) { 5295 return $content; 5296 } 5297 5298 $model = new RTMediaModel(); 5299 $media_items = $model->get( [ 'activity_id' => $activity->id ] ); 5300 5301 if ( empty( $media_items ) || ! is_array( $media_items ) ) { 5302 return $content; 5303 } 5304 5305 // Remove rtMedia default video <ul> 5306 $clean_content = preg_replace( 5307 '#<ul[^>]*class="[^"]*rtmedia-list[^"]*rtm-activity-media-list[^"]*rtmedia-activity-media-length-[0-9]+[^"]*rtm-activity-video-list[^"]*"[^>]*>.*?</ul>#si', 5308 '', 5309 $activity->content 5310 ); 5311 5312 // Group media by type 5313 $grouped_media = []; 5314 foreach ( $media_items as $media ) { 5315 $grouped_media[ $media->media_type ][] = $media; 5316 } 5317 5318 $godam_videos = ''; 5319 5320 // Build Godam player shortcodes for videos 5321 if ( ! empty( $grouped_media['video'] ) ) { 5322 foreach ( $grouped_media['video'] as $index => $video ) { 5323 $player_id = 'godam-activity-' . esc_attr( $activity->id ) . '-' . $index; 5324 $godam_videos .= do_shortcode( 5325 '[godam_video id="' . esc_attr( $video->media_id ) . 5326 '" context="buddypress" player_id="' . esc_attr( $player_id ) . '"]' 5327 ); 5289 add_filter( 5290 'bp_get_activity_content_body', 5291 function ( $content ) { 5292 global $activities_template; 5293 5294 // Bail early if activity object is not available. 5295 if ( empty( $activities_template->activity ) || ! is_object( $activities_template->activity ) ) { 5296 return $content; 5328 5297 } 5329 } 5330 5331 // Process video media in activity comments 5332 if ( ! empty( $activity->children ) && is_array( $activity->children ) ) { 5333 foreach ( $activity->children as $child ) { 5334 $child_media = $model->get( [ 'activity_id' => $child->id ] ); 5335 5336 if ( empty( $child_media ) ) { 5337 continue; 5338 } 5339 5340 $child_videos = ''; 5341 5342 foreach ( $child_media as $index => $video ) { 5343 $player_id = 'godam-comment-' . esc_attr( $child->id ) . '-' . $index; 5344 $child_videos .= do_shortcode( 5345 '[godam_video id="' . esc_attr( $video->media_id ) . '"]' 5298 5299 $activity = $activities_template->activity; 5300 5301 // Allow only certain activity types. 5302 $valid_types = array( 'rtmedia_update', 'activity_update', 'activity_comment' ); 5303 if ( ! isset( $activity->type ) || ! in_array( $activity->type, $valid_types, true ) ) { 5304 return $content; 5305 } 5306 5307 // Ensure RTMediaModel class exists. 5308 if ( ! class_exists( 'RTMediaModel' ) ) { 5309 return $content; 5310 } 5311 5312 $model = new RTMediaModel(); 5313 $media_items = $model->get( array( 'activity_id' => $activity->id ) ); 5314 5315 if ( empty( $media_items ) || ! is_array( $media_items ) ) { 5316 return $content; 5317 } 5318 5319 // Remove rtMedia default video <ul>. 5320 $clean_content = preg_replace( 5321 '#<ul[^>]*class="[^"]*rtmedia-list[^"]*rtm-activity-media-list[^"]*rtmedia-activity-media-length-[0-9]+[^"]*rtm-activity-video-list[^"]*"[^>]*>.*?</ul>#si', 5322 '', 5323 $activity->content 5324 ); 5325 5326 // Group media by type. 5327 $grouped_media = array(); 5328 foreach ( $media_items as $media ) { 5329 $grouped_media[ $media->media_type ][] = $media; 5330 } 5331 5332 $godam_videos = ''; 5333 5334 // Build Godam player shortcodes for videos. 5335 if ( ! empty( $grouped_media['video'] ) ) { 5336 foreach ( $grouped_media['video'] as $index => $video ) { 5337 $player_id = 'godam-activity-' . esc_attr( $activity->id ) . '-' . $index; 5338 $godam_videos .= do_shortcode( 5339 '[godam_video id="' . esc_attr( $video->media_id ) . 5340 '" context="buddypress" player_id="' . esc_attr( $player_id ) . '"]' 5346 5341 ); 5347 5342 } 5348 5349 if ( $child_videos ) { 5350 // Remove rtMedia <ul> from comment 5351 $child->content = preg_replace( 5352 '#<ul[^>]*class="[^"]*rtmedia-list[^"]*rtm-activity-media-list[^"]*rtmedia-activity-media-length-[0-9]+[^"]*rtm-activity-video-list[^"]*"[^>]*>.*?</ul>#si', 5353 '', 5354 $child->content 5355 ); 5356 5357 // Append Godam video players 5358 $child->content .= '<div class="godam-video-players-wrapper">' . $child_videos . '</div>'; 5343 } 5344 5345 // Process video media in activity comments. 5346 if ( ! empty( $activity->children ) && is_array( $activity->children ) ) { 5347 foreach ( $activity->children as $child ) { 5348 $child_media = $model->get( array( 'activity_id' => $child->id ) ); 5349 5350 if ( empty( $child_media ) ) { 5351 continue; 5352 } 5353 5354 $child_videos = ''; 5355 5356 foreach ( $child_media as $index => $video ) { 5357 $player_id = 'godam-comment-' . esc_attr( $child->id ) . '-' . $index; 5358 $child_videos .= do_shortcode( 5359 '[godam_video id="' . esc_attr( $video->media_id ) . '"]' 5360 ); 5361 } 5362 5363 if ( $child_videos ) { 5364 // Remove rtMedia <ul> from comment. 5365 $child->content = preg_replace( 5366 '#<ul[^>]*class="[^"]*rtmedia-list[^"]*rtm-activity-media-list[^"]*rtmedia-activity-media-length-[0-9]+[^"]*rtm-activity-video-list[^"]*"[^>]*>.*?</ul>#si', 5367 '', 5368 $child->content 5369 ); 5370 5371 // Append Godam video players. 5372 $child->content .= '<div class="godam-video-players-wrapper">' . $child_videos . '</div>'; 5373 } 5359 5374 } 5360 5375 } 5361 } 5362 5363 // Final video output appended to cleaned content 5364 if ( $godam_videos ) { 5365 $godam_videos = '<div class="godam-video-players-wrapper">' . $godam_videos . '</div>'; 5366 } 5367 5368 return wp_kses_post( $clean_content ) . $godam_videos; 5369 }, 10 ); 5376 5377 // Final video output appended to cleaned content. 5378 if ( $godam_videos ) { 5379 $godam_videos = '<div class="godam-video-players-wrapper">' . $godam_videos . '</div>'; 5380 } 5381 5382 return wp_kses_post( $clean_content ) . $godam_videos; 5383 }, 5384 10 5385 ); 5370 5386 5371 5387 /** … … 5375 5391 add_action( 'wp_ajax_nopriv_get_single_activity_comment_html', 'handle_get_single_activity_comment_html' ); 5376 5392 5393 /** 5394 * AJAX handler to fetch and return the HTML for a single activity comment. 5395 * 5396 * Validates the request, loads the activity comment by ID, 5397 * renders its HTML using the BuddyPress template, and returns it in a JSON response. 5398 * 5399 * @return void Outputs JSON response with rendered HTML or error message. 5400 */ 5377 5401 function handle_get_single_activity_comment_html() { 5378 5402 check_ajax_referer( 'godam-ajax-nonce', 'nonce' ); … … 5391 5415 global $activities_template; 5392 5416 5393 // Backup original activity 5417 // Backup original activity. 5394 5418 $original_activity = $activities_template->activity ?? null; 5395 5419 5396 // Replace global for template rendering 5420 // Replace global for template rendering. 5397 5421 $activities_template = new stdClass(); 5398 5422 $activities_template->activity = $activity; … … 5402 5426 $html = ob_get_clean(); 5403 5427 5404 // Restore original 5428 // Restore original. 5405 5429 if ( $original_activity ) { 5406 5430 $activities_template->activity = $original_activity; 5407 5431 } 5408 5432 5409 wp_send_json_success( [ 'html' => $html ]);5433 wp_send_json_success( array( 'html' => $html ) ); 5410 5434 } 5411 5435 … … 5436 5460 $in_footer = true; 5437 5461 5438 // Deregister the script if already registered or enqueued to prevent conflicts 5439 if ( wp_script_is($handle, 'registered') || wp_script_is($handle, 'enqueued')) {5440 wp_deregister_script( $handle);5441 } 5442 5443 // Determine dependencies based on whether Godam integration is active 5444 $dependencies = [];5445 5446 // If Godam plugin is NOT active, add dependencies for jQuery and mediaelement 5447 if ( !defined('RTMEDIA_GODAM_ACTIVE') || !RTMEDIA_GODAM_ACTIVE) {5448 $dependencies = ['jquery', 'rt-mediaelement-wp'];5449 } 5450 5451 // Enqueue the Magnific Popup script with the appropriate dependencies 5452 wp_enqueue_script( $handle, $script_src, $dependencies, $version, $in_footer);5453 } 5454 5455 add_action( 'wp_enqueue_scripts', 'enqueue_rtmedia_magnific_popup_script');5462 // Deregister the script if already registered or enqueued to prevent conflicts. 5463 if ( wp_script_is( $handle, 'registered' ) || wp_script_is( $handle, 'enqueued' ) ) { 5464 wp_deregister_script( $handle ); 5465 } 5466 5467 // Determine dependencies based on whether Godam integration is active. 5468 $dependencies = array(); 5469 5470 // If Godam plugin is NOT active, add dependencies for jQuery and mediaelement. 5471 if ( ! defined( 'RTMEDIA_GODAM_ACTIVE' ) || ! RTMEDIA_GODAM_ACTIVE ) { 5472 $dependencies = array( 'jquery', 'rt-mediaelement-wp' ); 5473 } 5474 5475 // Enqueue the Magnific Popup script with the appropriate dependencies. 5476 wp_enqueue_script( $handle, $script_src, $dependencies, $version, $in_footer ); 5477 } 5478 5479 add_action( 'wp_enqueue_scripts', 'enqueue_rtmedia_magnific_popup_script' ); -
buddypress-media/tags/4.7.1/index.php
r3305192 r3307451 4 4 * Plugin URI: https://rtmedia.io/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media 5 5 * Description: This plugin adds missing media rich features like photos, videos and audio uploading to BuddyPress which are essential if you are building social network, seriously! 6 * Version: 4.7. 06 * Version: 4.7.1 7 7 * Author: rtCamp 8 8 * Text Domain: buddypress-media … … 20 20 * The version of the plugin 21 21 */ 22 define( 'RTMEDIA_VERSION', '4.7. 0' );22 define( 'RTMEDIA_VERSION', '4.7.1' ); 23 23 } 24 24 -
buddypress-media/tags/4.7.1/readme.txt
r3305192 r3307451 6 6 Requires at least: WordPress 4.1 7 7 Tested up to: 6.8.1 8 Stable tag: 4.7. 08 Stable tag: 4.7.1 9 9 10 10 Add albums, photo, audio/video upload, privacy, sharing, front-end uploads & more. All this works on mobile/tablets devices. … … 134 134 == Changelog == 135 135 136 = 4.7.1 [June 6, 2025] = 137 138 * FIXED 139 * Fixed a critical error related to inline annotations on certain themes. 140 * Resolved shimmering issue for newly uploaded media on the BuddyPress Groups page when GoDAM is active. 141 136 142 = 4.7.0 [June 2, 2025] = 137 143 … … 1935 1941 == Upgrade Notice == 1936 1942 1943 = 4.7.1 = 1944 Improved integration with GoDAM services and resolved a critical inline annotation error on certain themes. 1945 1937 1946 = 4.7.0 = 1938 1947 This update introduces comprehensive support for the GoDAM video player across rtMedia galleries and all BuddyPress components, including activity streams, groups, and forums. -
buddypress-media/trunk/app/assets/js/godam-integration.js
r3305192 r3307451 63 63 } 64 64 65 if (node.classList?.contains('activity')) { 65 // Check for either 'activity' or 'groups' class. 66 if (node.classList?.contains('activity') || node.classList?.contains('groups')) { 66 67 setTimeout(() => safeGODAMPlayer(node), 100); 67 68 } -
buddypress-media/trunk/app/assets/js/godam-integration.min.js
r3305192 r3307451 1 const safeGODAMPlayer=(e=null)=>{try{return e&&1===e.nodeType&&e.isConnected?GODAMPlayer(e):GODAMPlayer(),!0}catch(e){return!1}};safeGODAMPlayer();let popupInitTimeout=null;const initializePopupVideos=()=>{clearTimeout(popupInitTimeout),popupInitTimeout=setTimeout((()=>{const e=document.querySelector(".mfp-content");if(e){e.querySelectorAll("video").length>0&&(safeGODAMPlayer(e)||safeGODAMPlayer())}}),200)};document.addEventListener("DOMContentLoaded",(()=>{safeGODAMPlayer();new MutationObserver((e=>{for(const t of e)for(const e of t.addedNodes)if(1===e.nodeType){const t=e.classList?.contains("mfp-content")||e.querySelector?.(".mfp-content"),o="VIDEO"===e.tagName||e.querySelector?.("video");(t||o&&e.closest(".mfp-content"))&&initializePopupVideos(), e.classList?.contains("activity")&&setTimeout((()=>safeGODAMPlayer(e)),100)}})).observe(document.body,{childList:!0,subtree:!0}),"undefined"!=typeof $&&$.magnificPopup&&($(document).on("mfpOpen mfpChange",(()=>{initializePopupVideos()})),$(document).on("mfpOpen",(()=>{setTimeout(initializePopupVideos,500)})))}));1 const safeGODAMPlayer=(e=null)=>{try{return e&&1===e.nodeType&&e.isConnected?GODAMPlayer(e):GODAMPlayer(),!0}catch(e){return!1}};safeGODAMPlayer();let popupInitTimeout=null;const initializePopupVideos=()=>{clearTimeout(popupInitTimeout),popupInitTimeout=setTimeout((()=>{const e=document.querySelector(".mfp-content");if(e){e.querySelectorAll("video").length>0&&(safeGODAMPlayer(e)||safeGODAMPlayer())}}),200)};document.addEventListener("DOMContentLoaded",(()=>{safeGODAMPlayer();new MutationObserver((e=>{for(const t of e)for(const e of t.addedNodes)if(1===e.nodeType){const t=e.classList?.contains("mfp-content")||e.querySelector?.(".mfp-content"),o="VIDEO"===e.tagName||e.querySelector?.("video");(t||o&&e.closest(".mfp-content"))&&initializePopupVideos(),(e.classList?.contains("activity")||e.classList?.contains("groups"))&&setTimeout((()=>safeGODAMPlayer(e)),100)}})).observe(document.body,{childList:!0,subtree:!0}),"undefined"!=typeof $&&$.magnificPopup&&($(document).on("mfpOpen mfpChange",(()=>{initializePopupVideos()})),$(document).on("mfpOpen",(()=>{setTimeout(initializePopupVideos,500)})))})); -
buddypress-media/trunk/app/main/RTMedia.php
r3305192 r3307451 1268 1268 ), 1269 1269 RTMEDIA_VERSION, 1270 args:true1270 true 1271 1271 ); 1272 1272 } else { -
buddypress-media/trunk/app/main/controllers/template/rtmedia-functions.php
r3305192 r3307451 594 594 if ( defined( 'RTMEDIA_GODAM_ACTIVE' ) && RTMEDIA_GODAM_ACTIVE ) { 595 595 $html .= do_shortcode( '[godam_video id="' . esc_attr( $rtmedia_media->media_id ) . '"]' ); 596 } elseif ( empty( $youtube_url ) ) { 597 $html .= sprintf( 598 '<video poster="%1$s" src="%2$s"%3$s type="video/mp4" class="wp-video-shortcode" id="rt_media_video_%4$s" controls="controls" preload="metadata" playsinline></video>', 599 esc_url( ! empty( $rtmedia_media->cover_art ) ? $rtmedia_media->cover_art : '' ), 600 esc_url( wp_get_attachment_url( $rtmedia_media->media_id ) ), 601 $size_attr, 602 esc_attr( $rtmedia_media->id ) 603 ); 596 604 } else { 597 // Fallback to native or YouTube player. 598 if ( empty( $youtube_url ) ) { 599 $html .= sprintf( 600 '<video poster="%1$s" src="%2$s"%3$s type="video/mp4" class="wp-video-shortcode" id="rt_media_video_%4$s" controls="controls" preload="metadata" playsinline></video>', 601 esc_url( $rtmedia_media->cover_art ?: '' ), 602 esc_url( wp_get_attachment_url( $rtmedia_media->media_id ) ), 603 $size_attr, 604 esc_attr( $rtmedia_media->id ) 605 ); 606 } else { 607 $html .= sprintf( 608 '<video width="640" height="360" class="url-video" id="video-id-%1$s" preload="none" playsinline><source type="video/youtube" src="%2$s" /></video>', 609 esc_attr( $rtmedia_media->id ), 610 esc_url( $youtube_url ) 611 ); 612 } 605 $html .= sprintf( 606 '<video width="640" height="360" class="url-video" id="video-id-%1$s" preload="none" playsinline><source type="video/youtube" src="%2$s" /></video>', 607 esc_attr( $rtmedia_media->id ), 608 esc_url( $youtube_url ) 609 ); 613 610 } 614 611 … … 998 995 999 996 $flag = false; 1000 if ( $rtmedia_media !== null&& isset( $rtmedia_media->media_author ) ) {997 if ( null !== $rtmedia_media && isset( $rtmedia_media->media_author ) ) { 1001 998 $flag = intval( $rtmedia_media->media_author ) === get_current_user_id(); 1002 999 } … … 1026 1023 1027 1024 $flag = false; 1028 if ( $rtmedia_media !== null&& isset( $rtmedia_media->media_author ) ) {1025 if ( null !== $rtmedia_media && isset( $rtmedia_media->media_author ) ) { 1029 1026 $flag = intval( $rtmedia_media->media_author ) === get_current_user_id(); 1030 1027 } … … 1483 1480 global $wpdb; 1484 1481 1485 // Replace all <video> tags with ID pattern rt_media_video_{id} 1482 // Replace all <video> tags with ID pattern rt_media_video_{id}. 1486 1483 $html = preg_replace_callback( 1487 1484 '#<video[^>]*id="rt_media_video_(\d+)"[^>]*>.*?</video>#is', 1488 function ( $matches ) use ( $wpdb ) {1489 $extracted_id = intval( $matches[1] ); // Extract numeric ID from video tag 1490 1491 // Fetch media_id from rt_rtm_media table using the extracted ID 1485 function ( $matches ) use ( $wpdb ) { 1486 $extracted_id = intval( $matches[1] ); // Extract numeric ID from video tag. 1487 1488 // Fetch media_id from rt_rtm_media table using the extracted ID. 1492 1489 $media_id = $wpdb->get_var( 1493 1490 $wpdb->prepare( … … 1497 1494 ); 1498 1495 1499 // If media_id exists, return Godam video shortcode 1496 // If media_id exists, return Godam video shortcode. 1500 1497 if ( ! empty( $media_id ) ) { 1501 1498 return '<div style="max-width: 480px; width: 100%; overflow: hidden;">' … … 1505 1502 } 1506 1503 1507 // If no media_id found, return original video HTML 1504 // If no media_id found, return original video HTML. 1508 1505 return $matches[0]; 1509 1506 }, … … 5234 5231 add_action( 'wp_enqueue_scripts', 'enqueue_scripts_globally', 20 ); 5235 5232 5233 /** 5234 * Enqueues all necessary frontend scripts and styles globally for the Godam player. 5235 * 5236 * This includes the player script, analytics script, and both frontend and core styles. 5237 * Intended to be called on every page load where the player may be used. 5238 * 5239 * @return void 5240 */ 5236 5241 function enqueue_scripts_globally() { 5237 5242 wp_enqueue_script( 'godam-player-frontend-script' ); … … 5244 5249 * Enqueue frontend scripts for Godam integration and AJAX refresh. 5245 5250 */ 5246 add_action( 'wp_enqueue_scripts', function() { 5247 5248 // Enqueue integration script for rtMedia and Godam. 5249 wp_enqueue_script( 5250 'godam-rtmedia-integration', 5251 RTMEDIA_URL . 'app/assets/js/godam-integration.min.js', 5252 [ 'godam-player-frontend-script' ], 5253 null, 5254 true 5255 ); 5256 5257 // Enqueue the script responsible for AJAX-based comment refresh. 5258 wp_enqueue_script( 5259 'godam-ajax-refresh', 5260 RTMEDIA_URL . 'app/assets/js/godam-ajax-refresh.min.js', 5261 [], 5262 null, 5263 true 5264 ); 5265 5266 // Pass AJAX URL and nonce to the script. 5267 wp_localize_script( 'godam-ajax-refresh', 'GodamAjax', [ 5268 'ajax_url' => admin_url( 'admin-ajax.php' ), 5269 'nonce' => wp_create_nonce( 'godam-ajax-nonce' ), 5270 ]); 5271 } ); 5251 add_action( 5252 'wp_enqueue_scripts', 5253 function () { 5254 5255 // Enqueue integration script for rtMedia and Godam. 5256 wp_enqueue_script( 5257 'godam-rtmedia-integration', 5258 RTMEDIA_URL . 'app/assets/js/godam-integration.min.js', 5259 array( 'godam-player-frontend-script' ), 5260 null, 5261 true 5262 ); 5263 5264 // Enqueue the script responsible for AJAX-based comment refresh. 5265 wp_enqueue_script( 5266 'godam-ajax-refresh', 5267 RTMEDIA_URL . 'app/assets/js/godam-ajax-refresh.min.js', 5268 array(), 5269 null, 5270 true 5271 ); 5272 5273 // Pass AJAX URL and nonce to the script. 5274 wp_localize_script( 5275 'godam-ajax-refresh', 5276 'GodamAjax', 5277 array( 5278 'ajax_url' => admin_url( 'admin-ajax.php' ), 5279 'nonce' => wp_create_nonce( 'godam-ajax-nonce' ), 5280 ) 5281 ); 5282 } 5283 ); 5272 5284 5273 5285 /** … … 5275 5287 * with Godam player shortcodes. 5276 5288 */ 5277 add_filter( 'bp_get_activity_content_body', function( $content ) { 5278 global $activities_template; 5279 5280 // Bail early if activity object is not available 5281 if ( empty( $activities_template->activity ) || ! is_object( $activities_template->activity ) ) { 5282 return $content; 5283 } 5284 5285 $activity = $activities_template->activity; 5286 5287 // Allow only certain activity types 5288 $valid_types = [ 'rtmedia_update', 'activity_update', 'activity_comment' ]; 5289 if ( ! isset( $activity->type ) || ! in_array( $activity->type, $valid_types, true ) ) { 5290 return $content; 5291 } 5292 5293 // Ensure RTMediaModel class exists 5294 if ( ! class_exists( 'RTMediaModel' ) ) { 5295 return $content; 5296 } 5297 5298 $model = new RTMediaModel(); 5299 $media_items = $model->get( [ 'activity_id' => $activity->id ] ); 5300 5301 if ( empty( $media_items ) || ! is_array( $media_items ) ) { 5302 return $content; 5303 } 5304 5305 // Remove rtMedia default video <ul> 5306 $clean_content = preg_replace( 5307 '#<ul[^>]*class="[^"]*rtmedia-list[^"]*rtm-activity-media-list[^"]*rtmedia-activity-media-length-[0-9]+[^"]*rtm-activity-video-list[^"]*"[^>]*>.*?</ul>#si', 5308 '', 5309 $activity->content 5310 ); 5311 5312 // Group media by type 5313 $grouped_media = []; 5314 foreach ( $media_items as $media ) { 5315 $grouped_media[ $media->media_type ][] = $media; 5316 } 5317 5318 $godam_videos = ''; 5319 5320 // Build Godam player shortcodes for videos 5321 if ( ! empty( $grouped_media['video'] ) ) { 5322 foreach ( $grouped_media['video'] as $index => $video ) { 5323 $player_id = 'godam-activity-' . esc_attr( $activity->id ) . '-' . $index; 5324 $godam_videos .= do_shortcode( 5325 '[godam_video id="' . esc_attr( $video->media_id ) . 5326 '" context="buddypress" player_id="' . esc_attr( $player_id ) . '"]' 5327 ); 5289 add_filter( 5290 'bp_get_activity_content_body', 5291 function ( $content ) { 5292 global $activities_template; 5293 5294 // Bail early if activity object is not available. 5295 if ( empty( $activities_template->activity ) || ! is_object( $activities_template->activity ) ) { 5296 return $content; 5328 5297 } 5329 } 5330 5331 // Process video media in activity comments 5332 if ( ! empty( $activity->children ) && is_array( $activity->children ) ) { 5333 foreach ( $activity->children as $child ) { 5334 $child_media = $model->get( [ 'activity_id' => $child->id ] ); 5335 5336 if ( empty( $child_media ) ) { 5337 continue; 5338 } 5339 5340 $child_videos = ''; 5341 5342 foreach ( $child_media as $index => $video ) { 5343 $player_id = 'godam-comment-' . esc_attr( $child->id ) . '-' . $index; 5344 $child_videos .= do_shortcode( 5345 '[godam_video id="' . esc_attr( $video->media_id ) . '"]' 5298 5299 $activity = $activities_template->activity; 5300 5301 // Allow only certain activity types. 5302 $valid_types = array( 'rtmedia_update', 'activity_update', 'activity_comment' ); 5303 if ( ! isset( $activity->type ) || ! in_array( $activity->type, $valid_types, true ) ) { 5304 return $content; 5305 } 5306 5307 // Ensure RTMediaModel class exists. 5308 if ( ! class_exists( 'RTMediaModel' ) ) { 5309 return $content; 5310 } 5311 5312 $model = new RTMediaModel(); 5313 $media_items = $model->get( array( 'activity_id' => $activity->id ) ); 5314 5315 if ( empty( $media_items ) || ! is_array( $media_items ) ) { 5316 return $content; 5317 } 5318 5319 // Remove rtMedia default video <ul>. 5320 $clean_content = preg_replace( 5321 '#<ul[^>]*class="[^"]*rtmedia-list[^"]*rtm-activity-media-list[^"]*rtmedia-activity-media-length-[0-9]+[^"]*rtm-activity-video-list[^"]*"[^>]*>.*?</ul>#si', 5322 '', 5323 $activity->content 5324 ); 5325 5326 // Group media by type. 5327 $grouped_media = array(); 5328 foreach ( $media_items as $media ) { 5329 $grouped_media[ $media->media_type ][] = $media; 5330 } 5331 5332 $godam_videos = ''; 5333 5334 // Build Godam player shortcodes for videos. 5335 if ( ! empty( $grouped_media['video'] ) ) { 5336 foreach ( $grouped_media['video'] as $index => $video ) { 5337 $player_id = 'godam-activity-' . esc_attr( $activity->id ) . '-' . $index; 5338 $godam_videos .= do_shortcode( 5339 '[godam_video id="' . esc_attr( $video->media_id ) . 5340 '" context="buddypress" player_id="' . esc_attr( $player_id ) . '"]' 5346 5341 ); 5347 5342 } 5348 5349 if ( $child_videos ) { 5350 // Remove rtMedia <ul> from comment 5351 $child->content = preg_replace( 5352 '#<ul[^>]*class="[^"]*rtmedia-list[^"]*rtm-activity-media-list[^"]*rtmedia-activity-media-length-[0-9]+[^"]*rtm-activity-video-list[^"]*"[^>]*>.*?</ul>#si', 5353 '', 5354 $child->content 5355 ); 5356 5357 // Append Godam video players 5358 $child->content .= '<div class="godam-video-players-wrapper">' . $child_videos . '</div>'; 5343 } 5344 5345 // Process video media in activity comments. 5346 if ( ! empty( $activity->children ) && is_array( $activity->children ) ) { 5347 foreach ( $activity->children as $child ) { 5348 $child_media = $model->get( array( 'activity_id' => $child->id ) ); 5349 5350 if ( empty( $child_media ) ) { 5351 continue; 5352 } 5353 5354 $child_videos = ''; 5355 5356 foreach ( $child_media as $index => $video ) { 5357 $player_id = 'godam-comment-' . esc_attr( $child->id ) . '-' . $index; 5358 $child_videos .= do_shortcode( 5359 '[godam_video id="' . esc_attr( $video->media_id ) . '"]' 5360 ); 5361 } 5362 5363 if ( $child_videos ) { 5364 // Remove rtMedia <ul> from comment. 5365 $child->content = preg_replace( 5366 '#<ul[^>]*class="[^"]*rtmedia-list[^"]*rtm-activity-media-list[^"]*rtmedia-activity-media-length-[0-9]+[^"]*rtm-activity-video-list[^"]*"[^>]*>.*?</ul>#si', 5367 '', 5368 $child->content 5369 ); 5370 5371 // Append Godam video players. 5372 $child->content .= '<div class="godam-video-players-wrapper">' . $child_videos . '</div>'; 5373 } 5359 5374 } 5360 5375 } 5361 } 5362 5363 // Final video output appended to cleaned content 5364 if ( $godam_videos ) { 5365 $godam_videos = '<div class="godam-video-players-wrapper">' . $godam_videos . '</div>'; 5366 } 5367 5368 return wp_kses_post( $clean_content ) . $godam_videos; 5369 }, 10 ); 5376 5377 // Final video output appended to cleaned content. 5378 if ( $godam_videos ) { 5379 $godam_videos = '<div class="godam-video-players-wrapper">' . $godam_videos . '</div>'; 5380 } 5381 5382 return wp_kses_post( $clean_content ) . $godam_videos; 5383 }, 5384 10 5385 ); 5370 5386 5371 5387 /** … … 5375 5391 add_action( 'wp_ajax_nopriv_get_single_activity_comment_html', 'handle_get_single_activity_comment_html' ); 5376 5392 5393 /** 5394 * AJAX handler to fetch and return the HTML for a single activity comment. 5395 * 5396 * Validates the request, loads the activity comment by ID, 5397 * renders its HTML using the BuddyPress template, and returns it in a JSON response. 5398 * 5399 * @return void Outputs JSON response with rendered HTML or error message. 5400 */ 5377 5401 function handle_get_single_activity_comment_html() { 5378 5402 check_ajax_referer( 'godam-ajax-nonce', 'nonce' ); … … 5391 5415 global $activities_template; 5392 5416 5393 // Backup original activity 5417 // Backup original activity. 5394 5418 $original_activity = $activities_template->activity ?? null; 5395 5419 5396 // Replace global for template rendering 5420 // Replace global for template rendering. 5397 5421 $activities_template = new stdClass(); 5398 5422 $activities_template->activity = $activity; … … 5402 5426 $html = ob_get_clean(); 5403 5427 5404 // Restore original 5428 // Restore original. 5405 5429 if ( $original_activity ) { 5406 5430 $activities_template->activity = $original_activity; 5407 5431 } 5408 5432 5409 wp_send_json_success( [ 'html' => $html ]);5433 wp_send_json_success( array( 'html' => $html ) ); 5410 5434 } 5411 5435 … … 5436 5460 $in_footer = true; 5437 5461 5438 // Deregister the script if already registered or enqueued to prevent conflicts 5439 if ( wp_script_is($handle, 'registered') || wp_script_is($handle, 'enqueued')) {5440 wp_deregister_script( $handle);5441 } 5442 5443 // Determine dependencies based on whether Godam integration is active 5444 $dependencies = [];5445 5446 // If Godam plugin is NOT active, add dependencies for jQuery and mediaelement 5447 if ( !defined('RTMEDIA_GODAM_ACTIVE') || !RTMEDIA_GODAM_ACTIVE) {5448 $dependencies = ['jquery', 'rt-mediaelement-wp'];5449 } 5450 5451 // Enqueue the Magnific Popup script with the appropriate dependencies 5452 wp_enqueue_script( $handle, $script_src, $dependencies, $version, $in_footer);5453 } 5454 5455 add_action( 'wp_enqueue_scripts', 'enqueue_rtmedia_magnific_popup_script');5462 // Deregister the script if already registered or enqueued to prevent conflicts. 5463 if ( wp_script_is( $handle, 'registered' ) || wp_script_is( $handle, 'enqueued' ) ) { 5464 wp_deregister_script( $handle ); 5465 } 5466 5467 // Determine dependencies based on whether Godam integration is active. 5468 $dependencies = array(); 5469 5470 // If Godam plugin is NOT active, add dependencies for jQuery and mediaelement. 5471 if ( ! defined( 'RTMEDIA_GODAM_ACTIVE' ) || ! RTMEDIA_GODAM_ACTIVE ) { 5472 $dependencies = array( 'jquery', 'rt-mediaelement-wp' ); 5473 } 5474 5475 // Enqueue the Magnific Popup script with the appropriate dependencies. 5476 wp_enqueue_script( $handle, $script_src, $dependencies, $version, $in_footer ); 5477 } 5478 5479 add_action( 'wp_enqueue_scripts', 'enqueue_rtmedia_magnific_popup_script' ); -
buddypress-media/trunk/index.php
r3305192 r3307451 4 4 * Plugin URI: https://rtmedia.io/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media 5 5 * Description: This plugin adds missing media rich features like photos, videos and audio uploading to BuddyPress which are essential if you are building social network, seriously! 6 * Version: 4.7. 06 * Version: 4.7.1 7 7 * Author: rtCamp 8 8 * Text Domain: buddypress-media … … 20 20 * The version of the plugin 21 21 */ 22 define( 'RTMEDIA_VERSION', '4.7. 0' );22 define( 'RTMEDIA_VERSION', '4.7.1' ); 23 23 } 24 24 -
buddypress-media/trunk/readme.txt
r3305192 r3307451 6 6 Requires at least: WordPress 4.1 7 7 Tested up to: 6.8.1 8 Stable tag: 4.7. 08 Stable tag: 4.7.1 9 9 10 10 Add albums, photo, audio/video upload, privacy, sharing, front-end uploads & more. All this works on mobile/tablets devices. … … 134 134 == Changelog == 135 135 136 = 4.7.1 [June 6, 2025] = 137 138 * FIXED 139 * Fixed a critical error related to inline annotations on certain themes. 140 * Resolved shimmering issue for newly uploaded media on the BuddyPress Groups page when GoDAM is active. 141 136 142 = 4.7.0 [June 2, 2025] = 137 143 … … 1935 1941 == Upgrade Notice == 1936 1942 1943 = 4.7.1 = 1944 Improved integration with GoDAM services and resolved a critical inline annotation error on certain themes. 1945 1937 1946 = 4.7.0 = 1938 1947 This update introduces comprehensive support for the GoDAM video player across rtMedia galleries and all BuddyPress components, including activity streams, groups, and forums.
Note: See TracChangeset
for help on using the changeset viewer.