diff --git a/Gruntfile.js b/Gruntfile.js index a59c033fb..418ba7ce9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -62,6 +62,16 @@ module.exports = function (grunt) { files: { 'app/assets/admin/js/admin.min.js': ['app/assets/admin/js/scripts.js'] } + }, + godam: { + files: { + 'app/assets/js/godam-integration.min.js': ['app/assets/js/godam-integration.js'] + } + }, + godam_ajax_refresh: { + files: { + 'app/assets/js/godam-ajax-refresh.min.js': ['app/assets/js/godam-ajax-refresh.js'] + } } } }); diff --git a/README.md b/README.md index c58967c00..70ff3f11c 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,18 @@ https://www.youtube.com/watch?v=dJrykKQGDcs ## Changelog ## +### 4.7.0 + +* ENHANCEMENTS + * Added integration with GoDAM plugin's video player. + * Enabled support for GoDAM video player in rtMedia media gallery, BuddyPress activity stream, groups, and forums. + * Improved handling of player enqueue conditions based on GoDAM plugin status. + * Refined script loading to ensure compatibility across WordPress, BuddyPress, and rtMedia components. + +* FIXED + * Prevented conflicts with `mediaelement.js` when GoDAM plugin is active. + * Deregistered conflicting scripts to ensure seamless fallback and prevent duplication in player initialization. + ### 4.6.23 * Fixed diff --git a/app/assets/js/godam-ajax-refresh.js b/app/assets/js/godam-ajax-refresh.js new file mode 100644 index 000000000..52ddada66 --- /dev/null +++ b/app/assets/js/godam-ajax-refresh.js @@ -0,0 +1,275 @@ +// Enhanced AJAX function with better error handling and retry logic +function refreshSingleComment(commentId, node) { + // Validation checks + if (!commentId || !node) { + return; + } + + // Check if GodamAjax object exists + if (typeof GodamAjax === 'undefined' || !GodamAjax.ajax_url || !GodamAjax.nonce) { + return; + } + + // Check if node is still in the DOM + if (!document.contains(node)) { + return; + } + + // Prevent duplicate requests + if (node.classList.contains('refreshing')) { + return; + } + node.classList.add('refreshing'); + + // Create AbortController for timeout handling + const controller = new AbortController(); + const timeoutId = setTimeout(() => { + controller.abort(); + }, 15000); // 15 second timeout + + fetch(GodamAjax.ajax_url, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: new URLSearchParams({ + action: 'get_single_activity_comment_html', + comment_id: commentId, + nonce: GodamAjax.nonce, + }), + signal: controller.signal + }) + .then(response => { + clearTimeout(timeoutId); + + // Check if response is ok + if (!response.ok) { + throw new Error(`HTTP ${response.status}: ${response.statusText}`); + } + + // Check content type + const contentType = response.headers.get('content-type'); + if (!contentType || !contentType.includes('application/json')) { + throw new Error('Server returned non-JSON response'); + } + + return response.json(); + }) + .then(data => { + if (data && data.success && data.data && data.data.html) { + // Success - handle the response + handleSuccessfulResponse(data, commentId, node); + } else { + // AJAX returned error + const errorMsg = data && data.data ? data.data : 'Unknown AJAX error'; + console.error('AJAX error:', errorMsg); + + // Optional: Retry once after a delay + setTimeout(() => { + retryRefreshComment(commentId, node, 1); + }, 2000); + } + }) + .catch(error => { + clearTimeout(timeoutId); + console.error('Fetch error:', error); + + // Handle specific error types + if (error.name === 'AbortError') { + console.error('Request timed out'); + } else if (error.message.includes('Failed to fetch')) { + console.error('Network error - possible connectivity issue'); + // Retry after network error + setTimeout(() => { + retryRefreshComment(commentId, node, 1); + }, 3000); + } + }) + .finally(() => { + clearTimeout(timeoutId); + // Always remove refreshing class + if (document.contains(node)) { + node.classList.remove('refreshing'); + } + }); +} + +// Retry function with exponential backoff +function retryRefreshComment(commentId, node, attempt = 1) { + const maxRetries = 2; + + if (attempt > maxRetries) { + console.error(`Failed to refresh comment ${commentId} after ${maxRetries} retries`); + return; + } + + // Check if node still exists + if (!document.contains(node)) { + return; + } + + // Exponential backoff delay + const delay = Math.pow(2, attempt) * 1000; // 2s, 4s, 8s... + + setTimeout(() => { + // Remove any existing refreshing class + node.classList.remove('refreshing'); + + // Try again with modified fetch (more conservative approach) + fetch(GodamAjax.ajax_url, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Cache-Control': 'no-cache', + }, + body: new URLSearchParams({ + action: 'get_single_activity_comment_html', + comment_id: commentId, + nonce: GodamAjax.nonce, + retry: attempt.toString() + }), + }) + .then(response => response.json()) + .then(data => { + if (data && data.success && data.data && data.data.html) { + handleSuccessfulResponse(data, commentId, node); + } else { + // Retry again if not max attempts + if (attempt < maxRetries) { + retryRefreshComment(commentId, node, attempt + 1); + } + } + }) + .catch(error => { + console.error(`Retry ${attempt} failed:`, error); + if (attempt < maxRetries) { + retryRefreshComment(commentId, node, attempt + 1); + } + }); + }, delay); +} + +// Handle successful AJAX response +function handleSuccessfulResponse(data, commentId, node) { + try { + // Find parent activity more safely + const activityItem = node.closest('.activity-item'); + if (!activityItem) { + console.error('Could not find parent activity item'); + return; + } + + const parentActivityId = activityItem.id.replace('activity-', ''); + + // Locate comment container + let commentList = document.querySelector(`#activity-${parentActivityId} .activity-comments`); + if (!commentList) { + commentList = document.createElement('ul'); + commentList.classList.add('activity-comments'); + activityItem.appendChild(commentList); + } + + // Create temporary container for HTML parsing + const tempDiv = document.createElement('div'); + tempDiv.innerHTML = data.data.html.trim(); + const newCommentNode = tempDiv.firstElementChild; + + if (newCommentNode) { + // Insert new comment + commentList.appendChild(newCommentNode); + + // Remove old node safely + if (node.parentNode && document.contains(node)) { + node.parentNode.removeChild(node); + } + + // Initialize GODAMPlayer if available + if (typeof GODAMPlayer === 'function') { + try { + GODAMPlayer(newCommentNode); + } catch (playerError) { + console.error('GODAMPlayer initialization failed:', playerError); + } + } + + // Dispatch custom event for other scripts + document.dispatchEvent(new CustomEvent('commentRefreshed', { + detail: { commentId, node: newCommentNode } + })); + + } else { + console.error('No valid comment node found in response HTML'); + } + } catch (error) { + console.error('Error handling successful response:', error); + } +} + +// Enhanced DOM observer with debouncing +document.addEventListener('DOMContentLoaded', () => { + const commentsContainers = document.querySelectorAll('.activity-comments'); + + if (commentsContainers.length === 0) { + return; + } + + // Debounce function to prevent rapid-fire calls + function debounce(func, wait) { + let timeout; + return function executedFunction(...args) { + const later = () => { + clearTimeout(timeout); + func(...args); + }; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + }; + } + + commentsContainers.forEach((container) => { + // Initialize GODAMPlayer on existing comments + if (typeof GODAMPlayer === 'function') { + try { + GODAMPlayer(container); + } catch (error) { + console.error('GODAMPlayer initialization failed:', error); + } + } + + // Debounced mutation handler + const debouncedHandler = debounce((mutations) => { + mutations.forEach((mutation) => { + mutation.addedNodes.forEach((node) => { + if (node.nodeType === 1 && node.matches && node.matches('li[id^="acomment-"]')) { + // Initialize GODAMPlayer first + if (typeof GODAMPlayer === 'function') { + try { + GODAMPlayer(node); + } catch (error) { + console.error('GODAMPlayer initialization failed:', error); + } + } + + // Extract comment ID and refresh with delay + const commentId = node.id.replace('acomment-', ''); + + // Add longer delay to ensure DOM stability + setTimeout(() => { + if (document.contains(node)) { + refreshSingleComment(commentId, node); + } + }, 250); + } + }); + }); + }, 100); // 100ms debounce + + // Create observer + const observer = new MutationObserver(debouncedHandler); + + observer.observe(container, { + childList: true, + subtree: true + }); + }); +}); diff --git a/app/assets/js/godam-ajax-refresh.min.js b/app/assets/js/godam-ajax-refresh.min.js new file mode 100644 index 000000000..25ba334bc --- /dev/null +++ b/app/assets/js/godam-ajax-refresh.min.js @@ -0,0 +1 @@ +function refreshSingleComment(e,t){if(!e||!t)return;if("undefined"==typeof GodamAjax||!GodamAjax.ajax_url||!GodamAjax.nonce)return;if(!document.contains(t))return;if(t.classList.contains("refreshing"))return;t.classList.add("refreshing");const o=new AbortController,n=setTimeout((()=>{o.abort()}),15e3);fetch(GodamAjax.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"get_single_activity_comment_html",comment_id:e,nonce:GodamAjax.nonce}),signal:o.signal}).then((e=>{if(clearTimeout(n),!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);const t=e.headers.get("content-type");if(!t||!t.includes("application/json"))throw new Error("Server returned non-JSON response");return e.json()})).then((o=>{if(o&&o.success&&o.data&&o.data.html)handleSuccessfulResponse(o,e,t);else{const n=o&&o.data?o.data:"Unknown AJAX error";console.error("AJAX error:",n),setTimeout((()=>{retryRefreshComment(e,t,1)}),2e3)}})).catch((o=>{clearTimeout(n),console.error("Fetch error:",o),"AbortError"===o.name?console.error("Request timed out"):o.message.includes("Failed to fetch")&&(console.error("Network error - possible connectivity issue"),setTimeout((()=>{retryRefreshComment(e,t,1)}),3e3))})).finally((()=>{clearTimeout(n),document.contains(t)&&t.classList.remove("refreshing")}))}function retryRefreshComment(e,t,o=1){if(o>2)return void console.error(`Failed to refresh comment ${e} after 2 retries`);if(!document.contains(t))return;const n=1e3*Math.pow(2,o);setTimeout((()=>{t.classList.remove("refreshing"),fetch(GodamAjax.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","Cache-Control":"no-cache"},body:new URLSearchParams({action:"get_single_activity_comment_html",comment_id:e,nonce:GodamAjax.nonce,retry:o.toString()})}).then((e=>e.json())).then((n=>{n&&n.success&&n.data&&n.data.html?handleSuccessfulResponse(n,e,t):o<2&&retryRefreshComment(e,t,o+1)})).catch((n=>{console.error(`Retry ${o} failed:`,n),o<2&&retryRefreshComment(e,t,o+1)}))}),n)}function handleSuccessfulResponse(e,t,o){try{const n=o.closest(".activity-item");if(!n)return void console.error("Could not find parent activity item");const r=n.id.replace("activity-","");let a=document.querySelector(`#activity-${r} .activity-comments`);a||(a=document.createElement("ul"),a.classList.add("activity-comments"),n.appendChild(a));const c=document.createElement("div");c.innerHTML=e.data.html.trim();const i=c.firstElementChild;if(i){if(a.appendChild(i),o.parentNode&&document.contains(o)&&o.parentNode.removeChild(o),"function"==typeof GODAMPlayer)try{GODAMPlayer(i)}catch(e){console.error("GODAMPlayer initialization failed:",e)}document.dispatchEvent(new CustomEvent("commentRefreshed",{detail:{commentId:t,node:i}}))}else console.error("No valid comment node found in response HTML")}catch(e){console.error("Error handling successful response:",e)}}document.addEventListener("DOMContentLoaded",(()=>{const e=document.querySelectorAll(".activity-comments");0!==e.length&&e.forEach((e=>{if("function"==typeof GODAMPlayer)try{GODAMPlayer(e)}catch(e){console.error("GODAMPlayer initialization failed:",e)}const t=function(e,t){let o;return function(...n){clearTimeout(o),o=setTimeout((()=>{clearTimeout(o),e(...n)}),t)}}((e=>{e.forEach((e=>{e.addedNodes.forEach((e=>{if(1===e.nodeType&&e.matches&&e.matches('li[id^="acomment-"]')){if("function"==typeof GODAMPlayer)try{GODAMPlayer(e)}catch(e){console.error("GODAMPlayer initialization failed:",e)}const t=e.id.replace("acomment-","");setTimeout((()=>{document.contains(e)&&refreshSingleComment(t,e)}),250)}}))}))}),100);new MutationObserver(t).observe(e,{childList:!0,subtree:!0})}))})); \ No newline at end of file diff --git a/app/assets/js/godam-integration.js b/app/assets/js/godam-integration.js new file mode 100644 index 000000000..f30b940d6 --- /dev/null +++ b/app/assets/js/godam-integration.js @@ -0,0 +1,87 @@ +/** + * GODAMPlayer Integration Script + * + * Initializes GODAMPlayer safely across the site, including: + * - Initial load + * - Popups using Magnific Popup + * - Dynamically added elements (e.g., via BuddyPress activities) + * + * Ensures robust handling of null or invalid elements and minimizes the risk of runtime errors. + */ + +const safeGODAMPlayer = (element = null) => { + try { + if (element) { + if (element.nodeType === 1 && element.isConnected) { + GODAMPlayer(element); + } else { + GODAMPlayer(); + } + } else { + GODAMPlayer(); + } + return true; + } catch (error) { + return false; + } +}; + +// Initial load +safeGODAMPlayer(); + +// Debounced popup initializer +let popupInitTimeout = null; +const initializePopupVideos = () => { + clearTimeout(popupInitTimeout); + popupInitTimeout = setTimeout(() => { + const popupContent = document.querySelector('.mfp-content'); + if (popupContent) { + const videos = popupContent.querySelectorAll('video'); + if (videos.length > 0) { + if (!safeGODAMPlayer(popupContent)) { + safeGODAMPlayer(); + } + } + } + }, 200); +}; + +document.addEventListener('DOMContentLoaded', () => { + safeGODAMPlayer(); + + const observer = new MutationObserver((mutations) => { + for (const mutation of mutations) { + for (const node of mutation.addedNodes) { + if (node.nodeType === 1) { + const isPopup = node.classList?.contains('mfp-content') || + node.querySelector?.('.mfp-content'); + const hasVideos = node.tagName === 'VIDEO' || + node.querySelector?.('video'); + + if (isPopup || (hasVideos && node.closest('.mfp-content'))) { + initializePopupVideos(); + } + + if (node.classList?.contains('activity')) { + setTimeout(() => safeGODAMPlayer(node), 100); + } + } + } + } + }); + + observer.observe(document.body, { + childList: true, + subtree: true + }); + + if (typeof $ !== 'undefined' && $.magnificPopup) { + $(document).on('mfpOpen mfpChange', () => { + initializePopupVideos(); + }); + + $(document).on('mfpOpen', () => { + setTimeout(initializePopupVideos, 500); + }); + } +}); diff --git a/app/assets/js/godam-integration.min.js b/app/assets/js/godam-integration.min.js new file mode 100644 index 000000000..6d059872d --- /dev/null +++ b/app/assets/js/godam-integration.min.js @@ -0,0 +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)})))})); \ No newline at end of file diff --git a/app/assets/js/rtmedia.min.js b/app/assets/js/rtmedia.min.js index 7c5ab5084..24b945aa1 100644 --- a/app/assets/js/rtmedia.min.js +++ b/app/assets/js/rtmedia.min.js @@ -1,6 +1 @@ -/*! - * rtMedia JavaScript Library - * @package rtMedia - */ - -var rtMagnificPopup,rtm_masonry_container;!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?e(require("jquery")):e(window.jQuery||window.Zepto)}(function(d){function e(){}function m(e,t){y.ev.on(i+e+b,t)}function u(e,t,i,a){var r=document.createElement("div");return r.className="mfp-"+e,i&&(r.innerHTML=i),a?t&&t.appendChild(r):(r=d(r),t&&r.appendTo(t)),r}function p(e,t){y.ev.triggerHandler(i+e,t),y.st.callbacks&&(e=e.charAt(0).toLowerCase()+e.slice(1),y.st.callbacks[e]&&y.st.callbacks[e].apply(y,d.isArray(t)?t:[t]))}function f(e){return e===t&&y.currTemplate.closeBtn||(y.currTemplate.closeBtn=d(y.st.closeMarkup.replace("%title%",y.st.tClose)),t=e),y.currTemplate.closeBtn}function n(){d.magnificPopup.instance||((y=new e).init(),d.magnificPopup.instance=y)}var y,a,_,r,v,t,l="Close",c="BeforeClose",g="MarkupParse",h="Open",o="Change",i="mfp",b="."+i,j="mfp-ready",s="mfp-removing",w="mfp-prevent-close",Q=!!window.jQuery,C=d(window);e.prototype={constructor:e,init:function(){var e=navigator.appVersion;y.isIE7=-1!==e.indexOf("MSIE 7."),y.isIE8=-1!==e.indexOf("MSIE 8."),y.isLowIE=y.isIE7||y.isIE8,y.isAndroid=/android/gi.test(e),y.isIOS=/iphone|ipad|ipod/gi.test(e),y.supportsTransition=function(){var e=document.createElement("p").style,t=["ms","O","Moz","Webkit"];if(void 0!==e.transition)return!0;for(;t.length;)if(t.pop()+"Transition"in e)return!0;return!1}(),y.probablyMobile=y.isAndroid||y.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),_=d(document),y.popupsCache={}},open:function(e){var t;if(!1===e.isObj){y.items=e.items.toArray(),y.index=0;var i,a=e.items;for(t=0;t(e||C.height())},_setFocus:function(){(y.st.focus?y.content.find(y.st.focus).eq(0):y.wrap).focus()},_onFocusIn:function(e){if(e.target!==y.wrap[0]&&!d.contains(y.wrap[0],e.target))return y._setFocus(),!1},_parseMarkup:function(r,e,t){var n;t.data&&(e=d.extend(t.data,e)),p(g,[r,e,t]),d.each(e,function(e,t){if(void 0===t||!1===t)return!0;if(1<(n=e.split("_")).length){var i=r.find(b+"-"+n[0]);if(0'):i.attr(n[1],t)}}else r.find(b+"-"+e).html(t)})},_getScrollbarSize:function(){if(void 0===y.scrollbarSize){var e=document.createElement("div");e.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(e),y.scrollbarSize=e.offsetWidth-e.clientWidth,document.body.removeChild(e)}return y.scrollbarSize}},d.magnificPopup={instance:null,proto:e.prototype,modules:[],open:function(e,t){return n(),(e=e?d.extend(!0,{},e):{}).isObj=!0,e.index=t||0,this.instance.open(e)},close:function(){return d.magnificPopup.instance&&d.magnificPopup.instance.close()},registerModule:function(e,t){t.options&&(d.magnificPopup.defaults[e]=t.options),d.extend(this.proto,t.proto),this.modules.push(e)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'',tClose:"Close (Esc)",tLoading:"Loading..."}},d.fn.magnificPopup=function(e){n();var t=d(this);if("string"==typeof e)if("open"===e){var i,a=Q?t.data("magnificPopup"):t[0].magnificPopup,r=parseInt(arguments[1],10)||0;i=a.items?a.items[r]:(i=t,a.delegate&&(i=i.find(a.delegate)),i.eq(r)),y._openClick({mfpEl:i},t,a)}else y.isOpen&&y[e].apply(y,Array.prototype.slice.call(arguments,1));else e=d.extend(!0,{},e),Q?t.data("magnificPopup",e):t[0].magnificPopup=e,y.addGroup(t,e);return t};function k(){I&&(T.after(I.addClass(x)).detach(),I=null)}var x,T,I,M="inline";d.magnificPopup.registerModule(M,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){y.types.push(M),m(l+"."+M,function(){k()})},getInline:function(e,t){if(k(),e.src){var i=y.st.inline,a=d(e.src);if(a.length){var r=a[0].parentNode;r&&r.tagName&&(T||(x=i.hiddenClass,T=u(x),x="mfp-"+x),I=a.after(T).detach().removeClass(x)),y.updateStatus("ready")}else y.updateStatus("error",i.tNotFound),a=d("
");return e.inlineElement=a}return y.updateStatus("ready"),y._parseMarkup(t,{},e),t}}});function P(){E&&d(document.body).removeClass(E)}function S(){P(),y.req&&y.req.abort()}var E,O="ajax";d.magnificPopup.registerModule(O,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'The content could not be loaded.'},proto:{initAjax:function(){y.types.push(O),E=y.st.ajax.cursor,m(l+"."+O,S),m("BeforeChange."+O,S)},getAjax:function(r){E&&d(document.body).addClass(E),y.updateStatus("loading");var e=d.extend({url:r.src,success:function(e,t,i){var a={data:e,xhr:i};p("ParseAjax",a),y.appendContent(d(a.data),O),r.finished=!0,P(),y._setFocus(),setTimeout(function(){y.wrap.addClass(j)},16),y.updateStatus("ready"),p("AjaxContentAdded")},error:function(){P(),r.finished=r.loadError=!0,y.updateStatus("error",y.st.ajax.tError.replace("%url%",r.src))}},y.st.ajax.settings);return y.req=d.ajax(e),""}}});var z;d.magnificPopup.registerModule("image",{options:{markup:'
',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'The image could not be loaded.'},proto:{initImage:function(){var e=y.st.image,t=".image";y.types.push("image"),m(h+t,function(){"image"===y.currItem.type&&e.cursor&&d(document.body).addClass(e.cursor)}),m(l+t,function(){e.cursor&&d(document.body).removeClass(e.cursor),C.off("resize"+b)}),m("Resize"+t,y.resizeImage),y.isLowIE&&m("AfterChange",y.resizeImage)},resizeImage:function(){var e=y.currItem;if(e&&e.img&&y.st.image.verticalFit){var t=0;y.isLowIE&&(t=parseInt(e.img.css("padding-top"),10)+parseInt(e.img.css("padding-bottom"),10)),e.img.css("max-height",y.wH-t)}},_onImageHasSize:function(e){e.img&&(e.hasSize=!0,z&&clearInterval(z),e.isCheckingImgSize=!1,p("ImageHasSize",e),e.imgHidden&&(y.content&&y.content.removeClass("mfp-loading"),e.imgHidden=!1))},findImageSize:function(t){var i=0,a=t.img[0],r=function(e){z&&clearInterval(z),z=setInterval(function(){0
',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){y.types.push(L),m("BeforeChange",function(e,t,i){t!==i&&(t===L?B():i===L&&B(!0))}),m(l+"."+L,function(){B()})},getIframe:function(e,t){var i=e.src,a=y.st.iframe;d.each(a.patterns,function(){if(-1',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var n=y.st.gallery,e=".mfp-gallery",r=Boolean(d.fn.mfpFastClick);if(y.direction=!0,!n||!n.enabled)return!1;v+=" mfp-gallery",m(h+e,function(){n.navigateByImgClick&&y.wrap.on("click"+e,".mfp-img",function(){if(1=y.index,y.index=e,y.updateItemHTML()},preloadNearbyImages:function(){var e,t=y.st.gallery.preload,i=Math.min(t[0],y.items.length),a=Math.min(t[1],y.items.length);for(e=1;e<=(y.direction?a:i);e++)y._preloadItem(y.index+e);for(e=1;e<=(y.direction?i:a);e++)y._preloadItem(y.index-e)},_preloadItem:function(e){if(e=A(e),!y.items[e].preloaded){var t=y.items[e];t.parsed||(t=y.parseEl(e)),p("LazyLoad",t),"image"===t.type&&(t.img=d('').on("load.mfploader",function(){t.hasSize=!0}).on("error.mfploader",function(){t.hasSize=!0,t.loadError=!0,p("LazyLoadError",t)}).attr("src",t.src)),t.preloaded=!0}}}});var F,R,D="retina";function W(){C.off("touchmove"+R+" touchend"+R)}d.magnificPopup.registerModule(D,{options:{replaceSrc:function(e){return e.src.replace(/\.\w+$/,function(e){return"@2x"+e})},ratio:1},proto:{initRetina:function(){if(1 a").siblings("p").children("a").length&&s(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").addClass("no-popup"),rtMagnificPopup=jQuery(t).magnificPopup({delegate:"a:not(.no-popup, .mejs-time-slider, .mejs-volume-slider, .mejs-horizontal-volume-slider)",type:"ajax",fixedContentPos:!0,fixedBgPos:!0,tLoading:e+" #%curr%...",mainClass:"mfp-img-mobile",preload:[1,3],closeOnBgClick:!0,gallery:{enabled:!0,navigateByImgClick:!0,arrowMarkup:"",preload:[0,1]},image:{tError:'The image #%curr% could not be loaded.',titleSrc:function(e){return e.el.attr("title")+"by Marsel Van Oosten"}},callbacks:{ajaxContentAdded:function(){e=jQuery.magnificPopup.instance,1===jQuery(e.items).size()&&jQuery(".mfp-arrow").remove();var e=jQuery.magnificPopup.instance,t=e.currItem.el,i=t.parent();if(i.is("li")||(i=i.parent()),(i.is(":nth-last-child(2)")||i.is(":last-child"))&&i.find("a").hasClass("rtmedia-list-item-a")){i.next();"block"==jQuery("#rtMedia-galary-next").css("display")&&(c||(n=e.ev.children(),c=!0,l=nextpage),jQuery("#rtMedia-galary-next").click())}var a=e.items.length;if(e.index!=a-1||i.is(":last-child")){"undefined"!=typeof _wpmejsSettings&&_wpmejsSettings.pluginPath;var o=jQuery(".rtmedia-container .rtmedia-single-meta").height(),r=!1;void 0!==e&&void 0!==e.probablyMobile&&1==e.probablyMobile&&(r=!0),s(".mfp-content .rtmedia-single-media .wp-audio-shortcode,.mfp-content .rtmedia-single-media .wp-video-shortcode,.mfp-content .rtmedia-single-media .bp_media_content video").attr("autoplay",!0),r&&s(".mfp-content .rtmedia-single-media .wp-video-shortcode,.mfp-content .rtmedia-single-media .bp_media_content video").attr("muted",!1),s(".mfp-content .rtmedia-single-media .wp-audio-shortcode,.mfp-content .rtmedia-single-media .wp-video-shortcode,.mfp-content .rtmedia-single-media .bp_media_content video").mediaelementplayer({classPrefix:"mejs-",defaultVideoWidth:480,hideVolumeOnTouchDevices:!1,features:["playpause","progress","current","volume","fullscreen"],defaultVideoHeight:270,alwaysShowControls:r,enableAutosize:!0,clickToPlayPause:!0,videoHeight:-1,success:function(n,e){n.addEventListener("loadeddata",function(e){var t=s(n).height(),i=s(window).height(),a=jQuery("div.rtm-ltb-action-container").height(),r=o-(a=a+50);i span,"+e+" .click-nav > div").toggleClass("no-js js"),jQuery(e+" .click-nav .js ul").hide(),jQuery(e+" .click-nav .clicker").click(function(e){t=jQuery("#rtm-media-options .click-nav .clicker").next("ul"),i=jQuery(this).next("ul"),jQuery.each(t,function(e,t){jQuery(t).html()!=i.html()&&jQuery(t).hide()}),jQuery(i).toggle(),e.stopPropagation()})}function bp_media_create_element(e){return!1}function rtmedia_version_compare(e,t){if(typeof e+typeof t!="stringstring")return!1;for(var i=e.split("."),a=t.split("."),r=0,n=Math.max(i.length,a.length);rparseInt(a[r]))return!0;if(a[r]&&!i[r]&&0",{title:"Click to dismiss",class:"rtmedia-message-container"+(i?" rtmedia-empty-comment-error-class":""),style:"margin:1em 0;"}),s=jQuery("",{class:a});s.html(e),s.appendTo(o),i?(n=jQuery("#rt_media_comment_form"),jQuery("#comment_content").focus()):void 0===i&&(n=jQuery(".rtmedia-single-media .rtmedia-media")).css("opacity","0.2"),n.after(o),r&&(s.css({border:"2px solid #884646"}),setTimeout(function(){s.css({border:"none"})},500)),setTimeout(function(){o.remove(),void 0===i&&n.css("opacity","1")},3e3),o.click(function(){o.remove(),void 0===i&&n.css("opacity","1")})}function rtmedia_gallery_action_alert_message(e,t){var i="rtmedia-success";"warning"==t&&(i="rtmedia-warning");jQuery("body").append(''),jQuery(".rtmedia-gallery-alert-container").append(""),setTimeout(function(){jQuery(".rtmedia-gallery-alert-container").remove()},3e3),jQuery(".rtmedia-gallery-message-box").click(function(){jQuery(".rtmedia-gallery-alert-container").remove()})}function rtmedia_activity_masonry(){jQuery("#activity-stream .rtmedia-activity-container .rtmedia-list").masonry({itemSelector:".rtmedia-list-item",gutter:7});var e=0,t=setInterval(function(){5===(e+=1)&&clearInterval(t),jQuery.each(jQuery(".rtmedia-activity-container .rtmedia-list.masonry .rtmedia-item-title"),function(e,t){jQuery(t).width(jQuery(t).siblings(".rtmedia-item-thumbnail").children("img").width())}),rtm_masonry_reload(jQuery("#activity-stream .rtmedia-activity-container .rtmedia-list"))},1e3)}function get_parameter(e,t){if(!e)return!1;t=t||window.location.href;e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var i=new RegExp(e+"=([^&#]*)").exec(t);return null!==i&&i[1]}function rtm_upload_terms_activity(){if(0 audio.wp-audio-shortcode, ul.activity-list li.rtmedia_update div.rtmedia-item-thumbnail > video.wp-video-shortcode").mediaelementplayer({classPrefix:"mejs-",defaultVideoWidth:480,defaultVideoHeight:270}),setTimeout(function(){rtmedia_activity_stream_comment_media()},900),rtMediaHook.call("rtmedia_js_after_activity_added",[])}}}),jQuery(".rtmedia-container").on("click",".select-all",function(e){jQuery(this).toggleClass("unselect-all").toggleClass("select-all"),jQuery(this).attr("title",rtmedia_unselect_all_visible),jQuery(".rtmedia-list input").each(function(){jQuery(this).prop("checked",!0)}),jQuery(".rtmedia-list-item").addClass("bulk-selected")}),jQuery(".rtmedia-container").on("click",".unselect-all",function(e){jQuery(this).toggleClass("select-all").toggleClass("unselect-all"),jQuery(this).attr("title",rtmedia_select_all_visible),jQuery(".rtmedia-list input").each(function(){jQuery(this).prop("checked",!1)}),jQuery(".rtmedia-list-item").removeClass("bulk-selected")}),jQuery(".rtmedia-container").on("click",".rtmedia-move",function(e){jQuery(".rtmedia-delete-container").slideUp(),jQuery(".rtmedia-move-container").slideToggle()}),jQuery("#rtmedia-create-album-modal").on("click","#rtmedia_create_new_album",function(e){if($albumname=jQuery("").text(jQuery.trim(jQuery("#rtmedia_album_name").val())).html(),$album_description=jQuery("#rtmedia_album_description"),$context=jQuery.trim(jQuery("#rtmedia_album_context").val()),$context_id=jQuery.trim(jQuery("#rtmedia_album_context_id").val()),$privacy=jQuery.trim(jQuery("#rtmedia_select_album_privacy").val()),$create_album_nonce=jQuery.trim(jQuery("#rtmedia_create_album_nonce").val()),""!=$albumname){var t={action:"rtmedia_create_album",name:$albumname,description:$album_description.val(),context:$context,context_id:$context_id,create_album_nonce:$create_album_nonce};""!==$privacy&&(t.privacy=$privacy),n("#rtmedia_create_new_album").attr("disabled","disabled");var r=n("#rtmedia_create_new_album").html();n("#rtmedia_create_new_album").prepend(""),jQuery.post(rtmedia_ajax_url,t,function(i){if(void 0!==i.album){i=jQuery.trim(i.album);var a=!0;$album_description.val(""),n("#rtmedia_album_name").focus(),jQuery(".rtmedia-user-album-list").each(function(){if(jQuery(this).children("optgroup").each(function(){if(jQuery(this).attr("value")===$context)return a=!1,void jQuery(this).append('")}),a){var e=$context.charAt(0).toUpperCase()+$context.slice(1)+" "+rtmedia_main_js_strings.rtmedia_albums,t='";jQuery(this).append(t)}}),jQuery('select.rtmedia-user-album-list option[value="'+i+'"]').prop("selected",!0),jQuery(".rtmedia-create-new-album-container").slideToggle(),jQuery("#rtmedia_album_name").val(""),jQuery("#rtmedia-create-album-modal").append("
"+$albumname+""+rtmedia_album_created_msg+"
"),setTimeout(function(){jQuery(".rtmedia-create-album-alert").remove()},4e3),setTimeout(function(){galleryObj.reloadView(),window.location.reload(),jQuery(".close-reveal-modal").click()},2e3)}else void 0!==i.error?rtmedia_gallery_action_alert_message(i.error,"warning"):rtmedia_gallery_action_alert_message(rtmedia_something_wrong_msg,"warning");n("#rtmedia_create_new_album").removeAttr("disabled"),n("#rtmedia_create_new_album").html(r)})}else rtmedia_gallery_action_alert_message(rtmedia_empty_album_name_msg,"warning")}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-selected",function(e){0'+t+"

"),setTimeout(function(){jQuery(a).siblings(".rtm-ac-privacy-updated").remove()},2e3)})}),jQuery(".media_search_input").on("keyup",function(){rtm_search_media_text_validation()}),r(),rtMediaHook.register("rtmedia_js_popup_after_content_added",function(){r(),jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",function(e){e.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()}),mfp=jQuery.magnificPopup.instance,1"+rtmedia_drop_media_msg+""),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&jQuery("#whats-new-textarea").append("
"+rtmedia_drop_media_msg+"
"),jQuery(document).on("dragover",function(e){e.preventDefault(),e.target!=this&&(jQuery("#rtm-media-gallery-uploader").show(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&i.addClass("rtm-drag-drop-active"),t.addClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").show())}).on("dragleave",function(e){if(e.preventDefault(),0!=e.originalEvent.pageX&&0!=e.originalEvent.pageY)return!1;"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&(i.removeClass("rtm-drag-drop-active"),i.removeAttr("style")),t.removeClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").hide()}).on("drop",function(e){e.preventDefault(),jQuery(".bp-suggestions").focus(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&(i.removeClass("rtm-drag-drop-active"),i.removeAttr("style")),t.removeClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").hide()}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-album",function(e){e.preventDefault(),confirm(rtmedia_album_delete_confirmation)&&jQuery(this).closest("form").submit()}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",function(e){e.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()}),rtmedia_init_action_dropdown(""),n(document).click(function(){n(".click-nav ul").is(":visible")&&n(".click-nav ul",this).hide()}),jQuery(".rtmedia-comment-link").on("click",function(e){e.preventDefault(),jQuery("#comment_content").focus()}),0m.showChars+m.minHideChars){var i=t.substr(0,m.showChars);if(0<=i.indexOf("<")){for(var a=!1,r="",n=0,o=[],s=null,l=0,c=0;c<=m.showChars;l++)if("<"!=t[l]||a||(a=!0,"/"==(s=t.substring(l+1,t.indexOf(">",l)))[0]?s!="/"+o[0]?m.errMsg="ERROR en HTML: the top of the stack should be the tag that closes":o.shift():"br"!=s.toLowerCase()&&o.unshift(s)),a&&">"==t[l]&&(a=!1),a)r+=t.charAt(l);else if(c++,n<=m.showChars)r+=t.charAt(l),n++;else if(0";break}i=u("
").html(r+''+m.ellipsesText+"").html()}else i+=m.ellipsesText;var d='
'+i+'
'+t+'
'+m.moreText+"";e.html(d),e.find(".allcontent").hide(),u(".shortcontent p:last",e).css("margin-bottom",0)}}))}}(jQuery),window.onload=function(){"undefined"!=typeof rtmedia_masonry_layout&&"true"==rtmedia_masonry_layout&&0==jQuery(".rtmedia-container .rtmedia-list.rtm-no-masonry").length&&rtm_masonry_reload(rtm_masonry_container),rtm_search_media_text_validation(),check_condition("search")&&jQuery("#media_search_remove").show()},jQuery(document).ready(function(){rtm_upload_terms_activity(),jQuery("body").hasClass("has-sidebar")&&0===jQuery("#secondary").length&&(jQuery(".rtmedia-single-container").length||jQuery(".rtmedia-container").length)&&jQuery("body").removeClass("has-sidebar"),rtmedia_main&&("undefined"!==rtmedia_main.rtmedia_direct_download_link&&parseInt(rtmedia_main.rtmedia_direct_download_link)||jQuery(document).on("bp_ajax_request",function(e){setTimeout(function(){jQuery("video").each(function(){jQuery(this).attr("controlsList","nodownload"),jQuery(this).attr("playsinline","playsinline"),jQuery(this).load()})},200)}))}); \ No newline at end of file +var rtMagnificPopup,rtm_masonry_container,comment_media=!1;function apply_rtMagnificPopup(e){jQuery("document").ready((function(t){var i="";if(i="undefined"==typeof rtmedia_load_more?"Loading media":rtmedia_load_more,"undefined"!=typeof rtmedia_lightbox_enabled&&"1"==rtmedia_lightbox_enabled){var a,r,n=!1;t(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").length>0&&t(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").addClass("no-popup"),rtMagnificPopup=jQuery(e).magnificPopup({delegate:"a:not(.no-popup, .mejs-time-slider, .mejs-volume-slider, .mejs-horizontal-volume-slider)",type:"ajax",fixedContentPos:!0,fixedBgPos:!0,tLoading:i+" #%curr%...",mainClass:"mfp-img-mobile",preload:[1,3],closeOnBgClick:!0,gallery:{enabled:!0,navigateByImgClick:!0,arrowMarkup:"",preload:[0,1]},image:{tError:'The image #%curr% could not be loaded.',titleSrc:function(e){return e.el.attr("title")+"by Marsel Van Oosten"}},callbacks:{ajaxContentAdded:function(){e=jQuery.magnificPopup.instance,1===jQuery(e.items).size()&&jQuery(".mfp-arrow").remove();var e=jQuery.magnificPopup.instance,i=e.currItem.el,o=i.parent();if(o.is("li")||(o=o.parent()),(o.is(":nth-last-child(2)")||o.is(":last-child"))&&o.find("a").hasClass("rtmedia-list-item-a")){o.next();"block"==jQuery("#rtMedia-galary-next").css("display")&&(n||(a=e.ev.children(),n=!0,r=nextpage),jQuery("#rtMedia-galary-next").click())}var m=e.items.length;if(e.index!=m-1||o.is(":last-child")){"undefined"!=typeof _wpmejsSettings&&_wpmejsSettings.pluginPath;var d=jQuery(".rtmedia-container .rtmedia-single-meta").height(),l=!1;void 0!==e&&void 0!==e.probablyMobile&&1==e.probablyMobile&&(l=!0),t(".mfp-content .rtmedia-single-media .wp-audio-shortcode,.mfp-content .rtmedia-single-media .wp-video-shortcode,.mfp-content .rtmedia-single-media .bp_media_content video").attr("autoplay",!0),l&&t(".mfp-content .rtmedia-single-media .wp-video-shortcode,.mfp-content .rtmedia-single-media .bp_media_content video").attr("muted",!1),t(".mfp-content .rtmedia-single-media .wp-audio-shortcode,.mfp-content .rtmedia-single-media .wp-video-shortcode,.mfp-content .rtmedia-single-media .bp_media_content video").mediaelementplayer({classPrefix:"mejs-",defaultVideoWidth:480,hideVolumeOnTouchDevices:!1,features:["playpause","progress","current","volume","fullscreen"],defaultVideoHeight:270,alwaysShowControls:l,enableAutosize:!0,clickToPlayPause:!0,videoHeight:-1,success:function(e,i){e.addEventListener("loadeddata",(function(i){var a=t(e).height(),r=t(window).height(),n=jQuery("div.rtm-ltb-action-container").height(),o=d-(n=n+50);a>r&&jQuery(".rtmedia-container #rtmedia-single-media-container .mejs-container").attr("style","height:"+o+"px !important; transition:0.2s")}),!1),l&&t(e).hasClass("wp-video-shortcode")?jQuery("body").on("touchstart",".mejs-overlay-button",(function(t){e.paused?e.play():e.pause()})):e.pause()}}),t(".mfp-content .mejs-audio .mejs-controls").css("position","relative"),rtMediaHook.call("rtmedia_js_popup_after_content_added",[]),"undefined"!=typeof bp&&void 0!==bp.mentions&&void 0!==bp.mentions.users&&(t("#atwho-container #atwho-ground-comment_content").remove(),t("#comment_content").bp_mentions(bp.mentions.users)),rtmedia_reset_video_and_audio_for_popup(),apply_rtMagnificPopup(".rtmedia-list-media.rtm-gallery-list, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content, .rtm-bbp-container, ul.rtm-comment-container")}else i.click()},open:function(){var e=jQuery(".mfp-bg"),t=jQuery(".mfp-wrap");e.height(e.height()+t.height())},close:function(e){n&&(mfp.ev.empty(),mfp.ev.append(a),nextpage=r,n=!1,nextpage>1&&jQuery("#rtMedia-galary-next").show()),rtmedia_single_page_popup_close()},BeforeChange:function(e){}}})}jQuery(document).ajaxComplete((function(){jQuery("[id^=imgedit-leaving]").filter((function(){var e=jQuery(this).text();jQuery(this).text(e.replace("OK","Save"))}))}))}))}jQuery(document).ready((function(){if("object"==typeof rtmedia_bp)for(var e in rtmedia_bp)window[e]=rtmedia_bp[e];if("object"==typeof rtmedia_main)for(var e in rtmedia_main)window[e]=rtmedia_main[e];if("object"==typeof rtmedia_upload_terms)for(var e in rtmedia_upload_terms)window[e]=rtmedia_upload_terms[e];if("object"==typeof rtmedia_magnific)for(var e in rtmedia_magnific)window[e]=rtmedia_magnific[e]}));var rtMediaHook={hooks:[],is_break:!1,register:function(e,t){void 0===rtMediaHook.hooks[e]&&(rtMediaHook.hooks[e]=[]),rtMediaHook.hooks[e].push(t)},call:function(e,arguments){if(void 0!==rtMediaHook.hooks[e])for(i=0;i span,"+e+" .click-nav > div").toggleClass("no-js js"),jQuery(e+" .click-nav .js ul").hide(),jQuery(e+" .click-nav .clicker").click((function(e){t=jQuery("#rtm-media-options .click-nav .clicker").next("ul"),i=jQuery(this).next("ul"),jQuery.each(t,(function(e,t){jQuery(t).html()!=i.html()&&jQuery(t).hide()})),jQuery(i).toggle(),e.stopPropagation()}))}function bp_media_create_element(e){return!1}function rtmedia_version_compare(e,t){if(typeof e+typeof t!="stringstring")return!1;for(var i=e.split("."),a=t.split("."),r=0,n=Math.max(i.length,a.length);r0||parseInt(i[r])>parseInt(a[r]))return!0;if(a[r]&&!i[r]&&parseInt(a[r])>0||parseInt(i[r])0}function rtm_masonry_reload(e){setTimeout((function(){e.masonry("reload")}),250)}function rtm_search_media_text_validation(){""===jQuery("#media_search_input").val()?jQuery("#media_search").css("cursor","not-allowed"):jQuery("#media_search").css("cursor","pointer")}function rtmediaGetParameterByName(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(location.search);return null==t?"":decodeURIComponent(t[1].replace(/\+/g," "))}function rtmedia_single_media_alert_message(e,t,i){var a="rtmedia-success";"warning"==t&&(a="rtmedia-warning");var r=!1;jQuery(".rtmedia-message-container").each((function(e,t){return t=jQuery(t),i&&t.hasClass("rtmedia-empty-comment-error-class")?(t.remove(),r=!0,!1):void 0!==i||t.hasClass("rtmedia-empty-comment-error-class")?void 0:(t.remove(),r=!0,!1)}));var n,o=jQuery("
",{title:"Click to dismiss",class:"rtmedia-message-container"+(i?" rtmedia-empty-comment-error-class":""),style:"margin:1em 0;"}),m=jQuery("",{class:a});m.html(e),m.appendTo(o),i?(n=jQuery("#rt_media_comment_form"),jQuery("#comment_content").focus()):void 0===i&&(n=jQuery(".rtmedia-single-media .rtmedia-media")).css("opacity","0.2"),n.after(o),r&&(m.css({border:"2px solid #884646"}),setTimeout((function(){m.css({border:"none"})}),500)),setTimeout((function(){o.remove(),void 0===i&&n.css("opacity","1")}),3e3),o.click((function(){o.remove(),void 0===i&&n.css("opacity","1")}))}function rtmedia_gallery_action_alert_message(e,t){var i="rtmedia-success";"warning"==t&&(i="rtmedia-warning");jQuery("body").append(''),jQuery(".rtmedia-gallery-alert-container").append(""),setTimeout((function(){jQuery(".rtmedia-gallery-alert-container").remove()}),3e3),jQuery(".rtmedia-gallery-message-box").click((function(){jQuery(".rtmedia-gallery-alert-container").remove()}))}function rtmedia_activity_masonry(){jQuery("#activity-stream .rtmedia-activity-container .rtmedia-list").masonry({itemSelector:".rtmedia-list-item",gutter:7});var e=0,t=setInterval((function(){5===(e+=1)&&clearInterval(t),jQuery.each(jQuery(".rtmedia-activity-container .rtmedia-list.masonry .rtmedia-item-title"),(function(e,t){jQuery(t).width(jQuery(t).siblings(".rtmedia-item-thumbnail").children("img").width())})),rtm_masonry_reload(jQuery("#activity-stream .rtmedia-activity-container .rtmedia-list"))}),1e3)}function get_parameter(e,t){if(!e)return!1;t||(t=window.location.href);e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var i=new RegExp(e+"=([^&#]*)").exec(t);return null!==i&&i[1]}function rtm_upload_terms_activity(){if(jQuery("#rtmedia_upload_terms_conditions").length>0){jQuery("#bp-nouveau-activity-form").on("click","#aw-whats-new-submit",(function(e){var t=jQuery("#whats-new-form"),i=t.find("#rtmedia_upload_terms_conditions");if(0!==i.length&&!1===i.prop("checked")&&0===t.find("#message").length){e.preventDefault();var a=t.find(".rtmedia-upload-terms");rtp_display_terms_warning(a,rtmedia_upload_terms_check_terms_message)}}));var e=jQuery("#whats-new-form");e.length>0&&jQuery("#whats-new-form, #rtmedia_upload_terms_conditions").on("click",(function(t){e.find("input:hidden").each((function(){jQuery(this).prop("disabled",!1)}))}))}}jQuery("document").ready((function(e){function t(){if(jQuery("#rtmedia-media-view-form").length>0){var e=jQuery("#rtmedia-media-view-form").attr("action");jQuery.post(e,{},(function(e){}))}}function i(e,t,i){var a=new Date;a.setTime(a.getTime()+24*i*60*60*1e3);var r="expires="+a.toUTCString();document.cookie=e+"="+t+";"+r+";path=/"}jQuery(document).ajaxComplete((function(e,t,i){if("legacy"!==bp_template_pack&&bp_template_pack){var a=get_parameter("action",i.data);"activity_filter"!==a&&"post_update"!==a&&"get_single_activity_content"!==a&&"activity_get_older_updates"!==a||"undefined"==typeof rtmedia_masonry_layout||"true"!==rtmedia_masonry_layout||"undefined"==typeof rtmedia_masonry_layout_activity||"true"!==rtmedia_masonry_layout_activity?"activity_filter"!==a&&"post_update"!==a&&"get_single_activity_content"!==a&&"activity_get_older_updates"!==a||setTimeout((function(){apply_rtMagnificPopup(".rtmedia-list-media.rtm-gallery-list, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content, .rtm-bbp-container, ul.rtm-comment-container"),rtmedia_activity_stream_comment_media()}),1e3):setTimeout((function(){apply_rtMagnificPopup(".rtmedia-list-media.rtm-gallery-list, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content, .rtm-bbp-container, ul.rtm-comment-container"),rtmedia_activity_masonry(),rtmedia_activity_stream_comment_media()}),1e3)}})),jQuery(".rtmedia-uploader-div").css({opacity:"1",display:"block",visibility:"visible"}),jQuery(" #whats-new-options ").css({opacity:"1"}),void 0!==e.fn.rtTab&&e(".rtm-tabs").rtTab(),jQuery(".rtmedia-modal-link").length>0&&e(".rtmedia-modal-link").magnificPopup({type:"inline",midClick:!0,closeBtnInside:!0}),e("#rt_media_comment_form").submit((function(t){return""!=e.trim(e("#comment_content").val())||(0==jQuery("#rtmedia-single-media-container").length?rtmedia_gallery_action_alert_message(rtmedia_empty_comment_msg,"warning"):rtmedia_single_media_alert_message(rtmedia_empty_comment_msg,"warning"),!1)})),e("li.rtmedia-list-item p a").each((function(t){e(this).addClass("no-popup")})),e("li.rtmedia-list-item p a").each((function(t){e(this).addClass("no-popup")})),"undefined"!=typeof rtmedia_lightbox_enabled&&"1"==rtmedia_lightbox_enabled&&apply_rtMagnificPopup(".rtmedia-list-media.rtm-gallery-list, .rtmedia-activity-container ul.rtmedia-list, #bp-media-list,.bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content, .rtm-bbp-container, ul.rtm-comment-container"),jQuery.ajaxPrefilter((function(e,t,i){try{if(null==t.data||void 0===t.data||void 0===t.data.action)return!0}catch(e){return!0}if("activity_get_older_updates"==t.data.action){var a=t.success;e.success=function(e){"function"==typeof a&&a(e),apply_rtMagnificPopup(".rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content"),rtMediaHook.call("rtmedia_js_after_activity_added",[])}}else if("get_single_activity_content"==t.data.action){a=t.success;e.success=function(e){"function"==typeof a&&a(e),setTimeout((function(){apply_rtMagnificPopup(".rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content"),jQuery("ul.activity-list li.rtmedia_update:first-child .wp-audio-shortcode, ul.activity-list li.rtmedia_update:first-child .wp-video-shortcode").mediaelementplayer({classPrefix:"mejs-",defaultVideoWidth:480,defaultVideoHeight:270})}),900)}}})),jQuery.ajaxPrefilter((function(e,t,i){try{if(null==t.data||void 0===t.data||void 0===t.data.action)return!0}catch(e){return!0}if("activity_get_older_updates"==t.data.action){var a=t.success;e.success=function(e){"function"==typeof a&&a(e),apply_rtMagnificPopup(".rtmedia-activity-container ul.rtmedia-list, #bp-media-list, .bp-media-sc-list, li.media.album_updated ul,ul.bp-media-list-media, li.activity-item div.activity-content div.activity-inner div.bp_media_content"),jQuery("ul.activity-list li.rtmedia_update div.rtmedia-item-thumbnail > audio.wp-audio-shortcode, ul.activity-list li.rtmedia_update div.rtmedia-item-thumbnail > video.wp-video-shortcode").mediaelementplayer({classPrefix:"mejs-",defaultVideoWidth:480,defaultVideoHeight:270}),setTimeout((function(){rtmedia_activity_stream_comment_media()}),900),rtMediaHook.call("rtmedia_js_after_activity_added",[])}}})),jQuery(".rtmedia-container").on("click",".select-all",(function(e){jQuery(this).toggleClass("unselect-all").toggleClass("select-all"),jQuery(this).attr("title",rtmedia_unselect_all_visible),jQuery(".rtmedia-list input").each((function(){jQuery(this).prop("checked",!0)})),jQuery(".rtmedia-list-item").addClass("bulk-selected")})),jQuery(".rtmedia-container").on("click",".unselect-all",(function(e){jQuery(this).toggleClass("select-all").toggleClass("unselect-all"),jQuery(this).attr("title",rtmedia_select_all_visible),jQuery(".rtmedia-list input").each((function(){jQuery(this).prop("checked",!1)})),jQuery(".rtmedia-list-item").removeClass("bulk-selected")})),jQuery(".rtmedia-container").on("click",".rtmedia-move",(function(e){jQuery(".rtmedia-delete-container").slideUp(),jQuery(".rtmedia-move-container").slideToggle()})),jQuery("#rtmedia-create-album-modal").on("click","#rtmedia_create_new_album",(function(t){if($albumname=jQuery("").text(jQuery.trim(jQuery("#rtmedia_album_name").val())).html(),$album_description=jQuery("#rtmedia_album_description"),$context=jQuery.trim(jQuery("#rtmedia_album_context").val()),$context_id=jQuery.trim(jQuery("#rtmedia_album_context_id").val()),$privacy=jQuery.trim(jQuery("#rtmedia_select_album_privacy").val()),$create_album_nonce=jQuery.trim(jQuery("#rtmedia_create_album_nonce").val()),""!=$albumname){var i={action:"rtmedia_create_album",name:$albumname,description:$album_description.val(),context:$context,context_id:$context_id,create_album_nonce:$create_album_nonce};""!==$privacy&&(i.privacy=$privacy),e("#rtmedia_create_new_album").attr("disabled","disabled");var a=e("#rtmedia_create_new_album").html();e("#rtmedia_create_new_album").prepend(""),jQuery.post(rtmedia_ajax_url,i,(function(t){if(void 0!==t.album){t=jQuery.trim(t.album);var i=!0;$album_description.val(""),e("#rtmedia_album_name").focus(),jQuery(".rtmedia-user-album-list").each((function(){if(jQuery(this).children("optgroup").each((function(){if(jQuery(this).attr("value")===$context)return i=!1,void jQuery(this).append('")})),i){var e=$context.charAt(0).toUpperCase()+$context.slice(1)+" "+rtmedia_main_js_strings.rtmedia_albums,a='";jQuery(this).append(a)}})),jQuery('select.rtmedia-user-album-list option[value="'+t+'"]').prop("selected",!0),jQuery(".rtmedia-create-new-album-container").slideToggle(),jQuery("#rtmedia_album_name").val(""),jQuery("#rtmedia-create-album-modal").append("
"+$albumname+""+rtmedia_album_created_msg+"
"),setTimeout((function(){jQuery(".rtmedia-create-album-alert").remove()}),4e3),setTimeout((function(){galleryObj.reloadView(),window.location.reload(),jQuery(".close-reveal-modal").click()}),2e3)}else void 0!==t.error?rtmedia_gallery_action_alert_message(t.error,"warning"):rtmedia_gallery_action_alert_message(rtmedia_something_wrong_msg,"warning");e("#rtmedia_create_new_album").removeAttr("disabled"),e("#rtmedia_create_new_album").html(a)}))}else rtmedia_gallery_action_alert_message(rtmedia_empty_album_name_msg,"warning")})),jQuery(".rtmedia-container").on("click",".rtmedia-delete-selected",(function(e){jQuery(".rtmedia-list :checkbox:checked").length>0?confirm(rtmedia_selected_media_delete_confirmation)&&jQuery(this).closest("form").attr("action","../../../"+rtmedia_media_slug+"/delete").submit():rtmedia_gallery_action_alert_message(rtmedia_no_media_selected,"warning")})),jQuery(".rtmedia-container").on("click",".rtmedia-move-selected",(function(e){jQuery(".rtmedia-list :checkbox:checked").length>0?confirm(rtmedia_selected_media_move_confirmation)&&jQuery(this).closest("form").attr("action","").submit():rtmedia_gallery_action_alert_message(rtmedia_no_media_selected,"warning")})),jQuery("#buddypress").on("change",".rtm-activity-privacy-opt",(function(){var e=jQuery(this).attr("id");e=(e=e.split("-"))[e.length-1];var t=this;data={activity_id:e,privacy:jQuery(this).val(),nonce:jQuery("#rtmedia_activity_privacy_nonce").val(),action:"rtm_change_activity_privacy"},jQuery.post(ajaxurl,data,(function(e){var i="",a="";"true"==e?(i=rtmedia_main_js_strings.privacy_update_success,a="rtmedia-success"):(i=rtmedia_main_js_strings.privacy_update_error,a="fail"),jQuery(t).after('

'+i+"

"),setTimeout((function(){jQuery(t).siblings(".rtm-ac-privacy-updated").remove()}),2e3)}))})),jQuery(".media_search_input").on("keyup",(function(){rtm_search_media_text_validation()})),t(),rtMediaHook.register("rtmedia_js_popup_after_content_added",(function(){t(),jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",(function(e){e.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()})),mfp=jQuery.magnificPopup.instance,jQuery(mfp.items).size()>1&&0==comment_media?function(){var e=jQuery.magnificPopup.instance,t=e.probablyMobile,a=function(e){for(var t=e+"=",i=document.cookie.split(";"),a=0;a"+rtmedia_drop_media_msg+"
"),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&jQuery("#whats-new-textarea").append("
"+rtmedia_drop_media_msg+"
"),jQuery(document).on("dragover",(function(e){e.preventDefault(),e.target!=this&&(jQuery("#rtm-media-gallery-uploader").show(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&r.addClass("rtm-drag-drop-active"),a.addClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").show())})).on("dragleave",(function(e){if(e.preventDefault(),0!=e.originalEvent.pageX&&0!=e.originalEvent.pageY)return!1;"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&(r.removeClass("rtm-drag-drop-active"),r.removeAttr("style")),a.removeClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").hide()})).on("drop",(function(e){e.preventDefault(),jQuery(".bp-suggestions").focus(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&(r.removeClass("rtm-drag-drop-active"),r.removeAttr("style")),a.removeClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").hide()})),jQuery(".rtmedia-container").on("click",".rtmedia-delete-album",(function(e){e.preventDefault(),confirm(rtmedia_album_delete_confirmation)&&jQuery(this).closest("form").submit()})),jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",(function(e){e.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()})),rtmedia_init_action_dropdown(""),e(document).click((function(){e(".click-nav ul").is(":visible")&&e(".click-nav ul",this).hide()})),jQuery(".rtmedia-comment-link").on("click",(function(e){e.preventDefault(),jQuery("#comment_content").focus()})),jQuery(".rtm-more").length>0&&e(".rtm-more").shorten({showChars:200}),"undefined"!=typeof rtmedia_masonry_layout&&"true"==rtmedia_masonry_layout&&"undefined"!=typeof rtmedia_masonry_layout_activity&&"true"==rtmedia_masonry_layout_activity&&rtmedia_activity_masonry(),jQuery(document).ajaxComplete((function(e,t,i){var a=get_parameter("action",i.data);"post_update"!==a&&"get_single_activity_content"!==a&&"activity_get_older_updates"!==a||"undefined"==typeof rtmedia_masonry_layout||"true"!=rtmedia_masonry_layout||"undefined"==typeof rtmedia_masonry_layout_activity||"true"!=rtmedia_masonry_layout_activity||rtmedia_activity_masonry()})),"undefined"!=typeof rtmedia_masonry_layout&&"true"==rtmedia_masonry_layout&&0==jQuery(".rtmedia-container .rtmedia-list.rtm-no-masonry").length&&((rtm_masonry_container=jQuery(".rtmedia-container .rtmedia-list")).masonry({itemSelector:".rtmedia-list-item"}),setInterval((function(){jQuery.each(jQuery(".rtmedia-list.masonry .rtmedia-item-title"),(function(e,t){jQuery(t).width(jQuery(t).siblings(".rtmedia-item-thumbnail").children("img").width())})),rtm_masonry_reload(rtm_masonry_container)}),1e3),jQuery.each(jQuery(".rtmedia-list.masonry .rtmedia-item-title"),(function(e,t){jQuery(t).width(jQuery(t).siblings(".rtmedia-item-thumbnail").children("img").width())}))),jQuery(".rtm-uploader-tabs").length>0&&jQuery(".rtm-uploader-tabs li").click((function(e){jQuery(this).hasClass("active")||(jQuery(this).siblings().removeClass("active"),jQuery(this).parents(".rtm-uploader-tabs").siblings().hide(),class_name=jQuery(this).attr("class"),jQuery(this).parents(".rtm-uploader-tabs").siblings('[data-id="'+class_name+'"]').show(),jQuery(this).addClass("active"),"rtm-upload-tab"!=class_name?jQuery("div.moxie-shim").hide():jQuery("div.moxie-shim").show())})),jQuery(".rtmedia-container").on("click",".rtm-delete-media",(function(e){e.preventDefault();var t=RTMedia_Main_JS.media_delete_confirmation;if(confirm(t)){var i=jQuery(this).closest("li"),a=jQuery("#rtmedia_media_delete_nonce").val(),r=jQuery(this).parents(".rtmedia-list-item").data("media_type"),n={action:"delete_uploaded_media",nonce:a,media_id:i.attr("id"),media_type:r};jQuery.ajax({url:RTMedia_Main_JS.rtmedia_ajaxurl,type:"POST",data:n,dataType:"JSON",success:function(e){window.location.reload(),"rtmedia-media-deleted"===e.data.code?(rtmedia_gallery_action_alert_message(RTMedia_Main_JS.media_delete_success,"success"),i.remove(),"undefined"!=typeof rtmedia_masonry_layout&&"true"===rtmedia_masonry_layout&&rtm_masonry_reload(rtm_masonry_container),jQuery("#user-media span, #media-groups-li #media span, #rtmedia-nav-item-all span").text(e.data.all_media_count),jQuery("#rtmedia-nav-item-photo span").text(e.data.photos_count),jQuery("#rtmedia-nav-item-music span").text(e.data.music_count),jQuery("#rtmedia-nav-item-video span").text(e.data.videos_count)):rtmedia_gallery_action_alert_message(e.data.message,"warning")}})}}))})),function(e){e.fn.shorten=function(t){"use strict";var i={showChars:100,minHideChars:10,ellipsesText:"...",moreText:rtmedia_read_more,lessText:rtmedia__show_less,onLess:function(){},onMore:function(){},errMsg:null,force:!1};return t&&e.extend(i,t),!(e(this).data("jquery.shorten")&&!i.force)&&(e(this).data("jquery.shorten",!0),e(document).off("click",".morelink"),e(document).on({click:function(){var t=e(this);return t.hasClass("less")?(t.removeClass("less"),t.html(i.moreText),t.parent().prev().hide(0,(function(){t.parent().prev().prev().show()})).hide(0,(function(){i.onLess()}))):(t.addClass("less"),t.html(i.lessText),t.parent().prev().show(0,(function(){t.parent().prev().prev().hide()})).show(0,(function(){i.onMore()}))),!1}},".morelink"),this.each((function(){var t=e(this),a=t.html();if(t.text().length>i.showChars+i.minHideChars){var r=a.substr(0,i.showChars);if(r.indexOf("<")>=0){for(var n=!1,o="",m=0,d=[],l=null,s=0,c=0;c<=i.showChars;s++)if("<"!=a[s]||n||(n=!0,"/"==(l=a.substring(s+1,a.indexOf(">",s)))[0]?l!="/"+d[0]?i.errMsg="ERROR en HTML: the top of the stack should be the tag that closes":d.shift():"br"!=l.toLowerCase()&&d.unshift(l)),n&&">"==a[s]&&(n=!1),n)o+=a.charAt(s);else if(c++,m<=i.showChars)o+=a.charAt(s),m++;else if(d.length>0){for(j=0;j";break}r=e("
").html(o+''+i.ellipsesText+"").html()}else r+=i.ellipsesText;var u='
'+r+'
'+a+'
'+i.moreText+"";t.html(u),t.find(".allcontent").hide(),e(".shortcontent p:last",t).css("margin-bottom",0)}})))}}(jQuery),window.onload=function(){"undefined"!=typeof rtmedia_masonry_layout&&"true"==rtmedia_masonry_layout&&0==jQuery(".rtmedia-container .rtmedia-list.rtm-no-masonry").length&&rtm_masonry_reload(rtm_masonry_container),rtm_search_media_text_validation(),check_condition("search")&&jQuery("#media_search_remove").show()},jQuery(document).ready((function(){rtm_upload_terms_activity(),jQuery("body").hasClass("has-sidebar")&&0===jQuery("#secondary").length&&(jQuery(".rtmedia-single-container").length||jQuery(".rtmedia-container").length)&&jQuery("body").removeClass("has-sidebar"),rtmedia_main&&("undefined"!==rtmedia_main.rtmedia_direct_download_link&&parseInt(rtmedia_main.rtmedia_direct_download_link)||jQuery(document).on("bp_ajax_request",(function(e){setTimeout((function(){jQuery("video").each((function(){jQuery(this).attr("controlsList","nodownload"),jQuery(this).attr("playsinline","playsinline"),jQuery(this).load()}))}),200)})))})); \ No newline at end of file diff --git a/app/main/RTMedia.php b/app/main/RTMedia.php index ccc1809ed..2efc61ff6 100755 --- a/app/main/RTMedia.php +++ b/app/main/RTMedia.php @@ -1248,16 +1248,6 @@ public function enqueue_scripts_styles() { } if ( '' === $suffix ) { - wp_enqueue_script( - 'rtmedia-magnific-popup', - RTMEDIA_URL . 'app/assets/js/vendors/magnific-popup.js', - array( - 'jquery', - 'rt-mediaelement-wp', - ), - RTMEDIA_VERSION, - true - ); wp_enqueue_script( 'rtmedia-admin-tabs', RTMEDIA_URL . 'app/assets/admin/js/vendors/tabs.js', @@ -1277,7 +1267,7 @@ public function enqueue_scripts_styles() { 'rtmedia-emoji-picker', ), RTMEDIA_VERSION, - true + args: true ); } else { wp_enqueue_script( diff --git a/app/main/controllers/api/RTMediaJsonApi.php b/app/main/controllers/api/RTMediaJsonApi.php index f95984678..a5d402de9 100644 --- a/app/main/controllers/api/RTMediaJsonApi.php +++ b/app/main/controllers/api/RTMediaJsonApi.php @@ -161,6 +161,10 @@ public function __construct() { add_action( 'wp_ajax_nopriv_rtmedia_api', array( $this, 'rtmedia_api_process_request' ) ); add_action( 'wp_ajax_rtmedia_api', array( $this, 'rtmedia_api_process_request' ) ); + + if ( defined( 'RTMEDIA_GODAM_ACTIVE' ) && RTMEDIA_GODAM_ACTIVE ) { + add_action( 'rest_api_init', [ $this, 'register_rest_pre_dispatch_filter' ] ); + } } /** @@ -1469,4 +1473,39 @@ public function api_new_media_upload_dir( $args ) { return $args; } } + + /** + * Registers the rest_pre_dispatch filter during rest_api_init. + */ + public function register_rest_pre_dispatch_filter() { + add_filter( 'rest_pre_dispatch', [ $this, 'handle_rest_pre_dispatch' ], 10, 3 ); + } + + /** + * Callback for rest_pre_dispatch filter. + * + * @param mixed $result Result to return instead of the request. Default null to continue with request. + * @param WP_REST_Server $server Server instance. + * @param WP_REST_Request $request Request object. + * + * @return mixed Modified result or original $result. + */ + public function handle_rest_pre_dispatch( $result, $server, $request ) { + $route = $request->get_route(); + $method = $request->get_method(); + + if ( 'GET' === $method && preg_match( '#^/wp/v2/media/(\d+)$#', $route, $matches ) ) { + $media_id = (int) $matches[1]; + $post = get_post( $media_id ); + + if ( $post && 'attachment' === $post->post_type ) { + $controller = new WP_REST_Attachments_Controller( 'attachment' ); + $response = $controller->prepare_item_for_response( $post, $request ); + + return rest_ensure_response( $response ); + } + } + + return $result; + } } diff --git a/app/main/controllers/template/rtmedia-functions.php b/app/main/controllers/template/rtmedia-functions.php index 8c9984346..a2c53b6b7 100644 --- a/app/main/controllers/template/rtmedia-functions.php +++ b/app/main/controllers/template/rtmedia-functions.php @@ -584,33 +584,35 @@ function rtmedia_media( $size_flag = true, $echo = true, $media_size = 'rt_media $youtube_url = get_rtmedia_meta( $rtmedia_media->id, 'video_url_uploaded_from' ); $height = $rtmedia->options['defaultSizes_video_singlePlayer_height']; - $height = ( $height * 75 ) / 640; - $size = ' width="' . esc_attr( $rtmedia->options['defaultSizes_video_singlePlayer_width'] ) . '" height="' . esc_attr( $height ) . '%" '; - $html = "
"; - - if ( empty( $youtube_url ) ) { - - // added poster for showing thumbnail and changed preload value to fix rtMedia GL-209. - $html .= sprintf( - '', - esc_url( $rtmedia_media->cover_art || '' ), - esc_url( wp_get_attachment_url( $rtmedia_media->media_id ) ), - esc_attr( $size ), - esc_attr( $rtmedia_media->id ) - ); - - } else { + $width = $rtmedia->options['defaultSizes_video_singlePlayer_width']; + $height_pct = ( $height * 75 ) / 640; + $size_attr = ' width="' . esc_attr( $width ) . '" height="' . esc_attr( $height_pct ) . '%" '; - $html .= sprintf( - '', - esc_attr( $rtmedia_media->id ), - esc_url( wp_get_attachment_url( $rtmedia_media->media_id ) ) - ); + $html = '
'; + // Check if Godam plugin is active. + if ( defined( 'RTMEDIA_GODAM_ACTIVE' ) && RTMEDIA_GODAM_ACTIVE ) { + $html .= do_shortcode( '[godam_video id="' . esc_attr( $rtmedia_media->media_id ) . '"]' ); + } else { + // Fallback to native or YouTube player. + if ( empty( $youtube_url ) ) { + $html .= sprintf( + '', + esc_url( $rtmedia_media->cover_art ?: '' ), + esc_url( wp_get_attachment_url( $rtmedia_media->media_id ) ), + $size_attr, + esc_attr( $rtmedia_media->id ) + ); + } else { + $html .= sprintf( + '', + esc_attr( $rtmedia_media->id ), + esc_url( $youtube_url ) + ); + } } $html .= '
'; - } elseif ( 'music' === $rtmedia_media->media_type ) { $width = $rtmedia->options['defaultSizes_music_singlePlayer_width']; @@ -1466,6 +1468,49 @@ function rmedia_single_comment( $comment, $count = false, $i = false ) { ); } + /** + * Replaces
'; return apply_filters( 'rtmedia_single_comment', $html, $comment ); @@ -5177,3 +5222,234 @@ function rtmedia_like_eraser( $email_address, $page = 1 ) { 'done' => $done, ); } + + +// ------------------------GODAM INTEGRATION-----------------------// + +if ( defined( 'RTMEDIA_GODAM_ACTIVE' ) && RTMEDIA_GODAM_ACTIVE ) { + + /** + * Enqueue GoDAM scripts and styles globally (player, analytics, and styles). + */ + add_action( 'wp_enqueue_scripts', 'enqueue_scripts_globally', 20 ); + + function enqueue_scripts_globally() { + wp_enqueue_script( 'godam-player-frontend-script' ); + wp_enqueue_script( 'godam-player-analytics-script' ); + wp_enqueue_style( 'godam-player-frontend-style' ); + wp_enqueue_style( 'godam-player-style' ); + } + + /** + * Enqueue frontend scripts for Godam integration and AJAX refresh. + */ + add_action( 'wp_enqueue_scripts', function() { + + // Enqueue integration script for rtMedia and Godam. + wp_enqueue_script( + 'godam-rtmedia-integration', + RTMEDIA_URL . 'app/assets/js/godam-integration.min.js', + [ 'godam-player-frontend-script' ], + null, + true + ); + + // Enqueue the script responsible for AJAX-based comment refresh. + wp_enqueue_script( + 'godam-ajax-refresh', + RTMEDIA_URL . 'app/assets/js/godam-ajax-refresh.min.js', + [], + null, + true + ); + + // Pass AJAX URL and nonce to the script. + wp_localize_script( 'godam-ajax-refresh', 'GodamAjax', [ + 'ajax_url' => admin_url( 'admin-ajax.php' ), + 'nonce' => wp_create_nonce( 'godam-ajax-nonce' ), + ]); + } ); + + /** + * Filter BuddyPress activity content to replace rtMedia video list + * with Godam player shortcodes. + */ + add_filter( 'bp_get_activity_content_body', function( $content ) { + global $activities_template; + + // Bail early if activity object is not available + if ( empty( $activities_template->activity ) || ! is_object( $activities_template->activity ) ) { + return $content; + } + + $activity = $activities_template->activity; + + // Allow only certain activity types + $valid_types = [ 'rtmedia_update', 'activity_update', 'activity_comment' ]; + if ( ! isset( $activity->type ) || ! in_array( $activity->type, $valid_types, true ) ) { + return $content; + } + + // Ensure RTMediaModel class exists + if ( ! class_exists( 'RTMediaModel' ) ) { + return $content; + } + + $model = new RTMediaModel(); + $media_items = $model->get( [ 'activity_id' => $activity->id ] ); + + if ( empty( $media_items ) || ! is_array( $media_items ) ) { + return $content; + } + + // Remove rtMedia default video
    + $clean_content = preg_replace( + '#]*class="[^"]*rtmedia-list[^"]*rtm-activity-media-list[^"]*rtmedia-activity-media-length-[0-9]+[^"]*rtm-activity-video-list[^"]*"[^>]*>.*?
#si', + '', + $activity->content + ); + + // Group media by type + $grouped_media = []; + foreach ( $media_items as $media ) { + $grouped_media[ $media->media_type ][] = $media; + } + + $godam_videos = ''; + + // Build Godam player shortcodes for videos + if ( ! empty( $grouped_media['video'] ) ) { + foreach ( $grouped_media['video'] as $index => $video ) { + $player_id = 'godam-activity-' . esc_attr( $activity->id ) . '-' . $index; + $godam_videos .= do_shortcode( + '[godam_video id="' . esc_attr( $video->media_id ) . + '" context="buddypress" player_id="' . esc_attr( $player_id ) . '"]' + ); + } + } + + // Process video media in activity comments + if ( ! empty( $activity->children ) && is_array( $activity->children ) ) { + foreach ( $activity->children as $child ) { + $child_media = $model->get( [ 'activity_id' => $child->id ] ); + + if ( empty( $child_media ) ) { + continue; + } + + $child_videos = ''; + + foreach ( $child_media as $index => $video ) { + $player_id = 'godam-comment-' . esc_attr( $child->id ) . '-' . $index; + $child_videos .= do_shortcode( + '[godam_video id="' . esc_attr( $video->media_id ) . '"]' + ); + } + + if ( $child_videos ) { + // Remove rtMedia
    from comment + $child->content = preg_replace( + '#]*class="[^"]*rtmedia-list[^"]*rtm-activity-media-list[^"]*rtmedia-activity-media-length-[0-9]+[^"]*rtm-activity-video-list[^"]*"[^>]*>.*?
#si', + '', + $child->content + ); + + // Append Godam video players + $child->content .= '
' . $child_videos . '
'; + } + } + } + + // Final video output appended to cleaned content + if ( $godam_videos ) { + $godam_videos = '
' . $godam_videos . '
'; + } + + return wp_kses_post( $clean_content ) . $godam_videos; + }, 10 ); + + /** + * Handle AJAX request for loading a single activity comment's HTML. + */ + add_action( 'wp_ajax_get_single_activity_comment_html', 'handle_get_single_activity_comment_html' ); + add_action( 'wp_ajax_nopriv_get_single_activity_comment_html', 'handle_get_single_activity_comment_html' ); + + function handle_get_single_activity_comment_html() { + check_ajax_referer( 'godam-ajax-nonce', 'nonce' ); + + $activity_id = isset( $_POST['comment_id'] ) ? intval( $_POST['comment_id'] ) : 0; + + if ( ! $activity_id ) { + wp_send_json_error( 'Invalid activity ID' ); + } + + $activity = new BP_Activity_Activity( $activity_id ); + if ( empty( $activity->id ) ) { + wp_send_json_error( 'Activity comment not found' ); + } + + global $activities_template; + + // Backup original activity + $original_activity = $activities_template->activity ?? null; + + // Replace global for template rendering + $activities_template = new stdClass(); + $activities_template->activity = $activity; + + ob_start(); + bp_get_template_part( 'activity/entry' ); + $html = ob_get_clean(); + + // Restore original + if ( $original_activity ) { + $activities_template->activity = $original_activity; + } + + wp_send_json_success( [ 'html' => $html ] ); + } + +} + +/** + * Enqueue the Magnific Popup script for rtMedia. + * + * This function ensures that the Magnific Popup script is loaded correctly on the frontend + * so that popup functionality works seamlessly with all combinations of plugin states: + * - When only rtMedia is active + * - When both rtMedia and Godam plugins are active + * - When Godam plugin is deactivated + * + * To achieve this, the script is deregistered first if already registered or enqueued, + * preventing conflicts or duplicates. + * + * When Godam plugin is active, the script is loaded without dependencies to avoid + * redundant or conflicting scripts. When Godam is not active, dependencies such as + * jQuery and rt-mediaelement-wp are included to ensure proper functionality. + * + * Enqueuing here guarantees consistent script loading regardless of Godam’s activation status. + */ +function enqueue_rtmedia_magnific_popup_script() { + $handle = 'rtmedia-magnific-popup'; + $script_src = RTMEDIA_URL . 'app/assets/js/vendors/magnific-popup.js'; + $version = RTMEDIA_VERSION; + $in_footer = true; + + // Deregister the script if already registered or enqueued to prevent conflicts + if (wp_script_is($handle, 'registered') || wp_script_is($handle, 'enqueued')) { + wp_deregister_script($handle); + } + + // Determine dependencies based on whether Godam integration is active + $dependencies = []; + + // If Godam plugin is NOT active, add dependencies for jQuery and mediaelement + if (!defined('RTMEDIA_GODAM_ACTIVE') || !RTMEDIA_GODAM_ACTIVE) { + $dependencies = ['jquery', 'rt-mediaelement-wp']; + } + + // Enqueue the Magnific Popup script with the appropriate dependencies + wp_enqueue_script($handle, $script_src, $dependencies, $version, $in_footer); +} + +add_action('wp_enqueue_scripts', 'enqueue_rtmedia_magnific_popup_script'); diff --git a/index.php b/index.php index 3d92d9395..558567272 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: rtMedia for WordPress, BuddyPress and bbPress * Plugin URI: https://rtmedia.io/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media * 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! - * Version: 4.6.23 + * Version: 4.7.0 * Author: rtCamp * Text Domain: buddypress-media * Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media @@ -19,7 +19,7 @@ /** * The version of the plugin */ - define( 'RTMEDIA_VERSION', '4.6.23' ); + define( 'RTMEDIA_VERSION', '4.7.0' ); } if ( ! defined( 'RTMEDIA_PATH' ) ) { @@ -55,6 +55,22 @@ define( 'RTMEDIA_BASE_NAME', plugin_basename( __FILE__ ) ); } +/** + * To prevent fatal errors when calling is_plugin_active(), we first check if the + * function exists. If it doesn't, we include the file manually to ensure the + * function is available. + */ +if ( ! function_exists( 'is_plugin_active' ) ) { + require_once ABSPATH . 'wp-admin/includes/plugin.php'; +} + +if ( ! defined( 'RTMEDIA_GODAM_ACTIVE' ) ) { + /** + * Check if Godam plugin is active and set constant accordingly. + */ + define( 'RTMEDIA_GODAM_ACTIVE', is_plugin_active( 'godam/godam.php' ) ); +} + /** * Auto Loader Function * diff --git a/readme.txt b/readme.txt index 1b67646b4..b4ea9aeb8 100644 --- a/readme.txt +++ b/readme.txt @@ -4,8 +4,8 @@ Tags: BuddyPress, media, multimedia, album, audio, music, video, photo, upload, License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Requires at least: WordPress 4.1 -Tested up to: 6.8 -Stable tag: 4.6.23 +Tested up to: 6.8.1 +Stable tag: 4.7.0 Add albums, photo, audio/video upload, privacy, sharing, front-end uploads & more. All this works on mobile/tablets devices. @@ -133,6 +133,18 @@ http://www.youtube.com/watch?v=dJrykKQGDcs == Changelog == += 4.7.0 [June 2, 2025] = + +* ENHANCEMENTS + * Added integration with GoDAM plugin's video player. + * Enabled support for GoDAM video player in rtMedia media gallery, BuddyPress activity stream, groups, and forums. + * Improved handling of player enqueue conditions based on GoDAM plugin status. + * Refined script loading to ensure compatibility across WordPress, BuddyPress, and rtMedia components. + +* FIXED + * Prevented conflicts with `mediaelement.js` when GoDAM plugin is active. + * Deregistered conflicting scripts to ensure seamless fallback and prevent duplication in player initialization. + = 4.6.23 [April 18, 2025] = * Fixed @@ -1922,6 +1934,9 @@ http://www.youtube.com/watch?v=dJrykKQGDcs == Upgrade Notice == += 4.7.0 = +This update introduces comprehensive support for the GoDAM video player across rtMedia galleries and all BuddyPress components, including activity streams, groups, and forums. + = 4.6.23 = rtMedia 4.6.23 with WP v6.8 compatibility, node package enhancements and updated admin notices.