WordPress Popular Posts - Version 5.5.0

Version Description

  • Adds the Sort by Average Daily Views option from the classic widget to the WordPress Popular Posts block.
  • Adds the WordPress Date Format option from the classic widget to the WordPress Popular Posts block (please see announcements for details).
  • Adds new Content Tags: author_name and author_url.
  • Improves cached data garbage collection.
  • Other minor performances improvements and fixes.

Release notes

Download this release

Release Info

Developer hcabrera
Plugin Icon 128x128 WordPress Popular Posts
Version 5.5.0
Comparing to
See all releases

Code changes from version 5.4.2 to 5.5.0

assets/css/wpp.css CHANGED
@@ -52,6 +52,10 @@ Use the following classes to style your popular posts list as you like.
52
  font-size: 0.8em;
53
  }
54
 
 
 
 
 
55
  /* Comments count styles */
56
  .wpp-comments {
57
  }
52
  font-size: 0.8em;
53
  }
54
 
55
+ .wpp-meta:empty, .post-stats:empty {
56
+ display: none;
57
+ }
58
+
59
  /* Comments count styles */
60
  .wpp-comments {
61
  }
assets/js/blocks/block-wpp-widget.asset.php CHANGED
@@ -1 +1 @@
1
- <?php return array('dependencies' => array('wp-polyfill'), 'version' => '2951ca110f8bc048797ca7e3ec49e87b');
1
+ <?php return array('dependencies' => array(), 'version' => 'bd6367a58d4de200ed825558aaf46c2c');
assets/js/blocks/block-wpp-widget.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function a(s){if(t[s])return t[s].exports;var r=t[s]={i:s,l:!1,exports:{}};return e[s].call(r.exports,r,r.exports,a),r.l=!0,r.exports}a.m=e,a.c=t,a.d=function(e,t,s){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(a.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)a.d(s,r,function(t){return e[t]}.bind(null,r));return s},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,a){"use strict";a.r(t);var s={};s.flame=React.createElement("svg",{viewBox:"0 0 248 379"},React.createElement("path",{fill:"#fff",d:"M-83,96q0-122.5,0-245H165q0,131,0,262a31.87,31.87,0,0,1-.95-4.33A123.87,123.87,0,0,0,153.47,68.3c-12.28-27.74-31.1-50.64-53-71.21C75.67-26.13,55.85-52,54.32-87.87c-.79-18.47.81-36.24,11.59-52.15,1.08-1.59.38-4.4.5-6.64-2.43.1-5.5-.7-7.18.47a140.91,140.91,0,0,0-17.12,13.72C19.49-110.67,3-84.6-9.51-56A149,149,0,0,0-21.86-3.77c-2,39.4,11.38,73.46,36.17,103.51,1.74,2.11,3.51,4.2,5.27,6.3l-.67,1.07c-3.94-1.07-8-1.83-11.82-3.24C-25.17,91.94-52.36,58.57-51.12,21c.1-2.91.21-6.45-3.51-6.49-2,0-4.76,2.16-5.79,4.09-9.4,17.55-16.35,36-19.73,55.73C-81.38,81.49-82.07,88.76-83,96Z",transform:"translate(83 149)"}),React.createElement("path",{fill:"#ba2f2f",d:"M-83,96c.93-7.24,1.62-14.51,2.85-21.7,3.38-19.69,10.33-38.18,19.73-55.73,1-1.93,3.83-4.11,5.79-4.09,3.72,0,3.61,3.58,3.51,6.49-1.25,37.59,25.94,71,58.2,82.89,3.82,1.41,7.87,2.18,11.82,3.24l.67-1.07c-1.76-2.1-3.52-4.19-5.27-6.3C-10.49,69.68-23.88,35.63-21.86-3.77A149,149,0,0,1-9.51-56c12.48-28.62,29-54.69,51.62-76.5a140.91,140.91,0,0,1,17.12-13.72c1.68-1.18,4.75-.37,7.18-.47-.13,2.24.58,5-.5,6.64-10.78,15.9-12.37,33.68-11.59,52.15,1.53,35.89,21.35,61.74,46.11,85,21.94,20.57,40.76,43.47,53,71.21a123.87,123.87,0,0,1,10.59,40.36A31.87,31.87,0,0,0,165,113v9c-.7,4.24-1.17,8.54-2.13,12.73-10.74,46.51-37.08,78.75-84.34,91.58C72.16,228,65.52,228.79,59,230H43a25.19,25.19,0,0,0-3.12-1.18c-10-2.37-20.21-4.12-30-7.12-45.83-14-75.19-44.64-89-90.24-2.28-7.52-2.64-15.63-3.88-23.46Q-83,102-83,96ZM61.63-143.61c-6.24,5.39-12.87,10.38-18.64,16.22A229,229,0,0,0-8.77-46.26,138.37,138.37,0,0,0-16.63,23c4.69,32.54,20.21,59.59,42.4,83.23,1.34,1.43,2.7,2.83,4.8,5-15.23,1-28-3.3-39.74-10.64-29.74-18.62-46-45.23-46.8-81a138.75,138.75,0,0,0-7.46,14.67A178.29,178.29,0,0,0-78.24,93.09C-80.9,129.7-68,160.25-42.78,185.71c28.91,29.16,65.19,41.42,105.43,38.91,43.82-2.73,80.34-35.08,93.53-79.39,8.68-29.18,3.11-56.71-10.29-83.15C134.15,38.92,117.71,19.34,99,1.57,85-11.65,71.34-25.28,62.72-42.69,46.33-75.79,44.36-109.22,61.63-143.61Z",transform:"translate(83 149)"}),React.createElement("path",{fill:"#fff",d:"M-83,108c1.25,7.84,1.61,15.94,3.88,23.46,13.79,45.6,43.15,76.21,89,90.24,9.82,3,20,4.76,30,7.12A25.19,25.19,0,0,1,43,230H-83Q-83,169-83,108Z",transform:"translate(83 149)"}),React.createElement("path",{fill:"#fff",d:"M59,230c6.52-1.21,13.16-2,19.53-3.69,47.26-12.83,73.6-45.07,84.34-91.58,1-4.18,1.43-8.48,2.13-12.73V230Z",transform:"translate(83 149)"}),React.createElement("path",{fill:"#ba2f2f",d:"M61.63-143.61c-17.28,34.39-15.3,67.82,1.09,100.92C71.34-25.28,85-11.65,99,1.57c18.75,17.77,35.2,37.35,46.94,60.51,13.4,26.44,19,54,10.29,83.15-13.18,44.31-49.71,76.66-93.53,79.39-40.25,2.51-76.52-9.75-105.43-38.91C-68,160.25-80.9,129.7-78.24,93.09A178.29,178.29,0,0,1-63.45,34.31,138.75,138.75,0,0,1-56,19.64c.77,35.79,17.06,62.4,46.8,81C2.54,108,15.33,112.3,30.56,111.3c-2.1-2.21-3.46-3.62-4.8-5C3.57,82.62-11.94,55.57-16.63,23A138.37,138.37,0,0,1-8.77-46.26,229,229,0,0,1,43-127.38C48.76-133.23,55.39-138.22,61.63-143.61Z",transform:"translate(83 149)"}));var r=s;function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var a=0;a<t.length;a++){var s=t[a];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){return!t||"object"!==o(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var u=wp.serverSideRender,c=wp.element,m=c.Component,d=c.Fragment,h=wp.blockEditor.BlockControls,f=wp.components,b=f.Button,_=f.CheckboxControl,g=f.Disabled,y=f.SelectControl,v=f.Spinner,w=f.TextareaControl,x=f.TextControl,R=f.Toolbar,__=wp.i18n.__,E="wordpress-popular-posts/v1",C=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(c,e);var t,a,s,r,o=(s=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=p(s);if(r){var a=p(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return i(this,e)});function c(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),(t=o.call(this,e)).state={error:null,editMode:!0,themes:null,imgSizes:null,taxonomies:null},t}return t=c,(a=[{key:"componentDidMount",value:function(){var e=this.props.attributes;this.getThemes(),this.getImageSizes(),this.getTaxonomies(),this.setState({editMode:e._editMode})}},{key:"getThemes",value:function(){var e=this;wp.apiFetch({path:E+"/themes"}).then((function(t){e.setState({themes:t})}),(function(t){e.setState({error:t,themes:null})}))}},{key:"getImageSizes",value:function(){var e=this;wp.apiFetch({path:E+"/thumbnails"}).then((function(t){e.setState({imgSizes:t})}),(function(t){e.setState({error:t,imgSizes:null})}))}},{key:"getTaxonomies",value:function(){var e=this,t=this.props.attributes;wp.apiFetch({path:E+"/taxonomies"}).then((function(a){if(a){var s=t.tax.split(";"),r=t.term_id.split(";");if(s.length&&s.length==r.length){for(var o={},n=0;n<s.length;n++)o[s[n]]=r[n];for(var l in a)a[l]._terms=void 0!==o[l]?o[l]:""}}e.setState({taxonomies:a})}),(function(t){e.setState({error:t,taxonomies:null})}))}},{key:"getBlockControls",value:function(){var e=this.props.setAttributes,t=this;return React.createElement(h,null,React.createElement(R,null,React.createElement(b,{label:this.state.editMode?__("Preview","wordpress-popular-posts"):__("Edit","wordpress-popular-posts"),icon:this.state.editMode?"format-image":"edit",onClick:function(){var a=!t.state.editMode;t.setState({editMode:a}),e({_editMode:a})}})))}},{key:"getMainFields",value:function(){var e=this.props,t=e.attributes,a=e.setAttributes;return React.createElement(d,null,React.createElement(x,{label:__("Title","wordpress-popular-posts"),value:t.title,onChange:function(e){e=function(e){var t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&grave;"};return e.replace(/[&<>"'/]/gi,(function(e){return t[e]}))}(function(e){var t=document.createElement("div");t.innerHTML=e;var a=t.childNodes[0];return a?a.nodeValue:""}(e)),a({title:e})}}),React.createElement(x,{label:__("Limit","wordpress-popular-posts"),value:t.limit,onChange:function(e){var t=Number.isInteger(Number(e))&&Number(e)>0?e:10;a({limit:Number(t)})}}),React.createElement(y,{label:__("Sort posts by","wordpress-popular-posts"),value:t.order_by,options:[{label:__("Total views","wordpress-popular-posts"),value:"views"},{label:__("Comments","wordpress-popular-posts"),value:"comments"}],onChange:function(e){a({order_by:e})}}),React.createElement(y,{label:__("Time Range","wordpress-popular-posts"),value:t.range,options:[{label:__("Last 24 Hours","wordpress-popular-posts"),value:"last24hours"},{label:__("Last 7 days","wordpress-popular-posts"),value:"last7days"},{label:__("Last 30 days","wordpress-popular-posts"),value:"last30days"},{label:__("All-time","wordpress-popular-posts"),value:"all"},{label:__("Custom","wordpress-popular-posts"),value:"custom"}],onChange:function(e){a({range:e})}}),"custom"==t.range&&React.createElement("div",{className:"option-subset"},React.createElement(x,{label:__("Time Quantity","wordpress-popular-posts"),value:t.time_quantity,onChange:function(e){var t=Number.isInteger(Number(e))&&Number(e)>0?e:24;a({time_quantity:Number(t)})}}),React.createElement(y,{label:__("Time Unit","wordpress-popular-posts"),value:t.time_unit,options:[{label:__("Minute(s)","wordpress-popular-posts"),value:"minute"},{label:__("Hour(s)","wordpress-popular-posts"),value:"hour"},{label:__("Day(s)","wordpress-popular-posts"),value:"day"}],onChange:function(e){a({time_unit:e})}})),React.createElement(_,{label:__("Display only posts published within the selected Time Range","wordpress-popular-posts"),checked:t.freshness,onChange:function(e){a({freshness:e})}}))}},{key:"getFiltersFields",value:function(){var e=this.props,t=e.attributes,a=e.setAttributes,s=this,r=[];if(this.state.taxonomies)for(var o in this.state.taxonomies)r.push({name:this.state.taxonomies[o].name,label:this.state.taxonomies[o].labels.singular_name+" ("+this.state.taxonomies[o].name+")",terms:this.state.taxonomies[o]._terms});return React.createElement(d,null,React.createElement("p",{className:"not-a-legend"},React.createElement("strong",null,__("Filters","wordpress-popular-posts"))),React.createElement(x,{label:__("Post type(s)","wordpress-popular-posts"),help:__("Post types must be comma separated.","wordpress-popular-posts"),value:t.post_type,onChange:function(e){var t=e.replace(/[^a-z0-9-_\,]+/gi,"");a({post_type:t})}}),React.createElement(x,{label:__("Post ID(s) to exclude","wordpress-popular-posts"),help:__("IDs must be comma separated.","wordpress-popular-posts"),value:t.pid,onChange:function(e){var t=e.replace(/[^0-9\,]/g,"");a({pid:t})}}),React.createElement(x,{label:__("Author ID(s)","wordpress-popular-posts"),help:__("IDs must be comma separated.","wordpress-popular-posts"),value:t.author,onChange:function(e){var t=e.replace(/[^0-9\,]/g,"");a({author:t})}}),r&&r.filter((function(e){return"post_format"!=e.name})).map((function(e){return React.createElement(x,{label:e.label,help:__("Term IDs must be comma separated, prefix a minus sign to exclude.","wordpress-popular-posts"),value:e.terms,onChange:function(t){return function(e,t){var a=s.state.taxonomies;t=t.replace(/[^0-9-\,]/g,""),a&&void 0!==a[e]&&(a[e]._terms=t,s.setState({taxonomies:a}))}(e.name,t)},onBlur:function(){return function(e){var t=s.state.taxonomies;if(t&&void 0!==t[e]){var r=t[e]._terms.split(",");r.length&&(r=r.map((function(e){return e.trim()})).filter((function(e){return""!=e&&"-"!=e}))),r.length&&(r=Array.from(new Set(r))),t[e]._terms=r.join(","),s.setState({taxonomies:t});var o="",n="";for(var l in s.state.taxonomies)if(s.state.taxonomies.hasOwnProperty(l)){if(!s.state.taxonomies[l]._terms.length)continue;o+=l+";",n+=s.state.taxonomies[l]._terms+";"}o&&n&&(o=o.replace(new RegExp(";$"),""),n=n.replace(new RegExp(";$"),"")),a({tax:o,term_id:n})}}(e.name)}})})))}},{key:"getPostSettingsFields",value:function(){var e=this.props,t=e.attributes,a=e.setAttributes,s=this;function r(e,t){var s=Number.isInteger(Number(t))&&Number(t)>=0?t:0;a("width"==e?{thumbnail_width:Number(s)}:{thumbnail_height:Number(s)})}var o=[];if(this.state.imgSizes)for(var n in this.state.imgSizes)o.push({label:n,value:n});return React.createElement(d,null,React.createElement("p",{className:"not-a-legend"},React.createElement("strong",null,__("Posts settings","wordpress-popular-posts"))),React.createElement(_,{label:__("Shorten title","wordpress-popular-posts"),checked:t.shorten_title,onChange:function(e){a(0==e?{title_length:0,title_by_words:0,shorten_title:e}:{shorten_title:e,title_length:25})}}),t.shorten_title&&React.createElement("div",{className:"option-subset"},React.createElement(x,{label:__("Shorten title to","wordpress-popular-posts"),value:t.title_length,onChange:function(e){var t=Number.isInteger(Number(e))&&Number(e)>=0?e:0;a({title_length:Number(t)})}}),React.createElement(y,{value:t.title_by_words,options:[{label:__("characters","wordpress-popular-posts"),value:0},{label:__("words","wordpress-popular-posts"),value:1}],onChange:function(e){return a({title_by_words:Number(e)})}})),React.createElement(_,{label:__("Display post excerpt","wordpress-popular-posts"),checked:t.display_post_excerpt,onChange:function(e){a(0==e?{excerpt_length:0,excerpt_by_words:0,display_post_excerpt:e}:{display_post_excerpt:e,excerpt_length:55})}}),t.display_post_excerpt&&React.createElement("div",{className:"option-subset"},React.createElement(_,{label:__("Keep text format and links","wordpress-popular-posts"),checked:t.excerpt_format,onChange:function(e){return a({excerpt_format:e})}}),React.createElement(x,{label:__("Excerpt length","wordpress-popular-posts"),value:t.excerpt_length,onChange:function(e){var t=Number.isInteger(Number(e))&&Number(e)>=0?e:0;a({excerpt_length:Number(t)})}}),React.createElement(y,{value:t.excerpt_by_words,options:[{label:__("characters","wordpress-popular-posts"),value:0},{label:__("words","wordpress-popular-posts"),value:1}],onChange:function(e){return a({excerpt_by_words:Number(e)})}})),React.createElement(_,{label:__("Display post thumbnail","wordpress-popular-posts"),checked:t.display_post_thumbnail,onChange:function(e){a(0==e?{thumbnail_width:0,thumbnail_height:0,display_post_thumbnail:e}:{thumbnail_width:75,thumbnail_height:75,display_post_thumbnail:e})}}),t.display_post_thumbnail&&React.createElement("div",{className:"option-subset"},React.createElement(y,{value:t.thumbnail_build,options:[{label:__("Set size manually","wordpress-popular-posts"),value:"manual"},{label:__("Use predefined size","wordpress-popular-posts"),value:"predefined"}],onChange:function(e){"predefined"==e&&a({thumbnail_width:s.state.imgSizes[o[0].value].width,thumbnail_height:s.state.imgSizes[o[0].value].height,thumbnail_size:o[0].value}),a({thumbnail_build:e})}}),"manual"==t.thumbnail_build&&React.createElement(d,null,React.createElement(x,{label:__("Thumbnail width","wordpress-popular-posts"),help:__("Size in px units (pixels)","wordpress-popular-posts"),value:t.thumbnail_width,onChange:function(e){return r("width",e)}}),React.createElement(x,{label:__("Thumbnail height","wordpress-popular-posts"),help:__("Size in px units (pixels)","wordpress-popular-posts"),value:t.thumbnail_height,onChange:function(e){return r("height",e)}})),"predefined"==t.thumbnail_build&&React.createElement(d,null,React.createElement(y,{value:t.thumbnail_size,options:o,onChange:function(e){a({thumbnail_width:s.state.imgSizes[e].width,thumbnail_height:s.state.imgSizes[e].height,thumbnail_size:e})}}))))}},{key:"getStatsTagFields",value:function(){var e=this.props,t=e.attributes,a=e.setAttributes,s=[];if(this.state.taxonomies)for(var r in this.state.taxonomies)s.push({label:this.state.taxonomies[r].labels.singular_name+" ("+this.state.taxonomies[r].name+")",value:this.state.taxonomies[r].name});return React.createElement(d,null,React.createElement("p",{className:"not-a-legend"},React.createElement("strong",null,__("Stats Tag settings","wordpress-popular-posts"))),React.createElement(_,{label:__("Display comments count","wordpress-popular-posts"),checked:t.stats_comments,onChange:function(e){return a({stats_comments:e})}}),React.createElement(_,{label:__("Display views","wordpress-popular-posts"),checked:t.stats_views,onChange:function(e){return a({stats_views:e})}}),React.createElement(_,{label:__("Display author","wordpress-popular-posts"),checked:t.stats_author,onChange:function(e){return a({stats_author:e})}}),React.createElement(_,{label:__("Display date","wordpress-popular-posts"),checked:t.stats_date,onChange:function(e){return a({stats_date:e})}}),t.stats_date&&React.createElement("div",{className:"option-subset"},React.createElement(y,{label:__("Date Format","wordpress-popular-posts"),value:t.stats_date_format,options:[{label:__("Relative","wordpress-popular-posts"),value:"relative"},{label:__("Month Day, Year","wordpress-popular-posts"),value:"F j, Y"},{label:__("yyyy/mm/dd","wordpress-popular-posts"),value:"Y/m/d"},{label:__("mm/dd/yyyy","wordpress-popular-posts"),value:"m/d/Y"},{label:__("dd/mm/yyyy","wordpress-popular-posts"),value:"d/m/Y"}],onChange:function(e){return a({stats_date_format:e})}})),React.createElement(_,{label:__("Display taxonomy","wordpress-popular-posts"),checked:t.stats_taxonomy,onChange:function(e){return a({stats_taxonomy:e})}}),t.stats_taxonomy&&React.createElement("div",{className:"option-subset"},React.createElement(y,{label:__("Taxonomy","wordpress-popular-posts"),value:t.taxonomy,options:s,onChange:function(e){return a({taxonomy:e})}})))}},{key:"getHTMLMarkupFields",value:function(){var e=this.props,t=e.attributes,a=e.setAttributes,s=this,r=[{label:__("None","wordpress-popular-posts"),value:""}];if(this.state.themes)for(var o in this.state.themes)r.push({label:this.state.themes[o].json.name,value:o});return React.createElement(d,null,React.createElement("p",{className:"not-a-legend"},React.createElement("strong",null,__("HTML Markup settings","wordpress-popular-posts"))),React.createElement(_,{label:__("Use custom HTML Markup","wordpress-popular-posts"),checked:t.custom_html,onChange:function(e){return a({custom_html:e})}}),t.custom_html&&React.createElement("div",{className:"option-subset"},React.createElement(w,{rows:"1",label:__("Before title","wordpress-popular-posts"),value:t.header_start,onChange:function(e){return a({header_start:e})}}),React.createElement(w,{rows:"1",label:__("After title","wordpress-popular-posts"),value:t.header_end,onChange:function(e){return a({header_end:e})}}),React.createElement(w,{rows:"1",label:__("Before popular posts","wordpress-popular-posts"),value:t.wpp_start,onChange:function(e){return a({wpp_start:e})}}),React.createElement(w,{rows:"1",label:__("After popular posts","wordpress-popular-posts"),value:t.wpp_end,onChange:function(e){return a({wpp_end:e})}}),React.createElement(w,{label:__("Post HTML markup","wordpress-popular-posts"),value:t.post_html,onChange:function(e){return a({post_html:e})}})),React.createElement(y,{label:__("Theme","wordpress-popular-posts"),value:t.theme,options:r,onChange:function(e){if(void 0!==s.state.themes[e]){var t=s.state.themes[e].json.config;a({shorten_title:t.shorten_title.active,title_length:t.shorten_title.title_length,title_by_words:t.shorten_title.words?1:0,display_post_excerpt:t["post-excerpt"].active,excerpt_format:t["post-excerpt"].format,excerpt_length:t["post-excerpt"].length,excerpt_by_words:t["post-excerpt"].words?1:0,display_post_thumbnail:t.thumbnail.active,thumbnail_build:t.thumbnail.build,thumbnail_width:t.thumbnail.width,thumbnail_height:t.thumbnail.height,stats_comments:t.stats_tag.comment_count,stats_views:t.stats_tag.views,stats_author:t.stats_tag.author,stats_date:t.stats_tag.date.active,stats_date_format:t.stats_tag.date.format,stats_taxonomy:t.stats_tag.taxonomy.active,taxonomy:t.stats_tag.taxonomy.name,custom_html:!0,wpp_start:t.markup["wpp-start"],wpp_end:t.markup["wpp-end"],post_html:t.markup["post-html"],theme:e})}else a({theme:e})}}))}},{key:"render",value:function(){if(!this.state.taxonomies||!this.state.themes||!this.state.imgSizes)return React.createElement(v,null);var e=this.props,t=e.isSelected,a=e.className,s=e.attributes,r=a;return r+=this.state.editMode?" in-edit-mode":" in-preview-mode",r+=t?" is-selected":"",[this.getBlockControls(),React.createElement("div",{className:r},this.state.editMode&&React.createElement(d,null,this.getMainFields(),this.getFiltersFields(),this.getPostSettingsFields(),this.getStatsTagFields(),this.getHTMLMarkupFields()),!this.state.editMode&&React.createElement(g,null,React.createElement(u,{block:this.props.name,className:a,attributes:s,urlQueryArgs:{isSelected:t}})))]}}])&&n(t.prototype,a),c}(m),S=wp.blocks.registerBlockType,k=wp.i18n.__;S("wordpress-popular-posts/widget",{title:"WordPress Popular Posts",category:"widgets",icon:r.flame,description:k("A highly customizable block that displays your most popular posts.","wordpress-popular-posts"),keywords:["popular","posts","trending","popularity"],attributes:{_editMode:{type:"boolean",default:!0},_isSelected:{type:"boolean",default:!1},title:{type:"string"},limit:{type:"number",default:10},offset:{type:"number",default:0},order_by:{type:"string",default:"views"},range:{type:"string",default:"last24hours"},time_quantity:{type:"number",default:24},time_unit:{type:"string",default:"hour"},freshness:{type:"boolean",default:!1},post_type:{type:"string",default:"post"},pid:{type:"string",default:""},author:{type:"string",default:""},tax:{type:"string",default:""},term_id:{type:"string",default:""},shorten_title:{type:"boolean",default:!1},title_length:{type:"number",default:0},title_by_words:{type:"number",default:0},display_post_excerpt:{type:"boolean",default:!1},excerpt_format:{type:"boolean",default:!1},excerpt_length:{type:"number",default:0},excerpt_by_words:{type:"number",default:0},display_post_thumbnail:{type:"boolean",default:!1},thumbnail_width:{type:"number",default:0},thumbnail_height:{type:"number",default:0},thumbnail_build:{type:"string",default:"manual"},thumbnail_size:{type:"string",default:""},stats_comments:{type:"boolean",default:!1},stats_views:{type:"boolean",default:!0},stats_author:{type:"boolean",default:!1},stats_date:{type:"boolean",default:!1},stats_date_format:{type:"string",default:"F j, Y"},stats_taxonomy:{type:"boolean",default:!1},taxonomy:{type:"string",default:""},custom_html:{type:"boolean",default:!1},header_start:{type:"string",default:"<h2>"},header_end:{type:"string",default:"</h2>"},wpp_start:{type:"string",default:'<ul class="wpp-list">'},wpp_end:{type:"string",default:"</ul>"},post_html:{type:"string",default:'<li>{thumb} {title} <span class="wpp-meta post-stats">{stats}</span></li>'},theme:{type:"string",default:""}},supports:{anchor:!0,align:!0,html:!1},example:{attributes:{_editMode:!1,title:"Popular Posts",limit:3,range:"last7days",display_post_excerpt:!0,excerpt_length:75,display_post_thumbnail:!0,thumbnail_width:75,thumbnail_height:75,stats_views:!1,stats_taxonomy:!0,custom_html:!0,wpp_start:'<ul class="wpp-list wpp-cards">',post_html:'<li>{thumb_img} <div class="wpp-item-data"><div class="taxonomies">{taxonomy}</div>{title} <p class="wpp-excerpt">{excerpt}</p></div></li>',theme:"cards"}},edit:C,save:function(){return null}})}]);
1
+ !function(){"use strict";var e={};e.flame=React.createElement("svg",{viewBox:"0 0 248 379"},React.createElement("path",{fill:"#fff",d:"M-83,96q0-122.5,0-245H165q0,131,0,262a31.87,31.87,0,0,1-.95-4.33A123.87,123.87,0,0,0,153.47,68.3c-12.28-27.74-31.1-50.64-53-71.21C75.67-26.13,55.85-52,54.32-87.87c-.79-18.47.81-36.24,11.59-52.15,1.08-1.59.38-4.4.5-6.64-2.43.1-5.5-.7-7.18.47a140.91,140.91,0,0,0-17.12,13.72C19.49-110.67,3-84.6-9.51-56A149,149,0,0,0-21.86-3.77c-2,39.4,11.38,73.46,36.17,103.51,1.74,2.11,3.51,4.2,5.27,6.3l-.67,1.07c-3.94-1.07-8-1.83-11.82-3.24C-25.17,91.94-52.36,58.57-51.12,21c.1-2.91.21-6.45-3.51-6.49-2,0-4.76,2.16-5.79,4.09-9.4,17.55-16.35,36-19.73,55.73C-81.38,81.49-82.07,88.76-83,96Z",transform:"translate(83 149)"}),React.createElement("path",{fill:"#ba2f2f",d:"M-83,96c.93-7.24,1.62-14.51,2.85-21.7,3.38-19.69,10.33-38.18,19.73-55.73,1-1.93,3.83-4.11,5.79-4.09,3.72,0,3.61,3.58,3.51,6.49-1.25,37.59,25.94,71,58.2,82.89,3.82,1.41,7.87,2.18,11.82,3.24l.67-1.07c-1.76-2.1-3.52-4.19-5.27-6.3C-10.49,69.68-23.88,35.63-21.86-3.77A149,149,0,0,1-9.51-56c12.48-28.62,29-54.69,51.62-76.5a140.91,140.91,0,0,1,17.12-13.72c1.68-1.18,4.75-.37,7.18-.47-.13,2.24.58,5-.5,6.64-10.78,15.9-12.37,33.68-11.59,52.15,1.53,35.89,21.35,61.74,46.11,85,21.94,20.57,40.76,43.47,53,71.21a123.87,123.87,0,0,1,10.59,40.36A31.87,31.87,0,0,0,165,113v9c-.7,4.24-1.17,8.54-2.13,12.73-10.74,46.51-37.08,78.75-84.34,91.58C72.16,228,65.52,228.79,59,230H43a25.19,25.19,0,0,0-3.12-1.18c-10-2.37-20.21-4.12-30-7.12-45.83-14-75.19-44.64-89-90.24-2.28-7.52-2.64-15.63-3.88-23.46Q-83,102-83,96ZM61.63-143.61c-6.24,5.39-12.87,10.38-18.64,16.22A229,229,0,0,0-8.77-46.26,138.37,138.37,0,0,0-16.63,23c4.69,32.54,20.21,59.59,42.4,83.23,1.34,1.43,2.7,2.83,4.8,5-15.23,1-28-3.3-39.74-10.64-29.74-18.62-46-45.23-46.8-81a138.75,138.75,0,0,0-7.46,14.67A178.29,178.29,0,0,0-78.24,93.09C-80.9,129.7-68,160.25-42.78,185.71c28.91,29.16,65.19,41.42,105.43,38.91,43.82-2.73,80.34-35.08,93.53-79.39,8.68-29.18,3.11-56.71-10.29-83.15C134.15,38.92,117.71,19.34,99,1.57,85-11.65,71.34-25.28,62.72-42.69,46.33-75.79,44.36-109.22,61.63-143.61Z",transform:"translate(83 149)"}),React.createElement("path",{fill:"#fff",d:"M-83,108c1.25,7.84,1.61,15.94,3.88,23.46,13.79,45.6,43.15,76.21,89,90.24,9.82,3,20,4.76,30,7.12A25.19,25.19,0,0,1,43,230H-83Q-83,169-83,108Z",transform:"translate(83 149)"}),React.createElement("path",{fill:"#fff",d:"M59,230c6.52-1.21,13.16-2,19.53-3.69,47.26-12.83,73.6-45.07,84.34-91.58,1-4.18,1.43-8.48,2.13-12.73V230Z",transform:"translate(83 149)"}),React.createElement("path",{fill:"#ba2f2f",d:"M61.63-143.61c-17.28,34.39-15.3,67.82,1.09,100.92C71.34-25.28,85-11.65,99,1.57c18.75,17.77,35.2,37.35,46.94,60.51,13.4,26.44,19,54,10.29,83.15-13.18,44.31-49.71,76.66-93.53,79.39-40.25,2.51-76.52-9.75-105.43-38.91C-68,160.25-80.9,129.7-78.24,93.09A178.29,178.29,0,0,1-63.45,34.31,138.75,138.75,0,0,1-56,19.64c.77,35.79,17.06,62.4,46.8,81C2.54,108,15.33,112.3,30.56,111.3c-2.1-2.21-3.46-3.62-4.8-5C3.57,82.62-11.94,55.57-16.63,23A138.37,138.37,0,0,1-8.77-46.26,229,229,0,0,1,43-127.38C48.76-133.23,55.39-138.22,61.63-143.61Z",transform:"translate(83 149)"}));var t=e;function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function s(e,t){for(var a=0;a<t.length;a++){var s=t[a];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,s.key,s)}}function r(e,t){return r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},r(e,t)}function o(e,t){if(t&&("object"===a(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}var l=wp.serverSideRender,i=wp.element,p=i.Component,u=i.Fragment,c=wp.blockEditor.BlockControls,m=wp.components,d=m.Button,h=m.CheckboxControl,f=m.Disabled,b=m.SelectControl,_=m.Spinner,g=m.TextareaControl,y=m.TextControl,v=m.Toolbar,__=wp.i18n.__,w="wordpress-popular-posts/v1",x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}(x,e);var t,a,i,p,m=(i=x,p=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=n(i);if(p){var a=n(this).constructor;e=Reflect.construct(t,arguments,a)}else e=t.apply(this,arguments);return o(this,e)});function x(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,x),(t=m.call(this,e)).state={error:null,editMode:!0,themes:null,imgSizes:null,taxonomies:null},t}return t=x,(a=[{key:"componentDidMount",value:function(){var e=this.props.attributes;this.getThemes(),this.getImageSizes(),this.getTaxonomies(),this.setState({editMode:e._editMode})}},{key:"getThemes",value:function(){var e=this;wp.apiFetch({path:w+"/themes"}).then((function(t){e.setState({themes:t})}),(function(t){e.setState({error:t,themes:null})}))}},{key:"getImageSizes",value:function(){var e=this;wp.apiFetch({path:w+"/thumbnails"}).then((function(t){e.setState({imgSizes:t})}),(function(t){e.setState({error:t,imgSizes:null})}))}},{key:"getTaxonomies",value:function(){var e=this,t=this.props.attributes;wp.apiFetch({path:w+"/taxonomies"}).then((function(a){if(a){var s=t.tax.split(";"),r=t.term_id.split(";");if(s.length&&s.length==r.length){for(var o={},n=0;n<s.length;n++)o[s[n]]=r[n];for(var l in a)a[l]._terms=void 0!==o[l]?o[l]:""}}e.setState({taxonomies:a})}),(function(t){e.setState({error:t,taxonomies:null})}))}},{key:"getBlockControls",value:function(){var e=this.props.setAttributes,t=this;return React.createElement(c,null,React.createElement(v,null,React.createElement(d,{label:this.state.editMode?__("Preview","wordpress-popular-posts"):__("Edit","wordpress-popular-posts"),icon:this.state.editMode?"format-image":"edit",onClick:function(){var a=!t.state.editMode;t.setState({editMode:a}),e({_editMode:a})}})))}},{key:"getMainFields",value:function(){var e=this.props,t=e.attributes,a=e.setAttributes;return React.createElement(u,null,React.createElement(y,{label:__("Title","wordpress-popular-posts"),value:t.title,onChange:function(e){e=function(e){var t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&grave;"};return e.replace(/[&<>"'/]/gi,(function(e){return t[e]}))}(function(e){var t=document.createElement("div");t.innerHTML=e;var a=t.childNodes[0];return a?a.nodeValue:""}(e)),a({title:e})}}),React.createElement(y,{label:__("Limit","wordpress-popular-posts"),value:t.limit,onChange:function(e){var t=Number.isInteger(Number(e))&&Number(e)>0?e:10;a({limit:Number(t)})}}),React.createElement(b,{label:__("Sort posts by","wordpress-popular-posts"),value:t.order_by,options:[{label:__("Total views","wordpress-popular-posts"),value:"views"},{label:__("Avg. daily views","wordpress-popular-posts"),value:"avg"},{label:__("Comments","wordpress-popular-posts"),value:"comments"}],onChange:function(e){a({order_by:e})}}),React.createElement(b,{label:__("Time Range","wordpress-popular-posts"),value:t.range,options:[{label:__("Last 24 Hours","wordpress-popular-posts"),value:"last24hours"},{label:__("Last 7 days","wordpress-popular-posts"),value:"last7days"},{label:__("Last 30 days","wordpress-popular-posts"),value:"last30days"},{label:__("All-time","wordpress-popular-posts"),value:"all"},{label:__("Custom","wordpress-popular-posts"),value:"custom"}],onChange:function(e){a({range:e})}}),"custom"==t.range&&React.createElement("div",{className:"option-subset"},React.createElement(y,{label:__("Time Quantity","wordpress-popular-posts"),value:t.time_quantity,onChange:function(e){var t=Number.isInteger(Number(e))&&Number(e)>0?e:24;a({time_quantity:Number(t)})}}),React.createElement(b,{label:__("Time Unit","wordpress-popular-posts"),value:t.time_unit,options:[{label:__("Minute(s)","wordpress-popular-posts"),value:"minute"},{label:__("Hour(s)","wordpress-popular-posts"),value:"hour"},{label:__("Day(s)","wordpress-popular-posts"),value:"day"}],onChange:function(e){a({time_unit:e})}})),React.createElement(h,{label:__("Display only posts published within the selected Time Range","wordpress-popular-posts"),checked:t.freshness,onChange:function(e){a({freshness:e})}}))}},{key:"getFiltersFields",value:function(){var e=this.props,t=e.attributes,a=e.setAttributes,s=this,r=[];if(this.state.taxonomies)for(var o in this.state.taxonomies)r.push({name:this.state.taxonomies[o].name,label:this.state.taxonomies[o].labels.singular_name+" ("+this.state.taxonomies[o].name+")",terms:this.state.taxonomies[o]._terms});return React.createElement(u,null,React.createElement("p",{className:"not-a-legend"},React.createElement("strong",null,__("Filters","wordpress-popular-posts"))),React.createElement(y,{label:__("Post type(s)","wordpress-popular-posts"),help:__("Post types must be comma separated.","wordpress-popular-posts"),value:t.post_type,onChange:function(e){var t=e.replace(/[^a-z0-9-_\,]+/gi,"");a({post_type:t})}}),React.createElement(y,{label:__("Post ID(s) to exclude","wordpress-popular-posts"),help:__("IDs must be comma separated.","wordpress-popular-posts"),value:t.pid,onChange:function(e){var t=e.replace(/[^0-9\,]/g,"");a({pid:t})}}),React.createElement(y,{label:__("Author ID(s)","wordpress-popular-posts"),help:__("IDs must be comma separated.","wordpress-popular-posts"),value:t.author,onChange:function(e){var t=e.replace(/[^0-9\,]/g,"");a({author:t})}}),r&&r.filter((function(e){return"post_format"!=e.name})).map((function(e){return React.createElement(y,{label:e.label,help:__("Term IDs must be comma separated, prefix a minus sign to exclude.","wordpress-popular-posts"),value:e.terms,onChange:function(t){return function(e,t){var a=s.state.taxonomies;t=t.replace(/[^0-9-\,]/g,""),a&&void 0!==a[e]&&(a[e]._terms=t,s.setState({taxonomies:a}))}(e.name,t)},onBlur:function(){return function(e){var t=s.state.taxonomies;if(t&&void 0!==t[e]){var r=t[e]._terms.split(",");r.length&&(r=r.map((function(e){return e.trim()})).filter((function(e){return""!=e&&"-"!=e}))),r.length&&(r=Array.from(new Set(r))),t[e]._terms=r.join(","),s.setState({taxonomies:t});var o="",n="";for(var l in s.state.taxonomies)if(s.state.taxonomies.hasOwnProperty(l)){if(!s.state.taxonomies[l]._terms.length)continue;o+=l+";",n+=s.state.taxonomies[l]._terms+";"}o&&n&&(o=o.replace(new RegExp(";$"),""),n=n.replace(new RegExp(";$"),"")),a({tax:o,term_id:n})}}(e.name)}})})))}},{key:"getPostSettingsFields",value:function(){var e=this.props,t=e.attributes,a=e.setAttributes,s=this;function r(e,t){var s=Number.isInteger(Number(t))&&Number(t)>=0?t:0;a("width"==e?{thumbnail_width:Number(s)}:{thumbnail_height:Number(s)})}var o=[];if(this.state.imgSizes)for(var n in this.state.imgSizes)o.push({label:n,value:n});return React.createElement(u,null,React.createElement("p",{className:"not-a-legend"},React.createElement("strong",null,__("Posts settings","wordpress-popular-posts"))),React.createElement(h,{label:__("Shorten title","wordpress-popular-posts"),checked:t.shorten_title,onChange:function(e){a(0==e?{title_length:0,title_by_words:0,shorten_title:e}:{shorten_title:e,title_length:25})}}),t.shorten_title&&React.createElement("div",{className:"option-subset"},React.createElement(y,{label:__("Shorten title to","wordpress-popular-posts"),value:t.title_length,onChange:function(e){var t=Number.isInteger(Number(e))&&Number(e)>=0?e:0;a({title_length:Number(t)})}}),React.createElement(b,{value:t.title_by_words,options:[{label:__("characters","wordpress-popular-posts"),value:0},{label:__("words","wordpress-popular-posts"),value:1}],onChange:function(e){return a({title_by_words:Number(e)})}})),React.createElement(h,{label:__("Display post excerpt","wordpress-popular-posts"),checked:t.display_post_excerpt,onChange:function(e){a(0==e?{excerpt_length:0,excerpt_by_words:0,display_post_excerpt:e}:{display_post_excerpt:e,excerpt_length:55})}}),t.display_post_excerpt&&React.createElement("div",{className:"option-subset"},React.createElement(h,{label:__("Keep text format and links","wordpress-popular-posts"),checked:t.excerpt_format,onChange:function(e){return a({excerpt_format:e})}}),React.createElement(y,{label:__("Excerpt length","wordpress-popular-posts"),value:t.excerpt_length,onChange:function(e){var t=Number.isInteger(Number(e))&&Number(e)>=0?e:0;a({excerpt_length:Number(t)})}}),React.createElement(b,{value:t.excerpt_by_words,options:[{label:__("characters","wordpress-popular-posts"),value:0},{label:__("words","wordpress-popular-posts"),value:1}],onChange:function(e){return a({excerpt_by_words:Number(e)})}})),React.createElement(h,{label:__("Display post thumbnail","wordpress-popular-posts"),checked:t.display_post_thumbnail,onChange:function(e){a(0==e?{thumbnail_width:0,thumbnail_height:0,display_post_thumbnail:e}:{thumbnail_width:75,thumbnail_height:75,display_post_thumbnail:e})}}),t.display_post_thumbnail&&React.createElement("div",{className:"option-subset"},React.createElement(b,{value:t.thumbnail_build,options:[{label:__("Set size manually","wordpress-popular-posts"),value:"manual"},{label:__("Use predefined size","wordpress-popular-posts"),value:"predefined"}],onChange:function(e){"predefined"==e&&a({thumbnail_width:s.state.imgSizes[o[0].value].width,thumbnail_height:s.state.imgSizes[o[0].value].height,thumbnail_size:o[0].value}),a({thumbnail_build:e})}}),"manual"==t.thumbnail_build&&React.createElement(u,null,React.createElement(y,{label:__("Thumbnail width","wordpress-popular-posts"),help:__("Size in px units (pixels)","wordpress-popular-posts"),value:t.thumbnail_width,onChange:function(e){return r("width",e)}}),React.createElement(y,{label:__("Thumbnail height","wordpress-popular-posts"),help:__("Size in px units (pixels)","wordpress-popular-posts"),value:t.thumbnail_height,onChange:function(e){return r("height",e)}})),"predefined"==t.thumbnail_build&&React.createElement(u,null,React.createElement(b,{value:t.thumbnail_size,options:o,onChange:function(e){a({thumbnail_width:s.state.imgSizes[e].width,thumbnail_height:s.state.imgSizes[e].height,thumbnail_size:e})}}))))}},{key:"getStatsTagFields",value:function(){var e=this.props,t=e.attributes,a=e.setAttributes,s=[];if(this.state.taxonomies)for(var r in this.state.taxonomies)s.push({label:this.state.taxonomies[r].labels.singular_name+" ("+this.state.taxonomies[r].name+")",value:this.state.taxonomies[r].name});return React.createElement(u,null,React.createElement("p",{className:"not-a-legend"},React.createElement("strong",null,__("Stats Tag settings","wordpress-popular-posts"))),React.createElement(h,{label:__("Display comments count","wordpress-popular-posts"),checked:t.stats_comments,onChange:function(e){return a({stats_comments:e})}}),React.createElement(h,{label:__("Display views","wordpress-popular-posts"),checked:t.stats_views,onChange:function(e){return a({stats_views:e})}}),React.createElement(h,{label:__("Display author","wordpress-popular-posts"),checked:t.stats_author,onChange:function(e){return a({stats_author:e})}}),React.createElement(h,{label:__("Display date","wordpress-popular-posts"),checked:t.stats_date,onChange:function(e){return a({stats_date:e})}}),t.stats_date&&React.createElement("div",{className:"option-subset"},React.createElement(b,{label:__("Date Format","wordpress-popular-posts"),value:t.stats_date_format,options:[{label:__("Relative","wordpress-popular-posts"),value:"relative"},{label:__("Month Day, Year","wordpress-popular-posts"),value:"F j, Y"},{label:__("yyyy/mm/dd","wordpress-popular-posts"),value:"Y/m/d"},{label:__("mm/dd/yyyy","wordpress-popular-posts"),value:"m/d/Y"},{label:__("dd/mm/yyyy","wordpress-popular-posts"),value:"d/m/Y"},{label:__("WordPress Date Format","wordpress-popular-posts"),value:"wp_date_format"}],onChange:function(e){return a({stats_date_format:e})}})),React.createElement(h,{label:__("Display taxonomy","wordpress-popular-posts"),checked:t.stats_taxonomy,onChange:function(e){return a({stats_taxonomy:e})}}),t.stats_taxonomy&&React.createElement("div",{className:"option-subset"},React.createElement(b,{label:__("Taxonomy","wordpress-popular-posts"),value:t.taxonomy,options:s,onChange:function(e){return a({taxonomy:e})}})))}},{key:"getHTMLMarkupFields",value:function(){var e=this.props,t=e.attributes,a=e.setAttributes,s=this,r=[{label:__("None","wordpress-popular-posts"),value:""}];if(this.state.themes)for(var o in this.state.themes)r.push({label:this.state.themes[o].json.name,value:o});return React.createElement(u,null,React.createElement("p",{className:"not-a-legend"},React.createElement("strong",null,__("HTML Markup settings","wordpress-popular-posts"))),React.createElement(h,{label:__("Use custom HTML Markup","wordpress-popular-posts"),checked:t.custom_html,onChange:function(e){return a({custom_html:e})}}),t.custom_html&&React.createElement("div",{className:"option-subset"},React.createElement(g,{rows:"1",label:__("Before title","wordpress-popular-posts"),value:t.header_start,onChange:function(e){return a({header_start:e})}}),React.createElement(g,{rows:"1",label:__("After title","wordpress-popular-posts"),value:t.header_end,onChange:function(e){return a({header_end:e})}}),React.createElement(g,{rows:"1",label:__("Before popular posts","wordpress-popular-posts"),value:t.wpp_start,onChange:function(e){return a({wpp_start:e})}}),React.createElement(g,{rows:"1",label:__("After popular posts","wordpress-popular-posts"),value:t.wpp_end,onChange:function(e){return a({wpp_end:e})}}),React.createElement(g,{label:__("Post HTML markup","wordpress-popular-posts"),value:t.post_html,onChange:function(e){return a({post_html:e})}})),React.createElement(b,{label:__("Theme","wordpress-popular-posts"),value:t.theme,options:r,onChange:function(e){if(void 0!==s.state.themes[e]){var t=s.state.themes[e].json.config;a({shorten_title:t.shorten_title.active,title_length:t.shorten_title.title_length,title_by_words:t.shorten_title.words?1:0,display_post_excerpt:t["post-excerpt"].active,excerpt_format:t["post-excerpt"].format,excerpt_length:t["post-excerpt"].length,excerpt_by_words:t["post-excerpt"].words?1:0,display_post_thumbnail:t.thumbnail.active,thumbnail_build:t.thumbnail.build,thumbnail_width:t.thumbnail.width,thumbnail_height:t.thumbnail.height,stats_comments:t.stats_tag.comment_count,stats_views:t.stats_tag.views,stats_author:t.stats_tag.author,stats_date:t.stats_tag.date.active,stats_date_format:t.stats_tag.date.format,stats_taxonomy:t.stats_tag.taxonomy.active,taxonomy:t.stats_tag.taxonomy.name,custom_html:!0,wpp_start:t.markup["wpp-start"],wpp_end:t.markup["wpp-end"],post_html:t.markup["post-html"],theme:e})}else a({theme:e})}}))}},{key:"render",value:function(){if(!this.state.taxonomies||!this.state.themes||!this.state.imgSizes)return React.createElement(_,null);var e=this.props,t=e.isSelected,a=e.className,s=e.attributes,r=a;return r+=this.state.editMode?" in-edit-mode":" in-preview-mode",r+=t?" is-selected":"",[this.getBlockControls(),React.createElement("div",{className:r},this.state.editMode&&React.createElement(u,null,this.getMainFields(),this.getFiltersFields(),this.getPostSettingsFields(),this.getStatsTagFields(),this.getHTMLMarkupFields()),!this.state.editMode&&React.createElement(f,null,React.createElement(l,{block:this.props.name,className:a,attributes:s,urlQueryArgs:{isSelected:t}})))]}}])&&s(t.prototype,a),x}(p),R=wp.blocks.registerBlockType,E=wp.i18n.__;R("wordpress-popular-posts/widget",{title:"WordPress Popular Posts",category:"widgets",icon:t.flame,description:E("A highly customizable block that displays your most popular posts.","wordpress-popular-posts"),keywords:["popular","posts","trending","popularity"],attributes:{_editMode:{type:"boolean",default:!0},_isSelected:{type:"boolean",default:!1},title:{type:"string"},limit:{type:"number",default:10},offset:{type:"number",default:0},order_by:{type:"string",default:"views"},range:{type:"string",default:"last24hours"},time_quantity:{type:"number",default:24},time_unit:{type:"string",default:"hour"},freshness:{type:"boolean",default:!1},post_type:{type:"string",default:"post"},pid:{type:"string",default:""},author:{type:"string",default:""},tax:{type:"string",default:""},term_id:{type:"string",default:""},shorten_title:{type:"boolean",default:!1},title_length:{type:"number",default:0},title_by_words:{type:"number",default:0},display_post_excerpt:{type:"boolean",default:!1},excerpt_format:{type:"boolean",default:!1},excerpt_length:{type:"number",default:0},excerpt_by_words:{type:"number",default:0},display_post_thumbnail:{type:"boolean",default:!1},thumbnail_width:{type:"number",default:0},thumbnail_height:{type:"number",default:0},thumbnail_build:{type:"string",default:"manual"},thumbnail_size:{type:"string",default:""},stats_comments:{type:"boolean",default:!1},stats_views:{type:"boolean",default:!0},stats_author:{type:"boolean",default:!1},stats_date:{type:"boolean",default:!1},stats_date_format:{type:"string",default:"F j, Y"},stats_taxonomy:{type:"boolean",default:!1},taxonomy:{type:"string",default:""},custom_html:{type:"boolean",default:!1},header_start:{type:"string",default:"<h2>"},header_end:{type:"string",default:"</h2>"},wpp_start:{type:"string",default:'<ul class="wpp-list">'},wpp_end:{type:"string",default:"</ul>"},post_html:{type:"string",default:'<li>{thumb} {title} <span class="wpp-meta post-stats">{stats}</span></li>'},theme:{type:"string",default:""}},supports:{anchor:!0,align:!0,html:!1},example:{attributes:{_editMode:!1,title:"Popular Posts",limit:3,range:"last7days",display_post_excerpt:!0,excerpt_length:75,display_post_thumbnail:!0,thumbnail_width:75,thumbnail_height:75,stats_views:!1,stats_taxonomy:!0,custom_html:!0,wpp_start:'<ul class="wpp-list wpp-cards">',post_html:'<li>{thumb_img} <div class="wpp-item-data"><div class="taxonomies">{taxonomy}</div>{title} <p class="wpp-excerpt">{excerpt}</p></div></li>',theme:"cards"}},edit:x,save:function(){return null}})}();
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: popular, posts, widget, popularity, top
5
  Requires at least: 4.9
6
  Tested up to: 5.8
7
  Requires PHP: 5.4
8
- Stable tag: 5.4.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -97,6 +97,16 @@ The FAQ section has been moved [here](https://github.com/cabrerahector/wordpress
97
 
98
  == Changelog ==
99
 
 
 
 
 
 
 
 
 
 
 
100
  = 5.4.2 =
101
 
102
  - Fixes a rare issue that prevented some users from seeing the Statistics chart (thanks Zsolt!)
5
  Requires at least: 4.9
6
  Tested up to: 5.8
7
  Requires PHP: 5.4
8
+ Stable tag: 5.5.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
97
 
98
  == Changelog ==
99
 
100
+ = 5.5.0 =
101
+
102
+ - Adds the Sort by Average Daily Views option from the classic widget to the WordPress Popular Posts block.
103
+ - Adds the WordPress Date Format option from the classic widget to the WordPress Popular Posts block (please see announcements for details).
104
+ - Adds new Content Tags: author_name and author_url.
105
+ - Improves cached data garbage collection.
106
+ - Other minor performances improvements and fixes.
107
+
108
+ [Release notes](https://cabrerahector.com/wordpress/wordpress-popular-posts-5-5-qol-improvements-and-php-5-announcement/)
109
+
110
  = 5.4.2 =
111
 
112
  - Fixes a rare issue that prevented some users from seeing the Statistics chart (thanks Zsolt!)
src/Activation/Activator.php CHANGED
@@ -75,6 +75,7 @@ class Activator {
75
  if (
76
  ! $wpp_ver
77
  || version_compare($wpp_ver, WPP_VERSION, '<')
 
78
  ) {
79
  global $wpdb;
80
 
@@ -119,7 +120,13 @@ class Activator {
119
  KEY postid (postid),
120
  KEY view_date (view_date),
121
  KEY view_datetime (view_datetime)
122
- ) {$charset_collate} ENGINE=InnoDB;";
 
 
 
 
 
 
123
 
124
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
125
  \dbDelta($sql);
75
  if (
76
  ! $wpp_ver
77
  || version_compare($wpp_ver, WPP_VERSION, '<')
78
+ || ( defined('WPP_DO_DB_TABLES') && WPP_DO_DB_TABLES )
79
  ) {
80
  global $wpdb;
81
 
120
  KEY postid (postid),
121
  KEY view_date (view_date),
122
  KEY view_datetime (view_datetime)
123
+ ) {$charset_collate} ENGINE=InnoDB;
124
+ CREATE TABLE {$prefix}transients (
125
+ ID bigint(20) NOT NULL AUTO_INCREMENT,
126
+ tkey varchar(191) NOT NULL,
127
+ tkey_date datetime NOT NULL,
128
+ PRIMARY KEY (ID)
129
+ ) {$charset_collate} ENGINE=InnoDB";
130
 
131
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
132
  \dbDelta($sql);
src/Admin/Admin.php CHANGED
@@ -125,6 +125,8 @@ class Admin {
125
  // Flush cached thumbnail on featured image change/deletion
126
  add_action('updated_post_meta', [$this, 'updated_post_meta'], 10, 4);
127
  add_action('deleted_post_meta', [$this, 'deleted_post_meta'], 10, 4);
 
 
128
  // Purge post data on post/page deletion
129
  add_action('admin_init', [$this, 'purge_post_data']);
130
  // Purge old data on demand
@@ -1210,13 +1212,15 @@ class Admin {
1210
  */
1211
  private function flush_transients()
1212
  {
1213
- $wpp_transients = get_option('wpp_transients');
 
 
1214
 
1215
  if ( $wpp_transients && is_array($wpp_transients) && ! empty($wpp_transients) ) {
1216
- for ( $t=0; $t < count($wpp_transients); $t++ )
1217
- delete_transient($wpp_transients[$t]);
1218
 
1219
- update_option('wpp_transients', []);
1220
  }
1221
  }
1222
 
@@ -1319,6 +1323,16 @@ class Admin {
1319
  }
1320
  }
1321
 
 
 
 
 
 
 
 
 
 
 
1322
  /**
1323
  * Purges post from data/summary tables.
1324
  *
125
  // Flush cached thumbnail on featured image change/deletion
126
  add_action('updated_post_meta', [$this, 'updated_post_meta'], 10, 4);
127
  add_action('deleted_post_meta', [$this, 'deleted_post_meta'], 10, 4);
128
+ // Purge transients when sending post/page to trash
129
+ add_action('wp_trash_post', [$this, 'purge_data_cache']);
130
  // Purge post data on post/page deletion
131
  add_action('admin_init', [$this, 'purge_post_data']);
132
  // Purge old data on demand
1212
  */
1213
  private function flush_transients()
1214
  {
1215
+ global $wpdb;
1216
+
1217
+ $wpp_transients = $wpdb->get_results("SELECT tkey FROM {$wpdb->prefix}popularpoststransients;");
1218
 
1219
  if ( $wpp_transients && is_array($wpp_transients) && ! empty($wpp_transients) ) {
1220
+ foreach( $wpp_transients as $wpp_transient )
1221
+ delete_transient($wpp_transient->tkey);
1222
 
1223
+ $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}popularpoststransients;");
1224
  }
1225
  }
1226
 
1323
  }
1324
  }
1325
 
1326
+ /**
1327
+ * Purges data cache when a post/page is trashed.
1328
+ *
1329
+ * @since 5.5.0
1330
+ */
1331
+ public function purge_data_cache()
1332
+ {
1333
+ $this->flush_transients();
1334
+ }
1335
+
1336
  /**
1337
  * Purges post from data/summary tables.
1338
  *
src/Block/Widget/edit.js CHANGED
@@ -187,6 +187,7 @@ export class WPPWidgetBlockEdit extends Component
187
  value={attributes.order_by}
188
  options={[
189
  {label: __('Total views', 'wordpress-popular-posts'), value: 'views'},
 
190
  {label: __('Comments', 'wordpress-popular-posts'), value: 'comments'}
191
  ]}
192
  onChange={onOrderByChange}
@@ -584,6 +585,7 @@ export class WPPWidgetBlockEdit extends Component
584
  { label: __('yyyy/mm/dd', 'wordpress-popular-posts'), value: 'Y/m/d' },
585
  { label: __('mm/dd/yyyy', 'wordpress-popular-posts'), value: 'm/d/Y' },
586
  { label: __('dd/mm/yyyy', 'wordpress-popular-posts'), value: 'd/m/Y' },
 
587
  ]}
588
  onChange={(value) => setAttributes({ stats_date_format: value })}
589
  />
187
  value={attributes.order_by}
188
  options={[
189
  {label: __('Total views', 'wordpress-popular-posts'), value: 'views'},
190
+ {label: __('Avg. daily views', 'wordpress-popular-posts'), value: 'avg'},
191
  {label: __('Comments', 'wordpress-popular-posts'), value: 'comments'}
192
  ]}
193
  onChange={onOrderByChange}
585
  { label: __('yyyy/mm/dd', 'wordpress-popular-posts'), value: 'Y/m/d' },
586
  { label: __('mm/dd/yyyy', 'wordpress-popular-posts'), value: 'm/d/Y' },
587
  { label: __('dd/mm/yyyy', 'wordpress-popular-posts'), value: 'd/m/Y' },
588
+ { label: __('WordPress Date Format', 'wordpress-popular-posts'), value: 'wp_date_format' },
589
  ]}
590
  onChange={(value) => setAttributes({ stats_date_format: value })}
591
  />
src/Cache.php CHANGED
@@ -96,17 +96,16 @@ class Cache {
96
  // Store transient
97
  set_transient($key, $data, $expiration);
98
 
99
- // Store transient in WPP transients array for garbage collection
100
- $wpp_transients = get_option('wpp_transients');
101
-
102
- if ( !$wpp_transients ) {
103
- $wpp_transients = [$key];
104
- add_option('wpp_transients', $wpp_transients);
105
- } else {
106
- if ( !in_array($key, $wpp_transients) ) {
107
- $wpp_transients[] = $key;
108
- update_option('wpp_transients', $wpp_transients);
109
- }
110
- }
111
  }
112
- }
96
  // Store transient
97
  set_transient($key, $data, $expiration);
98
 
99
+ // Store transient keys in WPP's transients table for garbage collection
100
+ global $wpdb;
101
+
102
+ $wpdb->insert(
103
+ $wpdb->prefix . "popularpoststransients",
104
+ [
105
+ 'tkey' => $key,
106
+ 'tkey_date' => Helper::now()
107
+ ],
108
+ ['%s', '%s']
109
+ );
 
110
  }
111
+ }
src/Helper.php CHANGED
@@ -262,6 +262,8 @@ class Helper {
262
  public static function truncate($text = '', $length = 25, $truncate_by_words = false, $more = '...')
263
  {
264
  if ( '' !== $text ) {
 
 
265
  // Truncate by words
266
  if ( $truncate_by_words ) {
267
  $words = explode(" ", $text, $length + 1);
@@ -272,8 +274,8 @@ class Helper {
272
  }
273
  }
274
  // Truncate by characters
275
- elseif ( strlen($text) > $length ) {
276
- $text = rtrim(mb_substr($text, 0, $length , get_bloginfo('charset')), " ,.") . $more;
277
  }
278
  }
279
 
262
  public static function truncate($text = '', $length = 25, $truncate_by_words = false, $more = '...')
263
  {
264
  if ( '' !== $text ) {
265
+ $charset = get_bloginfo('charset');
266
+
267
  // Truncate by words
268
  if ( $truncate_by_words ) {
269
  $words = explode(" ", $text, $length + 1);
274
  }
275
  }
276
  // Truncate by characters
277
+ elseif ( mb_strlen($text, $charset) > $length ) {
278
+ $text = rtrim(mb_substr($text, 0, $length , $charset), " ,.") . $more;
279
  }
280
  }
281
 
src/Output.php CHANGED
@@ -75,6 +75,14 @@ class Output {
75
  */
76
  private $themer;
77
 
 
 
 
 
 
 
 
 
78
  /**
79
  * Constructor.
80
  *
@@ -94,6 +102,11 @@ class Output {
94
  $this->themer = $themer;
95
 
96
  $this->more = '...';
 
 
 
 
 
97
  }
98
 
99
  /**
@@ -366,6 +379,8 @@ class Output {
366
  'taxonomy_copy' => isset($meta_arr['taxonomy']) ? $meta_arr['taxonomy'] : null,
367
  'author' => ( ! empty($post_author) ) ? '<a href="' . get_author_posts_url($post_object->uid != $post_id ? get_post_field('post_author', $post_id) : $post_object->uid ) . '">' . $post_author . '</a>' : '',
368
  'author_copy' => isset($meta_arr['author']) ? $meta_arr['author'] : null,
 
 
369
  'views' => ( $this->public_options['order_by'] == "views" || $this->public_options['order_by'] == "comments" ) ? ($prettify_numbers ? Helper::prettify_number($post_views) : number_format_i18n($post_views)) : ($prettify_numbers ? Helper::prettify_number($post_views, 2) : number_format_i18n($post_views, 2)),
370
  'views_copy' => isset($meta_arr['views']) ? $meta_arr['views'] : null,
371
  'comments' => $prettify_numbers ? Helper::prettify_number($post_comments) : number_format_i18n($post_comments),
@@ -589,9 +604,20 @@ class Output {
589
  $date = '';
590
 
591
  if ( $this->public_options['stats_tag']['date']['active'] ) {
592
- $date = ( 'relative' == $this->public_options['stats_tag']['date']['format'] )
593
- ? sprintf(__('%s ago', 'wordpress-popular-posts'), human_time_diff(strtotime($post_object->date), current_time('timestamp')))
594
- : date_i18n($this->public_options['stats_tag']['date']['format'], strtotime($post_object->date));
 
 
 
 
 
 
 
 
 
 
 
595
  }
596
 
597
  return $date;
@@ -803,7 +829,7 @@ class Output {
803
  return false;
804
 
805
  $params = [];
806
- $pattern = '/\{(pid|current_class|excerpt|summary|meta|stats|title|title_attr|image|thumb|thumb_img|thumb_url|rating|score|url|text_title|author|author_copy|taxonomy|taxonomy_copy|category|category_copy|views|views_copy|comments|comments_copy|date|date_copy|total_items|item_position)\}/i';
807
  preg_match_all($pattern, $string, $matches);
808
 
809
  array_map('strtolower', $matches[0]);
@@ -848,8 +874,8 @@ class Output {
848
 
849
  if ( $img_tag->length ) {
850
  foreach( $img_tag as $node ) {
851
- if ( $node->hasAttribute('src') || $node->hasAttribute('data-img-src') ) {
852
- $src = $node->hasAttribute('src') ? $node->getAttribute('src') : $node->getAttribute('data-img-src');
853
  $string = str_replace("{thumb_url}", $src, $string);
854
  }
855
  }
@@ -886,6 +912,14 @@ class Output {
886
  $string = str_replace("{author_copy}", $data['author_copy'], $string);
887
  }
888
 
 
 
 
 
 
 
 
 
889
  if ( in_array("{taxonomy}", $matches[0]) || in_array("{category}", $matches[0]) ) {
890
  $string = str_replace(["{taxonomy}", "{category}"], $data['taxonomy'], $string);
891
  }
75
  */
76
  private $themer;
77
 
78
+ /**
79
+ * WordPress Date format.
80
+ *
81
+ * @var string
82
+ * @access private
83
+ */
84
+ private $wp_date_format;
85
+
86
  /**
87
  * Constructor.
88
  *
102
  $this->themer = $themer;
103
 
104
  $this->more = '...';
105
+
106
+ $this->wp_date_format = get_option('date_format');
107
+
108
+ if ( ! $this->wp_date_format )
109
+ $this->wp_date_format = 'F j, Y';
110
  }
111
 
112
  /**
379
  'taxonomy_copy' => isset($meta_arr['taxonomy']) ? $meta_arr['taxonomy'] : null,
380
  'author' => ( ! empty($post_author) ) ? '<a href="' . get_author_posts_url($post_object->uid != $post_id ? get_post_field('post_author', $post_id) : $post_object->uid ) . '">' . $post_author . '</a>' : '',
381
  'author_copy' => isset($meta_arr['author']) ? $meta_arr['author'] : null,
382
+ 'author_name' => $post_author,
383
+ 'author_url' => ( ! empty($post_author) ) ? get_author_posts_url($post_object->uid != $post_id ? get_post_field('post_author', $post_id) : $post_object->uid ) : '',
384
  'views' => ( $this->public_options['order_by'] == "views" || $this->public_options['order_by'] == "comments" ) ? ($prettify_numbers ? Helper::prettify_number($post_views) : number_format_i18n($post_views)) : ($prettify_numbers ? Helper::prettify_number($post_views, 2) : number_format_i18n($post_views, 2)),
385
  'views_copy' => isset($meta_arr['views']) ? $meta_arr['views'] : null,
386
  'comments' => $prettify_numbers ? Helper::prettify_number($post_comments) : number_format_i18n($post_comments),
604
  $date = '';
605
 
606
  if ( $this->public_options['stats_tag']['date']['active'] ) {
607
+ if ( 'relative' == $this->public_options['stats_tag']['date']['format'] ) {
608
+ $date = sprintf(
609
+ __('%s ago', 'wordpress-popular-posts'),
610
+ human_time_diff(
611
+ strtotime($post_object->date),
612
+ current_time('timestamp')
613
+ )
614
+ );
615
+ } else {
616
+ $date = date_i18n(
617
+ ( 'wp_date_format' == $this->public_options['stats_tag']['date']['format'] ? $this->wp_date_format : $this->public_options['stats_tag']['date']['format'] ),
618
+ strtotime($post_object->date)
619
+ );
620
+ }
621
  }
622
 
623
  return $date;
829
  return false;
830
 
831
  $params = [];
832
+ $pattern = '/\{(pid|current_class|excerpt|summary|meta|stats|title|title_attr|image|thumb|thumb_img|thumb_url|rating|score|url|text_title|author|author_copy|author_name|author_url|taxonomy|taxonomy_copy|category|category_copy|views|views_copy|comments|comments_copy|date|date_copy|total_items|item_position)\}/i';
833
  preg_match_all($pattern, $string, $matches);
834
 
835
  array_map('strtolower', $matches[0]);
874
 
875
  if ( $img_tag->length ) {
876
  foreach( $img_tag as $node ) {
877
+ if ( $node->hasAttribute('src') ) {
878
+ $src = $node->getAttribute('src');
879
  $string = str_replace("{thumb_url}", $src, $string);
880
  }
881
  }
912
  $string = str_replace("{author_copy}", $data['author_copy'], $string);
913
  }
914
 
915
+ if ( in_array("{author_name}", $matches[0]) ) {
916
+ $string = str_replace("{author_name}", $data['author_name'], $string);
917
+ }
918
+
919
+ if ( in_array("{author_url}", $matches[0]) ) {
920
+ $string = str_replace("{author_url}", $data['author_url'], $string);
921
+ }
922
+
923
  if ( in_array("{taxonomy}", $matches[0]) || in_array("{category}", $matches[0]) ) {
924
  $string = str_replace(["{taxonomy}", "{category}"], $data['taxonomy'], $string);
925
  }
src/Themer.php CHANGED
@@ -59,6 +59,8 @@ class Themer {
59
  $directories = new \DirectoryIterator($this->path);
60
 
61
  foreach( $directories as $fileinfo ) {
 
 
62
  $this->load_theme($fileinfo->getPathName());
63
  }
64
 
59
  $directories = new \DirectoryIterator($this->path);
60
 
61
  foreach( $directories as $fileinfo ) {
62
+ if ( $fileinfo->isDot() || $fileinfo->isFile() )
63
+ continue;
64
  $this->load_theme($fileinfo->getPathName());
65
  }
66
 
src/Widget/form.php CHANGED
@@ -157,7 +157,7 @@ if ( $taxonomies = get_taxonomies(['public' => true], 'objects') ) {
157
  <legend><strong><?php _e('Date Format', 'wordpress-popular-posts'); ?></strong></legend><br />
158
 
159
  <label title='m/d/Y'><input type='radio' name='<?php echo $this->get_field_name('date_format'); ?>' value='relative' <?php echo ($instance['stats_tag']['date']['format'] == 'relative') ? 'checked="checked"' : ''; ?> /><?php _e('Relative', 'wordpress-popular-posts'); ?></label><br />
160
- <label title='<?php echo get_option('date_format'); ?>'><input type='radio' name='<?php echo $this->get_field_name('date_format'); ?>' value='<?php echo get_option('date_format'); ?>' <?php echo ($instance['stats_tag']['date']['format'] == get_option('date_format')) ? 'checked="checked"' : ''; ?> /><?php echo date_i18n(get_option('date_format'), time()); ?></label> <small>(<a href="<?php echo admin_url('options-general.php'); ?>" title="<?php _e('WordPress Date Format', 'wordpress-popular-posts'); ?>" target="_blank"><?php _e('WordPress Date Format', 'wordpress-popular-posts'); ?></a>)</small><br />
161
  <label title='F j, Y'><input type='radio' name='<?php echo $this->get_field_name('date_format'); ?>' value='F j, Y' <?php echo ($instance['stats_tag']['date']['format'] == 'F j, Y') ? 'checked="checked"' : ''; ?> /><?php echo date_i18n('F j, Y', time()); ?></label><br />
162
  <label title='Y/m/d'><input type='radio' name='<?php echo $this->get_field_name('date_format'); ?>' value='Y/m/d' <?php echo ($instance['stats_tag']['date']['format'] == 'Y/m/d') ? 'checked="checked"' : ''; ?> /><?php echo date_i18n('Y/m/d', time()); ?></label><br />
163
  <label title='m/d/Y'><input type='radio' name='<?php echo $this->get_field_name('date_format'); ?>' value='m/d/Y' <?php echo ($instance['stats_tag']['date']['format'] == 'm/d/Y') ? 'checked="checked"' : ''; ?> /><?php echo date_i18n('m/d/Y', time()); ?></label><br />
157
  <legend><strong><?php _e('Date Format', 'wordpress-popular-posts'); ?></strong></legend><br />
158
 
159
  <label title='m/d/Y'><input type='radio' name='<?php echo $this->get_field_name('date_format'); ?>' value='relative' <?php echo ($instance['stats_tag']['date']['format'] == 'relative') ? 'checked="checked"' : ''; ?> /><?php _e('Relative', 'wordpress-popular-posts'); ?></label><br />
160
+ <label title='<?php echo get_option('date_format'); ?>'><input type='radio' name='<?php echo $this->get_field_name('date_format'); ?>' value='wp_date_format' <?php echo ($instance['stats_tag']['date']['format'] == 'wp_date_format') ? 'checked="checked"' : ''; ?> /><?php echo date_i18n(get_option('date_format'), time()); ?></label> <small>(<a href="<?php echo admin_url('options-general.php'); ?>" title="<?php _e('WordPress Date Format', 'wordpress-popular-posts'); ?>" target="_blank"><?php _e('WordPress Date Format', 'wordpress-popular-posts'); ?></a>)</small><br />
161
  <label title='F j, Y'><input type='radio' name='<?php echo $this->get_field_name('date_format'); ?>' value='F j, Y' <?php echo ($instance['stats_tag']['date']['format'] == 'F j, Y') ? 'checked="checked"' : ''; ?> /><?php echo date_i18n('F j, Y', time()); ?></label><br />
162
  <label title='Y/m/d'><input type='radio' name='<?php echo $this->get_field_name('date_format'); ?>' value='Y/m/d' <?php echo ($instance['stats_tag']['date']['format'] == 'Y/m/d') ? 'checked="checked"' : ''; ?> /><?php echo date_i18n('Y/m/d', time()); ?></label><br />
163
  <label title='m/d/Y'><input type='radio' name='<?php echo $this->get_field_name('date_format'); ?>' value='m/d/Y' <?php echo ($instance['stats_tag']['date']['format'] == 'm/d/Y') ? 'checked="checked"' : ''; ?> /><?php echo date_i18n('m/d/Y', time()); ?></label><br />
uninstall.php CHANGED
@@ -77,4 +77,5 @@ function uninstall() {
77
  $wpdb->query("DROP TABLE IF EXISTS {$prefix}datacache_backup;");
78
  $wpdb->query("DROP TABLE IF EXISTS {$prefix}log;");
79
  $wpdb->query("DROP TABLE IF EXISTS {$prefix}summary;");
 
80
  }
77
  $wpdb->query("DROP TABLE IF EXISTS {$prefix}datacache_backup;");
78
  $wpdb->query("DROP TABLE IF EXISTS {$prefix}log;");
79
  $wpdb->query("DROP TABLE IF EXISTS {$prefix}summary;");
80
+ $wpdb->query("DROP TABLE IF EXISTS {$prefix}transients;");
81
  }
wordpress-popular-posts.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: WordPress Popular Posts
17
  * Plugin URI: https://wordpress.org/plugins/wordpress-popular-posts/
18
  * Description: A highly customizable widget that displays the most popular posts on your blog.
19
- * Version: 5.4.2
20
  * Author: Hector Cabrera
21
  * Author URI: https://cabrerahector.com/
22
  * License: GPL-2.0+
@@ -29,7 +29,7 @@ if ( ! defined( 'WPINC' ) ) {
29
  die();
30
  }
31
 
32
- define('WPP_VERSION', '5.4.2');
33
  define('WPP_MIN_PHP_VERSION', '5.4');
34
  define('WPP_MIN_WP_VERSION', '4.9');
35
 
16
  * Plugin Name: WordPress Popular Posts
17
  * Plugin URI: https://wordpress.org/plugins/wordpress-popular-posts/
18
  * Description: A highly customizable widget that displays the most popular posts on your blog.
19
+ * Version: 5.5.0
20
  * Author: Hector Cabrera
21
  * Author URI: https://cabrerahector.com/
22
  * License: GPL-2.0+
29
  die();
30
  }
31
 
32
+ define('WPP_VERSION', '5.5.0');
33
  define('WPP_MIN_PHP_VERSION', '5.4');
34
  define('WPP_MIN_WP_VERSION', '4.9');
35