Ultimate Tag Cloud Widget - Version 2.4-beta1

Version Description

= 2.4 =

  • New features, see plugin page at wordpress.org for full details.

= 2.3.1 =

  • Security fix for sensitive data exposed when using the debug option

= 2.3 =

  • New features, see plugin page at wordpress.org for full details. Watch out for the changes in class names: https://github.com/rickard2/utcw/issues/29

= 2.2.3 =

  • Fixed naming collision issue with other plugins

= 2.2.2 =

  • Fixed widget initialization issue

= 2.2.1 =

  • Fixes compatibility issue with PHP 5.2

= 2.2 =

  • New features, see the plugin page at wordpress.org for full details

= 2.1 =

  • New features, see the plugin page at wordpress.org for full details

= 2.0.1 =

  • Small bug fix in the widget options panel

= 2.0 =

  • New plugin architecture and a big rewrite of the plugin foundation. Watch out for breaking changes, please see http://exz.nu/utcwbreaking for more information.
Download this release

Release Info

Developer exz
Plugin Icon wp plugin Ultimate Tag Cloud Widget
Version 2.4-beta1
Comparing to
See all releases

Code changes from version 2.3.1 to 2.4-beta1

js/utcw.min.js CHANGED
@@ -1,22 +1 @@
1
- /* Wayfarer Tooltip
2
- * Version 1.0.9
3
- * Author Abel Mohler
4
- * URI: http://www.wayfarerweb.com/wtooltip.php
5
- * Released with the MIT License: http://www.wayfarerweb.com/mit.php
6
- */
7
- (function(a){a.fn.wTooltip=function(f,r){f=a.extend({content:null,ajax:null,follow:true,auto:true,fadeIn:0,fadeOut:0,appendTip:document.body,degrade:false,offsetY:10,offsetX:1,style:{},className:null,id:null,callBefore:function(t,p,o){},callAfter:function(t,p,o){},clickAction:function(p,o){a(p).hide()},delay:0,timeout:0},f||{});if(!f.style&&typeof f.style!="object"){f.style={};f.style.zIndex="1000"}else{f.style=a.extend({border:"1px solid gray",background:"#edeef0",color:"#000",padding:"10px",zIndex:"1000",textAlign:"left"},f.style||{})}if(typeof r=="function"){f.callAfter=r||f.callAfter}f.style.display="none",f.style.position="absolute";var m,l,q,c,k={},b=true,e=false,n=false,s=document.createElement("div"),g=(typeof document.body.style.maxWidth=="undefined")?true:false,j=(typeof a.talk=="function"&&typeof a.listen=="function")?true:false;if(f.id){s.id=f.id}if(f.className){s.className=f.className}f.degrade=(f.degrade&&g)?true:false;for(var d in f.style){s.style[d]=f.style[d]}function i(o){if(o){if(f.degrade){a(s).html(f.content.replace(/<\/?[^>]+>/gi,""))}else{a(s).html(f.content)}}}if(f.ajax){a.get(f.ajax,function(o){if(o){f.content=o}i(f.content)})}function h(p){function t(u){if(m&&!f.content){m=""}}function o(){if(!e&&f.auto){clearInterval(c);if(f.fadeOut){a(s).fadeOut(f.fadeOut,function(){t(p)})}else{t(p);s.style.display="none"}}if(typeof f.callAfter=="function"){f.callAfter(s,p,f)}if(j){f=a.listen(f)}}if(f.timeout>0){q=setTimeout(function(){o()},f.timeout)}else{o()}}a(s).hover(function(){e=true},function(){e=false;h(k)});if(j){f.key=s;f.plugin="wTooltip";f.channel="wayfarer";a.talk(f)}i(f.content&&!f.ajax);a(s).appendTo(f.appendTip);return this.each(function(){a(this).hover(function(){var p=this;clearTimeout(q);if((this.title||this.titleMemKeep)&&!f.degrade&&!f.content){m=this.title||this.titleMemKeep;if(this.title){this.titleMemKeep=this.title;this.title=""}}if(f.content&&f.degrade){this.title=s.innerHTML}function o(){if(typeof f.callBefore=="function"){f.callBefore(s,p,f)}if(j){f=a.listen(f)}var t;if(f.content){if(!f.degrade){t="block"}}else{if(m&&!f.degrade){a(s).html(unescape(m));t="block";m=""}else{t="none"}}if(f.auto){if(t=="block"&&f.fadeIn){a(s).fadeIn(f.fadeIn)}else{s.style.display=t}}}if(f.delay>0){l=setTimeout(function(){o()},f.delay)}else{o()}},function(){clearTimeout(l);var o=this;b=true;if(!f.follow||n||((f.offsetX<0&&(0-f.offsetX<a(s).outerWidth()))&&(f.offsetY>0&&0-f.offsetY<a(s).outerHeight()))){setTimeout(function(){c=setInterval(function(){h(o)},1)},1)}else{h(this)}});a(this).mousemove(function(v){k=this;if(f.follow||b){var y=a(window).scrollTop(),z=a(window).scrollLeft(),w=v.clientY+y+f.offsetY,t=v.clientX+z+f.offsetX,x=a(f.appendTip).outerHeight(),p=a(f.appendTip).innerHeight(),o=a(window).width()+z-a(s).outerWidth(),u=a(window).height()+y-a(s).outerHeight();w=(x>p)?w-(x-p):w;n=(w>u||t>o)?true:false;if(t-z<=0&&f.offsetX<0){t=z}else{if(t>o){t=o}}if(w-y<=0&&f.offsetY<0){w=y}else{if(w>u){w=u}}s.style.top=w+"px";s.style.left=t+"px";b=false}});if(typeof f.clickAction=="function"){a(this).click(function(){f.clickAction(s,this)})}})}})(jQuery);
8
-
9
- /*! jsUri v1.1.1 | https://github.com/derek-watson/jsUri */
10
- var Query=function(a){"use strict";var b=function(a){var b=[],c,d,e,f;if(typeof a=="undefined"||a===null||a==="")return b;a.indexOf("?")===0&&(a=a.substring(1)),d=a.toString().split(/[&;]/);for(c=0;c<d.length;c++)e=d[c],f=e.split("="),b.push([f[0],f[1]]);return b},c=b(a),d=function(){var a="",b,d;for(b=0;b<c.length;b++)d=c[b],a.length>0&&(a+="&"),a+=d.join("=");return a.length>0?"?"+a:a},e=function(a){a=decodeURIComponent(a),a=a.replace("+"," ");return a},f=function(a){var b,d;for(d=0;d<c.length;d++){b=c[d];if(e(a)===e(b[0]))return b[1]}},g=function(a){var b=[],d,f;for(d=0;d<c.length;d++)f=c[d],e(a)===e(f[0])&&b.push(f[1]);return b},h=function(a,b){var d=[],f,g,h,i;for(f=0;f<c.length;f++)g=c[f],h=e(g[0])===e(a),i=e(g[1])===e(b),(arguments.length===1&&!h||arguments.length===2&&!h&&!i)&&d.push(g);c=d;return this},i=function(a,b,d){arguments.length===3&&d!==-1?(d=Math.min(d,c.length),c.splice(d,0,[a,b])):arguments.length>0&&c.push([a,b]);return this},j=function(a,b,d){var f=-1,g,j;if(arguments.length===3){for(g=0;g<c.length;g++){j=c[g];if(e(j[0])===e(a)&&decodeURIComponent(j[1])===e(d)){f=g;break}}h(a,d).addParam(a,b,f)}else{for(g=0;g<c.length;g++){j=c[g];if(e(j[0])===e(a)){f=g;break}}h(a),i(a,b,f)}return this};return{getParamValue:f,getParamValues:g,deleteParam:h,addParam:i,replaceParam:j,toString:d}},Uri=function(a){"use strict";var b=!1,c=function(a){var c={strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/},d=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],e={name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},f=c[b?"strict":"loose"].exec(a),g={},h=14;while(h--)g[d[h]]=f[h]||"";g[e.name]={},g[d[12]].replace(e.parser,function(a,b,c){b&&(g[e.name][b]=c)});return g},d=c(a||""),e=new Query(d.query),f=function(a){typeof a!="undefined"&&(d.protocol=a);return d.protocol},g=null,h=function(a){typeof a!="undefined"&&(g=a);return g===null?d.source.indexOf("//")!==-1:g},i=function(a){typeof a!="undefined"&&(d.userInfo=a);return d.userInfo},j=function(a){typeof a!="undefined"&&(d.host=a);return d.host},k=function(a){typeof a!="undefined"&&(d.port=a);return d.port},l=function(a){typeof a!="undefined"&&(d.path=a);return d.path},m=function(a){typeof a!="undefined"&&(e=new Query(a));return e},n=function(a){typeof a!="undefined"&&(d.anchor=a);return d.anchor},o=function(a){f(a);return this},p=function(a){h(a);return this},q=function(a){i(a);return this},r=function(a){j(a);return this},s=function(a){k(a);return this},t=function(a){l(a);return this},u=function(a){m(a);return this},v=function(a){n(a);return this},w=function(a){return m().getParamValue(a)},x=function(a){return m().getParamValues(a)},y=function(a,b){arguments.length===2?m().deleteParam(a,b):m().deleteParam(a);return this},z=function(a,b,c){arguments.length===3?m().addParam(a,b,c):m().addParam(a,b);return this},A=function(a,b,c){arguments.length===3?m().replaceParam(a,b,c):m().replaceParam(a,b);return this},B=function(){var a="",b=function(a){return a!==null&&a!==""};b(f())?(a+=f(),f().indexOf(":")!==f().length-1&&(a+=":"),a+="//"):h()&&b(j())&&(a+="//"),b(i())&&b(j())&&(a+=i(),i().indexOf("@")!==i().length-1&&(a+="@")),b(j())&&(a+=j(),b(k())&&(a+=":"+k())),b(l())?a+=l():b(j())&&(b(m().toString())||b(n()))&&(a+="/"),b(m().toString())&&(m().toString().indexOf("?")!==0&&(a+="?"),a+=m().toString()),b(n())&&(n().indexOf("#")!==0&&(a+="#"),a+=n());return a},C=function(){return new Uri(B())};return{protocol:f,hasAuthorityPrefix:h,userInfo:i,host:j,port:k,path:l,query:m,anchor:n,setProtocol:o,setHasAuthorityPrefix:p,setUserInfo:q,setHost:r,setPort:s,setPath:t,setQuery:u,setAnchor:v,getQueryParamValue:w,getQueryParamValues:x,deleteQueryParam:y,addQueryParam:z,replaceQueryParam:A,toString:B,clone:C}},jsUri=Uri;
11
-
12
- /*! Ultimate Tag Cloud Widget - v2.3 - 2013-05-30
13
- * https://0x539.se/wordpress/ultimate-tag-cloud-widget/
14
- * Copyright (c) 2013 Rickard Andersson; Licensed GPLv2 */
15
- (function(b,k){var l={border:"solid 1px #6295fb",background:"#fff",color:"#000",padding:"5px",zIndex:1E3},c={activeTab:{},terms:{},init:function(){b("input[id$=-color_none], input[id$=-color_random], input[id$=-color_set], input[id$=-color_span]").live("click",this.colorClickHandler);b(".utcw-tab-button").live("click",this.tabClickHandler);b(".utcw-input-taxonomy").live("click",this.taxonomyClickHandler);b(".utcw-all-authors").live("click",this.allAuthorsClickHandler);b(".utcw-selected-authors").live("click",
16
- this.selectedAuthorsClickHandler);b(".utcw-remove-config").live("click",this.removeConfigClickHandler);b(".post-term-search").live("keyup",this.postTermSearchHandler).live("search",this.postTermSearchHandler);b(".utcw-remove-term").live("click",this.removeTermClickHandler);b(document).ready(this.initTooltip);b(document).ajaxSuccess(this.ajaxSuccessHandler);b.post(k,{action:"utcw_get_terms"},function(a){c.terms=a})},initTooltip:function(){b(".utcw-help").wTooltip({style:l,className:"utcw-tooltip"})},
17
- postTermSearchHandler:function(){var a=b(this),e=b(a.data("result-selector")),h=b(a.data("selected-selector")),f=a.val().toLocaleLowerCase(),d=[];e.text("");if(f){for(var g in c.terms)c.terms.hasOwnProperty(g)&&c.terms[g].forEach(function(a){-1!==a.name.toLocaleLowerCase().indexOf(f)&&d.push(a)});d.forEach(function(d){var f=b(document.createElement("li")),g=b(document.createElement("a"));g.text(d.name+" ("+d.taxonomy+")");g.data("id",d.term_id);g.click(c.postTermSearchClickHandler(h,a));f.append(g);
18
- e.append(f)})}},postTermSearchClickHandler:function(a,e){return function(){var c=b(this),f=b(document.createElement("li")),d=b(document.createElement("a")),g=b(document.createElement("span")),j=b(document.createElement("input")),k=c.parent().parent();f.text(c.text());j.attr("type","hidden");j.val(c.data("id"));j.attr("name",e.data("input-name")+"[]");d.addClass("submitdelete");d.addClass("deletion");d.addClass("utcw-remove-term");d.text(e.data("delete"));g.addClass("submitbox");g.append(d);f.append(g);
19
- f.append(j);a.append(f);k.text("");e.val("")}},removeTermClickHandler:function(){b(this).parent().parent().remove()},removeConfigClickHandler:function(){var a=b(this),e=c.findWidgetParent(a).find(".utcw-load-config"),h=e.val(),f=a.data("input-name")+"[]",d=b(document.createElement("input"));d.attr("type","hidden");d.attr("name",f);d.attr("value",h);a.after(d);e.find(":selected").remove()},allAuthorsClickHandler:function(){var a=b(this),a=c.findWidgetParent(a);a.find(".utcw-authors").addClass("hidden");
20
- a.find(".utcw-author-field").attr("checked",!1)},selectedAuthorsClickHandler:function(){var a=b(this);c.findWidgetParent(a).find(".utcw-authors").removeClass("hidden")},tabClickHandler:function(){var a=b(this);if("utcw-__i__"===a.data("id"))return!1;a.parent().find(".utcw-tab-button").removeClass("utcw-active");a.addClass("utcw-active");a.parent().find("fieldset.utcw").addClass("hidden");b("#"+a.data("tab")).removeClass("hidden");c.activeTab[a.data("id")]=a.data("tab");return!1},colorClickHandler:function(){var a=
21
- b('div[id$="set_chooser"]'),e=b('div[id$="span_chooser"]'),c=b(this).val();a.addClass("utcw-hidden");e.addClass("utcw-hidden");"set"===c?a.removeClass("utcw-hidden"):"span"===c&&e.removeClass("utcw-hidden")},findWidgetParent:function(a){return a.parents(".widget-content")},taxonomyClickHandler:function(){var a=b(this),e=a.val(),h=a.is(":checked"),a=c.findWidgetParent(a).find("#"+e+"-terms");h?a.removeClass("hidden"):a.addClass("hidden")},ajaxSuccessHandler:function(a,b,h){c.setCurrentTab.apply(c,
22
- [h.data]);c.initTooltip.apply(c)},setCurrentTab:function(a){var c=new Uri;c.setQuery(decodeURI(a));"save-widget"===c.getQueryParamValue("action")&&"utcw"===c.getQueryParamValue("id_base")&&(a=c.getQueryParamValue("widget-id"),this.activeTab[a]&&b('button[data-tab="'+this.activeTab[a]+'"]').trigger("click"))}};c.init()})(jQuery,ajaxurl);
1
+ /*! utcw - v2.4.0 - 2013-08-26*/var Query=function(a){"use strict";var b=function(a){var b,c,d,e,f=[];if("undefined"==typeof a||null===a||""===a)return f;for(0===a.indexOf("?")&&(a=a.substring(1)),c=a.toString().split(/[&;]/),b=0;b<c.length;b++)d=c[b],e=d.split("="),f.push([e[0],e[1]]);return f},c=b(a),d=function(){var a,b,d="";for(a=0;a<c.length;a++)b=c[a],d.length>0&&(d+="&"),d+=b.join("=");return d.length>0?"?"+d:d},e=function(a){return a=decodeURIComponent(a),a=a.replace("+"," ")},f=function(a){var b,d;for(d=0;d<c.length;d++)if(b=c[d],e(a)===e(b[0]))return b[1]},g=function(a){var b,d,f=[];for(b=0;b<c.length;b++)d=c[b],e(a)===e(d[0])&&f.push(d[1]);return f},h=function(a,b){var d,f,g,h,i=[];for(d=0;d<c.length;d++)f=c[d],g=e(f[0])===e(a),h=e(f[1])===e(b),(1===arguments.length&&!g||2===arguments.length&&!g&&!h)&&i.push(f);return c=i,this},i=function(a,b,d){return 3===arguments.length&&-1!==d?(d=Math.min(d,c.length),c.splice(d,0,[a,b])):arguments.length>0&&c.push([a,b]),this},j=function(a,b,d){var f,g,j=-1;if(3===arguments.length){for(f=0;f<c.length;f++)if(g=c[f],e(g[0])===e(a)&&decodeURIComponent(g[1])===e(d)){j=f;break}h(a,d).addParam(a,b,j)}else{for(f=0;f<c.length;f++)if(g=c[f],e(g[0])===e(a)){j=f;break}h(a),i(a,b,j)}return this};return{getParamValue:f,getParamValues:g,deleteParam:h,addParam:i,replaceParam:j,toString:d}},Uri=function(a){"use strict";var b=!1,c=function(a){for(var c={strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/},d=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],e={name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},f=c[b?"strict":"loose"].exec(a),g={},h=14;h--;)g[d[h]]=f[h]||"";return g[e.name]={},g[d[12]].replace(e.parser,function(a,b,c){b&&(g[e.name][b]=c)}),g},d=c(a||""),e=new Query(d.query),f=function(a){return"undefined"!=typeof a&&(d.protocol=a),d.protocol},g=null,h=function(a){return"undefined"!=typeof a&&(g=a),null===g?-1!==d.source.indexOf("//"):g},i=function(a){return"undefined"!=typeof a&&(d.userInfo=a),d.userInfo},j=function(a){return"undefined"!=typeof a&&(d.host=a),d.host},k=function(a){return"undefined"!=typeof a&&(d.port=a),d.port},l=function(a){return"undefined"!=typeof a&&(d.path=a),d.path},m=function(a){return"undefined"!=typeof a&&(e=new Query(a)),e},n=function(a){return"undefined"!=typeof a&&(d.anchor=a),d.anchor},o=function(a){return f(a),this},p=function(a){return h(a),this},q=function(a){return i(a),this},r=function(a){return j(a),this},s=function(a){return k(a),this},t=function(a){return l(a),this},u=function(a){return m(a),this},v=function(a){return n(a),this},w=function(a){return m().getParamValue(a)},x=function(a){return m().getParamValues(a)},y=function(a,b){return 2===arguments.length?m().deleteParam(a,b):m().deleteParam(a),this},z=function(a,b,c){return 3===arguments.length?m().addParam(a,b,c):m().addParam(a,b),this},A=function(a,b,c){return 3===arguments.length?m().replaceParam(a,b,c):m().replaceParam(a,b),this},B=function(){var a="",b=function(a){return null!==a&&""!==a};return b(f())?(a+=f(),f().indexOf(":")!==f().length-1&&(a+=":"),a+="//"):h()&&b(j())&&(a+="//"),b(i())&&b(j())&&(a+=i(),i().indexOf("@")!==i().length-1&&(a+="@")),b(j())&&(a+=j(),b(k())&&(a+=":"+k())),b(l())?a+=l():b(j())&&(b(m().toString())||b(n()))&&(a+="/"),b(m().toString())&&(0!==m().toString().indexOf("?")&&(a+="?"),a+=m().toString()),b(n())&&(0!==n().indexOf("#")&&(a+="#"),a+=n()),a},C=function(){return new Uri(B())};return{protocol:f,hasAuthorityPrefix:h,userInfo:i,host:j,port:k,path:l,query:m,anchor:n,setProtocol:o,setHasAuthorityPrefix:p,setUserInfo:q,setHost:r,setPort:s,setPath:t,setQuery:u,setAnchor:v,getQueryParamValue:w,getQueryParamValues:x,deleteQueryParam:y,addQueryParam:z,replaceQueryParam:A,toString:B,clone:C}},jsUri=Uri;!function(a){a.fn.wTooltip=function(b,c){function d(c){c&&(b.degrade?a(n).html(b.content.replace(/<\/?[^>]+>/gi,"")):a(n).html(b.content))}function e(c){function d(){f&&!b.content&&(f="")}function e(){!l&&b.auto&&(clearInterval(i),b.fadeOut?a(n).fadeOut(b.fadeOut,function(){d(c)}):(d(c),n.style.display="none")),"function"==typeof b.callAfter&&b.callAfter(n,c,b),p&&(b=a.listen(b))}b.timeout>0?h=setTimeout(function(){e()},b.timeout):e()}b=a.extend({content:null,ajax:null,follow:!0,auto:!0,fadeIn:0,fadeOut:0,appendTip:document.body,degrade:!1,offsetY:10,offsetX:1,style:{},className:null,id:null,callBefore:function(){},callAfter:function(){},clickAction:function(b){a(b).hide()},delay:0,timeout:0},b||{}),b.style||"object"==typeof b.style?b.style=a.extend({border:"1px solid gray",background:"#edeef0",color:"#000",padding:"10px",zIndex:"1000",textAlign:"left"},b.style||{}):(b.style={},b.style.zIndex="1000"),"function"==typeof c&&(b.callAfter=c||b.callAfter),b.style.display="none",b.style.position="absolute";var f,g,h,i,j={},k=!0,l=!1,m=!1,n=document.createElement("div"),o="undefined"==typeof document.body.style.maxWidth?!0:!1,p="function"==typeof a.talk&&"function"==typeof a.listen?!0:!1;b.id&&(n.id=b.id),b.className&&(n.className=b.className),b.degrade=b.degrade&&o?!0:!1;for(var q in b.style)n.style[q]=b.style[q];return b.ajax&&a.get(b.ajax,function(a){a&&(b.content=a),d(b.content)}),a(n).hover(function(){l=!0},function(){l=!1,e(j)}),p&&(b.key=n,b.plugin="wTooltip",b.channel="wayfarer",a.talk(b)),d(b.content&&!b.ajax),a(n).appendTo(b.appendTip),this.each(function(){a(this).hover(function(){function c(){"function"==typeof b.callBefore&&b.callBefore(n,d,b),p&&(b=a.listen(b));var c;b.content?b.degrade||(c="block"):f&&!b.degrade?(a(n).html(unescape(f)),c="block",f=""):c="none",b.auto&&("block"==c&&b.fadeIn?a(n).fadeIn(b.fadeIn):n.style.display=c)}var d=this;clearTimeout(h),!this.title&&!this.titleMemKeep||b.degrade||b.content||(f=this.title||this.titleMemKeep,this.title&&(this.titleMemKeep=this.title,this.title="")),b.content&&b.degrade&&(this.title=n.innerHTML),b.delay>0?g=setTimeout(function(){c()},b.delay):c()},function(){clearTimeout(g);var c=this;k=!0,!b.follow||m||b.offsetX<0&&0-b.offsetX<a(n).outerWidth()&&b.offsetY>0&&0-b.offsetY<a(n).outerHeight()?setTimeout(function(){i=setInterval(function(){e(c)},1)},1):e(this)}),a(this).mousemove(function(c){if(j=this,b.follow||k){var d=a(window).scrollTop(),e=a(window).scrollLeft(),f=c.clientY+d+b.offsetY,g=c.clientX+e+b.offsetX,h=a(b.appendTip).outerHeight(),i=a(b.appendTip).innerHeight(),l=a(window).width()+e-a(n).outerWidth(),o=a(window).height()+d-a(n).outerHeight();f=h>i?f-(h-i):f,m=f>o||g>l?!0:!1,0>=g-e&&b.offsetX<0?g=e:g>l&&(g=l),0>=f-d&&b.offsetY<0?f=d:f>o&&(f=o),n.style.top=f+"px",n.style.left=g+"px",k=!1}}),"function"==typeof b.clickAction&&a(this).click(function(){b.clickAction(n,this)})})}}(jQuery),function(a,b){"use strict";var c={border:"solid 1px #6295fb",background:"#fff",color:"#000",padding:"5px",zIndex:1e3},d={activeTab:{},terms:{},init:function(){var c=a("body");c.delegate("input[id$=-color_none], input[id$=-color_random], input[id$=-color_set], input[id$=-color_span]","click",this.colorClickHandler),c.delegate("input[id$=-title_type_counter], input[id$=-title_type_name], input[id$=-title_type_custom]","click",this.titleTypeClickHandler),c.delegate(".utcw-tab-button","click",this.tabClickHandler),c.delegate(".utcw-input-taxonomy","click",this.taxonomyClickHandler),c.delegate(".utcw-all-authors","click",this.allAuthorsClickHandler),c.delegate(".utcw-selected-authors","click",this.selectedAuthorsClickHandler),c.delegate(".utcw-remove-config","click",this.removeConfigClickHandler),c.delegate(".post-term-search","keyup",this.postTermSearchHandler),c.delegate(".post-term-search","search",this.postTermSearchHandler),c.delegate(".utcw-remove-term","click",this.removeTermClickHandler),a(document).ready(this.initTooltip),a(document).ajaxSuccess(this.ajaxSuccessHandler),a.post(b,{action:"utcw_get_terms"},function(a){d.terms=a})},initTooltip:function(){a(".utcw-help").wTooltip({style:c,className:"utcw-tooltip"})},postTermSearchHandler:function(){var b=a(this),c=a(b.data("result-selector")),e=a(b.data("selected-selector")),f=b.val().toLocaleLowerCase(),g=[],h=function(a){-1!==a.name.toLocaleLowerCase().indexOf(f)&&g.push(a)};if(c.text(""),f){for(var i in d.terms)d.terms.hasOwnProperty(i)&&d.terms[i].forEach(h);g.forEach(function(f){var g=a(document.createElement("li")),h=a(document.createElement("a")),i=f.name+" ("+f.taxonomy+")";h.text(i),h.data("id",f.term_id),h.click(d.postTermSearchClickHandler(e,b)),g.append(h),c.append(g)})}},postTermSearchClickHandler:function(b,c){return function(){var d=a(this),e=a(document.createElement("li")),f=a(document.createElement("a")),g=a(document.createElement("span")),h=a(document.createElement("input")),i=d.parent().parent();e.text(d.text()),h.attr("type","hidden"),h.val(d.data("id")),h.attr("name",c.data("input-name")+"[]"),f.addClass("submitdelete"),f.addClass("deletion"),f.addClass("utcw-remove-term"),f.text(c.data("delete")),g.addClass("submitbox"),g.append(f),e.append(g),e.append(h),b.append(e),i.text(""),c.val("")}},removeTermClickHandler:function(){a(this).parent().parent().remove()},removeConfigClickHandler:function(){var b=a(this),c=d.findWidgetParent(b),e=c.find(".utcw-load-config"),f=e.val(),g=b.data("input-name")+"[]",h=a(document.createElement("input"));h.attr("type","hidden"),h.attr("name",g),h.attr("value",f),b.after(h),e.find(":selected").remove()},allAuthorsClickHandler:function(){var b=a(this),c=d.findWidgetParent(b);c.find(".utcw-authors").addClass("hidden"),c.find(".utcw-author-field").attr("checked",!1)},selectedAuthorsClickHandler:function(){var b=a(this),c=d.findWidgetParent(b);c.find(".utcw-authors").removeClass("hidden")},tabClickHandler:function(){var b=a(this);return"utcw-__i__"===b.data("id")?!1:(b.parent().find(".utcw-tab-button").removeClass("utcw-active"),b.addClass("utcw-active"),b.parent().find("fieldset.utcw").addClass("hidden"),a("#"+b.data("tab")).removeClass("hidden"),d.activeTab[b.data("id")]=b.data("tab"),!1)},colorClickHandler:function(){var b=a('div[id$="set_chooser"]'),c=a('div[id$="span_chooser"]'),d=a(this).val();b.addClass("utcw-hidden"),c.addClass("utcw-hidden"),"set"===d?b.removeClass("utcw-hidden"):"span"===d&&c.removeClass("utcw-hidden")},titleTypeClickHandler:function(){var b=a('div[id$="-title_custom_template_container"]'),c=a(this).val();"custom"===c?b.removeClass("utcw-hidden"):b.addClass("utcw-hidden")},findWidgetParent:function(a){return a.parents(".widget-content")},taxonomyClickHandler:function(){var b=a(this),c=b.val(),e=b.is(":checked"),f=d.findWidgetParent(b),g=f.find("#"+c+"-terms");e?g.removeClass("hidden"):g.addClass("hidden")},ajaxSuccessHandler:function(a,b,c){d.setCurrentTab.apply(d,[c.data]),d.initTooltip.apply(d)},setCurrentTab:function(b){var c,d=new Uri;d.setQuery(decodeURI(b)),"save-widget"===d.getQueryParamValue("action")&&"utcw"===d.getQueryParamValue("id_base")&&(c=d.getQueryParamValue("widget-id"),this.activeTab[c]&&a('button[data-tab="'+this.activeTab[c]+'"]').trigger("click"))}};d.init()}(jQuery,ajaxurl);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pages/settings.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  * @author Rickard Andersson <rickard@0x539.se>
5
- * @version 2.3.1
6
  * @license GPLv2
