diff --git a/README.md b/README.md index 83d8dbe..fed3508 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # BP Reshare +![Personal stream](https://c1.staticflickr.com/5/4305/35212895163_f459cb68c6_o.png) + This is a **BuddyPress** plugin extending the Activity component with a reshare feature. Members will be able to promote the activity updates they found interesting by **re**-sharing them into their personal activity stream. ![Users list](https://c1.staticflickr.com/5/4318/35177996884_6fe6dc2114_o.png) @@ -53,7 +55,7 @@ WordPress **4.8+** and BuddyPress **2.8+** ## Installation & Updates -![Installation & Updates](https://c1.staticflickr.com/5/4296/35177996804_b226ee8266_o.png) +![Installation & Updates](https://c1.staticflickr.com/5/4292/35184370524_015ba027d0_o.png) BP Reshare is registered into the [EntrepĂ´t](https://github.com/imath/entrepot/releases). If you use this alternative source of free and open source WordPress plugins, installing or updating BP Reshare is automatic. diff --git a/bp-reshare.php b/bp-reshare.php index 5b7c206..ebf92b5 100755 --- a/bp-reshare.php +++ b/bp-reshare.php @@ -136,10 +136,10 @@ private function includes() { if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { require( $this->includes_dir . 'deprecated.php' ); } - } - if ( is_admin() ) { - require( $this->includes_dir . 'settings.php' ); + if ( is_admin() ) { + require( $this->includes_dir . 'settings.php' ); + } } } diff --git a/js/notifications.min.js b/js/notifications.min.js index 17c98f6..c869689 100644 --- a/js/notifications.min.js +++ b/js/notifications.min.js @@ -1,2 +1,2 @@ -/*! bp-reshare - v2.0.0-beta1 - 2017-07-19 5:39:44 AM UTC - https://imathi.eu/tag/reshare */ +/*! bp-reshare - v2.0.0-beta1 - 2017-07-19 12:29:53 PM UTC - https://imathi.eu/tag/reshare */ window.bpReshare=window.bpReshare||{},function(a,b){"undefined"!=typeof a.userNotifications&&(a.Notifications={start:function(){if(a.userNotifications.items&&0

'+c+"

