rtMedia for WordPress, BuddyPress and bbPress - Version 3.9.4

Version Description

Requires BuddyPress 1.7 or higher, if using BuddyPress. Fixed media slug issue while deleting media, added new hook in album gallery template.

=

Download this release

Release Info

Developer rtcamp
Plugin Icon 128x128 rtMedia for WordPress, BuddyPress and bbPress
Version 3.9.4
Comparing to
See all releases

Code changes from version 3.9.3 to 3.9.4

app/admin/RTMediaAdmin.php CHANGED
@@ -1936,10 +1936,10 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
1936
  }
1937
 
1938
  function rtmedia_update_template_notice() {
1939
- $site_option = rtmedia_get_site_option( 'rtmedia-update-template-notice-v3_9_2' );
1940
 
1941
  if ( ! $site_option || 'hide' != $site_option ) {
1942
- rtmedia_update_site_option( 'rtmedia-update-template-notice-v3_9_2', 'show' );
1943
  if ( is_dir( get_template_directory() . '/rtmedia' ) ) {
1944
  echo '<div class="error rtmedia-update-template-notice"><p>' . __( 'Please update rtMedia template files if you have overridden the default rtMedia templates in your theme. If not, you can ignore and hide this notice.', 'buddypress-media' ) . '<a href="#" onclick="rtmedia_hide_template_override_notice()" style="float:right">' . __( 'Hide', 'buddypress-media' ) . '</a>' . ' </p></div>';
1945
  ?>
@@ -1960,7 +1960,7 @@ if ( ! class_exists( 'RTMediaAdmin' ) ) {
1960
 
1961
  function rtmedia_hide_template_override_notice() {
1962
 
1963
- if ( rtmedia_update_site_option( 'rtmedia-update-template-notice-v3_9_2', 'hide' ) ) {
1964
  echo '1';
1965
  } else {
1966
  echo '0';
1936
  }
1937
 
1938
  function rtmedia_update_template_notice() {
1939
+ $site_option = rtmedia_get_site_option( 'rtmedia-update-template-notice-v3_9_4' );
1940
 
1941
  if ( ! $site_option || 'hide' != $site_option ) {
1942
+ rtmedia_update_site_option( 'rtmedia-update-template-notice-v3_9_4', 'show' );
1943
  if ( is_dir( get_template_directory() . '/rtmedia' ) ) {
1944
  echo '<div class="error rtmedia-update-template-notice"><p>' . __( 'Please update rtMedia template files if you have overridden the default rtMedia templates in your theme. If not, you can ignore and hide this notice.', 'buddypress-media' ) . '<a href="#" onclick="rtmedia_hide_template_override_notice()" style="float:right">' . __( 'Hide', 'buddypress-media' ) . '</a>' . ' </p></div>';
1945
  ?>
1960
 
1961
  function rtmedia_hide_template_override_notice() {
1962
 
1963
+ if ( rtmedia_update_site_option( 'rtmedia-update-template-notice-v3_9_4', 'hide' ) ) {
1964
  echo '1';
1965
  } else {
1966
  echo '0';
app/assets/js/rtMedia.js CHANGED
@@ -336,7 +336,7 @@ jQuery( 'document' ).ready( function ( $ ) {
336
  jQuery( '.rtmedia-container' ).on( 'click', '.rtmedia-delete-selected', function ( e ) {
337
  if ( jQuery( '.rtmedia-list :checkbox:checked' ).length > 0 ) {
338
  if ( confirm( rtmedia_selected_media_delete_confirmation ) ) {
339
- jQuery( this ).closest( 'form' ).attr( 'action', '../../../media/delete' ).submit();
340
  }
341
  } else {
342
  rtmedia_gallery_action_alert_message( rtmedia_no_media_selected, 'warning' );
@@ -592,6 +592,7 @@ jQuery( 'document' ).ready( function ( $ ) {
592
  type: 'post',
593
  data: data,
594
  success: function ( data ) {
 
595
  if ( data == '1' ) {
596
  //media delete
597
  rtmedia_gallery_action_alert_message( 'file deleted successfully.', 'success' );
336
  jQuery( '.rtmedia-container' ).on( 'click', '.rtmedia-delete-selected', function ( e ) {
337
  if ( jQuery( '.rtmedia-list :checkbox:checked' ).length > 0 ) {
338
  if ( confirm( rtmedia_selected_media_delete_confirmation ) ) {
339
+ jQuery( this ).closest( 'form' ).attr( 'action', '../../../' + rtmedia_media_slug + '/delete' ).submit();
340
  }
341
  } else {
342
  rtmedia_gallery_action_alert_message( rtmedia_no_media_selected, 'warning' );
592
  type: 'post',
593
  data: data,
594
  success: function ( data ) {
595
+
596
  if ( data == '1' ) {
597
  //media delete
598
  rtmedia_gallery_action_alert_message( 'file deleted successfully.', 'success' );
app/assets/js/rtmedia.min.js CHANGED
@@ -3,4 +3,4 @@
3
  * @package rtMedia
4
  */
5
  function apply_rtMagnificPopup(a){jQuery("document").ready(function(b){var c="";c="undefined"==typeof rtmedia_load_more?"Loading media":rtmedia_load_more,"undefined"!=typeof rtmedia_lightbox_enabled&&"1"==rtmedia_lightbox_enabled&&(b(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").length>0&&b(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").addClass("no-popup"),rtMagnificPopup=jQuery(a).magnificPopup({delegate:"a:not(.no-popup, .mejs-time-slider, .mejs-volume-slider, .mejs-horizontal-volume-slider)",type:"ajax",tLoading:c+" #%curr%...",mainClass:"mfp-img-mobile",preload:[1,3],closeOnBgClick:!0,gallery:{enabled:!0,navigateByImgClick:!0,arrowMarkup:"",preload:[0,1]},image:{tError:'<a href="%url%">The image #%curr%</a> could not be loaded.',titleSrc:function(a){return a.el.attr("title")+"<small>by Marsel Van Oosten</small>"}},callbacks:{ajaxContentAdded:function(){a=jQuery.magnificPopup.instance,1===jQuery(a.items).size()&&jQuery(".mfp-arrow").remove();var a=jQuery.magnificPopup.instance,c=a.currItem.el,d=c.parent();if(d.is("li")||(d=d.parent()),d.is(":nth-last-child(2)")||d.is(":last-child")){d.next();"block"==jQuery("#rtMedia-galary-next").css("display")&&jQuery("#rtMedia-galary-next").click()}var e=a.items.length;if(a.index==e-1&&!d.is(":last-child"))return void c.click();var f={};"undefined"!=typeof _wpmejsSettings&&(f.pluginPath=_wpmejsSettings.pluginPath),b(".mfp-content .wp-audio-shortcode,.mfp-content .wp-video-shortcode,.mfp-content .bp_media_content video").mediaelementplayer({defaultVideoWidth:480,defaultVideoHeight:270,success:function(a,b){a.play()}}),b(".mfp-content .mejs-audio .mejs-controls").css("position","relative"),rtMediaHook.call("rtmedia_js_popup_after_content_added",[])},close:function(a){rtmedia_init_action_dropdown()},BeforeChange:function(a){}}}))})}function rtmedia_init_action_dropdown(){var a,b;jQuery(".click-nav > span, .click-nav > div").toggleClass("no-js js"),jQuery(".click-nav .js ul").hide(),jQuery(".click-nav .clicker").click(function(c){a=jQuery("#rtm-media-options .click-nav .clicker").next("ul"),b=jQuery(this).next("ul"),jQuery.each(a,function(a,c){jQuery(c).html()!=b.html()&&jQuery(c).hide()}),jQuery(b).toggle(),c.stopPropagation()})}function bp_media_create_element(a){return!1}function rtmedia_version_compare(a,b){if(typeof a+typeof b!="stringstring")return!1;for(var c=a.split("."),d=b.split("."),e=0,f=Math.max(c.length,d.length);f>e;e++){if(c[e]&&!d[e]&&parseInt(c[e])>0||parseInt(c[e])>parseInt(d[e]))return!0;if(d[e]&&!c[e]&&parseInt(d[e])>0||parseInt(c[e])<parseInt(d[e]))return!1}return!0}function rtm_is_element_exist(a){return jQuery(a).length>0?!0:!1}function rtm_masonry_reload(a){setTimeout(function(){a.masonry("reload")},250)}function rtmediaGetParameterByName(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null==c?"":decodeURIComponent(c[1].replace(/\+/g," "))}function rtmedia_single_media_alert_message(a,b){var c="rtmedia-success";"warning"==b&&(c="rtmedia-warning"),jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","0.2"),jQuery(".rtmedia-single-media .rtmedia-media").after("<div class='rtmedia-message-container'><span class='"+c+"'>"+a+" </span></div>"),setTimeout(function(){jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","1"),jQuery(".rtmedia-message-container").remove()},3e3),jQuery(".rtmedia-message-container").click(function(){jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","1"),jQuery(".rtmedia-message-container").remove()})}function rtmedia_gallery_action_alert_message(a,b){var c="rtmedia-success";"warning"==b&&(c="rtmedia-warning");var d='<div class="rtmedia-gallery-alert-container"> </div>';jQuery("body").append(d),jQuery(".rtmedia-gallery-alert-container").append("<div class='rtmedia-gallery-message-box'><span class='"+c+"'>"+a+" </span></div>"),setTimeout(function(){jQuery(".rtmedia-gallery-alert-container").remove()},3e3),jQuery(".rtmedia-gallery-message-box").click(function(){jQuery(".rtmedia-gallery-alert-container").remove()})}!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):window.jQuery||window.Zepto)}(function(a){var b,c,d,e,f,g,h="Close",i="BeforeClose",j="AfterClose",k="BeforeAppend",l="MarkupParse",m="Open",n="Change",o="mfp",p="."+o,q="mfp-ready",r="mfp-removing",s="mfp-prevent-close",t=function(){},u=!!window.jQuery,v=a(window),w=function(a,c){b.ev.on(o+a+p,c)},x=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},y=function(c,d){b.ev.triggerHandler(o+c,d),b.st.callbacks&&(c=c.charAt(0).toLowerCase()+c.slice(1),b.st.callbacks[c]&&b.st.callbacks[c].apply(b,a.isArray(d)?d:[d]))},z=function(c){return c===g&&b.currTemplate.closeBtn||(b.currTemplate.closeBtn=a(b.st.closeMarkup.replace("%title%",b.st.tClose)),g=c),b.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(b=new t,b.init(),a.magnificPopup.instance=b)},B=function(){var a=document.createElement("p").style,b=["ms","O","Moz","Webkit"];if(void 0!==a.transition)return!0;for(;b.length;)if(b.pop()+"Transition"in a)return!0;return!1};t.prototype={constructor:t,init:function(){var c=navigator.appVersion;b.isIE7=-1!==c.indexOf("MSIE 7."),b.isIE8=-1!==c.indexOf("MSIE 8."),b.isLowIE=b.isIE7||b.isIE8,b.isAndroid=/android/gi.test(c),b.isIOS=/iphone|ipad|ipod/gi.test(c),b.supportsTransition=B(),b.probablyMobile=b.isAndroid||b.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),d=a(document),b.popupsCache={}},open:function(c){var e;if(c.isObj===!1){b.items=c.items.toArray(),b.index=0;var g,h=c.items;for(e=0;e<h.length;e++)if(g=h[e],g.parsed&&(g=g.el[0]),g===c.el[0]){b.index=e;break}}else b.items=a.isArray(c.items)?c.items:[c.items],b.index=c.index||0;if(b.isOpen)return void b.updateItemHTML();b.types=[],f="",c.mainEl&&c.mainEl.length?b.ev=c.mainEl.eq(0):b.ev=d,c.key?(b.popupsCache[c.key]||(b.popupsCache[c.key]={}),b.currTemplate=b.popupsCache[c.key]):b.currTemplate={},b.st=a.extend(!0,{},a.magnificPopup.defaults,c),b.fixedContentPos="auto"===b.st.fixedContentPos?!b.probablyMobile:b.st.fixedContentPos,b.st.modal&&(b.st.closeOnContentClick=!1,b.st.closeOnBgClick=!1,b.st.showCloseBtn=!1,b.st.enableEscapeKey=!1),b.bgOverlay||(b.bgOverlay=x("bg").on("click"+p,function(){b.close()}),b.wrap=x("wrap").attr("tabindex",-1).on("click"+p,function(a){b._checkIfClose(a.target)&&b.close()}),b.container=x("container",b.wrap)),b.contentContainer=x("content"),b.st.preloader&&(b.preloader=x("preloader",b.container,b.st.tLoading));var i=a.magnificPopup.modules;for(e=0;e<i.length;e++){var j=i[e];j=j.charAt(0).toUpperCase()+j.slice(1),b["init"+j].call(b)}y("BeforeOpen"),b.st.showCloseBtn&&(b.st.closeBtnInside?(w(l,function(a,b,c,d){c.close_replaceWith=z(d.type)}),f+=" mfp-close-btn-in"):b.wrap.append(z())),b.st.alignTop&&(f+=" mfp-align-top"),b.fixedContentPos?b.wrap.css({overflow:b.st.overflowY,overflowX:"hidden",overflowY:b.st.overflowY}):b.wrap.css({top:v.scrollTop(),position:"absolute"}),(b.st.fixedBgPos===!1||"auto"===b.st.fixedBgPos&&!b.fixedContentPos)&&b.bgOverlay.css({height:d.height(),position:"absolute"}),b.st.enableEscapeKey&&d.on("keyup"+p,function(a){27===a.keyCode&&b.close()}),v.on("resize"+p,function(){b.updateSize()}),b.st.closeOnContentClick||(f+=" mfp-auto-cursor"),f&&b.wrap.addClass(f);var k=b.wH=v.height(),n={};if(b.fixedContentPos&&b._hasScrollBar(k)){var o=b._getScrollbarSize();o&&(n.marginRight=o)}b.fixedContentPos&&(b.isIE7?a("body, html").css("overflow","hidden"):n.overflow="hidden");var r=b.st.mainClass;return b.isIE7&&(r+=" mfp-ie7"),r&&b._addClassToMFP(r),b.updateItemHTML(),y("BuildControls"),a("html").css(n),b.bgOverlay.add(b.wrap).prependTo(b.st.prependTo||a(document.body)),b._lastFocusedEl=document.activeElement,setTimeout(function(){b.content?(b._addClassToMFP(q),b._setFocus()):b.bgOverlay.addClass(q),d.on("focusin"+p,b._onFocusIn)},16),b.isOpen=!0,b.updateSize(k),y(m),c},close:function(){b.isOpen&&(y(i),b.isOpen=!1,b.st.removalDelay&&!b.isLowIE&&b.supportsTransition?(b._addClassToMFP(r),setTimeout(function(){b._close()},b.st.removalDelay)):b._close())},_close:function(){y(h);var c=r+" "+q+" ";if(b.bgOverlay.detach(),b.wrap.detach(),b.container.empty(),b.st.mainClass&&(c+=b.st.mainClass+" "),b._removeClassFromMFP(c),b.fixedContentPos){var e={marginRight:""};b.isIE7?a("body, html").css("overflow",""):e.overflow="",a("html").css(e)}d.off("keyup"+p+" focusin"+p),b.ev.off(p),b.wrap.attr("class","mfp-wrap").removeAttr("style"),b.bgOverlay.attr("class","mfp-bg"),b.container.attr("class","mfp-container"),!b.st.showCloseBtn||b.st.closeBtnInside&&b.currTemplate[b.currItem.type]!==!0||b.currTemplate.closeBtn&&b.currTemplate.closeBtn.detach(),b._lastFocusedEl&&a(b._lastFocusedEl).focus(),b.currItem=null,b.content=null,b.currTemplate=null,b.prevHeight=0,y(j)},updateSize:function(a){if(b.isIOS){var c=document.documentElement.clientWidth/window.innerWidth,d=window.innerHeight*c;b.wrap.css("height",d),b.wH=d}else b.wH=a||v.height();b.fixedContentPos||b.wrap.css("height",b.wH),y("Resize")},updateItemHTML:function(){var c=b.items[b.index];b.contentContainer.detach(),b.content&&b.content.detach(),c.parsed||(c=b.parseEl(b.index));var d=c.type;if(y("BeforeChange",[b.currItem?b.currItem.type:"",d]),b.currItem=c,!b.currTemplate[d]){var f=b.st[d]?b.st[d].markup:!1;y("FirstMarkupParse",f),f?b.currTemplate[d]=a(f):b.currTemplate[d]=!0}e&&e!==c.type&&b.container.removeClass("mfp-"+e+"-holder");var g=b["get"+d.charAt(0).toUpperCase()+d.slice(1)](c,b.currTemplate[d]);b.appendContent(g,d),c.preloaded=!0,y(n,c),e=c.type,b.container.prepend(b.contentContainer),y("AfterChange")},appendContent:function(a,c){b.content=a,a?b.st.showCloseBtn&&b.st.closeBtnInside&&b.currTemplate[c]===!0?b.content.find(".mfp-close").length||b.content.append(z()):b.content=a:b.content="",y(k),b.container.addClass("mfp-"+c+"-holder"),b.contentContainer.append(b.content)},parseEl:function(c){var d,e=b.items[c];if(e.tagName?e={el:a(e)}:(d=e.type,e={data:e,src:e.src}),e.el){for(var f=b.types,g=0;g<f.length;g++)if(e.el.hasClass("mfp-"+f[g])){d=f[g];break}e.src=e.el.attr("data-mfp-src"),e.src||(e.src=e.el.attr("href"))}return e.type=d||b.st.type||"inline",e.index=c,e.parsed=!0,b.items[c]=e,y("ElementParse",e),b.items[c]},addGroup:function(a,c){var d=function(d){d.mfpEl=this,b._openClick(d,a,c)};c||(c={});var e="click.magnificPopup";c.mainEl=a,c.items?(c.isObj=!0,a.off(e).on(e,d)):(c.isObj=!1,c.delegate?a.off(e).on(e,c.delegate,d):(c.items=a,a.off(e).on(e,d)))},_openClick:function(c,d,e){var f=void 0!==e.midClick?e.midClick:a.magnificPopup.defaults.midClick;if(f||2!==c.which&&!c.ctrlKey&&!c.metaKey){var g=void 0!==e.disableOn?e.disableOn:a.magnificPopup.defaults.disableOn;if(g)if(a.isFunction(g)){if(!g.call(b))return!0}else if(v.width()<g)return!0;c.type&&(c.preventDefault(),b.isOpen&&c.stopPropagation()),e.el=a(c.mfpEl),e.delegate&&(e.items=d.find(e.delegate)),b.open(e)}},updateStatus:function(a,d){if(b.preloader){c!==a&&b.container.removeClass("mfp-s-"+c),d||"loading"!==a||(d=b.st.tLoading);var e={status:a,text:d};y("UpdateStatus",e),a=e.status,d=e.text,b.preloader.html(d),b.preloader.find("a").on("click",function(a){a.stopImmediatePropagation()}),b.container.addClass("mfp-s-"+a),c=a}},_checkIfClose:function(c){if(!a(c).hasClass(s)){var d=b.st.closeOnContentClick,e=b.st.closeOnBgClick;if(d&&e)return!0;if(!b.content||a(c).hasClass("mfp-close")||b.preloader&&c===b.preloader[0])return!0;if(c===b.content[0]||a.contains(b.content[0],c)){if(d)return!0}else if(e&&a.contains(document,c))return!0;return!1}},_addClassToMFP:function(a){b.bgOverlay.addClass(a),b.wrap.addClass(a)},_removeClassFromMFP:function(a){this.bgOverlay.removeClass(a),b.wrap.removeClass(a)},_hasScrollBar:function(a){return(b.isIE7?d.height():document.body.scrollHeight)>(a||v.height())},_setFocus:function(){(b.st.focus?b.content.find(b.st.focus).eq(0):b.wrap).focus()},_onFocusIn:function(c){return c.target===b.wrap[0]||a.contains(b.wrap[0],c.target)?void 0:(b._setFocus(),!1)},_parseMarkup:function(b,c,d){var e;d.data&&(c=a.extend(d.data,c)),y(l,[b,c,d]),a.each(c,function(a,c){if(void 0===c||c===!1)return!0;if(e=a.split("_"),e.length>1){var d=b.find(p+"-"+e[0]);if(d.length>0){var f=e[1];"replaceWith"===f?d[0]!==c[0]&&d.replaceWith(c):"img"===f?d.is("img")?d.attr("src",c):d.replaceWith('<img src="'+c+'" class="'+d.attr("class")+'" />'):d.attr(e[1],c)}}else b.find(p+"-"+a).html(c)})},_getScrollbarSize:function(){if(void 0===b.scrollbarSize){var a=document.createElement("div");a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),b.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return b.scrollbarSize}},a.magnificPopup={instance:null,proto:t.prototype,modules:[],open:function(b,c){return A(),b=b?a.extend(!0,{},b):{},b.isObj=!0,b.index=c||0,this.instance.open(b)},close:function(){return a.magnificPopup.instance&&a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},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:'<button title="%title%" type="button" class="mfp-close">&times;</button>',tClose:"Close (Esc)",tLoading:"Loading..."}},a.fn.magnificPopup=function(c){A();var d=a(this);if("string"==typeof c)if("open"===c){var e,f=u?d.data("magnificPopup"):d[0].magnificPopup,g=parseInt(arguments[1],10)||0;f.items?e=f.items[g]:(e=d,f.delegate&&(e=e.find(f.delegate)),e=e.eq(g)),b._openClick({mfpEl:e},d,f)}else b.isOpen&&b[c].apply(b,Array.prototype.slice.call(arguments,1));else c=a.extend(!0,{},c),u?d.data("magnificPopup",c):d[0].magnificPopup=c,b.addGroup(d,c);return d};var C,D,E,F="inline",G=function(){E&&(D.after(E.addClass(C)).detach(),E=null)};a.magnificPopup.registerModule(F,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){b.types.push(F),w(h+"."+F,function(){G()})},getInline:function(c,d){if(G(),c.src){var e=b.st.inline,f=a(c.src);if(f.length){var g=f[0].parentNode;g&&g.tagName&&(D||(C=e.hiddenClass,D=x(C),C="mfp-"+C),E=f.after(D).detach().removeClass(C)),b.updateStatus("ready")}else b.updateStatus("error",e.tNotFound),f=a("<div>");return c.inlineElement=f,f}return b.updateStatus("ready"),b._parseMarkup(d,{},c),d}}});var H,I="ajax",J=function(){H&&a(document.body).removeClass(H)},K=function(){J(),b.req&&b.req.abort()};a.magnificPopup.registerModule(I,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){b.types.push(I),H=b.st.ajax.cursor,w(h+"."+I,K),w("BeforeChange."+I,K)},getAjax:function(c){H&&a(document.body).addClass(H),b.updateStatus("loading");var d=a.extend({url:c.src,success:function(d,e,f){var g={data:d,xhr:f};y("ParseAjax",g),b.appendContent(a(g.data),I),c.finished=!0,J(),b._setFocus(),setTimeout(function(){b.wrap.addClass(q)},16),b.updateStatus("ready"),y("AjaxContentAdded")},error:function(){J(),c.finished=c.loadError=!0,b.updateStatus("error",b.st.ajax.tError.replace("%url%",c.src))}},b.st.ajax.settings);return b.req=a.ajax(d),""}}});var L,M=function(c){if(c.data&&void 0!==c.data.title)return c.data.title;var d=b.st.image.titleSrc;if(d){if(a.isFunction(d))return d.call(b,c);if(c.el)return c.el.attr(d)||""}return""};a.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var c=b.st.image,d=".image";b.types.push("image"),w(m+d,function(){"image"===b.currItem.type&&c.cursor&&a(document.body).addClass(c.cursor)}),w(h+d,function(){c.cursor&&a(document.body).removeClass(c.cursor),v.off("resize"+p)}),w("Resize"+d,b.resizeImage),b.isLowIE&&w("AfterChange",b.resizeImage)},resizeImage:function(){var a=b.currItem;if(a&&a.img&&b.st.image.verticalFit){var c=0;b.isLowIE&&(c=parseInt(a.img.css("padding-top"),10)+parseInt(a.img.css("padding-bottom"),10)),a.img.css("max-height",b.wH-c)}},_onImageHasSize:function(a){a.img&&(a.hasSize=!0,L&&clearInterval(L),a.isCheckingImgSize=!1,y("ImageHasSize",a),a.imgHidden&&(b.content&&b.content.removeClass("mfp-loading"),a.imgHidden=!1))},findImageSize:function(a){var c=0,d=a.img[0],e=function(f){L&&clearInterval(L),L=setInterval(function(){return d.naturalWidth>0?void b._onImageHasSize(a):(c>200&&clearInterval(L),c++,void(3===c?e(10):40===c?e(50):100===c&&e(500)))},f)};e(1)},getImage:function(c,d){var e=0,f=function(){c&&(c.img[0].complete?(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("ready")),c.hasSize=!0,c.loaded=!0,y("ImageLoadComplete")):(e++,200>e?setTimeout(f,100):g()))},g=function(){c&&(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("error",h.tError.replace("%url%",c.src))),c.hasSize=!0,c.loaded=!0,c.loadError=!0)},h=b.st.image,i=d.find(".mfp-img");if(i.length){var j=document.createElement("img");j.className="mfp-img",c.el&&c.el.find("img").length&&(j.alt=c.el.find("img").attr("alt")),c.img=a(j).on("load.mfploader",f).on("error.mfploader",g),j.src=c.src,i.is("img")&&(c.img=c.img.clone()),j=c.img[0],j.naturalWidth>0?c.hasSize=!0:j.width||(c.hasSize=!1)}return b._parseMarkup(d,{title:M(c),img_replaceWith:c.img},c),b.resizeImage(),c.hasSize?(L&&clearInterval(L),c.loadError?(d.addClass("mfp-loading"),b.updateStatus("error",h.tError.replace("%url%",c.src))):(d.removeClass("mfp-loading"),b.updateStatus("ready")),d):(b.updateStatus("loading"),c.loading=!0,c.hasSize||(c.imgHidden=!0,d.addClass("mfp-loading"),b.findImageSize(c)),d)}}});var N,O=function(){return void 0===N&&(N=void 0!==document.createElement("p").style.MozTransform),N};a.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(a){return a.is("img")?a:a.find("img")}},proto:{initZoom:function(){var a,c=b.st.zoom,d=".zoom";if(c.enabled&&b.supportsTransition){var e,f,g=c.duration,j=function(a){var b=a.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),d="all "+c.duration/1e3+"s "+c.easing,e={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},f="transition";return e["-webkit-"+f]=e["-moz-"+f]=e["-o-"+f]=e[f]=d,b.css(e),b},k=function(){b.content.css("visibility","visible")};w("BuildControls"+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.content.css("visibility","hidden"),a=b._getItemToZoom(),!a)return void k();f=j(a),f.css(b._getOffset()),b.wrap.append(f),e=setTimeout(function(){f.css(b._getOffset(!0)),e=setTimeout(function(){k(),setTimeout(function(){f.remove(),a=f=null,y("ZoomAnimationEnded")},16)},g)},16)}}),w(i+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.st.removalDelay=g,!a){if(a=b._getItemToZoom(),!a)return;f=j(a)}f.css(b._getOffset(!0)),b.wrap.append(f),b.content.css("visibility","hidden"),setTimeout(function(){f.css(b._getOffset())},16)}}),w(h+d,function(){b._allowZoom()&&(k(),f&&f.remove(),a=null)})}},_allowZoom:function(){return"image"===b.currItem.type},_getItemToZoom:function(){return b.currItem.hasSize?b.currItem.img:!1},_getOffset:function(c){var d;d=c?b.currItem.img:b.st.zoom.opener(b.currItem.el||b.currItem);var e=d.offset(),f=parseInt(d.css("padding-top"),10),g=parseInt(d.css("padding-bottom"),10);e.top-=a(window).scrollTop()-f;var h={width:d.width(),height:(u?d.innerHeight():d[0].offsetHeight)-g-f};return O()?h["-moz-transform"]=h.transform="translate("+e.left+"px,"+e.top+"px)":(h.left=e.left,h.top=e.top),h}}});var P="iframe",Q="//about:blank",R=function(a){if(b.currTemplate[P]){var c=b.currTemplate[P].find("iframe");c.length&&(a||(c[0].src=Q),b.isIE8&&c.css("display",a?"block":"none"))}};a.magnificPopup.registerModule(P,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',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(){b.types.push(P),w("BeforeChange",function(a,b,c){b!==c&&(b===P?R():c===P&&R(!0))}),w(h+"."+P,function(){R()})},getIframe:function(c,d){var e=c.src,f=b.st.iframe;a.each(f.patterns,function(){return e.indexOf(this.index)>-1?(this.id&&(e="string"==typeof this.id?e.substr(e.lastIndexOf(this.id)+this.id.length,e.length):this.id.call(this,e)),e=this.src.replace("%id%",e),!1):void 0});var g={};return f.srcAction&&(g[f.srcAction]=e),b._parseMarkup(d,g,c),b.updateStatus("ready"),d}}});var S=function(a){var c=b.items.length;return a>c-1?a-c:0>a?c+a:a},T=function(a,b,c){return a.replace(/%curr%/gi,b+1).replace(/%total%/gi,c)};a.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',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 c=b.st.gallery,e=".mfp-gallery",g=Boolean(a.fn.mfpFastClick);return b.direction=!0,c&&c.enabled?(f+=" mfp-gallery",w(m+e,function(){c.navigateByImgClick&&b.wrap.on("click"+e,".mfp-img",function(){return b.items.length>1?(b.next(),!1):void 0}),d.on("keydown"+e,function(a){37===a.keyCode?b.prev():39===a.keyCode&&b.next()})}),w("UpdateStatus"+e,function(a,c){c.text&&(c.text=T(c.text,b.currItem.index,b.items.length))}),w(l+e,function(a,d,e,f){var g=b.items.length;e.counter=g>1?T(c.tCounter,f.index,g):""}),w("BuildControls"+e,function(){if(b.items.length>1&&c.arrows&&!b.arrowLeft){var d=c.arrowMarkup,e=b.arrowLeft=a(d.replace(/%title%/gi,c.tPrev).replace(/%dir%/gi,"left")).addClass(s),f=b.arrowRight=a(d.replace(/%title%/gi,c.tNext).replace(/%dir%/gi,"right")).addClass(s),h=g?"mfpFastClick":"click";e[h](function(){b.prev()}),f[h](function(){b.next()}),b.isIE7&&(x("b",e[0],!1,!0),x("a",e[0],!1,!0),x("b",f[0],!1,!0),x("a",f[0],!1,!0)),b.container.append(e.add(f))}}),w(n+e,function(){b._preloadTimeout&&clearTimeout(b._preloadTimeout),b._preloadTimeout=setTimeout(function(){b.preloadNearbyImages(),b._preloadTimeout=null},16)}),void w(h+e,function(){d.off(e),b.wrap.off("click"+e),b.arrowLeft&&g&&b.arrowLeft.add(b.arrowRight).destroyMfpFastClick(),b.arrowRight=b.arrowLeft=null})):!1},next:function(){b.direction=!0,b.index=S(b.index+1),b.updateItemHTML()},prev:function(){b.direction=!1,b.index=S(b.index-1),b.updateItemHTML()},goTo:function(a){b.direction=a>=b.index,b.index=a,b.updateItemHTML()},preloadNearbyImages:function(){var a,c=b.st.gallery.preload,d=Math.min(c[0],b.items.length),e=Math.min(c[1],b.items.length);for(a=1;a<=(b.direction?e:d);a++)b._preloadItem(b.index+a);for(a=1;a<=(b.direction?d:e);a++)b._preloadItem(b.index-a)},_preloadItem:function(c){if(c=S(c),!b.items[c].preloaded){var d=b.items[c];d.parsed||(d=b.parseEl(c)),y("LazyLoad",d),"image"===d.type&&(d.img=a('<img class="mfp-img" />').on("load.mfploader",function(){d.hasSize=!0}).on("error.mfploader",function(){d.hasSize=!0,d.loadError=!0,y("LazyLoadError",d)}).attr("src",d.src)),d.preloaded=!0}}}});var U="retina";a.magnificPopup.registerModule(U,{options:{replaceSrc:function(a){return a.src.replace(/\.\w+$/,function(a){return"@2x"+a})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var a=b.st.retina,c=a.ratio;c=isNaN(c)?c():c,c>1&&(w("ImageHasSize."+U,function(a,b){b.img.css({"max-width":b.img[0].naturalWidth/c,width:"100%"})}),w("ElementParse."+U,function(b,d){d.src=a.replaceSrc(d,c)}))}}}}),function(){var b=1e3,c="ontouchstart"in window,d=function(){v.off("touchmove"+f+" touchend"+f)},e="mfpFastClick",f="."+e;a.fn.mfpFastClick=function(e){return a(this).each(function(){var g,h=a(this);if(c){var i,j,k,l,m,n;h.on("touchstart"+f,function(a){l=!1,n=1,m=a.originalEvent?a.originalEvent.touches[0]:a.touches[0],j=m.clientX,k=m.clientY,v.on("touchmove"+f,function(a){m=a.originalEvent?a.originalEvent.touches:a.touches,n=m.length,m=m[0],(Math.abs(m.clientX-j)>10||Math.abs(m.clientY-k)>10)&&(l=!0,d())}).on("touchend"+f,function(a){d(),l||n>1||(g=!0,a.preventDefault(),clearTimeout(i),i=setTimeout(function(){g=!1},b),e())})})}h.on("click"+f,function(){g||e()})})},a.fn.destroyMfpFastClick=function(){a(this).off("touchstart"+f+" click"+f),c&&v.off("touchmove"+f+" touchend"+f)}}(),A()}),"function"!=typeof Object.create&&(Object.create=function(a){function b(){}return b.prototype=a,new b}),function(a,b,c,d){var e={init:function(b,c){var d=this;d.elem=c,d.$elem=a(c),d.options=a.extend({},a.fn.rtTab.options,b),d.rtTabs()},rtTabs:function(){var c=this,d=c.options.activeTab;c.$elem.find("li:nth-child("+d+")").addClass("active"),c.rtTabContent(activeTabContent="yes"),c.rtClick();var e="false"===c.$elem.attr("data-hash")?!1:!0;if(e===!0){var f=b.location.hash;f&&c.$elem.find("li").find("a[href="+f+"]").trigger("click"),a(b).on("hashchange",function(){var a=b.location.hash;c.$elem.find("li").find("a[href="+a+"]").trigger("click")})}},rtClick:function(){var c=this,d=c.$elem.find("li"),e=d.find("a");e.on("click",function(e){e.preventDefault(),d.removeClass("active"),c.rtTabContent(),a(this).parent().addClass("active");var f=a(this).attr("href");a(f).removeClass("hide");var g="false"===c.$elem.attr("data-hash")?!1:!0;if(g===!0){var h=a(b).scrollTop();location.hash=a(this).attr("href"),a(b).scrollTop(h)}"function"==typeof c.options.onComplete&&c.options.onComplete.apply(c.elem,arguments)})},rtTabContent:function(b){var c=this,d=c.$elem.find("li"),e=d.find("a");e.each(function(){var c=a(this),d=c.attr("href");"yes"===b?c.parent().hasClass("active")||a(d).addClass("hide"):a(d).addClass("hide")})}};a.fn.rtTab=function(b){return this.each(function(){var c=Object.create(e);c.init(b,this),a.data(this,"rtTab",c)})},a.fn.rtTab.options={activeTab:1,onComplete:null}}(jQuery,window,document);var rtMagnificPopup,rtm_masonry_container,rtMediaHook={hooks:[],is_break:!1,register:function(a,b){"undefined"==typeof rtMediaHook.hooks[a]&&(rtMediaHook.hooks[a]=[]),rtMediaHook.hooks[a].push(b)},call:function(a,b){if("undefined"!=typeof rtMediaHook.hooks[a])for(i=0;i<rtMediaHook.hooks[a].length;++i)if(1!=rtMediaHook.hooks[a][i](b))return rtMediaHook.is_break=!0,!1;return!0}};jQuery("document").ready(function(a){function b(){if(jQuery("#rtmedia-media-view-form").length>0){var a=jQuery("#rtmedia-media-view-form").attr("action");jQuery.post(a,{},function(a){})}}function c(){var a=jQuery.magnificPopup.instance;jQuery(".mfp-arrow-right").on("click",function(b){a.next()}),jQuery(".mfp-arrow-left").on("click",function(b){a.prev()}),jQuery(".mfp-content .rtmedia-media").swipe({swipeLeft:function(b,c,d,e,f){a.next()},swipeRight:function(b,c,d,e,f){a.prev()},threshold:0})}function d(){jQuery(document).on("focusin","#comment_content",function(){jQuery(document).unbind("keydown")}),jQuery(document).on("focusout","#comment_content",function(){var a=jQuery.magnificPopup.instance;jQuery(document).on("keydown",function(b){37===b.keyCode?a.prev():39===b.keyCode&&a.next()})})}function e(){jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",function(a){a.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()})}a(".rtm-tabs").rtTab(),jQuery(".rtmedia-modal-link").length>0&&a(".rtmedia-modal-link").magnificPopup({type:"inline",midClick:!0,closeBtnInside:!0}),a("#rt_media_comment_form").submit(function(b){return""==a.trim(a("#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):!0}),a("li.rtmedia-list-item p a").each(function(b){a(this).addClass("no-popup")}),a("li.rtmedia-list-item p a").each(function(b){a(this).addClass("no-popup")}),"undefined"!=typeof rtmedia_lightbox_enabled&&"1"==rtmedia_lightbox_enabled&&apply_rtMagnificPopup(".rtmedia-list-media, .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(a,b,c){try{if(null==b.data||"undefined"==typeof b.data||"undefined"==typeof b.data.action)return!0}catch(d){return!0}if("activity_get_older_updates"==b.data.action){var e=b.success;a.success=function(a){e(a),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"==b.data.action){var e=b.success;a.success=function(a){e(a),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({defaultVideoWidth:480,defaultVideoHeight:270})},900)}}}),jQuery.ajaxPrefilter(function(a,b,c){try{if(null==b.data||"undefined"==typeof b.data||"undefined"==typeof b.data.action)return!0}catch(d){return!0}if("activity_get_older_updates"==b.data.action){var e=b.success;a.success=function(a){e(a),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",[])}}}),jQuery(".rtmedia-container").on("click",".select-all",function(a){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(a){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(a){jQuery(".rtmedia-delete-container").slideUp(),jQuery(".rtmedia-move-container").slideToggle()}),jQuery("#rtmedia-create-album-modal").on("click","#rtmedia_create_new_album",function(b){if($albumname=jQuery.trim(jQuery("#rtmedia_album_name").val()),$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 c={action:"rtmedia_create_album",
6
- name:$albumname,context:$context,context_id:$context_id,create_album_nonce:$create_album_nonce};""!==$privacy&&(c.privacy=$privacy),a("#rtmedia_create_new_album").attr("disabled","disabled");var d=a("#rtmedia_create_new_album").html();a("#rtmedia_create_new_album").prepend("<img src='"+rMedia_loading_file+"' />"),jQuery.post(rtmedia_ajax_url,c,function(b){if(b=jQuery.parseJSON(b),"undefined"!=typeof b.album){b=jQuery.trim(b.album);var c=!0;jQuery(".rtmedia-user-album-list").each(function(){if(jQuery(this).children("optgroup").each(function(){return jQuery(this).attr("value")===$context?(c=!1,void jQuery(this).append('<option value="'+b+'">'+$albumname+"</option>")):void 0}),c){var a=$context.charAt(0).toUpperCase()+$context.slice(1),d='<optgroup value="'+$context+'" label="'+a+' Albums"><option value="'+b+'">'+$albumname+"</option></optgroup>";jQuery(this).append(d)}}),jQuery('select.rtmedia-user-album-list option[value="'+b+'"]').prop("selected",!0),jQuery(".rtmedia-create-new-album-container").slideToggle(),jQuery("#rtmedia_album_name").val(""),jQuery("#rtmedia-create-album-modal").append("<div class='rtmedia-success rtmedia-create-album-alert'><b>"+$albumname+"</b>"+rtmedia_album_created_msg+"</div>"),setTimeout(function(){jQuery(".rtmedia-create-album-alert").remove()},4e3),setTimeout(function(){galleryObj.reloadView(),jQuery(".close-reveal-modal").click()},2e3)}else"undefined"!=typeof b.error?rtmedia_gallery_action_alert_message(b.error,"warning"):rtmedia_gallery_action_alert_message(rtmedia_something_wrong_msg,"warning");a("#rtmedia_create_new_album").removeAttr("disabled"),a("#rtmedia_create_new_album").html(d)})}else rtmedia_gallery_action_alert_message(rtmedia_empty_album_name_msg,"warning")}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-selected",function(a){jQuery(".rtmedia-list :checkbox:checked").length>0?confirm(rtmedia_selected_media_delete_confirmation)&&jQuery(this).closest("form").attr("action","../../../media/delete").submit():rtmedia_gallery_action_alert_message(rtmedia_no_media_selected,"warning")}),jQuery(".rtmedia-container").on("click",".rtmedia-move-selected",function(a){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")}),b(),rtMediaHook.register("rtmedia_js_popup_after_content_added",function(){b(),e(),mfp=jQuery.magnificPopup.instance,jQuery(mfp.items).size()>1&&c(),d();var f=a(window).height();jQuery(".rtm-lightbox-container .mejs-video").css({height:.8*f,"max-height":.8*f,"over-flow":"hidden"}),jQuery(".mfp-content .rtmedia-media").css({"max-height":.87*f,"over-flow":"hidden"}),rtmedia_init_action_dropdown(),jQuery(".rtmedia-comment-link").on("click",function(a){a.preventDefault(),jQuery("#comment_content").focus()}),jQuery(".rtm-more").shorten({showChars:130});var g=a(".rtm-gallery-title"),h="";h=a.isEmptyObject(g)?a("#subnav.item-list-tabs li.selected ").html():g.html(),""!=h&&a(".rtm-ltb-gallery-title .ltb-title").html(h);var i=a("#subnav.item-list-tabs li.selected span").html();return a("li.total").html(i),!0});var f=jQuery("#drag-drop-area"),g=jQuery("#whats-new");f.html();jQuery("#rtmedia-upload-container").after("<div id='rtm-drop-files-title'>"+rtmedia_drop_media_msg+"</div>"),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&jQuery("#whats-new-textarea").append("<div id='rtm-drop-files-title'>"+rtmedia_drop_media_msg+"</div>"),jQuery(document).on("dragover",function(a){jQuery("#rtm-media-gallery-uploader").show(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&g.addClass("rtm-drag-drop-active"),f.addClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").show()}).on("dragleave",function(a){a.preventDefault(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&(g.removeClass("rtm-drag-drop-active"),g.removeAttr("style")),f.removeClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").hide()}).on("drop",function(a){a.preventDefault(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&(g.removeClass("rtm-drag-drop-active"),g.removeAttr("style")),f.removeClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").hide()}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-album",function(a){a.preventDefault(),confirm(rtmedia_album_delete_confirmation)&&jQuery(this).closest("form").submit()}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",function(a){a.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()}),rtmedia_init_action_dropdown(),a(document).click(function(){a(".click-nav ul").is(":visible")&&a(".click-nav ul",this).hide()}),jQuery(".rtmedia-comment-link").on("click",function(a){a.preventDefault(),jQuery("#comment_content").focus()}),jQuery(".rtm-more").length>0&&a(".rtm-more").shorten({showChars:200}),"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"),rtm_masonry_container.masonry({itemSelector:".rtmedia-list-item"}),setInterval(function(){jQuery.each(jQuery(".rtmedia-list.masonry .rtmedia-item-title"),function(a,b){jQuery(b).width(jQuery(b).siblings(".rtmedia-item-thumbnail").children("img").width())}),rtm_masonry_reload(rtm_masonry_container)},1e3),jQuery.each(jQuery(".rtmedia-list.masonry .rtmedia-item-title"),function(a,b){jQuery(b).width(jQuery(b).siblings(".rtmedia-item-thumbnail").children("img").width())})),jQuery(".rtm-uploader-tabs").length>0&&jQuery(".rtm-uploader-tabs li").click(function(a){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").children("input[type=file]").hide():jQuery("div.moxie-shim").children("input[type=file]").show())}),jQuery(".rtmedia-container").on("click",".rtm-delete-media",function(a){a.preventDefault();var b="Are you sure you want to delete this media?";if("undefined"!=typeof rtmedia_media_delete_confirmation&&(b=rtmedia_media_delete_confirmation),confirm(b)){var c=jQuery(this).closest("li"),d=jQuery("#rtmedia_media_delete_nonce").val(),e={action:"delete_uploaded_media",nonce:d,media_id:c.attr("id")};jQuery.ajax({url:ajaxurl,type:"post",data:e,success:function(a){"1"==a?(rtmedia_gallery_action_alert_message("file deleted successfully.","success"),c.remove(),"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)):rtmedia_gallery_action_alert_message(rtmedia_file_not_deleted,"warning")}})}})}),function(a){a.fn.shorten=function(b){var c={showChars:100,ellipsesText:"...",moreText:"more",lessText:"less"};return b&&a.extend(c,b),a(document).off("click",".morelink"),a(document).on({click:function(){var b=a(this);return b.hasClass("less")?(b.removeClass("less"),b.html(c.moreText)):(b.addClass("less"),b.html(c.lessText)),b.parent().prev().toggle(),b.prev().toggle(),!1}},".morelink"),this.each(function(){var b=a(this);if(!b.hasClass("shortened")){b.addClass("shortened");var d=b.html();if(d.length>c.showChars){var e=d.substr(0,c.showChars),f=d.substr(c.showChars,d.length-c.showChars),g=e+'<span class="moreellipses">'+c.ellipsesText+' </span><span class="morecontent"><span>'+f+'</span> <a href="#" class="morelink">'+c.moreText+"</a></span>";b.html(g),a(".morecontent span").hide()}}})}}(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)};
3
  * @package rtMedia
4
  */
5
  function apply_rtMagnificPopup(a){jQuery("document").ready(function(b){var c="";c="undefined"==typeof rtmedia_load_more?"Loading media":rtmedia_load_more,"undefined"!=typeof rtmedia_lightbox_enabled&&"1"==rtmedia_lightbox_enabled&&(b(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").length>0&&b(".activity-item .rtmedia-activity-container .rtmedia-list-item > a").siblings("p").children("a").addClass("no-popup"),rtMagnificPopup=jQuery(a).magnificPopup({delegate:"a:not(.no-popup, .mejs-time-slider, .mejs-volume-slider, .mejs-horizontal-volume-slider)",type:"ajax",tLoading:c+" #%curr%...",mainClass:"mfp-img-mobile",preload:[1,3],closeOnBgClick:!0,gallery:{enabled:!0,navigateByImgClick:!0,arrowMarkup:"",preload:[0,1]},image:{tError:'<a href="%url%">The image #%curr%</a> could not be loaded.',titleSrc:function(a){return a.el.attr("title")+"<small>by Marsel Van Oosten</small>"}},callbacks:{ajaxContentAdded:function(){a=jQuery.magnificPopup.instance,1===jQuery(a.items).size()&&jQuery(".mfp-arrow").remove();var a=jQuery.magnificPopup.instance,c=a.currItem.el,d=c.parent();if(d.is("li")||(d=d.parent()),d.is(":nth-last-child(2)")||d.is(":last-child")){d.next();"block"==jQuery("#rtMedia-galary-next").css("display")&&jQuery("#rtMedia-galary-next").click()}var e=a.items.length;if(a.index==e-1&&!d.is(":last-child"))return void c.click();var f={};"undefined"!=typeof _wpmejsSettings&&(f.pluginPath=_wpmejsSettings.pluginPath),b(".mfp-content .wp-audio-shortcode,.mfp-content .wp-video-shortcode,.mfp-content .bp_media_content video").mediaelementplayer({defaultVideoWidth:480,defaultVideoHeight:270,success:function(a,b){a.play()}}),b(".mfp-content .mejs-audio .mejs-controls").css("position","relative"),rtMediaHook.call("rtmedia_js_popup_after_content_added",[])},close:function(a){rtmedia_init_action_dropdown()},BeforeChange:function(a){}}}))})}function rtmedia_init_action_dropdown(){var a,b;jQuery(".click-nav > span, .click-nav > div").toggleClass("no-js js"),jQuery(".click-nav .js ul").hide(),jQuery(".click-nav .clicker").click(function(c){a=jQuery("#rtm-media-options .click-nav .clicker").next("ul"),b=jQuery(this).next("ul"),jQuery.each(a,function(a,c){jQuery(c).html()!=b.html()&&jQuery(c).hide()}),jQuery(b).toggle(),c.stopPropagation()})}function bp_media_create_element(a){return!1}function rtmedia_version_compare(a,b){if(typeof a+typeof b!="stringstring")return!1;for(var c=a.split("."),d=b.split("."),e=0,f=Math.max(c.length,d.length);f>e;e++){if(c[e]&&!d[e]&&parseInt(c[e])>0||parseInt(c[e])>parseInt(d[e]))return!0;if(d[e]&&!c[e]&&parseInt(d[e])>0||parseInt(c[e])<parseInt(d[e]))return!1}return!0}function rtm_is_element_exist(a){return jQuery(a).length>0?!0:!1}function rtm_masonry_reload(a){setTimeout(function(){a.masonry("reload")},250)}function rtmediaGetParameterByName(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null==c?"":decodeURIComponent(c[1].replace(/\+/g," "))}function rtmedia_single_media_alert_message(a,b){var c="rtmedia-success";"warning"==b&&(c="rtmedia-warning"),jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","0.2"),jQuery(".rtmedia-single-media .rtmedia-media").after("<div class='rtmedia-message-container'><span class='"+c+"'>"+a+" </span></div>"),setTimeout(function(){jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","1"),jQuery(".rtmedia-message-container").remove()},3e3),jQuery(".rtmedia-message-container").click(function(){jQuery(".rtmedia-single-media .rtmedia-media").css("opacity","1"),jQuery(".rtmedia-message-container").remove()})}function rtmedia_gallery_action_alert_message(a,b){var c="rtmedia-success";"warning"==b&&(c="rtmedia-warning");var d='<div class="rtmedia-gallery-alert-container"> </div>';jQuery("body").append(d),jQuery(".rtmedia-gallery-alert-container").append("<div class='rtmedia-gallery-message-box'><span class='"+c+"'>"+a+" </span></div>"),setTimeout(function(){jQuery(".rtmedia-gallery-alert-container").remove()},3e3),jQuery(".rtmedia-gallery-message-box").click(function(){jQuery(".rtmedia-gallery-alert-container").remove()})}!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):window.jQuery||window.Zepto)}(function(a){var b,c,d,e,f,g,h="Close",i="BeforeClose",j="AfterClose",k="BeforeAppend",l="MarkupParse",m="Open",n="Change",o="mfp",p="."+o,q="mfp-ready",r="mfp-removing",s="mfp-prevent-close",t=function(){},u=!!window.jQuery,v=a(window),w=function(a,c){b.ev.on(o+a+p,c)},x=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},y=function(c,d){b.ev.triggerHandler(o+c,d),b.st.callbacks&&(c=c.charAt(0).toLowerCase()+c.slice(1),b.st.callbacks[c]&&b.st.callbacks[c].apply(b,a.isArray(d)?d:[d]))},z=function(c){return c===g&&b.currTemplate.closeBtn||(b.currTemplate.closeBtn=a(b.st.closeMarkup.replace("%title%",b.st.tClose)),g=c),b.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(b=new t,b.init(),a.magnificPopup.instance=b)},B=function(){var a=document.createElement("p").style,b=["ms","O","Moz","Webkit"];if(void 0!==a.transition)return!0;for(;b.length;)if(b.pop()+"Transition"in a)return!0;return!1};t.prototype={constructor:t,init:function(){var c=navigator.appVersion;b.isIE7=-1!==c.indexOf("MSIE 7."),b.isIE8=-1!==c.indexOf("MSIE 8."),b.isLowIE=b.isIE7||b.isIE8,b.isAndroid=/android/gi.test(c),b.isIOS=/iphone|ipad|ipod/gi.test(c),b.supportsTransition=B(),b.probablyMobile=b.isAndroid||b.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),d=a(document),b.popupsCache={}},open:function(c){var e;if(c.isObj===!1){b.items=c.items.toArray(),b.index=0;var g,h=c.items;for(e=0;e<h.length;e++)if(g=h[e],g.parsed&&(g=g.el[0]),g===c.el[0]){b.index=e;break}}else b.items=a.isArray(c.items)?c.items:[c.items],b.index=c.index||0;if(b.isOpen)return void b.updateItemHTML();b.types=[],f="",c.mainEl&&c.mainEl.length?b.ev=c.mainEl.eq(0):b.ev=d,c.key?(b.popupsCache[c.key]||(b.popupsCache[c.key]={}),b.currTemplate=b.popupsCache[c.key]):b.currTemplate={},b.st=a.extend(!0,{},a.magnificPopup.defaults,c),b.fixedContentPos="auto"===b.st.fixedContentPos?!b.probablyMobile:b.st.fixedContentPos,b.st.modal&&(b.st.closeOnContentClick=!1,b.st.closeOnBgClick=!1,b.st.showCloseBtn=!1,b.st.enableEscapeKey=!1),b.bgOverlay||(b.bgOverlay=x("bg").on("click"+p,function(){b.close()}),b.wrap=x("wrap").attr("tabindex",-1).on("click"+p,function(a){b._checkIfClose(a.target)&&b.close()}),b.container=x("container",b.wrap)),b.contentContainer=x("content"),b.st.preloader&&(b.preloader=x("preloader",b.container,b.st.tLoading));var i=a.magnificPopup.modules;for(e=0;e<i.length;e++){var j=i[e];j=j.charAt(0).toUpperCase()+j.slice(1),b["init"+j].call(b)}y("BeforeOpen"),b.st.showCloseBtn&&(b.st.closeBtnInside?(w(l,function(a,b,c,d){c.close_replaceWith=z(d.type)}),f+=" mfp-close-btn-in"):b.wrap.append(z())),b.st.alignTop&&(f+=" mfp-align-top"),b.fixedContentPos?b.wrap.css({overflow:b.st.overflowY,overflowX:"hidden",overflowY:b.st.overflowY}):b.wrap.css({top:v.scrollTop(),position:"absolute"}),(b.st.fixedBgPos===!1||"auto"===b.st.fixedBgPos&&!b.fixedContentPos)&&b.bgOverlay.css({height:d.height(),position:"absolute"}),b.st.enableEscapeKey&&d.on("keyup"+p,function(a){27===a.keyCode&&b.close()}),v.on("resize"+p,function(){b.updateSize()}),b.st.closeOnContentClick||(f+=" mfp-auto-cursor"),f&&b.wrap.addClass(f);var k=b.wH=v.height(),n={};if(b.fixedContentPos&&b._hasScrollBar(k)){var o=b._getScrollbarSize();o&&(n.marginRight=o)}b.fixedContentPos&&(b.isIE7?a("body, html").css("overflow","hidden"):n.overflow="hidden");var r=b.st.mainClass;return b.isIE7&&(r+=" mfp-ie7"),r&&b._addClassToMFP(r),b.updateItemHTML(),y("BuildControls"),a("html").css(n),b.bgOverlay.add(b.wrap).prependTo(b.st.prependTo||a(document.body)),b._lastFocusedEl=document.activeElement,setTimeout(function(){b.content?(b._addClassToMFP(q),b._setFocus()):b.bgOverlay.addClass(q),d.on("focusin"+p,b._onFocusIn)},16),b.isOpen=!0,b.updateSize(k),y(m),c},close:function(){b.isOpen&&(y(i),b.isOpen=!1,b.st.removalDelay&&!b.isLowIE&&b.supportsTransition?(b._addClassToMFP(r),setTimeout(function(){b._close()},b.st.removalDelay)):b._close())},_close:function(){y(h);var c=r+" "+q+" ";if(b.bgOverlay.detach(),b.wrap.detach(),b.container.empty(),b.st.mainClass&&(c+=b.st.mainClass+" "),b._removeClassFromMFP(c),b.fixedContentPos){var e={marginRight:""};b.isIE7?a("body, html").css("overflow",""):e.overflow="",a("html").css(e)}d.off("keyup"+p+" focusin"+p),b.ev.off(p),b.wrap.attr("class","mfp-wrap").removeAttr("style"),b.bgOverlay.attr("class","mfp-bg"),b.container.attr("class","mfp-container"),!b.st.showCloseBtn||b.st.closeBtnInside&&b.currTemplate[b.currItem.type]!==!0||b.currTemplate.closeBtn&&b.currTemplate.closeBtn.detach(),b._lastFocusedEl&&a(b._lastFocusedEl).focus(),b.currItem=null,b.content=null,b.currTemplate=null,b.prevHeight=0,y(j)},updateSize:function(a){if(b.isIOS){var c=document.documentElement.clientWidth/window.innerWidth,d=window.innerHeight*c;b.wrap.css("height",d),b.wH=d}else b.wH=a||v.height();b.fixedContentPos||b.wrap.css("height",b.wH),y("Resize")},updateItemHTML:function(){var c=b.items[b.index];b.contentContainer.detach(),b.content&&b.content.detach(),c.parsed||(c=b.parseEl(b.index));var d=c.type;if(y("BeforeChange",[b.currItem?b.currItem.type:"",d]),b.currItem=c,!b.currTemplate[d]){var f=b.st[d]?b.st[d].markup:!1;y("FirstMarkupParse",f),f?b.currTemplate[d]=a(f):b.currTemplate[d]=!0}e&&e!==c.type&&b.container.removeClass("mfp-"+e+"-holder");var g=b["get"+d.charAt(0).toUpperCase()+d.slice(1)](c,b.currTemplate[d]);b.appendContent(g,d),c.preloaded=!0,y(n,c),e=c.type,b.container.prepend(b.contentContainer),y("AfterChange")},appendContent:function(a,c){b.content=a,a?b.st.showCloseBtn&&b.st.closeBtnInside&&b.currTemplate[c]===!0?b.content.find(".mfp-close").length||b.content.append(z()):b.content=a:b.content="",y(k),b.container.addClass("mfp-"+c+"-holder"),b.contentContainer.append(b.content)},parseEl:function(c){var d,e=b.items[c];if(e.tagName?e={el:a(e)}:(d=e.type,e={data:e,src:e.src}),e.el){for(var f=b.types,g=0;g<f.length;g++)if(e.el.hasClass("mfp-"+f[g])){d=f[g];break}e.src=e.el.attr("data-mfp-src"),e.src||(e.src=e.el.attr("href"))}return e.type=d||b.st.type||"inline",e.index=c,e.parsed=!0,b.items[c]=e,y("ElementParse",e),b.items[c]},addGroup:function(a,c){var d=function(d){d.mfpEl=this,b._openClick(d,a,c)};c||(c={});var e="click.magnificPopup";c.mainEl=a,c.items?(c.isObj=!0,a.off(e).on(e,d)):(c.isObj=!1,c.delegate?a.off(e).on(e,c.delegate,d):(c.items=a,a.off(e).on(e,d)))},_openClick:function(c,d,e){var f=void 0!==e.midClick?e.midClick:a.magnificPopup.defaults.midClick;if(f||2!==c.which&&!c.ctrlKey&&!c.metaKey){var g=void 0!==e.disableOn?e.disableOn:a.magnificPopup.defaults.disableOn;if(g)if(a.isFunction(g)){if(!g.call(b))return!0}else if(v.width()<g)return!0;c.type&&(c.preventDefault(),b.isOpen&&c.stopPropagation()),e.el=a(c.mfpEl),e.delegate&&(e.items=d.find(e.delegate)),b.open(e)}},updateStatus:function(a,d){if(b.preloader){c!==a&&b.container.removeClass("mfp-s-"+c),d||"loading"!==a||(d=b.st.tLoading);var e={status:a,text:d};y("UpdateStatus",e),a=e.status,d=e.text,b.preloader.html(d),b.preloader.find("a").on("click",function(a){a.stopImmediatePropagation()}),b.container.addClass("mfp-s-"+a),c=a}},_checkIfClose:function(c){if(!a(c).hasClass(s)){var d=b.st.closeOnContentClick,e=b.st.closeOnBgClick;if(d&&e)return!0;if(!b.content||a(c).hasClass("mfp-close")||b.preloader&&c===b.preloader[0])return!0;if(c===b.content[0]||a.contains(b.content[0],c)){if(d)return!0}else if(e&&a.contains(document,c))return!0;return!1}},_addClassToMFP:function(a){b.bgOverlay.addClass(a),b.wrap.addClass(a)},_removeClassFromMFP:function(a){this.bgOverlay.removeClass(a),b.wrap.removeClass(a)},_hasScrollBar:function(a){return(b.isIE7?d.height():document.body.scrollHeight)>(a||v.height())},_setFocus:function(){(b.st.focus?b.content.find(b.st.focus).eq(0):b.wrap).focus()},_onFocusIn:function(c){return c.target===b.wrap[0]||a.contains(b.wrap[0],c.target)?void 0:(b._setFocus(),!1)},_parseMarkup:function(b,c,d){var e;d.data&&(c=a.extend(d.data,c)),y(l,[b,c,d]),a.each(c,function(a,c){if(void 0===c||c===!1)return!0;if(e=a.split("_"),e.length>1){var d=b.find(p+"-"+e[0]);if(d.length>0){var f=e[1];"replaceWith"===f?d[0]!==c[0]&&d.replaceWith(c):"img"===f?d.is("img")?d.attr("src",c):d.replaceWith('<img src="'+c+'" class="'+d.attr("class")+'" />'):d.attr(e[1],c)}}else b.find(p+"-"+a).html(c)})},_getScrollbarSize:function(){if(void 0===b.scrollbarSize){var a=document.createElement("div");a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),b.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return b.scrollbarSize}},a.magnificPopup={instance:null,proto:t.prototype,modules:[],open:function(b,c){return A(),b=b?a.extend(!0,{},b):{},b.isObj=!0,b.index=c||0,this.instance.open(b)},close:function(){return a.magnificPopup.instance&&a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},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:'<button title="%title%" type="button" class="mfp-close">&times;</button>',tClose:"Close (Esc)",tLoading:"Loading..."}},a.fn.magnificPopup=function(c){A();var d=a(this);if("string"==typeof c)if("open"===c){var e,f=u?d.data("magnificPopup"):d[0].magnificPopup,g=parseInt(arguments[1],10)||0;f.items?e=f.items[g]:(e=d,f.delegate&&(e=e.find(f.delegate)),e=e.eq(g)),b._openClick({mfpEl:e},d,f)}else b.isOpen&&b[c].apply(b,Array.prototype.slice.call(arguments,1));else c=a.extend(!0,{},c),u?d.data("magnificPopup",c):d[0].magnificPopup=c,b.addGroup(d,c);return d};var C,D,E,F="inline",G=function(){E&&(D.after(E.addClass(C)).detach(),E=null)};a.magnificPopup.registerModule(F,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){b.types.push(F),w(h+"."+F,function(){G()})},getInline:function(c,d){if(G(),c.src){var e=b.st.inline,f=a(c.src);if(f.length){var g=f[0].parentNode;g&&g.tagName&&(D||(C=e.hiddenClass,D=x(C),C="mfp-"+C),E=f.after(D).detach().removeClass(C)),b.updateStatus("ready")}else b.updateStatus("error",e.tNotFound),f=a("<div>");return c.inlineElement=f,f}return b.updateStatus("ready"),b._parseMarkup(d,{},c),d}}});var H,I="ajax",J=function(){H&&a(document.body).removeClass(H)},K=function(){J(),b.req&&b.req.abort()};a.magnificPopup.registerModule(I,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){b.types.push(I),H=b.st.ajax.cursor,w(h+"."+I,K),w("BeforeChange."+I,K)},getAjax:function(c){H&&a(document.body).addClass(H),b.updateStatus("loading");var d=a.extend({url:c.src,success:function(d,e,f){var g={data:d,xhr:f};y("ParseAjax",g),b.appendContent(a(g.data),I),c.finished=!0,J(),b._setFocus(),setTimeout(function(){b.wrap.addClass(q)},16),b.updateStatus("ready"),y("AjaxContentAdded")},error:function(){J(),c.finished=c.loadError=!0,b.updateStatus("error",b.st.ajax.tError.replace("%url%",c.src))}},b.st.ajax.settings);return b.req=a.ajax(d),""}}});var L,M=function(c){if(c.data&&void 0!==c.data.title)return c.data.title;var d=b.st.image.titleSrc;if(d){if(a.isFunction(d))return d.call(b,c);if(c.el)return c.el.attr(d)||""}return""};a.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var c=b.st.image,d=".image";b.types.push("image"),w(m+d,function(){"image"===b.currItem.type&&c.cursor&&a(document.body).addClass(c.cursor)}),w(h+d,function(){c.cursor&&a(document.body).removeClass(c.cursor),v.off("resize"+p)}),w("Resize"+d,b.resizeImage),b.isLowIE&&w("AfterChange",b.resizeImage)},resizeImage:function(){var a=b.currItem;if(a&&a.img&&b.st.image.verticalFit){var c=0;b.isLowIE&&(c=parseInt(a.img.css("padding-top"),10)+parseInt(a.img.css("padding-bottom"),10)),a.img.css("max-height",b.wH-c)}},_onImageHasSize:function(a){a.img&&(a.hasSize=!0,L&&clearInterval(L),a.isCheckingImgSize=!1,y("ImageHasSize",a),a.imgHidden&&(b.content&&b.content.removeClass("mfp-loading"),a.imgHidden=!1))},findImageSize:function(a){var c=0,d=a.img[0],e=function(f){L&&clearInterval(L),L=setInterval(function(){return d.naturalWidth>0?void b._onImageHasSize(a):(c>200&&clearInterval(L),c++,void(3===c?e(10):40===c?e(50):100===c&&e(500)))},f)};e(1)},getImage:function(c,d){var e=0,f=function(){c&&(c.img[0].complete?(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("ready")),c.hasSize=!0,c.loaded=!0,y("ImageLoadComplete")):(e++,200>e?setTimeout(f,100):g()))},g=function(){c&&(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("error",h.tError.replace("%url%",c.src))),c.hasSize=!0,c.loaded=!0,c.loadError=!0)},h=b.st.image,i=d.find(".mfp-img");if(i.length){var j=document.createElement("img");j.className="mfp-img",c.el&&c.el.find("img").length&&(j.alt=c.el.find("img").attr("alt")),c.img=a(j).on("load.mfploader",f).on("error.mfploader",g),j.src=c.src,i.is("img")&&(c.img=c.img.clone()),j=c.img[0],j.naturalWidth>0?c.hasSize=!0:j.width||(c.hasSize=!1)}return b._parseMarkup(d,{title:M(c),img_replaceWith:c.img},c),b.resizeImage(),c.hasSize?(L&&clearInterval(L),c.loadError?(d.addClass("mfp-loading"),b.updateStatus("error",h.tError.replace("%url%",c.src))):(d.removeClass("mfp-loading"),b.updateStatus("ready")),d):(b.updateStatus("loading"),c.loading=!0,c.hasSize||(c.imgHidden=!0,d.addClass("mfp-loading"),b.findImageSize(c)),d)}}});var N,O=function(){return void 0===N&&(N=void 0!==document.createElement("p").style.MozTransform),N};a.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(a){return a.is("img")?a:a.find("img")}},proto:{initZoom:function(){var a,c=b.st.zoom,d=".zoom";if(c.enabled&&b.supportsTransition){var e,f,g=c.duration,j=function(a){var b=a.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),d="all "+c.duration/1e3+"s "+c.easing,e={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},f="transition";return e["-webkit-"+f]=e["-moz-"+f]=e["-o-"+f]=e[f]=d,b.css(e),b},k=function(){b.content.css("visibility","visible")};w("BuildControls"+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.content.css("visibility","hidden"),a=b._getItemToZoom(),!a)return void k();f=j(a),f.css(b._getOffset()),b.wrap.append(f),e=setTimeout(function(){f.css(b._getOffset(!0)),e=setTimeout(function(){k(),setTimeout(function(){f.remove(),a=f=null,y("ZoomAnimationEnded")},16)},g)},16)}}),w(i+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.st.removalDelay=g,!a){if(a=b._getItemToZoom(),!a)return;f=j(a)}f.css(b._getOffset(!0)),b.wrap.append(f),b.content.css("visibility","hidden"),setTimeout(function(){f.css(b._getOffset())},16)}}),w(h+d,function(){b._allowZoom()&&(k(),f&&f.remove(),a=null)})}},_allowZoom:function(){return"image"===b.currItem.type},_getItemToZoom:function(){return b.currItem.hasSize?b.currItem.img:!1},_getOffset:function(c){var d;d=c?b.currItem.img:b.st.zoom.opener(b.currItem.el||b.currItem);var e=d.offset(),f=parseInt(d.css("padding-top"),10),g=parseInt(d.css("padding-bottom"),10);e.top-=a(window).scrollTop()-f;var h={width:d.width(),height:(u?d.innerHeight():d[0].offsetHeight)-g-f};return O()?h["-moz-transform"]=h.transform="translate("+e.left+"px,"+e.top+"px)":(h.left=e.left,h.top=e.top),h}}});var P="iframe",Q="//about:blank",R=function(a){if(b.currTemplate[P]){var c=b.currTemplate[P].find("iframe");c.length&&(a||(c[0].src=Q),b.isIE8&&c.css("display",a?"block":"none"))}};a.magnificPopup.registerModule(P,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',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(){b.types.push(P),w("BeforeChange",function(a,b,c){b!==c&&(b===P?R():c===P&&R(!0))}),w(h+"."+P,function(){R()})},getIframe:function(c,d){var e=c.src,f=b.st.iframe;a.each(f.patterns,function(){return e.indexOf(this.index)>-1?(this.id&&(e="string"==typeof this.id?e.substr(e.lastIndexOf(this.id)+this.id.length,e.length):this.id.call(this,e)),e=this.src.replace("%id%",e),!1):void 0});var g={};return f.srcAction&&(g[f.srcAction]=e),b._parseMarkup(d,g,c),b.updateStatus("ready"),d}}});var S=function(a){var c=b.items.length;return a>c-1?a-c:0>a?c+a:a},T=function(a,b,c){return a.replace(/%curr%/gi,b+1).replace(/%total%/gi,c)};a.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',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 c=b.st.gallery,e=".mfp-gallery",g=Boolean(a.fn.mfpFastClick);return b.direction=!0,c&&c.enabled?(f+=" mfp-gallery",w(m+e,function(){c.navigateByImgClick&&b.wrap.on("click"+e,".mfp-img",function(){return b.items.length>1?(b.next(),!1):void 0}),d.on("keydown"+e,function(a){37===a.keyCode?b.prev():39===a.keyCode&&b.next()})}),w("UpdateStatus"+e,function(a,c){c.text&&(c.text=T(c.text,b.currItem.index,b.items.length))}),w(l+e,function(a,d,e,f){var g=b.items.length;e.counter=g>1?T(c.tCounter,f.index,g):""}),w("BuildControls"+e,function(){if(b.items.length>1&&c.arrows&&!b.arrowLeft){var d=c.arrowMarkup,e=b.arrowLeft=a(d.replace(/%title%/gi,c.tPrev).replace(/%dir%/gi,"left")).addClass(s),f=b.arrowRight=a(d.replace(/%title%/gi,c.tNext).replace(/%dir%/gi,"right")).addClass(s),h=g?"mfpFastClick":"click";e[h](function(){b.prev()}),f[h](function(){b.next()}),b.isIE7&&(x("b",e[0],!1,!0),x("a",e[0],!1,!0),x("b",f[0],!1,!0),x("a",f[0],!1,!0)),b.container.append(e.add(f))}}),w(n+e,function(){b._preloadTimeout&&clearTimeout(b._preloadTimeout),b._preloadTimeout=setTimeout(function(){b.preloadNearbyImages(),b._preloadTimeout=null},16)}),void w(h+e,function(){d.off(e),b.wrap.off("click"+e),b.arrowLeft&&g&&b.arrowLeft.add(b.arrowRight).destroyMfpFastClick(),b.arrowRight=b.arrowLeft=null})):!1},next:function(){b.direction=!0,b.index=S(b.index+1),b.updateItemHTML()},prev:function(){b.direction=!1,b.index=S(b.index-1),b.updateItemHTML()},goTo:function(a){b.direction=a>=b.index,b.index=a,b.updateItemHTML()},preloadNearbyImages:function(){var a,c=b.st.gallery.preload,d=Math.min(c[0],b.items.length),e=Math.min(c[1],b.items.length);for(a=1;a<=(b.direction?e:d);a++)b._preloadItem(b.index+a);for(a=1;a<=(b.direction?d:e);a++)b._preloadItem(b.index-a)},_preloadItem:function(c){if(c=S(c),!b.items[c].preloaded){var d=b.items[c];d.parsed||(d=b.parseEl(c)),y("LazyLoad",d),"image"===d.type&&(d.img=a('<img class="mfp-img" />').on("load.mfploader",function(){d.hasSize=!0}).on("error.mfploader",function(){d.hasSize=!0,d.loadError=!0,y("LazyLoadError",d)}).attr("src",d.src)),d.preloaded=!0}}}});var U="retina";a.magnificPopup.registerModule(U,{options:{replaceSrc:function(a){return a.src.replace(/\.\w+$/,function(a){return"@2x"+a})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var a=b.st.retina,c=a.ratio;c=isNaN(c)?c():c,c>1&&(w("ImageHasSize."+U,function(a,b){b.img.css({"max-width":b.img[0].naturalWidth/c,width:"100%"})}),w("ElementParse."+U,function(b,d){d.src=a.replaceSrc(d,c)}))}}}}),function(){var b=1e3,c="ontouchstart"in window,d=function(){v.off("touchmove"+f+" touchend"+f)},e="mfpFastClick",f="."+e;a.fn.mfpFastClick=function(e){return a(this).each(function(){var g,h=a(this);if(c){var i,j,k,l,m,n;h.on("touchstart"+f,function(a){l=!1,n=1,m=a.originalEvent?a.originalEvent.touches[0]:a.touches[0],j=m.clientX,k=m.clientY,v.on("touchmove"+f,function(a){m=a.originalEvent?a.originalEvent.touches:a.touches,n=m.length,m=m[0],(Math.abs(m.clientX-j)>10||Math.abs(m.clientY-k)>10)&&(l=!0,d())}).on("touchend"+f,function(a){d(),l||n>1||(g=!0,a.preventDefault(),clearTimeout(i),i=setTimeout(function(){g=!1},b),e())})})}h.on("click"+f,function(){g||e()})})},a.fn.destroyMfpFastClick=function(){a(this).off("touchstart"+f+" click"+f),c&&v.off("touchmove"+f+" touchend"+f)}}(),A()}),"function"!=typeof Object.create&&(Object.create=function(a){function b(){}return b.prototype=a,new b}),function(a,b,c,d){var e={init:function(b,c){var d=this;d.elem=c,d.$elem=a(c),d.options=a.extend({},a.fn.rtTab.options,b),d.rtTabs()},rtTabs:function(){var c=this,d=c.options.activeTab;c.$elem.find("li:nth-child("+d+")").addClass("active"),c.rtTabContent(activeTabContent="yes"),c.rtClick();var e="false"===c.$elem.attr("data-hash")?!1:!0;if(e===!0){var f=b.location.hash;f&&c.$elem.find("li").find("a[href="+f+"]").trigger("click"),a(b).on("hashchange",function(){var a=b.location.hash;c.$elem.find("li").find("a[href="+a+"]").trigger("click")})}},rtClick:function(){var c=this,d=c.$elem.find("li"),e=d.find("a");e.on("click",function(e){e.preventDefault(),d.removeClass("active"),c.rtTabContent(),a(this).parent().addClass("active");var f=a(this).attr("href");a(f).removeClass("hide");var g="false"===c.$elem.attr("data-hash")?!1:!0;if(g===!0){var h=a(b).scrollTop();location.hash=a(this).attr("href"),a(b).scrollTop(h)}"function"==typeof c.options.onComplete&&c.options.onComplete.apply(c.elem,arguments)})},rtTabContent:function(b){var c=this,d=c.$elem.find("li"),e=d.find("a");e.each(function(){var c=a(this),d=c.attr("href");"yes"===b?c.parent().hasClass("active")||a(d).addClass("hide"):a(d).addClass("hide")})}};a.fn.rtTab=function(b){return this.each(function(){var c=Object.create(e);c.init(b,this),a.data(this,"rtTab",c)})},a.fn.rtTab.options={activeTab:1,onComplete:null}}(jQuery,window,document);var rtMagnificPopup,rtm_masonry_container,rtMediaHook={hooks:[],is_break:!1,register:function(a,b){"undefined"==typeof rtMediaHook.hooks[a]&&(rtMediaHook.hooks[a]=[]),rtMediaHook.hooks[a].push(b)},call:function(a,b){if("undefined"!=typeof rtMediaHook.hooks[a])for(i=0;i<rtMediaHook.hooks[a].length;++i)if(1!=rtMediaHook.hooks[a][i](b))return rtMediaHook.is_break=!0,!1;return!0}};jQuery("document").ready(function(a){function b(){if(jQuery("#rtmedia-media-view-form").length>0){var a=jQuery("#rtmedia-media-view-form").attr("action");jQuery.post(a,{},function(a){})}}function c(){var a=jQuery.magnificPopup.instance;jQuery(".mfp-arrow-right").on("click",function(b){a.next()}),jQuery(".mfp-arrow-left").on("click",function(b){a.prev()}),jQuery(".mfp-content .rtmedia-media").swipe({swipeLeft:function(b,c,d,e,f){a.next()},swipeRight:function(b,c,d,e,f){a.prev()},threshold:0})}function d(){jQuery(document).on("focusin","#comment_content",function(){jQuery(document).unbind("keydown")}),jQuery(document).on("focusout","#comment_content",function(){var a=jQuery.magnificPopup.instance;jQuery(document).on("keydown",function(b){37===b.keyCode?a.prev():39===b.keyCode&&a.next()})})}function e(){jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",function(a){a.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()})}a(".rtm-tabs").rtTab(),jQuery(".rtmedia-modal-link").length>0&&a(".rtmedia-modal-link").magnificPopup({type:"inline",midClick:!0,closeBtnInside:!0}),a("#rt_media_comment_form").submit(function(b){return""==a.trim(a("#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):!0}),a("li.rtmedia-list-item p a").each(function(b){a(this).addClass("no-popup")}),a("li.rtmedia-list-item p a").each(function(b){a(this).addClass("no-popup")}),"undefined"!=typeof rtmedia_lightbox_enabled&&"1"==rtmedia_lightbox_enabled&&apply_rtMagnificPopup(".rtmedia-list-media, .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(a,b,c){try{if(null==b.data||"undefined"==typeof b.data||"undefined"==typeof b.data.action)return!0}catch(d){return!0}if("activity_get_older_updates"==b.data.action){var e=b.success;a.success=function(a){e(a),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"==b.data.action){var e=b.success;a.success=function(a){e(a),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({defaultVideoWidth:480,defaultVideoHeight:270})},900)}}}),jQuery.ajaxPrefilter(function(a,b,c){try{if(null==b.data||"undefined"==typeof b.data||"undefined"==typeof b.data.action)return!0}catch(d){return!0}if("activity_get_older_updates"==b.data.action){var e=b.success;a.success=function(a){e(a),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",[])}}}),jQuery(".rtmedia-container").on("click",".select-all",function(a){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(a){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(a){jQuery(".rtmedia-delete-container").slideUp(),jQuery(".rtmedia-move-container").slideToggle()}),jQuery("#rtmedia-create-album-modal").on("click","#rtmedia_create_new_album",function(b){if($albumname=jQuery.trim(jQuery("#rtmedia_album_name").val()),$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 c={action:"rtmedia_create_album",
6
+ name:$albumname,context:$context,context_id:$context_id,create_album_nonce:$create_album_nonce};""!==$privacy&&(c.privacy=$privacy),a("#rtmedia_create_new_album").attr("disabled","disabled");var d=a("#rtmedia_create_new_album").html();a("#rtmedia_create_new_album").prepend("<img src='"+rMedia_loading_file+"' />"),jQuery.post(rtmedia_ajax_url,c,function(b){if(b=jQuery.parseJSON(b),"undefined"!=typeof b.album){b=jQuery.trim(b.album);var c=!0;jQuery(".rtmedia-user-album-list").each(function(){if(jQuery(this).children("optgroup").each(function(){return jQuery(this).attr("value")===$context?(c=!1,void jQuery(this).append('<option value="'+b+'">'+$albumname+"</option>")):void 0}),c){var a=$context.charAt(0).toUpperCase()+$context.slice(1),d='<optgroup value="'+$context+'" label="'+a+' Albums"><option value="'+b+'">'+$albumname+"</option></optgroup>";jQuery(this).append(d)}}),jQuery('select.rtmedia-user-album-list option[value="'+b+'"]').prop("selected",!0),jQuery(".rtmedia-create-new-album-container").slideToggle(),jQuery("#rtmedia_album_name").val(""),jQuery("#rtmedia-create-album-modal").append("<div class='rtmedia-success rtmedia-create-album-alert'><b>"+$albumname+"</b>"+rtmedia_album_created_msg+"</div>"),setTimeout(function(){jQuery(".rtmedia-create-album-alert").remove()},4e3),setTimeout(function(){galleryObj.reloadView(),jQuery(".close-reveal-modal").click()},2e3)}else"undefined"!=typeof b.error?rtmedia_gallery_action_alert_message(b.error,"warning"):rtmedia_gallery_action_alert_message(rtmedia_something_wrong_msg,"warning");a("#rtmedia_create_new_album").removeAttr("disabled"),a("#rtmedia_create_new_album").html(d)})}else rtmedia_gallery_action_alert_message(rtmedia_empty_album_name_msg,"warning")}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-selected",function(a){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(a){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")}),b(),rtMediaHook.register("rtmedia_js_popup_after_content_added",function(){b(),e(),mfp=jQuery.magnificPopup.instance,jQuery(mfp.items).size()>1&&c(),d();var f=a(window).height();jQuery(".rtm-lightbox-container .mejs-video").css({height:.8*f,"max-height":.8*f,"over-flow":"hidden"}),jQuery(".mfp-content .rtmedia-media").css({"max-height":.87*f,"over-flow":"hidden"}),rtmedia_init_action_dropdown(),jQuery(".rtmedia-comment-link").on("click",function(a){a.preventDefault(),jQuery("#comment_content").focus()}),jQuery(".rtm-more").shorten({showChars:130});var g=a(".rtm-gallery-title"),h="";h=a.isEmptyObject(g)?a("#subnav.item-list-tabs li.selected ").html():g.html(),""!=h&&a(".rtm-ltb-gallery-title .ltb-title").html(h);var i=a("#subnav.item-list-tabs li.selected span").html();return a("li.total").html(i),!0});var f=jQuery("#drag-drop-area"),g=jQuery("#whats-new");f.html();jQuery("#rtmedia-upload-container").after("<div id='rtm-drop-files-title'>"+rtmedia_drop_media_msg+"</div>"),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&jQuery("#whats-new-textarea").append("<div id='rtm-drop-files-title'>"+rtmedia_drop_media_msg+"</div>"),jQuery(document).on("dragover",function(a){jQuery("#rtm-media-gallery-uploader").show(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&g.addClass("rtm-drag-drop-active"),f.addClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").show()}).on("dragleave",function(a){a.preventDefault(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&(g.removeClass("rtm-drag-drop-active"),g.removeAttr("style")),f.removeClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").hide()}).on("drop",function(a){a.preventDefault(),"undefined"!=typeof rtmedia_bp_enable_activity&&"1"==rtmedia_bp_enable_activity&&(g.removeClass("rtm-drag-drop-active"),g.removeAttr("style")),f.removeClass("rtm-drag-drop-active"),jQuery("#rtm-drop-files-title").hide()}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-album",function(a){a.preventDefault(),confirm(rtmedia_album_delete_confirmation)&&jQuery(this).closest("form").submit()}),jQuery(".rtmedia-container").on("click",".rtmedia-delete-media",function(a){a.preventDefault(),confirm(rtmedia_media_delete_confirmation)&&jQuery(this).closest("form").submit()}),rtmedia_init_action_dropdown(),a(document).click(function(){a(".click-nav ul").is(":visible")&&a(".click-nav ul",this).hide()}),jQuery(".rtmedia-comment-link").on("click",function(a){a.preventDefault(),jQuery("#comment_content").focus()}),jQuery(".rtm-more").length>0&&a(".rtm-more").shorten({showChars:200}),"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"),rtm_masonry_container.masonry({itemSelector:".rtmedia-list-item"}),setInterval(function(){jQuery.each(jQuery(".rtmedia-list.masonry .rtmedia-item-title"),function(a,b){jQuery(b).width(jQuery(b).siblings(".rtmedia-item-thumbnail").children("img").width())}),rtm_masonry_reload(rtm_masonry_container)},1e3),jQuery.each(jQuery(".rtmedia-list.masonry .rtmedia-item-title"),function(a,b){jQuery(b).width(jQuery(b).siblings(".rtmedia-item-thumbnail").children("img").width())})),jQuery(".rtm-uploader-tabs").length>0&&jQuery(".rtm-uploader-tabs li").click(function(a){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").children("input[type=file]").hide():jQuery("div.moxie-shim").children("input[type=file]").show())}),jQuery(".rtmedia-container").on("click",".rtm-delete-media",function(a){a.preventDefault();var b="Are you sure you want to delete this media?";if("undefined"!=typeof rtmedia_media_delete_confirmation&&(b=rtmedia_media_delete_confirmation),confirm(b)){var c=jQuery(this).closest("li"),d=jQuery("#rtmedia_media_delete_nonce").val(),e={action:"delete_uploaded_media",nonce:d,media_id:c.attr("id")};jQuery.ajax({url:ajaxurl,type:"post",data:e,success:function(a){"1"==a?(rtmedia_gallery_action_alert_message("file deleted successfully.","success"),c.remove(),"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)):rtmedia_gallery_action_alert_message(rtmedia_file_not_deleted,"warning")}})}})}),function(a){a.fn.shorten=function(b){var c={showChars:100,ellipsesText:"...",moreText:"more",lessText:"less"};return b&&a.extend(c,b),a(document).off("click",".morelink"),a(document).on({click:function(){var b=a(this);return b.hasClass("less")?(b.removeClass("less"),b.html(c.moreText)):(b.addClass("less"),b.html(c.lessText)),b.parent().prev().toggle(),b.prev().toggle(),!1}},".morelink"),this.each(function(){var b=a(this);if(!b.hasClass("shortened")){b.addClass("shortened");var d=b.html();if(d.length>c.showChars){var e=d.substr(0,c.showChars),f=d.substr(c.showChars,d.length-c.showChars),g=e+'<span class="moreellipses">'+c.ellipsesText+' </span><span class="morecontent"><span>'+f+'</span> <a href="#" class="morelink">'+c.moreText+"</a></span>";b.html(g),a(".morecontent span").hide()}}})}}(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)};
app/main/controllers/activity/RTMediaBuddyPressActivity.php CHANGED
@@ -409,7 +409,7 @@ class RTMediaBuddyPressActivity {
409
  }
410
  }
411
 
412
- $action = apply_filters( 'rtmedia_buddypress_action_text_fitler', $action, $user_link, $count, $user->user_nicename, $rtmedia_media_type_array[ $activities[ $index ]->id ][ 0 ], $activities[ $index ]->id );
413
  $activities[ $index ]->action = $action;
414
  }
415
  }
409
  }
410
  }
411
 
412
+ $action = apply_filters( 'rtmedia_bp_activity_action_text', $action, $user_link, $count, $user, $rtmedia_media_type_array[ $activities[ $index ]->id ][ 0 ], $activities[ $index ]->id );
413
  $activities[ $index ]->action = $action;
414
  }
415
  }
app/main/controllers/media/RTMediaMedia.php CHANGED
@@ -12,616 +12,617 @@
12
  */
13
  class RTMediaMedia {
14
 
15
- static $default_object = array(
16
- 'id', 'blog_id', 'media_id', 'media_author', 'media_title', 'album_id', 'media_type', 'context', 'context_id', 'source', 'source_id', 'activity_id', 'cover_art', 'privacy', 'views', 'downloads', 'ratings_total', 'ratings_count', 'ratings_average', 'likes', 'dislikes'
17
- );
18
-
19
- /**
20
- * DB Model object to interact on Database operations
21
- *
22
- * @var object the database model
23
- */
24
- var $model;
25
-
26
- /**
27
- * Initialises the model object of the mediua object
28
- */
29
- public function __construct() {
30
-
31
- $this->model = new RTMediaModel();
32
- }
33
-
34
- /**
35
- * Generate nonce
36
- *
37
- * @param boolean $echo whether nonce should be echoed
38
- *
39
- * @return string json encoded nonce
40
- */
41
- static function media_nonce_generator( $id, $echo = true ) {
42
- if ( $echo ){
43
- wp_nonce_field( 'rtmedia_' . $id, 'rtmedia_media_nonce' );
44
- } else {
45
- $token = array(
46
- 'action' => 'rtmedia_media_nonce', 'nonce' => wp_create_nonce( 'rtmedia_' . $id )
47
- );
48
-
49
- return json_encode( $token );
50
- }
51
- }
52
-
53
- /**
54
- * Method verifies the nonce passed while performing any CRUD operations
55
- * on the media.
56
- *
57
- * @param string $mode The upload mode
58
- *
59
- * @return boolean whether the nonce is valid
60
- */
61
- function verify_nonce( $mode ) {
62
-
63
- $nonce = $_REQUEST[ "rtmedia_{$mode}_media_nonce" ];
64
- $mode = $_REQUEST[ 'mode' ];
65
-
66
- if ( wp_verify_nonce( $nonce, 'rtmedia_' . $mode ) ){
67
- return true;
68
- } else {
69
- return false;
70
- }
71
- }
72
-
73
- /**
74
- * Adds a hook to delete_attachment tag called
75
- * when a media is deleted externally out of rtMedia context
76
- */
77
- public function delete_hook() {
78
- add_action( 'delete_attachment', array( $this, 'delete_wordpress_attachment' ) );
79
- add_action( 'delete_user', array( $this, 'reassign_wordpress_user'), 10, 2 );
80
- }
81
-
82
- /**
83
- * Adds taxonomy
84
- *
85
- * @param array $attachments ids of the attachments created after upload
86
- * @param array $taxonomies array of terms indexed by a taxonomy
87
- */
88
- function add_taxonomy( $attachments, $taxonomies ) {
89
-
90
- foreach ( $attachments as $id ) {
91
-
92
- foreach ( $taxonomies as $taxonomy => $terms ) {
93
- if ( ! taxonomy_exists( $taxonomy ) ){
94
- continue;
95
- }
96
-
97
- wp_set_object_terms( $id, $terms, $taxonomy );
98
- }
99
- }
100
- }
101
-
102
- /**
103
- *
104
- * @param array $attachments attachment ids
105
- * @param array $custom_fields array of key value pairs of meta
106
- *
107
- * @return boolean success of meta
108
- */
109
- function add_meta( $attachments, $custom_fields ) {
110
-
111
- foreach ( $attachments as $id ) {
112
- $row = array( 'media_id' => $id );
113
-
114
- foreach ( $custom_fields as $key => $value ) {
115
-
116
- if ( ! is_null( $value ) ){
117
- $row[ 'meta_key' ] = $key;
118
- $row[ 'meta_value' ] = $value;
119
- $status = add_rtmedia_meta( $id, $key, $value );
120
-
121
- if ( is_wp_error( $status ) || $status == 0 ){
122
- return false;
123
- }
124
- }
125
- }
126
- }
127
-
128
- return true;
129
- }
130
-
131
- /**
132
- * Helper method to check for multisite - will add a few additional checks
133
- * for handling taxonomies
134
- *
135
- * @return boolean
136
- */
137
- function is_multisite() {
138
- return is_multisite();
139
- }
140
-
141
- /**
142
- * Generic method to add a media
143
- *
144
- * @param type $uploaded
145
- * @param type $file_object
146
- *
147
- * @return type
148
- */
149
- function add( $uploaded, $file_object ) {
150
-
151
- /* action to perform any task before adding a media */
152
- do_action( 'rtmedia_before_add_media', $file_object, $uploaded );
153
-
154
- /* Generate media details required to feed in database */
155
- $attachments = $this->generate_post_array( $uploaded, $file_object );
156
-
157
- /* Insert the media as an attachment in Wordpress context */
158
- $attachment_ids = $this->insert_attachment( $attachments, $file_object );
159
-
160
- /* check for multisite and if valid then add taxonomies */
161
- if ( ! $this->is_multisite() ){
162
- $this->add_taxonomy( $attachment_ids, $uploaded[ 'taxonomy' ] );
163
- }
164
-
165
- /* fetch custom fields and add them to meta table */
166
- $this->add_meta( $attachment_ids, $uploaded[ 'custom_fields' ] );
167
-
168
-
169
- /* add media in rtMedia context */
170
- $media_ids = $this->insertmedia( $attachment_ids, $uploaded, $file_object /* passing file object to check the extension */ );
171
-
172
- $rtmedia_type = rtmedia_type( $media_ids );
173
- /* action to perform any task after adding a media */
174
- global $rtmedia_points_media_id;
175
- if ( $media_ids && is_array( $media_ids ) && isset( $media_ids[ 0 ] ) ){
176
- $rtmedia_points_media_id = $media_ids[ 0 ];
177
- }
178
-
179
- do_action( 'rtmedia_after_add_' . $rtmedia_type );
180
-
181
- do_action( 'rtmedia_after_add_media', $media_ids, $file_object, $uploaded );
182
-
183
- return $media_ids;
184
- }
185
-
186
- /**
187
- * Generic method to update a media. media details can be changed from this method
188
- *
189
- * @param type $media_id
190
- * @param type $meta
191
- *
192
- * @return boolean
193
- */
194
- function update( $id, $data, $media_id ) {
195
-
196
- /* action to perform any task before updating a media */
197
- do_action( 'rtmedia_before_update_media', $id );
198
-
199
- $defaults = array();
200
- $data = wp_parse_args( $data, $defaults );
201
- $where = array( 'id' => $id );
202
-
203
- if ( array_key_exists( 'media_title', $data ) || array_key_exists( 'description', $data ) ){
204
- $post_data[ 'ID' ] = $media_id;
205
- if ( isset ( $data[ 'media_title' ] ) ){
206
- $data[ 'media_title' ] = wp_kses( $data[ 'media_title' ], wp_kses_allowed_html() );
207
- $post_data[ 'post_title' ] = $data[ 'media_title' ];
208
- $post_data[ 'post_name' ] = $data[ 'media_title' ];
209
- }
210
- if ( isset ( $data[ 'description' ] ) ){
211
- $post_data[ 'post_content' ] = $data[ 'description' ];
212
- $post_data[ 'description' ] = sanitize_text_field( $data[ 'description' ] );
213
- unset ( $data[ 'description' ] );
214
- }
215
- wp_update_post( $post_data );
216
- }
217
-
218
- $status = $this->model->update( $data, $where );
219
-
220
- // insert/update activity details in rtmedia activity table
221
- $media_model = new RTMediaModel();
222
- $media = $media_model->get( array( 'id' => $id ) );
223
-
224
- if( !empty( $media ) ){
225
- $rtmedia_activity_model = new RTMediaActivityModel();
226
- $similar_media = $media_model->get( array( 'activity_id' => $media[ 0 ]->activity_id ) );
227
- $max_privacy = 0;
228
-
229
- foreach ( $similar_media as $s_media ) {
230
- if ( $s_media->privacy > $max_privacy ){
231
- $max_privacy = $s_media->privacy;
232
- }
233
- }
234
-
235
- if ( ! $rtmedia_activity_model->check( $media[ 0 ]->activity_id ) ){
236
- $rtmedia_activity_model->insert( array(
237
- 'activity_id' => $media[ 0 ]->activity_id, 'user_id' => $media[ 0 ]->media_author, 'privacy' => $max_privacy
238
- ) );
239
- } else {
240
- $rtmedia_activity_model->update( array(
241
- 'activity_id' => $media[ 0 ]->activity_id, 'user_id' => $media[ 0 ]->media_author, 'privacy' => $max_privacy
242
- ), array( 'activity_id' => $media[ 0 ]->activity_id ) );
243
- }
244
- }
245
-
246
- /* action to perform any task after updating a media */
247
- do_action( 'rtmedia_after_update_media', $id );
248
-
249
- if ( $status === false ){
250
- return false;
251
- } else {
252
- return true;
253
- }
254
- }
255
-
256
- /**
257
- * Generic method to delete a media from wordpress media library ( other than by rtMedia )
258
- *
259
- * @param type $media_id
260
- *
261
- * @return boolean
262
- */
263
- function delete_wordpress_attachment( $id ) {
264
- $media = $this->model->get( array( 'media_id' => $id ), false, false );
265
-
266
- if ( $media ){
267
- $this->delete( $media[ 0 ]->id, true );
268
- }
269
- }
270
-
271
- /**
272
- * Method to reassign media to another user while deleting user
273
- *
274
- * @param type $user_id, $reassign
275
- *
276
- */
277
- public function reassign_wordpress_user( $user_id , $reassign ){
278
- if( $reassign != null || $reassign != '' ){
279
- // Updating media author
280
- $rtmedia_model = new RTMediaModel();
281
- $rtmedia_model->update( array( 'media_author' => $reassign ), array( 'media_author' => $user_id ) );
282
-
283
- // Updating user id from interaction
284
- $rtmediainteraction = new RTMediaInteractionModel();
285
- $rtmediainteraction->update( array( 'user_id' => $reassign ), array( 'user_id' => $user_id ) );
286
- }
287
- }
288
-
289
- /**
290
- * Generic method to delete a media
291
- *
292
- * @param type $media_id
293
- *
294
- * @return boolean
295
- */
296
- function delete( $id, $core = false, $delete_activity = true ) {
297
- do_action( 'rtmedia_before_delete_media', $id );
298
-
299
- $media = $this->model->get( array( 'id' => $id ), false, false );
300
-
301
- $status = 0;
302
-
303
- if ( $media ){
304
- /* delete meta */
305
- //delete_rtmedia_meta($id);
306
- if ( $delete_activity ){
307
- if ( $media[ 0 ]->activity_id && function_exists( 'bp_activity_delete_by_activity_id' ) ){
308
- $related_media = $this->model->get( array( 'activity_id' => $media[ 0 ]->activity_id ), false, false );
309
- if ( count( $related_media ) > 1 ){
310
- $activity_media = array();
311
- foreach ( $related_media as $temp_media ) {
312
- if ( $temp_media->id == $id ){
313
- continue;
314
- }
315
- $activity_media[ ] = $temp_media->id;
316
- }
317
- $objActivity = new RTMediaActivity ( $activity_media );
318
- global $wpdb, $bp;
319
- $wpdb->update( $bp->activity->table_name, array( "type" => "rtmedia_update", "content" => $objActivity->create_activity_html() ), array( "id" => $media[ 0 ]->activity_id ) );
320
- } else {
321
  if( isset( $media[ 0 ] ) && isset( $media[ 0 ]->activity_id ) ) {
322
  bp_activity_delete_by_activity_id( $media[ 0 ]->activity_id );
323
  }
324
- }
325
- }
326
- }
327
- if ( ! $core ){
328
- wp_delete_attachment( $media[ 0 ]->media_id, true );
329
- }
330
- $status = $this->model->delete( array( 'id' => $id ) );
331
-
332
- //delete media meta (view) from wp_rt_rtm_media_meta
333
- $delete_rtmedia_views = delete_rtmedia_meta( $id, 'view' );
334
-
335
- if ( $status != 0 && ( $media[ 0 ]->media_type == "album" || $media[ 0 ]->media_type == "playlist" ) ){
336
- $status = wp_delete_post( $media[ 0 ]->media_id );
337
- }
338
- $rtMediaNav = new RTMediaNav();
339
- if ( $media[ 0 ]->context == "group" ){
340
- $rtMediaNav->refresh_counts( $media[ 0 ]->context_id, array(
341
- "context" => $media[ 0 ]->context, 'context_id' => $media[ 0 ]->context_id
342
- ) );
343
- } else {
344
- $rtMediaNav->refresh_counts( $media[ 0 ]->media_author, array(
345
- "context" => "profile", 'media_author' => $media[ 0 ]->media_author
346
- ) );
347
- }
348
- }
349
-
350
- if ( ! $status ){
351
- return false;
352
- } else {
353
- global $rtmedia_points_media_id;
354
- $rtmedia_points_media_id = $id;
355
- do_action( 'rtmedia_after_delete_media', $id );
356
-
357
- return true;
358
- }
359
- }
360
-
361
- /**
362
- * Move a media from one album to another
363
- *
364
- * @global type $wpdb
365
- *
366
- * @param type $media_id
367
- * @param type $album_id
368
- *
369
- * @return boolean
370
- */
371
- function move( $media_id, $album_id ) {
372
-
373
- global $wpdb;
374
- /* update the post_parent value in wp_post table */
375
- $status = $wpdb->update( $wpdb->posts, array( 'post_parent' => $album_id ), array( 'ID' => $media_id ) );
376
-
377
- if ( is_wp_error( $status ) || $status == 0 ){
378
- return false;
379
- } else {
380
- $id = rtmedia_id( $media_id );
381
- /* update album_id, context, context_id and privacy in rtMedia context */
382
- $album_data = $this->model->get( array( 'media_id' => $media_id ) );
383
- $data = array(
384
- 'album_id' => $album_id,
385
- 'context' => $album_data->context,
386
- 'context_id' => $album_data->context_id,
387
- 'privacy' => $album_data->privacy
388
- );
389
-
390
- return $this->update( $id, $data, $media_id );
391
- }
392
- }
393
-
394
- /**
395
- * Imports attachment as media
396
- */
397
- function import_attachment() {
398
-
399
- }
400
-
401
- /**
402
- * Check if BuddyPress and the activity component are enabled
403
- *
404
- * @return boolean
405
- */
406
- function activity_enabled() {
407
-
408
- if ( ! function_exists( 'bp_is_active' ) || ! bp_is_active( 'activity' ) ){
409
- return false;
410
- }
411
-
412
- global $rtmedia;
413
-
414
- return $rtmedia->options[ 'buddypress_enableOnActivity' ];
415
- }
416
-
417
- /**
418
- *
419
- * @param type $uploaded
420
- * @param type $file_object
421
- *
422
- * @return type
423
- */
424
- function generate_post_array( $uploaded, $file_object ) {
425
- if ( $uploaded[ 'album_id' ] ){
426
- $model = new RTMediaModel();
427
- $parent_details = $model->get( array( 'id' => $uploaded[ 'album_id' ] ) );
428
- if ( is_array( $parent_details ) && sizeof( $parent_details ) > 0 ){
429
- $album_id = $parent_details[ 0 ]->media_id;
430
- } else {
431
- $album_id = 0;
432
- }
433
- } else {
434
- $album_id = 0;
435
- }
436
-
437
- if ( ! in_array( $uploaded[ "context" ], array( "profile", "group" ) ) ){
438
- $album_id = $uploaded[ "context_id" ];
439
- }
440
-
441
- $attachments = array();
442
-
443
- foreach ( $file_object as $index => $file ) {
444
- $uploaded[ 'title' ] = wp_kses( $uploaded[ 'title' ], wp_kses_allowed_html() );
445
- $uploaded[ 'description' ] = sanitize_text_field( $uploaded[ 'description' ] );
446
- $attachments[$index] = array(
447
- 'post_mime_type' => $file[ 'type' ],
448
- 'guid' => $file[ 'url' ],
449
- 'post_title' => $uploaded[ 'title' ] ? $uploaded[ 'title' ] : preg_replace( "/\\.[^.\\s]{3,4}$/", "", $file[ 'name' ] ),
450
- 'post_content' => $uploaded[ 'description' ] ? $uploaded[ 'description' ] : '',
451
- 'post_parent' => $album_id,
452
- 'post_author' => $uploaded[ 'media_author' ]
453
- );
454
-
455
- if( ! empty( $uploaded['date'] ) ){
456
- $attachments[$index]['post_date'] = $uploaded['date'];
457
- }
458
- }
459
-
460
- return $attachments;
461
- }
462
-
463
- /**
464
- *
465
- * @param type $attachments
466
- * @param type $file_object
467
- *
468
- * @return array $updated_attachment_ids
469
- * @throws Exception
470
- */
471
- function insert_attachment( $attachments, $file_object ) {
472
- $updated_attachment_ids = array();
473
- foreach ( $attachments as $key => $attachment ) {
474
- $attachment_id = wp_insert_attachment( $attachment, $file_object[ $key ][ 'file' ], $attachment[ 'post_parent' ] );
475
- if ( ! is_wp_error( $attachment_id ) ){
476
- add_filter( 'intermediate_image_sizes', array( $this, 'image_sizes' ), 99 );
477
- /**
478
- * FIX WORDPRESS 3.6 METADATA
479
- */
480
- require_once( ABSPATH . 'wp-admin/includes/media.php' );
481
- /**
482
- *
483
- */
484
- wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file_object[ $key ][ 'file' ] ) );
485
- } else {
486
- unlink( $file_object[ $key ][ 'file' ] );
487
- throw new Exception ( __( 'Error creating attachment for the media file, please try again', 'buddypress-media' ) );
488
- }
489
- $updated_attachment_ids[ ] = $attachment_id;
490
- }
491
-
492
- return $updated_attachment_ids;
493
- }
494
-
495
- /**
496
- *
497
- * @param type $sizes
498
- *
499
- * @return type
500
- */
501
- function image_sizes( $sizes ) {
502
- return array( 'rt_media_thumbnail', 'rt_media_activity_image', 'rt_media_single_image', 'rt_media_featured_image' );
503
- }
504
-
505
- /**
506
- *
507
- * @param type $attributes
508
- */
509
- function insert_album( $attributes ) {
510
-
511
- return $this->model->insert( $attributes );
512
- }
513
-
514
- function set_media_type( $mime_type, $file_object ) {
515
- switch ( $mime_type ) {
516
- case 'image':
517
- return 'photo';
518
- break;
519
- case 'audio':
520
- return 'music';
521
- break;
522
- case 'video':
523
- return 'video';
524
- break;
525
- default:
526
- return apply_filters( 'rtmedia_set_media_type_filter', $mime_type, $file_object );
527
- break;
528
- }
529
- }
530
-
531
- /**
532
- *
533
- * @param array $attachment_ids
534
- * @param array $uploaded
535
- */
536
- function insertmedia( $attachment_ids, $uploaded, $file_object /* added for file extension */ ) {
537
-
538
- $defaults = array(
539
- 'activity_id' => $this->activity_enabled(),
540
- 'privacy' => 0
541
- );
542
-
543
- $uploaded = wp_parse_args( $uploaded, $defaults );
544
-
545
- $blog_id = get_current_blog_id();
546
- $media_id = Array();
547
- foreach ( $attachment_ids as $id ) {
548
- $attachment = get_post( $id, ARRAY_A );
549
- $mime_type = explode( '/', $attachment[ 'post_mime_type' ] );
550
-
551
- $media = array(
552
- 'blog_id' => $blog_id,
553
- 'media_id' => $id,
554
- 'album_id' => $uploaded[ 'album_id' ],
555
- 'media_author' => $attachment[ 'post_author' ],
556
- 'media_title' => $attachment[ 'post_title' ],
557
- 'media_type' => $this->set_media_type( $mime_type[ 0 ], $file_object /* added for file extension */ ),
558
- 'context' => $uploaded[ 'context' ],
559
- 'context_id' => $uploaded[ 'context_id' ],
560
- 'privacy' => $uploaded[ 'privacy' ]
561
- );
562
- if ( isset( $file_object ) && isset( $file_object[ 0 ] ) && isset( $file_object[ 0 ][ 'file' ] ) ){
563
- $media[ 'file_size' ] = filesize( $file_object[ 0 ][ 'file' ] );
564
- }
565
- $media[ 'upload_date' ] = $attachment[ 'post_date' ];
566
- $media_id[ ] = $this->model->insert( $media );
567
- }
568
-
569
- return $media_id;
570
- }
571
-
572
- function insert_activity( $id, $media ) {
573
- if ( ! $this->activity_enabled() ){
574
- return false;
575
- }
576
- $activity = new RTMediaActivity ( $media->id, $media->privacy );
577
- $activity_content = $activity->create_activity_html();
578
- $user = get_userdata( $media->media_author );
579
- $username = '<a href="' . get_rtmedia_user_link( $media->media_author ) . '">' . $user->user_nicename . '</a>';
580
- $count = count( $id );
581
- $media_const = 'RTMEDIA_' . strtoupper( $media->media_type );
582
- if ( $count > 1 ){
583
- $media_const .= '_PLURAL';
584
- }
585
- $media_const .= '_LABEL';
586
-
587
- $media_str = constant( $media_const );
588
-
589
- $action = sprintf( ( $count == 1 ) ? __( '%1$s added a %2$s', 'buddypress-media' ) : __( '%1$s added %4$d %3$s', 'buddypress-media' ), $username, $media->media_type, $media_str, $count );
590
- $action = apply_filters( 'rtmedia_buddypress_action_text_fitler', $action, $username, $count, $user->user_nicename, $media->media_type );
591
- $activity_args = array(
592
- 'user_id' => $user->ID,
593
- 'action' => $action,
594
- 'content' => $activity_content,
595
- 'type' => 'rtmedia_update',
596
- 'primary_link' => '',
597
- 'item_id' => $id
598
- );
599
-
600
- if ( $media->context == "group" && function_exists( "bp_get_group_status" ) && bp_get_group_status( groups_get_group( array( "group_id" => $media->context_id ) ) ) != "public" ){
601
- $activity_args[ "hide_sitewide" ] = true;
602
- }
603
-
604
- if ( $media->context == 'group' || 'profile' ){
605
- $activity_args[ 'component' ] = $media->context;
606
- if ( $media->context == 'group' ){
607
- $activity_args[ 'component' ] = "groups";
608
- $activity_args[ 'item_id' ] = $media->context_id;
609
- }
610
- }
611
-
612
- $activity_id = bp_activity_add( $activity_args );
613
- bp_activity_update_meta( $activity_id, 'rtmedia_privacy', ( $media->privacy == 0 ) ? - 1 : $media->privacy );
614
-
615
- $this->model->update( array( 'activity_id' => $activity_id ), array( 'id' => $media->id ) );
616
-
617
- // insert/update activity details in rtmedia activity table
618
- $rtmedia_activity_model = new RTMediaActivityModel();
619
- if ( ! $rtmedia_activity_model->check( $activity_id ) ){
620
- $rtmedia_activity_model->insert( array( 'activity_id' => $activity_id, 'user_id' => $media->media_author, 'privacy' => $media->privacy) );
621
- } else {
622
- $rtmedia_activity_model->update( array( 'activity_id' => $activity_id, 'user_id' => $media->media_author, 'privacy' => $media->privacy ), array( 'activity_id' => $activity_id ) );
623
- }
624
-
625
- return $activity_id;
626
- }
 
627
  }
12
  */
13
  class RTMediaMedia {
14
 
15
+ static $default_object = array(
16
+ 'id', 'blog_id', 'media_id', 'media_author', 'media_title', 'album_id', 'media_type', 'context', 'context_id', 'source', 'source_id', 'activity_id', 'cover_art', 'privacy', 'views', 'downloads', 'ratings_total', 'ratings_count', 'ratings_average', 'likes', 'dislikes'
17
+ );
18
+
19
+ /**
20
+ * DB Model object to interact on Database operations
21
+ *
22
+ * @var object the database model
23
+ */
24
+ var $model;
25
+
26
+ /**
27
+ * Initialises the model object of the mediua object
28
+ */
29
+ public function __construct() {
30
+
31
+ $this->model = new RTMediaModel();
32
+ }
33
+
34
+ /**
35
+ * Generate nonce
36
+ *
37
+ * @param boolean $echo whether nonce should be echoed
38
+ *
39
+ * @return string json encoded nonce
40
+ */
41
+ static function media_nonce_generator( $id, $echo = true ) {
42
+ if( $echo ) {
43
+ wp_nonce_field( 'rtmedia_' . $id, 'rtmedia_media_nonce' );
44
+ } else {
45
+ $token = array(
46
+ 'action' => 'rtmedia_media_nonce', 'nonce' => wp_create_nonce( 'rtmedia_' . $id )
47
+ );
48
+
49
+ return json_encode( $token );
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Method verifies the nonce passed while performing any CRUD operations
55
+ * on the media.
56
+ *
57
+ * @param string $mode The upload mode
58
+ *
59
+ * @return boolean whether the nonce is valid
60
+ */
61
+ function verify_nonce( $mode ) {
62
+
63
+ $nonce = $_REQUEST[ "rtmedia_{$mode}_media_nonce" ];
64
+ $mode = $_REQUEST[ 'mode' ];
65
+
66
+ if( wp_verify_nonce( $nonce, 'rtmedia_' . $mode ) ) {
67
+ return true;
68
+ } else {
69
+ return false;
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Adds a hook to delete_attachment tag called
75
+ * when a media is deleted externally out of rtMedia context
76
+ */
77
+ public function delete_hook() {
78
+ add_action( 'delete_attachment', array( $this, 'delete_wordpress_attachment' ) );
79
+ add_action( 'delete_user', array( $this, 'reassign_wordpress_user' ), 10, 2 );
80
+ }
81
+
82
+ /**
83
+ * Adds taxonomy
84
+ *
85
+ * @param array $attachments ids of the attachments created after upload
86
+ * @param array $taxonomies array of terms indexed by a taxonomy
87
+ */
88
+ function add_taxonomy( $attachments, $taxonomies ) {
89
+
90
+ foreach( $attachments as $id ) {
91
+
92
+ foreach( $taxonomies as $taxonomy => $terms ) {
93
+ if( !taxonomy_exists( $taxonomy ) ) {
94
+ continue;
95
+ }
96
+
97
+ wp_set_object_terms( $id, $terms, $taxonomy );
98
+ }
99
+ }
100
+ }
101
+
102
+ /**
103
+ *
104
+ * @param array $attachments attachment ids
105
+ * @param array $custom_fields array of key value pairs of meta
106
+ *
107
+ * @return boolean success of meta
108
+ */
109
+ function add_meta( $attachments, $custom_fields ) {
110
+
111
+ foreach( $attachments as $id ) {
112
+ $row = array( 'media_id' => $id );
113
+
114
+ foreach( $custom_fields as $key => $value ) {
115
+
116
+ if( !is_null( $value ) ) {
117
+ $row[ 'meta_key' ] = $key;
118
+ $row[ 'meta_value' ] = $value;
119
+ $status = add_rtmedia_meta( $id, $key, $value );
120
+
121
+ if( is_wp_error( $status ) || $status == 0 ) {
122
+ return false;
123
+ }
124
+ }
125
+ }
126
+ }
127
+
128
+ return true;
129
+ }
130
+
131
+ /**
132
+ * Helper method to check for multisite - will add a few additional checks
133
+ * for handling taxonomies
134
+ *
135
+ * @return boolean
136
+ */
137
+ function is_multisite() {
138
+ return is_multisite();
139
+ }
140
+
141
+ /**
142
+ * Generic method to add a media
143
+ *
144
+ * @param type $uploaded
145
+ * @param type $file_object
146
+ *
147
+ * @return type
148
+ */
149
+ function add( $uploaded, $file_object ) {
150
+
151
+ /* action to perform any task before adding a media */
152
+ do_action( 'rtmedia_before_add_media', $file_object, $uploaded );
153
+
154
+ /* Generate media details required to feed in database */
155
+ $attachments = $this->generate_post_array( $uploaded, $file_object );
156
+
157
+ /* Insert the media as an attachment in Wordpress context */
158
+ $attachment_ids = $this->insert_attachment( $attachments, $file_object );
159
+
160
+ /* check for multisite and if valid then add taxonomies */
161
+ if( !$this->is_multisite() ) {
162
+ $this->add_taxonomy( $attachment_ids, $uploaded[ 'taxonomy' ] );
163
+ }
164
+
165
+ /* fetch custom fields and add them to meta table */
166
+ $this->add_meta( $attachment_ids, $uploaded[ 'custom_fields' ] );
167
+
168
+
169
+ /* add media in rtMedia context */
170
+ $media_ids = $this->insertmedia( $attachment_ids, $uploaded, $file_object /* passing file object to check the extension */ );
171
+
172
+ $rtmedia_type = rtmedia_type( $media_ids );
173
+ /* action to perform any task after adding a media */
174
+ global $rtmedia_points_media_id;
175
+ if( $media_ids && is_array( $media_ids ) && isset( $media_ids[ 0 ] ) ) {
176
+ $rtmedia_points_media_id = $media_ids[ 0 ];
177
+ }
178
+
179
+ do_action( 'rtmedia_after_add_' . $rtmedia_type );
180
+
181
+ do_action( 'rtmedia_after_add_media', $media_ids, $file_object, $uploaded );
182
+
183
+ return $media_ids;
184
+ }
185
+
186
+ /**
187
+ * Generic method to update a media. media details can be changed from this method
188
+ *
189
+ * @param type $media_id
190
+ * @param type $meta
191
+ *
192
+ * @return boolean
193
+ */
194
+ function update( $id, $data, $media_id ) {
195
+
196
+ /* action to perform any task before updating a media */
197
+ do_action( 'rtmedia_before_update_media', $id );
198
+
199
+ $defaults = array();
200
+ $data = wp_parse_args( $data, $defaults );
201
+ $where = array( 'id' => $id );
202
+
203
+ if( array_key_exists( 'media_title', $data ) || array_key_exists( 'description', $data ) ) {
204
+ $post_data[ 'ID' ] = $media_id;
205
+ if( isset( $data[ 'media_title' ] ) ) {
206
+ $data[ 'media_title' ] = wp_kses( $data[ 'media_title' ], wp_kses_allowed_html() );
207
+ $post_data[ 'post_title' ] = $data[ 'media_title' ];
208
+ $post_data[ 'post_name' ] = $data[ 'media_title' ];
209
+ }
210
+ if( isset( $data[ 'description' ] ) ) {
211
+ $post_data[ 'post_content' ] = $data[ 'description' ];
212
+ $post_data[ 'description' ] = sanitize_text_field( $data[ 'description' ] );
213
+ unset( $data[ 'description' ] );
214
+ }
215
+ wp_update_post( $post_data );
216
+ }
217
+
218
+ $status = $this->model->update( $data, $where );
219
+
220
+ // insert/update activity details in rtmedia activity table
221
+ $media_model = new RTMediaModel();
222
+ $media = $media_model->get( array( 'id' => $id ) );
223
+
224
+ if( !empty( $media ) ) {
225
+ $rtmedia_activity_model = new RTMediaActivityModel();
226
+ $similar_media = $media_model->get( array( 'activity_id' => $media[ 0 ]->activity_id ) );
227
+ $max_privacy = 0;
228
+
229
+ foreach( $similar_media as $s_media ) {
230
+ if( $s_media->privacy > $max_privacy ) {
231
+ $max_privacy = $s_media->privacy;
232
+ }
233
+ }
234
+
235
+ if( !$rtmedia_activity_model->check( $media[ 0 ]->activity_id ) ) {
236
+ $rtmedia_activity_model->insert( array(
237
+ 'activity_id' => $media[ 0 ]->activity_id, 'user_id' => $media[ 0 ]->media_author, 'privacy' => $max_privacy
238
+ ) );
239
+ } else {
240
+ $rtmedia_activity_model->update( array(
241
+ 'activity_id' => $media[ 0 ]->activity_id, 'user_id' => $media[ 0 ]->media_author, 'privacy' => $max_privacy
242
+ ), array( 'activity_id' => $media[ 0 ]->activity_id ) );
243
+ }
244
+ }
245
+
246
+ /* action to perform any task after updating a media */
247
+ do_action( 'rtmedia_after_update_media', $id );
248
+
249
+ if( $status === false ) {
250
+ return false;
251
+ } else {
252
+ return true;
253
+ }
254
+ }
255
+
256
+ /**
257
+ * Generic method to delete a media from wordpress media library ( other than by rtMedia )
258
+ *
259
+ * @param type $media_id
260
+ *
261
+ * @return boolean
262
+ */
263
+ function delete_wordpress_attachment( $id ) {
264
+ $media = $this->model->get( array( 'media_id' => $id ), false, false );
265
+
266
+ if( $media ) {
267
+ $this->delete( $media[ 0 ]->id, true );
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Method to reassign media to another user while deleting user
273
+ *
274
+ * @param type $user_id, $reassign
275
+ *
276
+ */
277
+ public function reassign_wordpress_user( $user_id, $reassign ) {
278
+ if( $reassign != null || $reassign != '' ) {
279
+ // Updating media author
280
+ $rtmedia_model = new RTMediaModel();
281
+ $rtmedia_model->update( array( 'media_author' => $reassign ), array( 'media_author' => $user_id ) );
282
+
283
+ // Updating user id from interaction
284
+ $rtmediainteraction = new RTMediaInteractionModel();
285
+ $rtmediainteraction->update( array( 'user_id' => $reassign ), array( 'user_id' => $user_id ) );
286
+ }
287
+ }
288
+
289
+ /**
290
+ * Generic method to delete a media
291
+ *
292
+ * @param type $media_id
293
+ *
294
+ * @return boolean
295
+ */
296
+ function delete( $id, $core = false, $delete_activity = true ) {
297
+ do_action( 'rtmedia_before_delete_media', $id );
298
+
299
+ $media = $this->model->get( array( 'id' => $id ), false, false );
300
+
301
+ $status = 0;
302
+
303
+ if( $media ) {
304
+ /* delete meta */
305
+ //delete_rtmedia_meta($id);
306
+ if( $delete_activity ) {
307
+ if( $media[ 0 ]->activity_id && function_exists( 'bp_activity_delete_by_activity_id' ) ) {
308
+ $related_media = $this->model->get( array( 'activity_id' => $media[ 0 ]->activity_id ), false, false );
309
+ if( count( $related_media ) > 1 ) {
310
+ $activity_media = array();
311
+ foreach( $related_media as $temp_media ) {
312
+ if( $temp_media->id == $id ) {
313
+ continue;
314
+ }
315
+ $activity_media[] = $temp_media->id;
316
+ }
317
+ $objActivity = new RTMediaActivity( $activity_media );
318
+ global $wpdb, $bp;
319
+ $wpdb->update( $bp->activity->table_name, array( "type" => "rtmedia_update", "content" => $objActivity->create_activity_html() ), array( "id" => $media[ 0 ]->activity_id ) );
320
+ } else {
321
  if( isset( $media[ 0 ] ) && isset( $media[ 0 ]->activity_id ) ) {
322
  bp_activity_delete_by_activity_id( $media[ 0 ]->activity_id );
323
  }
324
+ }
325
+ }
326
+ }
327
+ if( !$core ) {
328
+ wp_delete_attachment( $media[ 0 ]->media_id, true );
329
+ }
330
+ $status = $this->model->delete( array( 'id' => $id ) );
331
+
332
+ //delete media meta (view) from wp_rt_rtm_media_meta
333
+ $delete_rtmedia_views = delete_rtmedia_meta( $id, 'view' );
334
+
335
+ if( $status != 0 && ( $media[ 0 ]->media_type == "album" || $media[ 0 ]->media_type == "playlist" ) ) {
336
+ $status = wp_delete_post( $media[ 0 ]->media_id );
337
+ }
338
+ $rtMediaNav = new RTMediaNav();
339
+ if( $media[ 0 ]->context == "group" ) {
340
+ $rtMediaNav->refresh_counts( $media[ 0 ]->context_id, array(
341
+ "context" => $media[ 0 ]->context, 'context_id' => $media[ 0 ]->context_id
342
+ ) );
343
+ } else {
344
+ $rtMediaNav->refresh_counts( $media[ 0 ]->media_author, array(
345
+ "context" => "profile", 'media_author' => $media[ 0 ]->media_author
346
+ ) );
347
+ }
348
+ }
349
+
350
+ if( !$status ) {
351
+ return false;
352
+ } else {
353
+ global $rtmedia_points_media_id;
354
+ $rtmedia_points_media_id = $id;
355
+ do_action( 'rtmedia_after_delete_media', $id );
356
+
357
+ return true;
358
+ }
359
+ }
360
+
361
+ /**
362
+ * Move a media from one album to another
363
+ *
364
+ * @global type $wpdb
365
+ *
366
+ * @param type $media_id
367
+ * @param type $album_id
368
+ *
369
+ * @return boolean
370
+ */
371
+ function move( $media_id, $album_id ) {
372
+
373
+ global $wpdb;
374
+ /* update the post_parent value in wp_post table */
375
+ $status = $wpdb->update( $wpdb->posts, array( 'post_parent' => $album_id ), array( 'ID' => $media_id ) );
376
+
377
+ if( is_wp_error( $status ) || $status == 0 ) {
378
+ return false;
379
+ } else {
380
+ $id = rtmedia_id( $media_id );
381
+ /* update album_id, context, context_id and privacy in rtMedia context */
382
+ $album_data = $this->model->get( array( 'media_id' => $media_id ) );
383
+ $data = array(
384
+ 'album_id' => $album_id,
385
+ 'context' => $album_data->context,
386
+ 'context_id' => $album_data->context_id,
387
+ 'privacy' => $album_data->privacy
388
+ );
389
+
390
+ return $this->update( $id, $data, $media_id );
391
+ }
392
+ }
393
+
394
+ /**
395
+ * Imports attachment as media
396
+ */
397
+ function import_attachment() {
398
+
399
+ }
400
+
401
+ /**
402
+ * Check if BuddyPress and the activity component are enabled
403
+ *
404
+ * @return boolean
405
+ */
406
+ function activity_enabled() {
407
+
408
+ if( !function_exists( 'bp_is_active' ) || !bp_is_active( 'activity' ) ) {
409
+ return false;
410
+ }
411
+
412
+ global $rtmedia;
413
+
414
+ return $rtmedia->options[ 'buddypress_enableOnActivity' ];
415
+ }
416
+
417
+ /**
418
+ *
419
+ * @param type $uploaded
420
+ * @param type $file_object
421
+ *
422
+ * @return type
423
+ */
424
+ function generate_post_array( $uploaded, $file_object ) {
425
+ if( $uploaded[ 'album_id' ] ) {
426
+ $model = new RTMediaModel();
427
+ $parent_details = $model->get( array( 'id' => $uploaded[ 'album_id' ] ) );
428
+ if( is_array( $parent_details ) && sizeof( $parent_details ) > 0 ) {
429
+ $album_id = $parent_details[ 0 ]->media_id;
430
+ } else {
431
+ $album_id = 0;
432
+ }
433
+ } else {
434
+ $album_id = 0;
435
+ }
436
+
437
+ if( !in_array( $uploaded[ "context" ], array( "profile", "group" ) ) ) {
438
+ $album_id = $uploaded[ "context_id" ];
439
+ }
440
+
441
+ $attachments = array();
442
+
443
+ foreach( $file_object as $index => $file ) {
444
+ $uploaded[ 'title' ] = wp_kses( $uploaded[ 'title' ], wp_kses_allowed_html() );
445
+ $uploaded[ 'description' ] = sanitize_text_field( $uploaded[ 'description' ] );
446
+ $attachments[ $index ] = array(
447
+ 'post_mime_type' => $file[ 'type' ],
448
+ 'guid' => $file[ 'url' ],
449
+ 'post_title' => $uploaded[ 'title' ] ? $uploaded[ 'title' ] : preg_replace( "/\\.[^.\\s]{3,4}$/", "", $file[ 'name' ] ),
450
+ 'post_content' => $uploaded[ 'description' ] ? $uploaded[ 'description' ] : '',
451
+ 'post_parent' => $album_id,
452
+ 'post_author' => $uploaded[ 'media_author' ]
453
+ );
454
+
455
+ if( !empty( $uploaded[ 'date' ] ) ) {
456
+ $attachments[ $index ][ 'post_date' ] = $uploaded[ 'date' ];
457
+ }
458
+ }
459
+
460
+ return $attachments;
461
+ }
462
+
463
+ /**
464
+ *
465
+ * @param type $attachments
466
+ * @param type $file_object
467
+ *
468
+ * @return array $updated_attachment_ids
469
+ * @throws Exception
470
+ */
471
+ function insert_attachment( $attachments, $file_object ) {
472
+ $updated_attachment_ids = array();
473
+ foreach( $attachments as $key => $attachment ) {
474
+ $attachment_id = wp_insert_attachment( $attachment, $file_object[ $key ][ 'file' ], $attachment[ 'post_parent' ] );
475
+ if( !is_wp_error( $attachment_id ) ) {
476
+ add_filter( 'intermediate_image_sizes', array( $this, 'image_sizes' ), 99 );
477
+ /**
478
+ * FIX WORDPRESS 3.6 METADATA
479
+ */
480
+ require_once( ABSPATH . 'wp-admin/includes/media.php' );
481
+ /**
482
+ *
483
+ */
484
+ wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file_object[ $key ][ 'file' ] ) );
485
+ } else {
486
+ unlink( $file_object[ $key ][ 'file' ] );
487
+ throw new Exception( __( 'Error creating attachment for the media file, please try again', 'buddypress-media' ) );
488
+ }
489
+ $updated_attachment_ids[] = $attachment_id;
490
+ }
491
+
492
+ return $updated_attachment_ids;
493
+ }
494
+
495
+ /**
496
+ *
497
+ * @param type $sizes
498
+ *
499
+ * @return type
500
+ */
501
+ function image_sizes( $sizes ) {
502
+ return array( 'rt_media_thumbnail', 'rt_media_activity_image', 'rt_media_single_image', 'rt_media_featured_image' );
503
+ }
504
+
505
+ /**
506
+ *
507
+ * @param type $attributes
508
+ */
509
+ function insert_album( $attributes ) {
510
+
511
+ return $this->model->insert( $attributes );
512
+ }
513
+
514
+ function set_media_type( $mime_type, $file_object ) {
515
+ switch( $mime_type ) {
516
+ case 'image':
517
+ return 'photo';
518
+ break;
519
+ case 'audio':
520
+ return 'music';
521
+ break;
522
+ case 'video':
523
+ return 'video';
524
+ break;
525
+ default:
526
+ return apply_filters( 'rtmedia_set_media_type_filter', $mime_type, $file_object );
527
+ break;
528
+ }
529
+ }
530
+
531
+ /**
532
+ *
533
+ * @param array $attachment_ids
534
+ * @param array $uploaded
535
+ */
536
+ function insertmedia( $attachment_ids, $uploaded, $file_object /* added for file extension */ ) {
537
+
538
+ $defaults = array(
539
+ 'activity_id' => $this->activity_enabled(),
540
+ 'privacy' => 0
541
+ );
542
+
543
+ $uploaded = wp_parse_args( $uploaded, $defaults );
544
+
545
+ $blog_id = get_current_blog_id();
546
+ $media_id = Array();
547
+ foreach( $attachment_ids as $id ) {
548
+ $attachment = get_post( $id, ARRAY_A );
549
+ $mime_type = explode( '/', $attachment[ 'post_mime_type' ] );
550
+
551
+ $media = array(
552
+ 'blog_id' => $blog_id,
553
+ 'media_id' => $id,
554
+ 'album_id' => $uploaded[ 'album_id' ],
555
+ 'media_author' => $attachment[ 'post_author' ],
556
+ 'media_title' => $attachment[ 'post_title' ],
557
+ 'media_type' => $this->set_media_type( $mime_type[ 0 ], $file_object /* added for file extension */ ),
558
+ 'context' => $uploaded[ 'context' ],
559
+ 'context_id' => $uploaded[ 'context_id' ],
560
+ 'privacy' => $uploaded[ 'privacy' ]
561
+ );
562
+ if( isset( $file_object ) && isset( $file_object[ 0 ] ) && isset( $file_object[ 0 ][ 'file' ] ) ) {
563
+ $media[ 'file_size' ] = ( isset( $file_object[ 0 ][ 'file_size' ] ) ) ? $file_object[ 0 ][ 'file_size' ] : filesize( $file_object[ 0 ][ 'file' ] );
564
+ }
565
+ $media[ 'upload_date' ] = $attachment[ 'post_date' ];
566
+ $media_id[] = $this->model->insert( $media );
567
+ }
568
+
569
+ return $media_id;
570
+ }
571
+
572
+ function insert_activity( $id, $media ) {
573
+ if( !$this->activity_enabled() ) {
574
+ return false;
575
+ }
576
+ $activity = new RTMediaActivity( $media->id, $media->privacy );
577
+ $activity_content = $activity->create_activity_html();
578
+ $user = get_userdata( $media->media_author );
579
+ $username = '<a href="' . get_rtmedia_user_link( $media->media_author ) . '">' . $user->user_nicename . '</a>';
580
+ $count = count( $id );
581
+ $media_const = 'RTMEDIA_' . strtoupper( $media->media_type );
582
+ if( $count > 1 ) {
583
+ $media_const .= '_PLURAL';
584
+ }
585
+ $media_const .= '_LABEL';
586
+
587
+ $media_str = constant( $media_const );
588
+
589
+ $action = sprintf( ( $count == 1 ) ? __( '%1$s added a %2$s', 'buddypress-media' ) : __( '%1$s added %4$d %3$s', 'buddypress-media' ), $username, $media->media_type, $media_str, $count );
590
+ $action = apply_filters( 'rtmedia_buddypress_action_text_fitler', $action, $username, $count, $user->user_nicename, $media->media_type );
591
+ $activity_args = array(
592
+ 'user_id' => $user->ID,
593
+ 'action' => $action,
594
+ 'content' => $activity_content,
595
+ 'type' => 'rtmedia_update',
596
+ 'primary_link' => '',
597
+ 'item_id' => $id
598
+ );
599
+
600
+ if( $media->context == "group" && function_exists( "bp_get_group_status" ) && bp_get_group_status( groups_get_group( array( "group_id" => $media->context_id ) ) ) != "public" ) {
601
+ $activity_args[ "hide_sitewide" ] = true;
602
+ }
603
+
604
+ if( $media->context == 'group' || 'profile' ) {
605
+ $activity_args[ 'component' ] = $media->context;
606
+ if( $media->context == 'group' ) {
607
+ $activity_args[ 'component' ] = "groups";
608
+ $activity_args[ 'item_id' ] = $media->context_id;
609
+ }
610
+ }
611
+
612
+ $activity_id = bp_activity_add( $activity_args );
613
+ bp_activity_update_meta( $activity_id, 'rtmedia_privacy', ( $media->privacy == 0 ) ? - 1 : $media->privacy );
614
+
615
+ $this->model->update( array( 'activity_id' => $activity_id ), array( 'id' => $media->id ) );
616
+
617
+ // insert/update activity details in rtmedia activity table
618
+ $rtmedia_activity_model = new RTMediaActivityModel();
619
+ if( !$rtmedia_activity_model->check( $activity_id ) ) {
620
+ $rtmedia_activity_model->insert( array( 'activity_id' => $activity_id, 'user_id' => $media->media_author, 'privacy' => $media->privacy ) );
621
+ } else {
622
+ $rtmedia_activity_model->update( array( 'activity_id' => $activity_id, 'user_id' => $media->media_author, 'privacy' => $media->privacy ), array( 'activity_id' => $activity_id ) );
623
+ }
624
+
625
+ return $activity_id;
626
+ }
627
+
628
  }
app/main/controllers/template/RTMediaTemplate.php CHANGED
@@ -478,9 +478,9 @@ class RTMediaTemplate {
478
 
479
  if ( strpos( $_SERVER[ "HTTP_REFERER" ], "/" . $rtmedia_query->media[ 0 ]->id ) > 0 ) {
480
  if ( $context == 'profile' && isset( $rtmedia_query->media[ 0 ]->album_id ) && intval( $rtmedia_query->media[ 0 ]->album_id ) > 0 ) {
481
- $redirect_url = trailingslashit( $parent_link ) . "media/" . $rtmedia_query->media[ 0 ]->album_id;
482
  } else {
483
- $redirect_url = trailingslashit( $parent_link ) . "media/";
484
  }
485
  }
486
 
478
 
479
  if ( strpos( $_SERVER[ "HTTP_REFERER" ], "/" . $rtmedia_query->media[ 0 ]->id ) > 0 ) {
480
  if ( $context == 'profile' && isset( $rtmedia_query->media[ 0 ]->album_id ) && intval( $rtmedia_query->media[ 0 ]->album_id ) > 0 ) {
481
+ $redirect_url = trailingslashit( $parent_link ) . RTMEDIA_MEDIA_SLUG . '/' . $rtmedia_query->media[ 0 ]->album_id;
482
  } else {
483
+ $redirect_url = trailingslashit( $parent_link ) . RTMEDIA_MEDIA_SLUG . '/';
484
  }
485
  }
486
 
app/main/routers/query/RTMediaQuery.php CHANGED
@@ -923,7 +923,7 @@ class RTMediaQuery {
923
  $parent_link = get_author_posts_url( $rtmedia_media->media_author );
924
  }
925
 
926
- $link = trailingslashit( $parent_link . 'media/' . $rtmedia_media->id );
927
 
928
  return $link;
929
  }
923
  $parent_link = get_author_posts_url( $rtmedia_media->media_author );
924
  }
925
 
926
+ $link = trailingslashit( $parent_link . RTMEDIA_MEDIA_SLUG . $rtmedia_media->id );
927
 
928
  return $link;
929
  }
index.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: rtMedia for WordPress, BuddyPress and bbPress
5
  Plugin URI: http://rtcamp.com/rtmedia/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
6
  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!
7
- Version: 3.9.3
8
  Author: rtCamp
9
  Text Domain: buddypress-media
10
  Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
4
  Plugin Name: rtMedia for WordPress, BuddyPress and bbPress
5
  Plugin URI: http://rtcamp.com/rtmedia/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
6
  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!
7
+ Version: 3.9.4
8
  Author: rtCamp
9
  Text Domain: buddypress-media
10
  Author URI: http://rtcamp.com/?utm_source=dashboard&utm_medium=plugin&utm_campaign=buddypress-media
languages/buddypress-media.po CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the rtMedia for WordPress, BuddyPress and bbPress package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: rtMedia for WordPress, BuddyPress and bbPress 3.9\n"
6
  "Report-Msgid-Bugs-To: http://community.rtcamp.com/c/rtmedia/\n"
7
- "POT-Creation-Date: 2015-11-03 06:34:43+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
2
  # This file is distributed under the same license as the rtMedia for WordPress, BuddyPress and bbPress package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: rtMedia for WordPress, BuddyPress and bbPress 3.9.3\n"
6
  "Report-Msgid-Bugs-To: http://community.rtcamp.com/c/rtmedia/\n"
7
+ "POT-Creation-Date: 2015-12-04 10:36:47+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
readme.txt CHANGED
@@ -5,8 +5,8 @@ Tags: BuddyPress, media, multimedia, album, audio, songs, music, video, photo, i
5
  License: GPLv2 or later
6
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  Requires at least: WordPress 3.6
8
- Tested up to: 4.3.1
9
- Stable tag: 3.9.3
10
 
11
  Add albums, photo, audio/video encoding, privacy, sharing, front-end uploads & more. All this works on mobile/tablets devices.
12
 
@@ -140,6 +140,10 @@ http://www.youtube.com/watch?v=dJrykKQGDcs
140
 
141
  == Changelog ==
142
 
 
 
 
 
143
  = 3.9.3 [Nov 19, 2015] =
144
  * Update rtMedia main template
145
  * Fix undefined function call error
@@ -1106,8 +1110,8 @@ http://www.youtube.com/watch?v=dJrykKQGDcs
1106
 
1107
  == Upgrade Notice ==
1108
 
1109
- = 3.9.3 =
1110
- Requires BuddyPress 1.7 or higher, if using BuddyPress. Update rtMedia main template.
1111
 
1112
  == Sponsors ==
1113
 
5
  License: GPLv2 or later
6
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  Requires at least: WordPress 3.6
8
+ Tested up to: 4.4
9
+ Stable tag: 3.9.4
10
 
11
  Add albums, photo, audio/video encoding, privacy, sharing, front-end uploads & more. All this works on mobile/tablets devices.
12
 
140
 
141
  == Changelog ==
142
 
143
+ = 3.9.4 [Dec 07, 2015] =
144
+ * Fixed media slug issue while deleting media
145
+ * Added new hook in album gallery template
146
+
147
  = 3.9.3 [Nov 19, 2015] =
148
  * Update rtMedia main template
149
  * Fix undefined function call error
1110
 
1111
  == Upgrade Notice ==
1112
 
1113
+ = 3.9.4 =
1114
+ Requires BuddyPress 1.7 or higher, if using BuddyPress. Fixed media slug issue while deleting media, added new hook in album gallery template.
1115
 
1116
  == Sponsors ==
1117
 
templates/media/album-gallery-item.php CHANGED
@@ -36,4 +36,5 @@ if ( isset( $_POST[ 'is_edit_allowed' ] ) ) {
36
  <?php } ?>
37
 
38
  </a>
 
39
  </li>
36
  <?php } ?>
37
 
38
  </a>
39
+ <?php do_action( 'rtmedia_after_album_gallery_item' ) ?>
40
  </li>