7
  * @package utcw
8
  * @subpackage pages
@@ -327,19 +327,40 @@ if ( ! defined( 'ABSPATH' ) ) die();
327
  <label for="<?php echo $this->get_field_id('display_list') ?>"><?php _e('List', 'utcw') ?></label><br>
328
  <br>
329
 
330
- <legend></legend>
331
- <a class="utcw-help"
332
- title="<?php _e( 'The title is the small (usually) yellow label which will appear when the user hovers the tag. Try to hover the text to the left to see an example of what a title text looks like.', 'utcw' ) ?>">?</a>
333
- <input type="checkbox" name="<?php echo $this->get_field_name( 'show_title' ) ?>"
334
- id="<?php echo $this->get_field_id( 'show_title' ) ?>" <?php echo $renderConfig->show_title === true ? 'checked="checked"' : ''?>>
335
- <label for="<?php echo $this->get_field_id( 'show_title' ) ?>"
336
- title="<?php _e( 'This is a title', 'utcw' ) ?>"><?php _e( 'Show title (hover text)', 'utcw' ) ?></label><br> <a class="utcw-help"
337
  title="<?php _e( 'Uncheck this option if you do not want your tag cloud to contain links to the archive page for each tag.', 'utcw' ) ?>">?</a>
338
  <input type="checkbox" name="<?php echo $this->get_field_name( 'show_links' ) ?>"