",b.insertBefore(e,b.childNodes[0])),window.setTimeout(function(){b.childNodes[0].remove()},4e3))}})}(window.bpReshare); \ No newline at end of file diff --git a/js/script.min.js b/js/script.min.js index 53251e4..0884e03 100644 --- a/js/script.min.js +++ b/js/script.min.js @@ -1,2 +1,2 @@ -/*! bp-reshare - v2.0.0-beta1 - 2017-07-19 5:39:44 AM UTC - https://imathi.eu/tag/reshare */ +/*! bp-reshare - v2.0.0-beta1 - 2017-07-19 12:29:53 PM UTC - https://imathi.eu/tag/reshare */ window.bpReshare=window.bpReshare||{},function(a,b){"undefined"!=typeof a.templates&&(a.activities=[],a.disabledActivities={},a.getURLparams=function(a,b){var c;if(c=a?-1!==a.indexOf("?")?"?"+a.split("?")[1]:"":document.location.search,!c)return null;var d=c.replace(/(^\?)/,"").split("&").map(function(a){return a=a.split("="),this[a[0]]=a[1],this}.bind({}))[0];return b?d[b]:d},a.isTypeDisabled=function(c,d,e){if(!c)return!0;var f=!1;if(d)f=a.params.disabled_types&&-1!==b.inArray(d,a.params.disabled_types);else if("undefined"==typeof a.disabledActivities[c]){var g=b("#activity-"+c).prop("class");!g&&e&&(g=b(e).prop("class")),g=g.split(" "),a.params.disabled_types&&(b.each(a.params.disabled_types,function(a,c){-1!==b.inArray(c,g)&&(f=!0)}),a.disabledActivities[c]=f)}else f=a.disabledActivities[c];return f},a.IndexOf=function(a,c){var d=-1;return c=c||[],a&&b.isArray(c)?(b.each(c,function(b,c){a===c.id&&(d=b)}),d):d},a.getTimeSince=function(c){var d,e,f,g,h,i,j=new Date(b.now()),k=[],l=b.extend({},a.params.time_since.time_chunks);if(void 0===c)return" "+a.params.time_since.sometime;if(c=new Date(1e3*c),d=j-c,1e3>d)return" "+a.params.time_since.now;b.each(l,function(a,b){var c=1e3*b,g=Math.floor(d/c);0===g||f||(f=a,e=g,i=c)}),f=f.substr(2),k.push(1===e?a.params.time_since[f].replace("%",e):a.params.time_since[f+"s"].replace("%",e)),delete l.a_year,b.each(l,function(a,b){var c=1e3*b,f=Math.floor((d-i*e)/c);0===f||h||(h=a,g=f)}),void 0!==h&&(h=h.substr(2),k.push(1===g?a.params.time_since[h].replace("%",g):a.params.time_since[h+"s"].replace("%",g)));var m=a.params.time_since.sometime;return k.length>=1&&(m=a.params.time_since.ago.replace("%",k.shift()))," "+m},a.refreshActivity=function(c){if(!c)return!1;var d,e,f={link:"addLink",text:"addReshare"},g={},h=".activity-header a.activity-time-since";if(c.id)g=c;else{c=parseInt(c,10);var i=a.IndexOf(c,a.activities);if(-1===i)return!1;g=a.activities[i]}return!(!b("#activity-"+g.id).length||!0!==g.isChecked)&&(e=b("#activity-"+g.id),!e.find(".reshare-time-since").length&&g.time&&(e.prop("class",e.prop("class").replace(/date-recorded-([0-9]+)/,"date-recorded-"+g.time)),e.find(h).length||(h=".activity-header span.time-since"),e.find(h).after(b("").addClass("reshare-time-since").html(a.getTimeSince(g.time)))),d=e.find(".bp-reshare").first(),d.find("span.count").first().html(g.users.length),-1!==b.inArray(a.params.u.toString(),g.users)&&(f={link:"removeLink",text:"removeReshare"}),d.prop("href",a.strings[f.link].replace("%i",g.id)).removeClass("add-reshare remove-reshare").addClass("removeLink"===f.link?"remove-reshare":"add-reshare"),d.find(".bp-screen-reader-text").html(a.strings[f.text]),!0)},a.get=function(){if(!b(".bp-reshare").length)return!1;var c=[];return b.each(a.activities,function(b,d){if(!0===a.activities[b].isChecked)a.refreshActivity(d);else{if(a.isTypeDisabled(d.id))return;c.push(d.id),a.activities[b].isChecked=!0}}),c.length&&a.Ajax.get("all",{activities:c.join(",")},function(c,d){if(200===c){if(!b.isArray(d)||!d.length)return;b.each(d,function(b,c){var d=parseInt(c.id,10),e=a.IndexOf(d,a.activities);-1!==e&&(a.activities[e].users=c.users,a.activities[e].time=c.time,a.refreshActivity(d))})}}),!0},a.Scan=function(c){return!!c&&(b.each(b(c).children(),function(c,d){var e=parseInt(b(d).prop("id").replace("activity-",""),10);e&&!a.isTypeDisabled(e,null,d)&&-1===a.IndexOf(e,a.activities)&&a.activities.push({id:e,users:[],markUp:!1,isChecked:!1})}),!0)},a.setMarkup=function(){return!!a.activities.length&&(b.each(a.activities,function(c,d){var e=b("#activity-"+d.id),f=b(e).find(".activity-header a").first().prop("href");if(e.length&&!b(e).find("a.bp-reshare").length&&!a.isTypeDisabled(d.id)){if(!1===d.markUp){var g=b.trim(f.replace(a.params.root_members,""),"/").split("/")[0],h="add-reshare";g===a.params.u_nicename&&(h="disabled"),a.activities[c].markUp=a.templates.reshareButton.replace("%l",a.strings.addLink.replace("%i",d.id)).replace("%r",h).replace("%a",d.id).replace("%u",g).replace("%t",a.strings.addReshare).replace("%c",0)}if(b(e).find(".activity-meta a").first().after(a.activities[c].markUp),a.displayedUser){var i=b(e).find(".activity-avatar"),j=b(a.displayedUser.avatar).prop("src");j.split("?")[0]===i.find("img").prop("src").split("?")[0]||b(e).find(".activity-reshared-by").length||b(i).before(b("
").addClass("activity-reshared-by").html(a.displayedUser.resharedText.replace("%s",a.displayedUser.avatar)))}}}),!0)},a.isResharesScope=function(){return"reshares"===decodeURIComponent(document.cookie).split(";").map(function(a){var c=a.split("=");if("bp-activity-scope"===b.trim(c[0]))return b.trim(c[1])}).filter(function(a){if(a)return a}).shift()},a.activityTab=function(c,d){a.params.u_count=parseInt(a.params.u_count,10),(a.params.u_count||c)&&(c?"-1"===c?a.params.u_count-=1:a.params.u_count+=parseInt(c,10):c=a.params.u_count,b("body.directory #activity-reshares").length?b("body.directory #activity-reshares").find("span").first().html(a.params.u_count):b("body.directory .activity-type-tabs ul li").first().after(b(a.templates.directoryTab.replace("%c",a.params.u_count)).addClass(!0===d?"selected":"")))},a.Button=function(b,c){c||(c="#activity-stream"),!0===a.Scan(c)&&("populate"===b?(a.setMarkup(),a.get()):window.setTimeout(function(){a.setMarkup(),a.get()},500))},b(document).ready(function(){a.Button("populate"),a.activityTab(null,a.isResharesScope())}),b(document).ajaxSuccess(function(c,d,e){var f,g=decodeURIComponent(e.data),h=a.getURLparams("?"+g,"action"),i=e.url&&-1!==e.url.indexOf(a.params.root_url);i||-1===b.inArray(h,["activity_get_older_updates","activity_widget_filter","post_update"])||("post_update"===h?f=b("").html(d.responseText):(f=b(d.responseJSON.contents)[0],"LI"===f.nodeName&&(f=b("").html(b.map(b(d.responseJSON.contents),function(a){return b(a).prop("outerHTML")}).join(" "))),"activity_widget_filter"===h&&(a.activities=[])),a.Button("refresh",f))}),b("body.activity #buddypress").on("click",".load-newest a",function(c){var d=b(c.currentTarget).closest("ul"),e=b(c.currentTarget).parent();window.setTimeout(function(){var c=b("").html(b.map(b(d.find(".just-posted")),function(a){return b(a).prop("outerHTML")}).join(" "));a.Button("populate",c),e.length&&e.remove()},500)}),a.add=function(c){var d=c.currentTarget,e=b(d).data("activity-id"),f=b(d).data("author-name"),g=b(d).find("span.count").first(),h=".activity-header a.activity-time-since";c.preventDefault(),f!==a.params.u_nicename&&(b(d).hasClass("add-reshare")?a.Ajax.post(e,{user_id:a.params.u,author_slug:f},function(c,f){if(200===c&&f.reshared)b(d).closest(".activity-content").find(".reshare-time-since").remove(),b("#activity-"+e).find(h).length||(h=".activity-header span.time-since"),b(d).removeClass("add-reshare").addClass("remove-reshare").prop("href",a.strings.removeLink.replace("%i",e)).closest(".activity-content").find(h).after(b("").addClass("reshare-time-since").html(a.getTimeSince(f.reshared))),b(g).html(parseInt(b(g).html(),10)+1),a.activityTab(1);else{var i=a.strings.genericError;f.message&&(i=f.message),a.Ajax.feedback(b(d).closest(".activity-meta").get(0),i,"error")}}):b(d).hasClass("remove-reshare")&&a.Ajax.remove(e,{user_id:a.params.u,author_slug:f},function(c,f){if(200===c)b(d).removeClass("remove-reshare").addClass("add-reshare").prop("href",a.strings.addLink.replace("%i",e)).closest(".activity-content").find(".reshare-time-since").remove(),b(g).html(parseInt(b(g).html(),10)-1),a.activityTab("-1"),(a.isResharesScope()||a.displayedUser&&a.params.u===a.displayedUser.userID)&&b("#activity-"+e).remove();else{var h=a.strings.genericError;f.message&&(h=f.message),a.Ajax.feedback(b(d).closest(".activity-meta").get(0),h,"error")}}))},b("#buddypress").on("click",".bp-reshare",a.add),b("#buddypress").on("change.livestamp",".time-since",function(c){var d,e,f=b(c.currentTarget).parents("li").first(),g=f.find(".bp-reshare").first();b(g).length&&(d=parseInt(b(g).data("activity-id"),10),e=a.IndexOf(d,a.activities),-1!==e&&b(f).find(".reshare-time-since").html(a.getTimeSince(a.activities[e].time)))}))}(window.bpReshare,jQuery); \ No newline at end of file diff --git a/js/single-activity.min.js b/js/single-activity.min.js index 6b11270..cc2a56a 100644 --- a/js/single-activity.min.js +++ b/js/single-activity.min.js @@ -1,2 +1,2 @@ -/*! bp-reshare - v2.0.0-beta1 - 2017-07-19 5:39:44 AM UTC - https://imathi.eu/tag/reshare */ +/*! bp-reshare - v2.0.0-beta1 - 2017-07-19 12:29:53 PM UTC - https://imathi.eu/tag/reshare */ window.bpReshare=window.bpReshare||{},function(a,b){"undefined"!=typeof a.activity&&(a.outputNoItem=function(c,d,e){if(!b(c).find("#message").length){var f="info";e?f+=" keep":e=a.activity.nav[d].no_item,"comments"!==d&&b(c).html(""),b(c).prepend(b("
").prop("id","message").addClass(f).html("

