Plugin Directory

Changeset 3307451


Ignore:
Timestamp:
06/06/2025 09:58:10 AM (10 months ago)
Author:
rtcamp
Message:

Update to version 4.7.1 from GitHub

Location:
buddypress-media
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • buddypress-media/tags/4.7.1/app/assets/js/godam-integration.js

    r3305192 r3307451  
    6363                    }
    6464
    65                     if (node.classList?.contains('activity')) {
     65                    // Check for either 'activity' or 'groups' class.
     66                    if (node.classList?.contains('activity') || node.classList?.contains('groups')) {
    6667                        setTimeout(() => safeGODAMPlayer(node), 100);
    6768                    }
  • 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)})))}));
     1const 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  
    12681268                ),
    12691269                RTMEDIA_VERSION,
    1270                 args: true
     1270                true
    12711271            );
    12721272        } else {
  • buddypress-media/tags/4.7.1/app/main/controllers/template/rtmedia-functions.php

    r3305192 r3307451  
    594594            if ( defined( 'RTMEDIA_GODAM_ACTIVE' ) && RTMEDIA_GODAM_ACTIVE ) {
    595595                $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                );
    596604            } 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                );
    613610            }
    614611
     
    998995
    999996    $flag = false;
    1000     if ( $rtmedia_media !== null && isset( $rtmedia_media->media_author ) ) {
     997    if ( null !== $rtmedia_media && isset( $rtmedia_media->media_author ) ) {
    1001998        $flag = intval( $rtmedia_media->media_author ) === get_current_user_id();
    1002999    }
     
    10261023
    10271024    $flag = false;
    1028     if ( $rtmedia_media !== null && isset( $rtmedia_media->media_author ) ) {
     1025    if ( null !== $rtmedia_media && isset( $rtmedia_media->media_author ) ) {
    10291026        $flag = intval( $rtmedia_media->media_author ) === get_current_user_id();
    10301027    }
     
    14831480        global $wpdb;
    14841481
    1485         // Replace all <video> tags with ID pattern rt_media_video_{id}
     1482        // Replace all <video> tags with ID pattern rt_media_video_{id}.
    14861483        $html = preg_replace_callback(
    14871484            '#<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.
    14921489                $media_id = $wpdb->get_var(
    14931490                    $wpdb->prepare(
     
    14971494                );
    14981495
    1499                 // If media_id exists, return Godam video shortcode
     1496                // If media_id exists, return Godam video shortcode.
    15001497                if ( ! empty( $media_id ) ) {
    15011498                    return '<div style="max-width: 480px; width: 100%; overflow: hidden;">'
     
    15051502                }
    15061503
    1507                 // If no media_id found, return original video HTML
     1504                // If no media_id found, return original video HTML.
    15081505                return $matches[0];
    15091506            },
     
    52345231    add_action( 'wp_enqueue_scripts', 'enqueue_scripts_globally', 20 );
    52355232
     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     */
    52365241    function enqueue_scripts_globally() {
    52375242        wp_enqueue_script( 'godam-player-frontend-script' );
     
    52445249     * Enqueue frontend scripts for Godam integration and AJAX refresh.
    52455250     */
    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    );
    52725284
    52735285    /**
     
    52755287     * with Godam player shortcodes.
    52765288     */
    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;
    53285297            }
    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 ) . '"]'
    53465341                    );
    53475342                }
    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                    }
    53595374                }
    53605375            }
    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    );
    53705386
    53715387    /**
     
    53755391    add_action( 'wp_ajax_nopriv_get_single_activity_comment_html', 'handle_get_single_activity_comment_html' );
    53765392
     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     */
    53775401    function handle_get_single_activity_comment_html() {
    53785402        check_ajax_referer( 'godam-ajax-nonce', 'nonce' );
     
    53915415        global $activities_template;
    53925416
    5393         // Backup original activity
     5417        // Backup original activity.
    53945418        $original_activity = $activities_template->activity ?? null;
    53955419
    5396         // Replace global for template rendering
     5420        // Replace global for template rendering.
    53975421        $activities_template             = new stdClass();
    53985422        $activities_template->activity  = $activity;
     
    54025426        $html = ob_get_clean();
    54035427
    5404         // Restore original
     5428        // Restore original.
    54055429        if ( $original_activity ) {
    54065430            $activities_template->activity = $original_activity;
    54075431        }
    54085432
    5409         wp_send_json_success( [ 'html' => $html ] );
     5433        wp_send_json_success( array( 'html' => $html ) );
    54105434    }
    54115435
     
    54365460    $in_footer  = true;
    54375461
    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
     5479add_action( 'wp_enqueue_scripts', 'enqueue_rtmedia_magnific_popup_script' );
  • buddypress-media/tags/4.7.1/index.php

    r3305192 r3307451  
    44 * Plugin URI: https://rtmedia.io/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
    55 * 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.0
     6 * Version: 4.7.1
    77 * Author: rtCamp
    88 * Text Domain: buddypress-media
     
    2020     * The version of the plugin
    2121     */
    22     define( 'RTMEDIA_VERSION', '4.7.0' );
     22    define( 'RTMEDIA_VERSION', '4.7.1' );
    2323}
    2424
  • buddypress-media/tags/4.7.1/readme.txt

    r3305192 r3307451  
    66Requires at least: WordPress 4.1
    77Tested up to: 6.8.1
    8 Stable tag: 4.7.0
     8Stable tag: 4.7.1
    99
    1010Add albums, photo, audio/video upload, privacy, sharing, front-end uploads & more. All this works on mobile/tablets devices.
     
    134134== Changelog ==
    135135
     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
    136142= 4.7.0 [June 2, 2025] =
    137143
     
    19351941== Upgrade Notice ==
    19361942
     1943= 4.7.1 =
     1944Improved integration with GoDAM services and resolved a critical inline annotation error on certain themes.
     1945
    19371946= 4.7.0 =
    19381947This 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  
    6363                    }
    6464
    65                     if (node.classList?.contains('activity')) {
     65                    // Check for either 'activity' or 'groups' class.
     66                    if (node.classList?.contains('activity') || node.classList?.contains('groups')) {
    6667                        setTimeout(() => safeGODAMPlayer(node), 100);
    6768                    }
  • 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)})))}));
     1const 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  
    12681268                ),
    12691269                RTMEDIA_VERSION,
    1270                 args: true
     1270                true
    12711271            );
    12721272        } else {
  • buddypress-media/trunk/app/main/controllers/template/rtmedia-functions.php

    r3305192 r3307451  
    594594            if ( defined( 'RTMEDIA_GODAM_ACTIVE' ) && RTMEDIA_GODAM_ACTIVE ) {
    595595                $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                );
    596604            } 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                );
    613610            }
    614611
     
    998995
    999996    $flag = false;
    1000     if ( $rtmedia_media !== null && isset( $rtmedia_media->media_author ) ) {
     997    if ( null !== $rtmedia_media && isset( $rtmedia_media->media_author ) ) {
    1001998        $flag = intval( $rtmedia_media->media_author ) === get_current_user_id();
    1002999    }
     
    10261023
    10271024    $flag = false;
    1028     if ( $rtmedia_media !== null && isset( $rtmedia_media->media_author ) ) {
     1025    if ( null !== $rtmedia_media && isset( $rtmedia_media->media_author ) ) {
    10291026        $flag = intval( $rtmedia_media->media_author ) === get_current_user_id();
    10301027    }
     
    14831480        global $wpdb;
    14841481
    1485         // Replace all <video> tags with ID pattern rt_media_video_{id}
     1482        // Replace all <video> tags with ID pattern rt_media_video_{id}.
    14861483        $html = preg_replace_callback(
    14871484            '#<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.
    14921489                $media_id = $wpdb->get_var(
    14931490                    $wpdb->prepare(
     
    14971494                );
    14981495
    1499                 // If media_id exists, return Godam video shortcode
     1496                // If media_id exists, return Godam video shortcode.
    15001497                if ( ! empty( $media_id ) ) {
    15011498                    return '<div style="max-width: 480px; width: 100%; overflow: hidden;">'
     
    15051502                }
    15061503
    1507                 // If no media_id found, return original video HTML
     1504                // If no media_id found, return original video HTML.
    15081505                return $matches[0];
    15091506            },
     
    52345231    add_action( 'wp_enqueue_scripts', 'enqueue_scripts_globally', 20 );
    52355232
     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     */
    52365241    function enqueue_scripts_globally() {
    52375242        wp_enqueue_script( 'godam-player-frontend-script' );
     
    52445249     * Enqueue frontend scripts for Godam integration and AJAX refresh.
    52455250     */
    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    );
    52725284
    52735285    /**
     
    52755287     * with Godam player shortcodes.
    52765288     */
    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;
    53285297            }
    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 ) . '"]'
    53465341                    );
    53475342                }
    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                    }
    53595374                }
    53605375            }
    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    );
    53705386
    53715387    /**
     
    53755391    add_action( 'wp_ajax_nopriv_get_single_activity_comment_html', 'handle_get_single_activity_comment_html' );
    53765392
     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     */
    53775401    function handle_get_single_activity_comment_html() {
    53785402        check_ajax_referer( 'godam-ajax-nonce', 'nonce' );
     
    53915415        global $activities_template;
    53925416
    5393         // Backup original activity
     5417        // Backup original activity.
    53945418        $original_activity = $activities_template->activity ?? null;
    53955419
    5396         // Replace global for template rendering
     5420        // Replace global for template rendering.
    53975421        $activities_template             = new stdClass();
    53985422        $activities_template->activity  = $activity;
     
    54025426        $html = ob_get_clean();
    54035427
    5404         // Restore original
     5428        // Restore original.
    54055429        if ( $original_activity ) {
    54065430            $activities_template->activity = $original_activity;
    54075431        }
    54085432
    5409         wp_send_json_success( [ 'html' => $html ] );
     5433        wp_send_json_success( array( 'html' => $html ) );
    54105434    }
    54115435
     
    54365460    $in_footer  = true;
    54375461
    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
     5479add_action( 'wp_enqueue_scripts', 'enqueue_rtmedia_magnific_popup_script' );
  • buddypress-media/trunk/index.php

    r3305192 r3307451  
    44 * Plugin URI: https://rtmedia.io/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
    55 * 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.0
     6 * Version: 4.7.1
    77 * Author: rtCamp
    88 * Text Domain: buddypress-media
     
    2020     * The version of the plugin
    2121     */
    22     define( 'RTMEDIA_VERSION', '4.7.0' );
     22    define( 'RTMEDIA_VERSION', '4.7.1' );
    2323}
    2424
  • buddypress-media/trunk/readme.txt

    r3305192 r3307451  
    66Requires at least: WordPress 4.1
    77Tested up to: 6.8.1
    8 Stable tag: 4.7.0
     8Stable tag: 4.7.1
    99
    1010Add albums, photo, audio/video upload, privacy, sharing, front-end uploads & more. All this works on mobile/tablets devices.
     
    134134== Changelog ==
    135135
     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
    136142= 4.7.0 [June 2, 2025] =
    137143
     
    19351941== Upgrade Notice ==
    19361942
     1943= 4.7.1 =
     1944Improved integration with GoDAM services and resolved a critical inline annotation error on certain themes.
     1945
    19371946= 4.7.0 =
    19381947This 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.