339
  id="<?php echo $this->get_field_id( 'show_links' ) ?>" <?php echo $renderConfig->show_links === true ? 'checked="checked"' : ''?>>
340
  <label for="<?php echo $this->get_field_id( 'show_links' ) ?>"><?php _e( 'Show links', 'utcw' ) ?></label><br>
 
 
 
 
341
  <br>
342
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
  <a class="utcw-help"
344
  title="<?php _e( 'The spacing is a numerical value which controls how much space there is between letters, words, tags or rows. To use the default value for these settings just use the corresponding default value from the CSS specification: <ul><li>Letter spacing: normal</li><li>Word spacing: normal</li><li>Tag spacing (CSS margin): auto</li><li>Row spacing (CSS line height): inherit</li></ul>To use anything but the default values, just specify a number (the unit is pixels).', 'utcw' ) ?>">?</a>
345
  <strong><?php _e( 'Spacing:', 'utcw' ) ?></strong><br>
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  * @author Rickard Andersson <rickard@0x539.se>
5
+ * @version 2.4
6
  * @license GPLv2
7
  * @package utcw
8
  * @subpackage pages
327
  <label for="<?php echo $this->get_field_id('display_list') ?>"><?php _e('List', 'utcw') ?></label><br>
328
  <br>
329
 