"+e+"

"))}},a.getLoading=function(c){b(c).html(b("
").css({background:"url( "+a.activity.loader+" ) no-repeat",width:"100%",height:"40px","background-position":"50% 50%"}))},a.getUsers=function(c,d,e){e||(e=1),1===e&&a.getLoading(c);var f={type:d,include:a.activity.nav[d].users.join(","),page:e};a.Ajax.get(a.activity.id,f,function(f,g){if(200===f&&g.users)a.activity.nav[d].usersDetail=g.users,g.has_more&&(a.activity.nav[d].nextPage=e+1,g.users.loadmore='
  • Load More
  • '),1!==e&&b("#"+d+"-users").length?b(c).find(".loading").length&&b(c).find(".loading").remove():b(c).html(b("").prop({id:d+"-users",class:"item-list","aria-live":"assertive","aria-relevant":"all"})),b.each(g.users,function(a,c){b("#"+d+"-users").append(c)});else{var h=a.strings.genericError;g.message&&(h=g.message),b(c).find("div").first().css({background:"none"}),a.Ajax.feedback(b(c).get(0),h,"error")}})},a.activityNav=function(){var c=0,d=[];b.each(a.activity.nav,function(e,f){var g;f.count=0,c===f.position&&("comments"===e?f.count=parseInt(b("#acomment-comment-"+a.activity.id+" span").html(),10):f.count=f.users.length,g=1>=f.count?f.singular:f.plural,d.push(b("").html(g).prop({id:"display-"+e,href:"#display-"+e}).get(0).outerHTML)),c++}),b("#activity-"+a.activity.id+" .activity-comments").before(b("").html("
  • "+d.join("
  • ")+"
  • ").prop("id","buddyreshare-activity-nav")).addClass("buddyreshare-nav-content"),b("#display-comments").parent().addClass("selected"),0===a.activity.nav.comments.count?a.outputNoItem("#activity-"+a.activity.id+" .activity-comments","comments"):b("#activity-"+a.activity.id+" .activity-comments").get(0).children.length||a.outputNoItem("#activity-"+a.activity.id+" .activity-comments","comments",a.activity.nav.comments.no_comments),a.activity.nav.favorites&&a.activity.nav.favorites.count&&b("#activity-"+a.activity.id+" .activity-meta").find(".fav, .unfav").prepend(" ").prepend(b("").addClass("count").html(a.activity.nav.favorites.count))},b("#buddypress").on("click","#buddyreshare-activity-nav li a",function(c){var d=b(c.currentTarget),e=d.prop("id").replace("display","activity"),f=d.prop("id").replace("display-","");c.preventDefault(),b.each(b("#buddyreshare-activity-nav li a"),function(a,c){b(c).parent().removeClass("selected"),b(c).prop("id")===d.prop("id")&&b(c).parent().addClass("selected")}),b("#activity-"+a.activity.id+" ."+e).length||b("#activity-"+a.activity.id).append(b("
    ").addClass(e+" buddyreshare-nav-content")),b.each(b(".buddyreshare-nav-content"),function(c,d){b(d).hasClass(e)?(b(d).show(),0===a.activity.nav[f].count?a.outputNoItem(d,f):(b(d).find("#message").hasClass("keep")||b(d).find("#message").remove(),b(d).hasClass("activity-comments")||a.getUsers(d,f))):b(d).hide()})}),b("#buddypress").on("click",".buddyreshare-nav-content .load-more-users a",function(c){c.preventDefault();var d=b(c.currentTarget).data("next-page"),e=b(c.currentTarget).closest(".buddyreshare-nav-content"),f=b(e).prop("class").split(" ")[0].replace("activity-","");b(c.currentTarget).parent().addClass("loading").html(a.getLoading(b(this))),a.getUsers(e,f,d)}),a.refreshCounts=function(c,d,e){var f=0;return"comments"!==c?("-1"===e?a.activity.nav[c].users.splice(a.activity.nav[c].users.indexOf(d.toString()),1):1===e&&a.activity.nav[c].users.push(d.toString()),f=a.activity.nav[c].users.length,b("#display-comments").trigger("click")):(f=e,b(".activity-comments").find("#message.info").remove()),f<=1?b("#display-"+c).html(a.activity.nav[c].singular):b("#display-"+c).html(a.activity.nav[c].plural),f},b("#buddypress .activity-meta").on("click","a",function(c){if(!a.isTypeDisabled(a.activity.id)){var d=0;b(c.currentTarget).hasClass("acomment-reply")?b("#display-comments").trigger("click"):b(c.currentTarget).hasClass("bp-reshare")&&(b(c.currentTarget).hasClass("add-reshare")?d=1:b(c.currentTarget).hasClass("remove-reshare")&&(d="-1"),a.activity.nav.reshares.count=a.refreshCounts("reshares",a.params.u,d))}}),b(document).ajaxSuccess(function(c,d,e){if(!a.isTypeDisabled(a.activity.id)){var f=decodeURIComponent(e.data),g=1,h=a.getURLparams("?"+f,"action");"activity_mark_fav"===h||"activity_mark_unfav"===h?("activity_mark_unfav"===h&&(g="-1"),a.activity.nav.favorites.count=a.refreshCounts("favorites",a.params.u,g),window.setTimeout(function(){b("#activity-"+a.activity.id+" .activity-meta").find(".fav, .unfav").html(b("").addClass("count").html(a.activity.nav.favorites.count).get(0).outerHTML+" "+d.responseText)},500)):"delete_activity_comment"!==h&&"new_activity_comment"!==h||("delete_activity_comment"===h?a.activity.nav.comments.count-=1:a.activity.nav.comments.count+=1,a.refreshCounts("comments",!1,a.activity.nav.comments.count))}}),b(document).ready(function(){a.isTypeDisabled(a.activity.id)||a.activityNav()}))}(window.bpReshare,jQuery); \ No newline at end of file diff --git a/languages/bp-reshare.pot b/languages/bp-reshare.pot index ebb2393..c03a02d 100644 --- a/languages/bp-reshare.pot +++ b/languages/bp-reshare.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: BP Reshare 2.0.0-beta1\n" "Report-Msgid-Bugs-To: https://github.com/imath/bp-reshare/issues\n" -"POT-Creation-Date: 2017-07-19 05:39:43+00:00\n" +"POT-Creation-Date: 2017-07-19 12:29:52+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n"