330
+ <strong><?php _e('Term appearance', 'utcw') ?></strong><br>
331
+ <a class="utcw-help"
 
 
 
 
 
332
  title="<?php _e( 'Uncheck this option if you do not want your tag cloud to contain links to the archive page for each tag.', 'utcw' ) ?>">?</a>
333
  <input type="checkbox" name="<?php echo $this->get_field_name( 'show_links' ) ?>"
334
  id="<?php echo $this->get_field_id( 'show_links' ) ?>" <?php echo $renderConfig->show_links === true ? 'checked="checked"' : ''?>>
335
  <label for="<?php echo $this->get_field_id( 'show_links' ) ?>"><?php _e( 'Show links', 'utcw' ) ?></label><br>
336
+ <a class="utcw-help" title="<?php _e('Select this option if you would like the output to contain the number of posts associated with each term. Like: Hello World (2)', 'utcw') ?>">?</a>
337
+ <input type="checkbox" name="<?php echo $this->get_field_name( 'show_post_count' ) ?>"
338
+ id="<?php echo $this->get_field_id( 'show_post_count' ) ?>" <?php echo $renderConfig->show_post_count === true ? 'checked="checked"' : ''?>>
339
+ <label for="<?php echo $this->get_field_id( 'show_post_count' ) ?>"><?php _e( 'Show post count', 'utcw' ) ?></label><br>
340
  <br>
341
 
342
+ <strong><?php _e('Term titles (hover text)', 'utcw') ?></strong><br>
343
+ <a class="utcw-help"
344
+ title="<?php _e( 'The title is the small (usually) yellow label which will appear when the user hovers the tag. Try to hover the text to the left to see an example of what a title text looks like.', 'utcw' ) ?>">?</a>
345
+ <input type="checkbox" name="<?php echo $this->get_field_name( 'show_title' ) ?>"
346
+ id="<?php echo $this->get_field_id( 'show_title' ) ?>" <?php echo $renderConfig->show_title === true ? 'checked="checked"' : ''?>>
347
+ <label for="<?php echo $this->get_field_id( 'show_title' ) ?>"
348
+ title="<?php _e( 'This is a title', 'utcw' ) ?>"><?php _e( 'Enable titles', 'utcw' ) ?></label><br>
349
+ <a class="utcw-help" title="<?php _e('This is the WordPress default option, it will add the post count as title like this: 2 topics', 'utcw') ?>">?</a>
350
+ <input type="radio" name="<?php echo $this->get_field_name('title_type') ?>" id="<?php echo $this->get_field_id('title_type_counter') ?>" value="counter" <?php if ($renderConfig->title_type === 'counter') echo ' checked="checked"' ?>>
351
+ <label for="<?php echo $this->get_field_id('title_type_counter') ?>"><?php _e('Post count', 'utcw') ?></label><br>
352
+ <a class="utcw-help" title="<?php _e('This option will use the term name as title', 'utcw') ?>">?</a>
353
+ <input type="radio" name="<?php echo $this->get_field_name('title_type') ?>" id="<?php echo $this->get_field_id('title_type_name') ?>" value="name" <?php if ($renderConfig->title_type === 'name') echo ' checked="checked"' ?>>
354
+ <label for="<?php echo $this->get_field_id('title_type_name') ?>"><?php _e('Term name', 'utcw') ?></label><br>
355
+ <a class="utcw-help" title="<?php _e('This option allows you to define a C-style printf template to be used when generating the title. You can use %d and %s to get the post count and term name. To get a title like this: <br><code>The term Hello World has been used with 14 posts</code><br><br>Use a template like this:<br><code>The term %s has been used with %d posts</code>', 'utcw') ?>">?</a>
356
+ <input type="radio" name="<?php echo $this->get_field_name('title_type') ?>" id="<?php echo $this->get_field_id('title_type_custom') ?>" value="custom" <?php if ($renderConfig->title_type === 'custom') echo ' checked="checked"' ?>>
357
+ <label for="<?php echo $this->get_field_id('title_type_custom') ?>"><?php _e('Custom template', 'utcw') ?></label><br>
358
+ <div id="<?php echo $this->get_field_id('title_custom_template_container') ?>" class="<?php if ($renderConfig->title_type !== 'custom') echo 'utcw-hidden' ?>">
359
+ <label class="utcw-hidden" for="<?php echo $this->get_field_id('title_custom_template') ?>"><?php _e('Custom title template', 'utcw') ?></label>
360
+ <input type="text" name="<?php echo $this->get_field_name('title_custom_template') ?>" id="<?php echo $this->get_field_id('title_custom_template') ?>" value="<?php echo $renderConfig->title_custom_template ?>"><br>
361
+ </div>
362
+ <br>
363
+
364
  <a class="utcw-help"
365
  title="<?php _e( 'The spacing is a numerical value which controls how much space there is between letters, words, tags or rows. To use the default value for these settings just use the corresponding default value from the CSS specification: <ul><li>Letter spacing: normal</li><li>Word spacing: normal</li><li>Tag spacing (CSS margin): auto</li><li>Row spacing (CSS line height): inherit</li></ul>To use anything but the default values, just specify a number (the unit is pixels).', 'utcw' ) ?>">?</a>
366
  <strong><?php _e( 'Spacing:', 'utcw' ) ?></strong><br>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: exz
3
  Tags: widget, tags, configurable, tag cloud
4
  Requires at least: 3.0
5
  Tested up to: 3.6
6
- Stable tag: 2.3.1
7
  Donate link: https://flattr.com/thing/112193/Ultimate-Tag-Cloud-Widget
8
  License: GPLv2 or later
9
 
@@ -47,6 +47,14 @@ If you have questions, please post them in the forums.
47
 
48
  == Changelog ==
49
 
 
 
 
 
 
 
 
 
50
  = 2.3.1 =
51
  * Security fix for sensitive data exposed when using the debug option
52
 
@@ -100,7 +108,12 @@ The upgrade notice history for the 1.x branch is available on [GitHub](https://g
100
 
101
  == Upgrade Notice ==
102
 
 
 
 
 
103
  = 2.3.1 =
 
104
  * Security fix for sensitive data exposed when using the debug option
105
 
106
  = 2.3 =
@@ -170,6 +183,8 @@ If you're not able to change your theme you can also use the shortcode `[utcw]`
170
 
171
  `[utcw title="Most awesome title ever"]`
172
 
 
 
173
  == Configuration ==
174
 
175
  All the configuration options can be found in the [configuration documentation at GitHub](https://github.com/rickard2/utcw/blob/master/CONFIG.md).
3
  Tags: widget, tags, configurable, tag cloud
4
  Requires at least: 3.0
5
  Tested up to: 3.6
6
+ Stable tag: 2.4
7
  Donate link: https://flattr.com/thing/112193/Ultimate-Tag-Cloud-Widget
8
  License: GPLv2 or later
9
 
47
 
48
  == Changelog ==
49
 
50
+ = 2.4 =
51
+
52
+ * [#32](https://github.com/rickard2/utcw/issues/32): Added filters to enable developers to hook into the plugin
53
+ * [#33](https://github.com/rickard2/utcw/issues/33): Updated JS code to support newer versions of jQuery
54
+ * [#36](https://github.com/rickard2/utcw/issues/36), [#38](https://github.com/rickard2/utcw/issues/38): Added options for changing the value of the title attribute
55
+ * [#37](https://github.com/rickard2/utcw/issues/37): Fixed UI issue with the show title option always being checked
56
+ * [#39](https://github.com/rickard2/utcw/issues/39): Added option to add post count to the term name
57
+
58
  = 2.3.1 =
59
  * Security fix for sensitive data exposed when using the debug option
60
 
108
 
109
  == Upgrade Notice ==
110
 
111
+ = 2.4 =
112
+
113
+ * New features, see plugin page at wordpress.org for full details.
114
+
115
  = 2.3.1 =
116
+
117
  * Security fix for sensitive data exposed when using the debug option
118
 
119
  = 2.3 =
183
 
184
  `[utcw title="Most awesome title ever"]`
185
 
186
+ The plugin also uses a couple of filters for you to be able to alter the output. These are documented in the [filters documentation at GitHub](https://github.com/rickard2/utcw/blob/master/FILTERS.md).
187
+
188
  == Configuration ==
189
 
190
  All the configuration options can be found in the [configuration documentation at GitHub](https://github.com/rickard2/utcw/blob/master/CONFIG.md).
src/Cache/W3TotalCacheHandler.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Ultimate Tag Cloud Widget
5
+ *
6
+ * @author Rickard Andersson <rickard@0x539.se>
7
+ * @version 2.4
8
+ * @license GPLv2
9
+ * @package utcw
10
+ * @subpackage cache
11
+ * @since 2.4
12
+ */
13
+ class UTCW_W3TotalCacheHandler extends UTCW_Handler
14
+ {
15
+
16
+ protected $args;
17
+
18
+ /**
19
+ * Returns true if W3 Total Cache is enabled
20
+ *
21
+ * @return bool
22
+ * @since 2.4
23
+ */
24
+ public function isEnabled()
25
+ {
26
+ // todo: check late init
27
+ return class_exists('W3_Plugin');
28
+ }
29
+
30
+ /**
31
+ * Initializes the handler
32
+ *
33
+ * @since 2.4
34
+ */
35
+ public function init()
36
+ {
37
+ add_filter('filter_shortcode', array($this, 'filterShortCode'));
38
+ add_action('utcw_shortcode', array($this, 'onShortCode'));
39
+ }
40
+
41
+ /**
42
+ * Called when the short code is used
43
+ *
44
+ * @since 2.4
45
+ */
46
+ public function onShortCode($args)
47
+ {
48
+ $this->args = $args;
49
+ }
50
+
51
+ /**
52
+ * @param $content
53
+ *
54
+ * @return string
55
+ */
56
+ public function filterShortCode($content)
57
+ {
58
+ $return = array(
59
+ sprintf('<!-- mfunc %s -->', W3TC_DYNAMIC_SECURITY),
60
+ sprintf("echo do_utcw(%s);", $this->argsToArray($this->args)),
61
+ sprintf('<!-- /mfunc %s -->', W3TC_DYNAMIC_SECURITY),
62
+ );
63
+
64
+ return join("\r\n", $return);
65
+ }
66
+
67
+ /**
68
+ * @param array $args
69
+ *
70
+ * @return string
71
+ */
72
+ protected function argsToArray(array $args)
73
+ {
74
+ $values = array();
75
+
76
+ foreach ($args as $key => $value) {
77
+ $values[] = sprintf('"%s" => "%s"', $key, addslashes($value));
78
+ }
79
+
80
+ $values[] = '"mfunc" => 1';
81
+
82
+ return sprintf('array(%s)', join(',', $values));
83
+ }
84
+ }
src/Cache/WPSuperCacheHandler.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ultimate Tag Cloud Widget
4
+ *
5
+ * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
+ * @license GPLv2
8
+ * @package utcw
9
+ * @subpackage cache
10
+ * @since 2.4
11
+ */
12
+ class UTCW_WPSuperCacheHandler extends UTCW_Handler
13
+ {
14
+
15
+ /**
16
+ * Returns true if WP Super Cache is enabled
17
+ *
18
+ * @return bool
19
+ * @since 2.4
20
+ */
21
+ public function isEnabled()
22
+ {
23
+ return function_exists('add_cacheaction');
24
+ }
25
+
26
+ /**
27
+ * Initializes the handler
28
+ *
29
+ * @since 2.4
30
+ */
31
+ public function init()
32
+ {
33
+ add_action('utcw_shortcode', array($this, 'onShortCode'));
34
+ }
35
+
36
+ /**
37
+ * Called when the shortcode is used
38
+ *
39
+ * @since 2.4
40
+ */
41
+ public function onShortCode()
42
+ {
43
+ if (!defined('DONOTCACHEPAGE')) {
44
+ define('DONOTCACHEPAGE', true);
45
+ }
46
+ }
47
+ }
src/Config/Config.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config
src/Config/DataConfig.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config
src/Config/RenderConfig.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config
@@ -14,40 +14,43 @@
14
  * Class to represent a the configuration options for cloud rendering retrieval
15
  *
16
  * @since 2.3
17
- * @property-read string title Title text of the widget
18
- * @property-read string letter_spacing CSS letter-spacing value (in pixels)
19
- * @property-read string word_spacing CSS word-spacing value (in pixels)
20
- * @property-read string text_transform CSS text-transform value
21
- * @property-read string show_title If the title attribute should be added to links in the cloud
22
- * @property-read string show_links If the tags should be wrapped in links
23
- * @property-read string link_underline If links should be styled with underline decoration
24
- * @property-read string link_bold If links should be styled as bold
25
- * @property-read string link_italic If links should be styled as italic
26
- * @property-read string link_bg_color Background color for links
27
- * @property-read string link_border_style Border style for links
28
- * @property-read string link_border_width Border width for links
29
- * @property-read string link_border_color Border color for links
30
- * @property-read string hover_underline If links should be decorated with underline decoration in their hover state
31
- * @property-read string hover_bold If links should be styled as bold in their hover state
32
- * @property-read string hover_italic If links should be styled as italic in their hover state
33
- * @property-read string hover_bg_color Background color for links in their hover state
34
- * @property-read string hover_color Text color for links in their hover state
35
- * @property-read string hover_border_style Border style for links in their hover state
36
- * @property-read string hover_border_width Border width for links in their hover state
37
- * @property-read string hover_border_color Border color for links in their hover state
38
- * @property-read string tag_spacing CSS margin between tags
39
- * @property-read bool debug If debug output should be included
40
- * @property-read string line_height CSS line-height for the tags
41
- * @property-read string separator Separator between tags
42
- * @property-read string prefix Prefix before each tag
43
- * @property-read string suffix Suffix after each tag
44
- * @property-read bool show_title_text If the widget title should be shown
45
- * @property-read string alignment How the text in the resulting cloud should be aligned
46
- * @property-read string display How the resulting cloud should be displayed
47
- * @property-read string before_widget @internal
48
- * @property-read string after_widget @internal
49
- * @property-read string before_title @internal
50
- * @property-read string after_title @internal
 
 
 
51
  */
52
 
53
  class UTCW_RenderConfig extends UTCW_Config
@@ -91,6 +94,14 @@ class UTCW_RenderConfig extends UTCW_Config
91
  'justify',
92
  );
93
 
 
 
 
 
 
 
 
 
94
  /**
95
  * Valid values for display set
96
  *
@@ -129,6 +140,7 @@ class UTCW_RenderConfig extends UTCW_Config
129
  $this->addOption('hover_border_style', 'set', array('values' => $this->borderStyleValues));
130
  $this->addOption('alignment', 'set', array('values' => $this->alignmentValues, 'default' => ''));
131
  $this->addOption('display', 'set', array('values' => $this->displayValues));
 
132
 
133
  $this->addOption('link_bg_color', 'color');
134
  $this->addOption('hover_bg_color', 'color');
@@ -151,10 +163,12 @@ class UTCW_RenderConfig extends UTCW_Config
151
  $this->addOption('after_widget', 'string');
152
  $this->addOption('before_title', 'string');
153
  $this->addOption('after_title', 'string');
 
154
 
155
  $this->addOption('show_title', 'boolean', array('default' => true));
156
  $this->addOption('show_links', 'boolean', array('default' => true));
157
  $this->addOption('show_title_text', 'boolean', array('default' => true));
 
158
  $this->addOption('debug', 'boolean');
159
 
160
  parent::__construct($input, $plugin);
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config
14
  * Class to represent a the configuration options for cloud rendering retrieval
15
  *
16
  * @since 2.3
17
+ * @property-read string title Title text of the widget
18
+ * @property-read string letter_spacing CSS letter-spacing value (in pixels)
19
+ * @property-read string word_spacing CSS word-spacing value (in pixels)
20
+ * @property-read string text_transform CSS text-transform value
21
+ * @property-read string show_title If the title attribute should be added to links in the cloud
22
+ * @property-read string show_links If the tags should be wrapped in links
23
+ * @property-read string link_underline If links should be styled with underline decoration
24
+ * @property-read string link_bold If links should be styled as bold
25
+ * @property-read string link_italic If links should be styled as italic
26
+ * @property-read string link_bg_color Background color for links
27
+ * @property-read string link_border_style Border style for links
28
+ * @property-read string link_border_width Border width for links
29
+ * @property-read string link_border_color Border color for links
30
+ * @property-read string hover_underline If links should be decorated with underline decoration in their hover state
31
+ * @property-read string hover_bold If links should be styled as bold in their hover state
32
+ * @property-read string hover_italic If links should be styled as italic in their hover state
33
+ * @property-read string hover_bg_color Background color for links in their hover state
34
+ * @property-read string hover_color Text color for links in their hover state
35
+ * @property-read string hover_border_style Border style for links in their hover state
36
+ * @property-read string hover_border_width Border width for links in their hover state
37
+ * @property-read string hover_border_color Border color for links in their hover state
38
+ * @property-read string tag_spacing CSS margin between tags
39
+ * @property-read bool debug If debug output should be included
40
+ * @property-read string line_height CSS line-height for the tags
41
+ * @property-read string separator Separator between tags
42
+ * @property-read string prefix Prefix before each tag
43
+ * @property-read string suffix Suffix after each tag
44
+ * @property-read bool show_title_text If the widget title should be shown
45
+ * @property-read string alignment How the text in the resulting cloud should be aligned
46
+ * @property-read string display How the resulting cloud should be displayed
47
+ * @property-read bool show_post_count If the number of posts with that term should be displayed with the name
48
+ * @property-read string title_type What type of information the title text should contain
49
+ * @property-read string title_custom_template A C-style printf-template for the title text. Include %d to get the post count and %s to get the term name.
50
+ * @property-read string before_widget @internal
51
+ * @property-read string after_widget @internal
52
+ * @property-read string before_title @internal
53
+ * @property-read string after_title @internal
54
  */
55
 
56
  class UTCW_RenderConfig extends UTCW_Config
94
  'justify',
95
  );
96
 
97
+ /**
98
+ * Valid values for title type
99
+ *
100
+ * @var array
101
+ * @since 2.4
102
+ */
103
+ protected $titleTypeValues = array('counter', 'name', 'custom');
104
+
105
  /**
106
  * Valid values for display set
107
  *
140
  $this->addOption('hover_border_style', 'set', array('values' => $this->borderStyleValues));
141
  $this->addOption('alignment', 'set', array('values' => $this->alignmentValues, 'default' => ''));
142
  $this->addOption('display', 'set', array('values' => $this->displayValues));
143
+ $this->addOption('title_type', 'set', array('values' => $this->titleTypeValues));
144
 
145
  $this->addOption('link_bg_color', 'color');
146
  $this->addOption('hover_bg_color', 'color');
163
  $this->addOption('after_widget', 'string');
164
  $this->addOption('before_title', 'string');
165
  $this->addOption('after_title', 'string');
166
+ $this->addOption('title_custom_template', 'string');
167
 
168
  $this->addOption('show_title', 'boolean', array('default' => true));
169
  $this->addOption('show_links', 'boolean', array('default' => true));
170
  $this->addOption('show_title_text', 'boolean', array('default' => true));
171
+ $this->addOption('show_post_count', 'boolean', array('default' => false));
172
  $this->addOption('debug', 'boolean');
173
 
174
  parent::__construct($input, $plugin);
src/Config/Type/ArrayType.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
src/Config/Type/BooleanType.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
src/Config/Type/ColorType.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
src/Config/Type/IntegerType.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
src/Config/Type/MeasurementType.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
src/Config/Type/SetType.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
src/Config/Type/StringType.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
src/Config/Type/Type.php CHANGED
@@ -3,7 +3,7 @@
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
- * @version 2.3.1
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage config-type
src/Data.php CHANGED
@@ -1,24 +1,15 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW;
4
-
5
  /**
6
  * Ultimate Tag Cloud Widget
7
  *
8
  * @author Rickard Andersson <rickard@0x539.se>
9
- * @version 2.3.1
10
  * @license GPLv2
11
  * @package utcw
12
  * @subpackage main
13
  * @since 2.0
14
  */
15
 
16
- //use Rickard\UTCW\Selection\PopularityStrategy;
17
- //use Rickard\UTCW\Selection\RandomStrategy;
18
- //use Rickard\UTCW\Selection\SelectionStrategy;
19
- //use wpdb;
20
- //use stdClass;
21
-
22
  /**
23
  * Class for loading data for the cloud
24
  *
@@ -124,7 +115,7 @@ class UTCW_Data
124
  $max_count = 0;
125
 
126
  // Get translation handler if a translation plugin is active
127
- $this->translationHandler = $this->plugin->getTranslationHandler();
128
 
129
  foreach ($this->result as $item) {
130
  if ($item->count < $min_count) {
1
  <?php
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage main
10
  * @since 2.0
11
  */
12
 
 
 
 
 
 
 
13
  /**
14
  * Class for loading data for the cloud
15
  *
115
  $max_count = 0;
116
 
117
  // Get translation handler if a translation plugin is active
118
+ $this->translationHandler = $this->plugin->get('translationHandler');
119
 
120
  foreach ($this->result as $item) {
121
  if ($item->count < $min_count) {
src/Database/QueryBuilder.php CHANGED
@@ -1,21 +1,15 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW\Database;
4
-
5
  /**
6
  * Ultimate Tag Cloud Widget
7
  *
8
  * @author Rickard Andersson <rickard@0x539.se>
9
- * @version 2.3.1
10
  * @license GPLv2
11
  * @package utcw
12
  * @subpackage language
13
  * @since 2.2
14
  */
15
 
16
- //use Rickard\UTCW\Plugin;
17
- //use wpdb;
18
-
19
  /**
20
  * Class to handle QTranslate multi language support
21
  *
1
  <?php
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage language
10
  * @since 2.2
11
  */
12
 
 
 
 
13
  /**
14
  * Class to handle QTranslate multi language support
15
  *
src/Handler/Handler.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class UTCW_Handler
4
+ {
5
+ abstract public function isEnabled();
6
+
7
+ abstract public function init();
8
+ }
src/Handler/HandlerFactory.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class UTCW_HandlerFactory
4
+ {
5
+ protected $handlers;
6
+
7
+ public function __construct(array $handlers)
8
+ {
9
+ $this->handlers = $handlers;
10
+ }
11
+
12
+ public function getInstance()
13
+ {
14
+ foreach ($this->handlers as $handler) {
15
+
16
+ $instance = new $handler();
17
+
18
+ /** @var UTCW_Handler $instance */
19
+
20
+ if ($instance->isEnabled()) {
21
+ $instance->init();
22
+
23
+ return $instance;
24
+ }
25
+ }
26
+
27
+ return false;
28
+ }
29
+ }
src/Language/QTranslateHandler.php CHANGED
@@ -1,22 +1,15 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW\Language;
4
-
5
  /**
6
  * Ultimate Tag Cloud Widget
7
  *
8
  * @author Rickard Andersson <rickard@0x539.se>
9
- * @version 2.3.1
10
  * @license GPLv2
11
  * @package utcw
12
  * @subpackage language
13
  * @since 2.2
14
  */
15
 
16
- //use Rickard\UTCW\Plugin;
17
- //use Rickard\UTCW\Term;
18
- //use stdClass;
19
-
20
  /**
21
  * Class to handle QTranslate multi language support
22
  *
@@ -35,26 +28,28 @@ class UTCW_QTranslateHandler extends UTCW_TranslationHandler
35
  protected $nameMap;
36
 
37
  /**
38
- * Initializes the class with a map of term names
39
- *
40
- * @param array $nameMap An array of term names mapped to translated names
41
  *
 
42
  * @since 2.2
43
  */
44
- public function __construct(array $nameMap)
45
  {
46
- $this->nameMap = $nameMap;
47
  }
48
 
 
49
  /**
50
- * Returns true if QTranslate is installed and active
51
  *
52
- * @return bool
53
- * @since 2.2
54
  */
55
- public function isEnabled()
56
  {
57
- return defined('QT_SUPPORTED_WP_VERSION');
 
 
 
58
  }
59
 
60
  /**
@@ -71,8 +66,8 @@ class UTCW_QTranslateHandler extends UTCW_TranslationHandler
71
  /**
72
  * {@inheritdoc}
73
  *
74
- * @param stdClass $input
75
- * @param UTCW_Plugin $plugin
76
  *
77
  * @return null|UTCW_Term
78
  * @since 2.2
1
  <?php
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage language
10
  * @since 2.2
11
  */
12
 
 
 
 
 
13
  /**
14
  * Class to handle QTranslate multi language support
15
  *
28
  protected $nameMap;
29
 
30
  /**
31
+ * Returns true if QTranslate is installed and active
 
 
32
  *
33
+ * @return bool
34
  * @since 2.2
35
  */
36
+ public function isEnabled()
37
  {
38
+ return defined('QT_SUPPORTED_WP_VERSION');
39
  }
40
 
41
+
42
  /**
43
+ * Initializes the QTranslate Handler
44
  *
45
+ * @since 2.4
 
46
  */
47
+ public function init()
48
  {
49
+ $names = get_option('qtranslate_term_name');
50
+ $names = $names ? $names : array();
51
+
52
+ $this->nameMap = $names;
53
  }
54
 
55
  /**
66
  /**
67
  * {@inheritdoc}
68
  *
69
+ * @param stdClass $input
70
+ * @param UTCW_Plugin $plugin
71
  *
72
  * @return null|UTCW_Term
73
  * @since 2.2
src/Language/TranslationHandler.php CHANGED
@@ -1,22 +1,15 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW\Language;
4
-
5
  /**
6
  * Ultimate Tag Cloud Widget
7
  *
8
  * @author Rickard Andersson <rickard@0x539.se>
9
- * @version 2.3.1
10
  * @license GPLv2
11
  * @package utcw
12
  * @subpackage language
13
  * @since 2.2
14
  */
15
 
16
- //use Rickard\UTCW\Plugin;
17
- //use Rickard\UTCW\Term;
18
- //use stdClass;
19
-
20
  /**
21
  * Abstract class to handle multi language support
22
  *
@@ -24,22 +17,14 @@
24
  * @package utcw
25
  * @subpackage language
26
  */
27
- abstract class UTCW_TranslationHandler
28
  {
29
- /**
30
- * Returns true if this multi-language plugin is enabled
31
- *
32
- * @return bool
33
- * @since 2.2
34
- */
35
- abstract public function isEnabled();
36
-
37
  /**
38
  * Returns a new Term or null depending on if the term should be included with the current language settings.
39
  * The returned Term will have its name translated into the current language
40
  *
41
- * @param stdClass $input
42
- * @param UTCW_Plugin $plugin
43
  *
44
  * @return null|UTCW_Term
45
  * @since 2.2
1
  <?php
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage language
10
  * @since 2.2
11
  */
12
 
 
 
 
 
13
  /**
14
  * Abstract class to handle multi language support
15
  *
17
  * @package utcw
18
  * @subpackage language
19
  */
20
+ abstract class UTCW_TranslationHandler extends UTCW_Handler
21
  {
 
 
 
 
 
 
 
 
22
  /**
23
  * Returns a new Term or null depending on if the term should be included with the current language settings.
24
  * The returned Term will have its name translated into the current language
25
  *
26
+ * @param stdClass $input
27
+ * @param UTCW_Plugin $plugin
28
  *
29
  * @return null|UTCW_Term
30
  * @since 2.2
src/Language/WPMLHandler.php CHANGED
@@ -1,22 +1,15 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW\Language;
4
-
5
  /**
6
  * Ultimate Tag Cloud Widget
7
  *
8
  * @author Rickard Andersson <rickard@0x539.se>
9
- * @version 2.3.1
10
  * @license GPLv2
11
  * @package utcw
12
  * @subpackage language
13
  * @since 2.2
14
  */
15
 
16
- //use Rickard\UTCW\Plugin;
17
- //use Rickard\UTCW\Term;
18
- //use stdClass;
19
-
20
  /**
21
  * Class to handle WPML multi-language support
22
  *
@@ -37,6 +30,14 @@ class UTCW_WPMLHandler extends UTCW_TranslationHandler
37
  return defined('ICL_LANGUAGE_CODE');
38
  }
39
 
 
 
 
 
 
 
 
 
40
  /**
41
  * Returns the current WPML language
42
  *
@@ -107,8 +108,8 @@ class UTCW_WPMLHandler extends UTCW_TranslationHandler
107
  /**
108
  * {@inheritdoc}
109
  *
110
- * @param stdClass $input
111
- * @param UTCW_Plugin $plugin
112
  *
113
  * @return null|UTCW_Term
114
  * @since 2.2
1
  <?php
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage language
10
  * @since 2.2
11
  */
12
 
 
 
 
 
13
  /**
14
  * Class to handle WPML multi-language support
15
  *
30
  return defined('ICL_LANGUAGE_CODE');
31
  }
32
 
33
+ /**
34
+ * @since 2.4
35
+ */
36
+ public function init()
37
+ {
38
+ // void
39
+ }
40
+
41
  /**
42
  * Returns the current WPML language
43
  *
108
  /**
109
  * {@inheritdoc}
110
  *
111
+ * @param stdClass $input
112
+ * @param UTCW_Plugin $plugin
113
  *
114
  * @return null|UTCW_Term
115
  * @since 2.2
src/Plugin.php CHANGED
@@ -1,7 +1,4 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW;
4
-
5
  /**
6
  * Class for general plugin integration with WordPress
7
  *
@@ -9,15 +6,12 @@
9
  * @package utcw
10
  * @subpackage main
11
  */
12
- //use Rickard\UTCW\Language\QTranslateHandler;
13
- //use Rickard\UTCW\Language\TranslationHandler;
14
- //use Rickard\UTCW\Language\WPMLHandler;
15
 
16
  /**
17
  * Ultimate Tag Cloud Widget
18
  *
19
  * @author Rickard Andersson <rickard@0x539.se>
20
- * @version 2.3.1
21
  * @license GPLv2
22
  * @package utcw
23
  * @subpackage main
@@ -67,6 +61,7 @@ class UTCW_Plugin
67
  private function __construct()
68
  {
69
  $this->setHooks();
 
70
  }
71
 
72
  /**
@@ -80,7 +75,54 @@ class UTCW_Plugin
80
  add_action('wp_loaded', array($this, 'wpLoaded'));
81
  add_action('widgets_init', array($this, 'widgetsInit'));
82
  add_action('wp_ajax_utcw_get_terms', array($this, 'outputTermsJson'));
83
- add_shortcode('utcw', array($this, 'shortcode'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
85
 
86
  /**
@@ -189,36 +231,6 @@ class UTCW_Plugin
189
  $this->allowed_post_types = get_post_types(array('public' => true));
190
  }
191
 
192
- /**
193
- * Short code handler for 'utcw' hook
194
- *
195
- * @param array $args
196
- *
197
- * @return string
198
- * @since 2.0
199
- */
200
- public function shortcode(array $args)
201
- {
202
- global $wpdb;
203
-
204
- if (isset($args['load_config'])) {
205
- $loaded = $this->loadConfiguration($args['load_config']);
206
-
207
- if (is_array($loaded)) {
208
- $args = $loaded;
209
- }
210
- }
211
-
212
- $this->set('wpdb', $wpdb);
213
- $this->set('dataConfig', new UTCW_DataConfig($args, $this));
214
- $this->set('renderConfig', new UTCW_RenderConfig($args, $this));
215
- $this->set('data', new UTCW_Data($this));
216
-
217
- $render = new UTCW_Render($this);
218
-
219
- return $render->getCloud();
220
- }
221
-
222
  /**
223
  * Action handler for 'admin_head-widgets.php' hook
224
  * Loads assets needed by the administration interface
@@ -247,7 +259,7 @@ class UTCW_Plugin
247
  );
248
  wp_enqueue_script(
249
  'utcw',
250
- plugins_url('ultimate-tag-cloud-widget/js/utcw.js'),
251
  array('utcw-lib-jsuri', 'utcw-lib-tooltip', 'jquery'),
252
  UTCW_VERSION,
253
  true
@@ -471,28 +483,4 @@ class UTCW_Plugin
471
  {
472
  return apply_filters($tag, $value);
473
  }
474
-
475
- /**
476
- * Returns a new instance of the QTranslate Handler class
477
- *
478
- * @return null|UTCW_TranslationHandler
479
- */
480
- public function getTranslationHandler()
481
- {
482
- $names = get_option('qtranslate_term_name');
483
- $names = $names ? $names : array();
484
- $qTranslate = new UTCW_QTranslateHandler($names);
485
-
486
- if ($qTranslate->isEnabled()) {
487
- return $qTranslate;
488
- }
489
-
490
- $WPML = new UTCW_WPMLHandler();
491
-
492
- if ($WPML->isEnabled()) {
493
- return $WPML;
494
- }
495
-
496
- return null;
497
- }
498
  }
1
  <?php
 
 
 
2
  /**
3
  * Class for general plugin integration with WordPress
4
  *
6
  * @package utcw
7
  * @subpackage main
8
  */
 
 
 
9
 
10
  /**
11
  * Ultimate Tag Cloud Widget
12
  *
13
  * @author Rickard Andersson <rickard@0x539.se>
14
+ * @version 2.4
15
  * @license GPLv2
16
  * @package utcw
17
  * @subpackage main
61
  private function __construct()
62
  {
63
  $this->setHooks();
64
+ $this->set('shortCode', new UTCW_ShortCode($this));
65
  }
66
 
67
  /**
75
  add_action('wp_loaded', array($this, 'wpLoaded'));
76
  add_action('widgets_init', array($this, 'widgetsInit'));
77
  add_action('wp_ajax_utcw_get_terms', array($this, 'outputTermsJson'));
78
+ // add_action('init', array($this, 'setCacheHandler')); Disabled for now
79
+ add_action('init', array($this, 'setTranslationHandler'));
80
+ }
81
+
82
+ /**
83
+ * Sets the translation handler if any is available
84
+ *
85
+ * @return bool
86
+ * @since 2.4
87
+ */
88
+ public function setTranslationHandler()
89
+ {
90
+ $factory = new UTCW_HandlerFactory(array(
91
+ 'UTCW_QTranslateHandler',
92
+ 'UTCW_WPMLHandler'
93
+ ));
94
+
95
+ $instance = $factory->getInstance();
96
+
97
+ if ($instance) {
98
+ $this->set('translationHandler', $instance);
99
+ return true;
100
+ }
101
+
102
+ return false;
103
+ }
104
+
105
+ /**
106
+ * Sets the cache handler if any is available
107
+ *
108
+ * @return bool
109
+ * @since 2.4
110
+ */
111
+ public function setCacheHandler()
112
+ {
113
+ $factory = new UTCW_HandlerFactory(array(
114
+ 'UTCW_WPSuperCacheHandler',
115
+ 'UTCW_W3TotalCacheHandler',
116
+ ));
117
+
118
+ $instance = $factory->getInstance();
119
+
120
+ if ($instance) {
121
+ $this->set('cacheHandler', $instance);
122
+ return true;
123
+ }
124
+
125
+ return false;
126
  }
127
 
128
  /**
231
  $this->allowed_post_types = get_post_types(array('public' => true));
232
  }
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  /**
235
  * Action handler for 'admin_head-widgets.php' hook
236
  * Loads assets needed by the administration interface
259
  );
260
  wp_enqueue_script(
261
  'utcw',
262
+ plugins_url('ultimate-tag-cloud-widget/js/src/utcw.js'),
263
  array('utcw-lib-jsuri', 'utcw-lib-tooltip', 'jquery'),
264
  UTCW_VERSION,
265
  true
483
  {
484
  return apply_filters($tag, $value);
485
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  }
src/Render.php CHANGED
@@ -1,12 +1,9 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW;
4
-
5
  /**
6
  * Ultimate Tag Cloud Widget
7
  *
8
  * @author Rickard Andersson <rickard@0x539.se>
9
- * @version 2.3.1
10
  * @license GPLv2
11
  * @package utcw
12
  * @subpackage main
@@ -34,7 +31,7 @@ class UTCW_Render
34
  /**
35
  * Reference to the current configuration
36
  *
37
- * @var UTCW_Config
38
  * @since 2.0
39
  */
40
  private $config;
@@ -101,7 +98,7 @@ class UTCW_Render
101
  $markup = array();
102
 
103
  if ($this->css) {
104
- $markup[] = $this->css;
105
  }
106
 
107
  if ($this->config->before_widget) {
@@ -122,15 +119,24 @@ class UTCW_Render
122
 
123
  $markup[] = '<div class="tagcloud utcw-' . $this->id . '">';
124
 
 
 
125
  $terms = array();
126
 
127
- foreach ($this->data->getTerms() as $term) {
128
  $color = $term->color ? ';color:' . $term->color : '';
129
- $title = $this->config->show_title ? sprintf(
130
- ' title="' . _n('%s topic', '%s topics', $term->count) . '"',
131
- $term->count
132
- ) : '';
133
- $tag = $this->config->show_links ? 'a' : 'span';
 
 
 
 
 
 
 
134
 
135
  $terms[] = sprintf(
136
  '%s<%s class="tag-link-%s" href="%s" style="font-size:%s%s"%s>%s</%s>%s',
@@ -141,7 +147,7 @@ class UTCW_Render
141
  $term->size,
142
  $color,
143
  $title,
144
- $term->name,
145
  $tag,
146
  $this->config->suffix
147
  );
@@ -327,6 +333,59 @@ class UTCW_Render
327
  }
328
  }
329
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  /**
331
  * Checks if option still has the default value
332
  *
1
  <?php
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage main
31
  /**
32
  * Reference to the current configuration
33
  *
34
+ * @var UTCW_RenderConfig
35
  * @since 2.0
36
  */
37
  private $config;
98
  $markup = array();
99
 
100
  if ($this->css) {
101
+ $markup[] = $this->plugin->applyFilters('utcw_render_css', $this->css);
102
  }
103
 
104
  if ($this->config->before_widget) {
119
 
120
  $markup[] = '<div class="tagcloud utcw-' . $this->id . '">';
121
 
122
+ $termObjects = $this->plugin->applyFilters('utcw_render_terms', $this->data->getTerms());
123
+
124
  $terms = array();
125
 
126
+ foreach ($termObjects as $term) {
127
  $color = $term->color ? ';color:' . $term->color : '';
128
+
129
+ $title = '';
130
+
131
+ if ($this->config->show_title) {
132
+ $title = $this->getTitle($term);
133
+ }
134
+
135
+ $tag = $this->config->show_links ? 'a' : 'span';
136
+ $tag = $this->plugin->applyFilters('utcw_render_tag', $tag);
137
+
138
+ $displayName = $this->config->show_post_count ? sprintf('%s (%d)', $term->name, $term->count) : $term->name;
139
+ $displayName = $this->plugin->applyFilters('utcw_render_term_display_name', $displayName, $term->name);
140
 
141
  $terms[] = sprintf(
142
  '%s<%s class="tag-link-%s" href="%s" style="font-size:%s%s"%s>%s</%s>%s',
147
  $term->size,
148
  $color,
149
  $title,
150
+ $displayName,
151
  $tag,
152
  $this->config->suffix
153
  );
333
  }
334
  }
335
 
336
+ /**
337
+ * Returns the title attribute for the given term
338
+ *
339
+ * @param UTCW_Term $term
340
+ *
341
+ * @return string
342
+ * @since 2.4
343
+ */
344
+ private function getTitle(UTCW_Term $term)
345
+ {
346
+ $title = '';
347
+
348
+ switch ($this->config->title_type) {
349
+ case 'counter':
350
+ $term_title_singular = $this->plugin->applyFilters('utcw_render_term_title_singular', '%d topic');
351
+ $term_title_plural = $this->plugin->applyFilters('utcw_render_term_title_plural', '%d topics');
352
+
353
+ $title = _n($term_title_singular, $term_title_plural, $term->count);
354
+
355
+ if (strpos($title, '%d') !== false) {
356
+ $title = sprintf(' title="' . $title . '"', $term->count);
357
+ }
358
+ break;
359
+
360
+ case 'name':
361
+ $title = sprintf(' title="%s"', $term->name);
362
+ break;
363
+
364
+ case 'custom':
365
+ $template = $this->config->title_custom_template;
366
+ $stringPosition = strpos($template, '%s');
367
+ $numberPosition = strpos($template, '%d');
368
+ $containsString = $stringPosition !== false;
369
+ $containsNumber = $numberPosition !== false;
370
+ $stringFirst = $stringPosition < $numberPosition;
371
+
372
+ if ($containsString && $containsNumber && $stringFirst) {
373
+ $title = sprintf(' title="' . $template . '"', $term->name, $term->count);
374
+ } elseif ($containsString && $containsNumber) {
375
+ $title = sprintf(' title="' . $template . '"', $term->count, $term->name);
376
+ } elseif ($containsString) {
377
+ $title = sprintf(' title="' . $template . '"', $term->name);
378
+ } elseif ($containsNumber) {
379
+ $title = sprintf(' title="' . $template . '"', $term->count);
380
+ } else {
381
+ $title = sprintf(' title="%s"', $template);
382
+ }
383
+ break;
384
+ }
385
+
386
+ return $title;
387
+ }
388
+
389
  /**
390
  * Checks if option still has the default value
391
  *
src/Selection/PopularityStrategy.php CHANGED
@@ -1,24 +1,15 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW\Selection;
4
-
5
  /**
6
  * Ultimate Tag Cloud Widget
7
  *
8
  * @author Rickard Andersson <rickard@0x539.se>
9
- * @version 2.3.1
10
  * @license GPLv2
11
  * @package utcw
12
  * @subpackage language
13
  * @since 2.2
14
  */
15
 
16
- //use Rickard\UTCW\Config;
17
- //use Rickard\UTCW\Database\QueryBuilder;
18
- //use Rickard\UTCW\Plugin;
19
- //use \stdClass;
20
- //use wpdb;
21
-
22
  /**
23
  * Class to select the most popular terms from the DB
24
  *
1
  <?php
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.3
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage language
10
  * @since 2.2
11
  */
12
 
 
 
 
 
 
 
13
  /**
14
  * Class to select the most popular terms from the DB
15
  *
src/Selection/RandomStrategy.php CHANGED
@@ -1,24 +1,15 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW\Selection;
4
-
5
  /**
6
  * Ultimate Tag Cloud Widget
7
  *
8
  * @author Rickard Andersson <rickard@0x539.se>
9
- * @version 2.3.1
10
  * @license GPLv2
11
  * @package utcw
12
  * @subpackage language
13
  * @since 2.2
14
  */
15
 
16
- //use Rickard\UTCW\Config;
17
- //use Rickard\UTCW\Database\QueryBuilder;
18
- //use Rickard\UTCW\Plugin;
19
- //use stdClass;
20
- //use wpdb;
21
-
22
  /**
23
  * Class to select a random set of terms from the DB
24
  *
1
  <?php
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage language
10
  * @since 2.2
11
  */
12
 
 
 
 
 
 
 
13
  /**
14
  * Class to select a random set of terms from the DB
15
  *
src/Selection/SelectionStrategy.php CHANGED
@@ -1,23 +1,15 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW\Selection;
4
-
5
  /**
6
  * Ultimate Tag Cloud Widget
7
  *
8
  * @author Rickard Andersson <rickard@0x539.se>
9
- * @version 2.3.1
10
  * @license GPLv2
11
  * @package utcw
12
  * @subpackage selection
13
  * @since 2.2
14
  */
15
 
16
- //use Rickard\UTCW\Config;
17
- //use Rickard\UTCW\Plugin;
18
- //use \stdClass;
19
- //use wpdb;
20
-
21
  /**
22
  * Abstract class to define selection strategy for finding terms
23
  *
1
  <?php
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage selection
10
  * @since 2.2
11
  */
12
 
 
 
 
 
 
13
  /**
14
  * Abstract class to define selection strategy for finding terms
15
  *
src/ShortCode.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class UTCW_ShortCode
4
+ {
5
+
6
+ /**
7
+ * @var UTCW_Plugin
8
+ * @since 2.4
9
+ */
10
+ protected $plugin;
11
+
12
+ /**
13
+ * @param UTCW_Plugin $plugin
14
+ *
15
+ * @since 2.4
16
+ */
17
+ public function __construct(UTCW_Plugin $plugin)
18
+ {
19
+ $this->plugin = $plugin;
20
+
21
+ add_shortcode('utcw', array($this, 'render'));
22
+ }
23
+
24
+ /**
25
+ * @since 2.4
26
+ */
27
+ public function triggerPreShortCode()
28
+ {
29
+ global $post;
30
+
31
+ if ($post && isset($post->post_content) && $this->hasShortCode($post->post_content)) {
32
+ do_action('utcw_pre_shortcode');
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Check if the content contains the shortcode. Will use WP 3.6+ has_shortcode if available, otherwise
38
+ * fall back to string matching.
39
+ *
40
+ * @param $content
41
+ *
42
+ * @return bool
43
+ * @since 2.4
44
+ */
45
+ protected function hasShortCode($content)
46
+ {
47
+ if (function_exists('has_shortcode')) {
48
+ return has_shortcode($content, 'utcw');
49
+ }
50
+
51
+ return strpos($content, '[utcw') !== false;
52
+ }
53
+
54
+
55
+ /**
56
+ * Short code handler for 'utcw' hook
57
+ *
58
+ * @param array $args
59
+ *
60
+ * @return string
61
+ * @since 2.4
62
+ */
63
+ public function render(array $args)
64
+ {
65
+ global $wpdb;
66
+
67
+ if (isset($args['load_config'])) {
68
+ $loaded = $this->plugin->loadConfiguration($args['load_config']);
69
+
70
+ if (is_array($loaded)) {
71
+ $args = $loaded;
72
+ }
73
+ }
74
+
75
+ $this->plugin->set('wpdb', $wpdb);
76
+ $this->plugin->set('dataConfig', new UTCW_DataConfig($args, $this->plugin));
77
+ $this->plugin->set('renderConfig', new UTCW_RenderConfig($args, $this->plugin));
78
+ $this->plugin->set('data', new UTCW_Data($this->plugin));
79
+
80
+ $render = new UTCW_Render($this->plugin);
81
+
82
+ do_action('utcw_shortcode', $args);
83
+
84
+ return apply_filters('filter_shortcode', $render->getCloud());
85
+ }
86
+ }
src/Term.php CHANGED
@@ -1,14 +1,9 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW;
4
-
5
- //use stdClass;
6
-
7
  /**
8
  * Ultimate Tag Cloud Widget
9
  *
10
  * @author Rickard Andersson <rickard@0x539.se>
11
- * @version 2.3.1
12
  * @license GPLv2
13
  * @package utcw
14
  * @subpackage main
1
  <?php
 
 
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage main
src/Widget.php CHANGED
@@ -1,14 +1,9 @@
1
  <?php
2
-
3
- //namespace Rickard\UTCW;
4
-
5
- //use WP_Widget;
6
-
7
  /**
8
  * Ultimate Tag Cloud Widget
9
  *
10
  * @author Rickard Andersson <rickard@0x539.se>
11
- * @version 2.3.1
12
  * @license GPLv2
13
  * @package utcw
14
  * @subpackage main
1
  <?php
 
 
 
 
 
2
  /**
3
  * Ultimate Tag Cloud Widget
4
  *
5
  * @author Rickard Andersson <rickard@0x539.se>
6
+ * @version 2.4
7
  * @license GPLv2
8
  * @package utcw
9
  * @subpackage main
ultimate-tag-cloud-widget.php CHANGED
@@ -1,11 +1,9 @@
1
  <?php
2
- //use Rickard\UTCW\Plugin;
3
-
4
  /*
5
- Plugin Name: Ultimate tag cloud widget
6
  Plugin URI: https://www.0x539.se/wordpress/ultimate-tag-cloud-widget/
7
  Description: This plugin aims to be the most configurable tag cloud widget out there.
8
- Version: 2.3.1
9
  Author: Rickard Andersson
10
  Author URI: https://www.0x539.se
11
  License: GPLv2
@@ -17,7 +15,7 @@ License: GPLv2
17
  * @var string
18
  * @since 2.0
19
  */
20
- define('UTCW_VERSION', '2.3.1');
21
 
22
  /**
23
  * If development mode is currently enabled
@@ -51,33 +49,47 @@ define('UTCW_DECIMAL_REGEX', '\d+(\.\d+)?');
51
  */
52
  define('UTCW_HEX_COLOR_FORMAT', '#%02x%02x%02x');
53
 
54
- $__prefix = UTCW_DEV ? '/www/utcw2/' : '';
55
 
56
- require_once $__prefix . 'src/Plugin.php';
57
- require_once $__prefix . 'src/Widget.php';
58
- require_once $__prefix . 'src/Data.php';
59
- require_once $__prefix . 'src/Render.php';
60
- require_once $__prefix . 'src/Term.php';
61
- require_once $__prefix . 'src/Language/TranslationHandler.php';
62
- require_once $__prefix . 'src/Language/QTranslateHandler.php';
63
- require_once $__prefix . 'src/Language/WPMLHandler.php';
64
- require_once $__prefix . 'src/Selection/SelectionStrategy.php';
65
- require_once $__prefix . 'src/Selection/PopularityStrategy.php';
66
- require_once $__prefix . 'src/Selection/RandomStrategy.php';
67
- require_once $__prefix . 'src/Database/QueryBuilder.php';
68
- require_once $__prefix . 'src/Config/Config.php';
69
- require_once $__prefix . 'src/Config/DataConfig.php';
70
- require_once $__prefix . 'src/Config/RenderConfig.php';
71
- require_once $__prefix . 'src/Config/Type/Type.php';
72
- require_once $__prefix . 'src/Config/Type/SetType.php';
73
- require_once $__prefix . 'src/Config/Type/ColorType.php';
74
- require_once $__prefix . 'src/Config/Type/ArrayType.php';
75
- require_once $__prefix . 'src/Config/Type/IntegerType.php';
76
- require_once $__prefix . 'src/Config/Type/MeasurementType.php';
77
- require_once $__prefix . 'src/Config/Type/StringType.php';
78
- require_once $__prefix . 'src/Config/Type/BooleanType.php';
 
 
 
 
 
 
 
 
 
 
79
 
80
- unset($__prefix);
 
 
 
 
 
81
 
82
  // Instantiates the plugin
83
  UTCW_Plugin::getInstance();
@@ -91,6 +103,8 @@ UTCW_Plugin::getInstance();
91
  */
92
  function do_utcw(array $args)
93
  {
94
- $plugin = UTCW_Plugin::getInstance();
95
- echo $plugin->shortcode($args);
 
 
96
  }
1
  <?php
 
 
2
  /*
3
+ Plugin Name: Ultimate Tag Cloud Widget
4
  Plugin URI: https://www.0x539.se/wordpress/ultimate-tag-cloud-widget/
5
  Description: This plugin aims to be the most configurable tag cloud widget out there.
6
+ Version: 2.4
7
  Author: Rickard Andersson
8
  Author URI: https://www.0x539.se
9
  License: GPLv2
15
  * @var string
16
  * @since 2.0
17
  */
18
+ define('UTCW_VERSION', '2.4');
19
 
20
  /**
21
  * If development mode is currently enabled
49
  */
50
  define('UTCW_HEX_COLOR_FORMAT', '#%02x%02x%02x');
51
 
 
52
 
53
+ function utcw_load()
54
+ {
55
+ $prefix = UTCW_DEV ? '/www/utcw2/src/' : 'src/';
56
+ $files = array(
57
+ 'Plugin.php',
58
+ 'ShortCode.php',
59
+ 'Widget.php',
60
+ 'Data.php',
61
+ 'Render.php',
62
+ 'Term.php',
63
+ 'Handler/Handler.php',
64
+ 'Handler/HandlerFactory.php',
65
+ 'Language/TranslationHandler.php',
66
+ 'Language/QTranslateHandler.php',
67
+ 'Language/WPMLHandler.php',
68
+ 'Selection/SelectionStrategy.php',
69
+ 'Selection/PopularityStrategy.php',
70
+ 'Selection/RandomStrategy.php',
71
+ 'Database/QueryBuilder.php',
72
+ 'Config/Config.php',
73
+ 'Config/DataConfig.php',
74
+ 'Config/RenderConfig.php',
75
+ 'Config/Type/Type.php',
76
+ 'Config/Type/SetType.php',
77
+ 'Config/Type/ColorType.php',
78
+ 'Config/Type/ArrayType.php',
79
+ 'Config/Type/IntegerType.php',
80
+ 'Config/Type/MeasurementType.php',
81
+ 'Config/Type/StringType.php',
82
+ 'Config/Type/BooleanType.php',
83
+ 'Cache/WPSuperCacheHandler.php',
84
+ 'Cache/W3TotalCacheHandler.php',
85
+ );
86
 
87
+ foreach ($files as $file) {
88
+ require_once $prefix . $file;
89
+ }
90
+ }
91
+
92
+ utcw_load();
93
 
94
  // Instantiates the plugin
95
  UTCW_Plugin::getInstance();
103
  */
104
  function do_utcw(array $args)
105
  {
106
+ $plugin = UTCW_Plugin::getInstance();
107
+ $shortCode = new UTCW_ShortCode($plugin);
108
+
109
+ echo $shortCode->render($args);
110
  }