Public Post Preview - Version 2.9.3

Version Description

(2021-03-12): = * Compatibility with WordPress 5.7. * Create a fresh preview URL when enabling public preview. * Add check for possibly undefined PHP "superglobals". Props @waviaei.

Download this release

Release Info

Developer ocean90
Plugin Icon 128x128 Public Post Preview
Version 2.9.3
Comparing to
See all releases

Code changes from version 2.9.2 to 2.9.3

.npmrc ADDED
@@ -0,0 +1,2 @@
 
 
1
+ save-exact = true
2
+ engine-strict = true
.nvmrc ADDED
@@ -0,0 +1 @@
 
1
+ lts/*
CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
  # Changelog
2
 
 
 
 
 
 
3
  ## 2.9.2 (2020-10-03):
4
- * Fixes saving of preview status without a previous Ajax request.
5
 
6
  ## 2.9.1 (2020-07-25):
7
  * Improve HTTP status codes for expired/invalid preview links.
1
  # Changelog
2
 
3
+ ## 2.9.3 (2021-03-12)
4
+ * Compatibility with WordPress 5.7.
5
+ * Create a fresh preview URL when enabling public preview.
6
+ * Add check for possibly undefined PHP "superglobals". Props [@waviaei](https://github.com/waviaei).
7
+
8
  ## 2.9.2 (2020-10-03):
9
+ * Fix saving of preview status without a previous Ajax request.
10
 
11
  ## 2.9.1 (2020-07-25):
12
  * Improve HTTP status codes for expired/invalid preview links.
js/dist/gutenberg-integration.asset.php CHANGED
@@ -1 +1 @@
1
- <?php return array('dependencies' => array('lodash', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => '1fbe33bd17e10ed54999d3aada052ff9');
1
+ <?php return array('dependencies' => array('lodash', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-polyfill'), 'version' => 'd531c624345a43a19eb64679ce599064');
js/dist/gutenberg-integration.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=16)}([function(e,t){!function(){e.exports=this.wp.element}()},function(e,t){!function(){e.exports=this.wp.i18n}()},function(e,t){!function(){e.exports=this.wp.components}()},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t){!function(){e.exports=this.wp.compose}()},function(e,t){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},r(t)}e.exports=r},function(e,t){!function(){e.exports=this.wp.data}()},function(e,t){!function(){e.exports=this.wp.editPost}()},function(e,t){!function(){e.exports=this.wp.plugins}()},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}},function(e,t,r){var n=r(14);e.exports=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&&n(e,t)}},function(e,t,r){var n=r(15),a=r(3);e.exports=function(e,t){return!t||"object"!==n(t)&&"function"!=typeof t?a(e):t}},function(e,t){!function(){e.exports=this.lodash}()},function(e,t){function r(t,n){return e.exports=r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},r(t,n)}e.exports=r},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=r=function(e){return typeof e}:e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(t)}e.exports=r},function(e,t,r){"use strict";r.r(t);var n=r(8),a=r(9),i=r.n(a),c=r(10),o=r.n(c),s=r(3),u=r.n(s),l=r(11),f=r.n(l),p=r(12),h=r.n(p),d=r(5),b=r.n(d);var v=function(){function e(e){this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.before=null}var t=e.prototype;return t.insert=function(e){if(this.ctr%(this.isSpeedy?65e3:1)==0){var t,r=function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t}(this);t=0===this.tags.length?this.before:this.tags[this.tags.length-1].nextSibling,this.container.insertBefore(r,t),this.tags.push(r)}var n=this.tags[this.tags.length-1];if(this.isSpeedy){var a=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(n);try{var i=105===e.charCodeAt(1)&&64===e.charCodeAt(0);a.insertRule(e,i?0:a.cssRules.length)}catch(e){0}}else n.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){return e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0},e}();var m=function(e){function t(e,t,n){var a=t.trim().split(d);t=a;var i=a.length,c=e.length;switch(c){case 0:case 1:var o=0;for(e=0===c?"":e[0]+" ";o<i;++o)t[o]=r(e,t[o],n).trim();break;default:var s=o=0;for(t=[];o<i;++o)for(var u=0;u<c;++u)t[s++]=r(e[u]+" ",a[o],n).trim()}return t}function r(e,t,r){var n=t.charCodeAt(0);switch(33>n&&(n=(t=t.trim()).charCodeAt(0)),n){case 38:return t.replace(b,"$1"+e.trim());case 58:return e.trim()+t.replace(b,"$1"+e.trim());default:if(0<1*r&&0<t.indexOf("\f"))return t.replace(b,(58===e.charCodeAt(0)?"":"$1")+e.trim())}return e+t}function n(e,t,r,i){var c=e+";",o=2*t+3*r+4*i;if(944===o){e=c.indexOf(":",9)+1;var s=c.substring(e,c.length-1).trim();return s=c.substring(0,e).trim()+s+";",1===P||2===P&&a(s,1)?"-webkit-"+s+s:s}if(0===P||2===P&&!a(c,1))return c;switch(o){case 1015:return 97===c.charCodeAt(10)?"-webkit-"+c+c:c;case 951:return 116===c.charCodeAt(3)?"-webkit-"+c+c:c;case 963:return 110===c.charCodeAt(5)?"-webkit-"+c+c:c;case 1009:if(100!==c.charCodeAt(4))break;case 969:case 942:return"-webkit-"+c+c;case 978:return"-webkit-"+c+"-moz-"+c+c;case 1019:case 983:return"-webkit-"+c+"-moz-"+c+"-ms-"+c+c;case 883:if(45===c.charCodeAt(8))return"-webkit-"+c+c;if(0<c.indexOf("image-set(",11))return c.replace(O,"$1-webkit-$2")+c;break;case 932:if(45===c.charCodeAt(4))switch(c.charCodeAt(5)){case 103:return"-webkit-box-"+c.replace("-grow","")+"-webkit-"+c+"-ms-"+c.replace("grow","positive")+c;case 115:return"-webkit-"+c+"-ms-"+c.replace("shrink","negative")+c;case 98:return"-webkit-"+c+"-ms-"+c.replace("basis","preferred-size")+c}return"-webkit-"+c+"-ms-"+c+c;case 964:return"-webkit-"+c+"-ms-flex-"+c+c;case 1023:if(99!==c.charCodeAt(8))break;return"-webkit-box-pack"+(s=c.substring(c.indexOf(":",15)).replace("flex-","").replace("space-between","justify"))+"-webkit-"+c+"-ms-flex-pack"+s+c;case 1005:return p.test(c)?c.replace(f,":-webkit-")+c.replace(f,":-moz-")+c:c;case 1e3:switch(t=(s=c.substring(13).trim()).indexOf("-")+1,s.charCodeAt(0)+s.charCodeAt(t)){case 226:s=c.replace(g,"tb");break;case 232:s=c.replace(g,"tb-rl");break;case 220:s=c.replace(g,"lr");break;default:return c}return"-webkit-"+c+"-ms-"+s+c;case 1017:if(-1===c.indexOf("sticky",9))break;case 975:switch(t=(c=e).length-10,o=(s=(33===c.charCodeAt(t)?c.substring(0,t):c).substring(e.indexOf(":",7)+1).trim()).charCodeAt(0)+(0|s.charCodeAt(7))){case 203:if(111>s.charCodeAt(8))break;case 115:c=c.replace(s,"-webkit-"+s)+";"+c;break;case 207:case 102:c=c.replace(s,"-webkit-"+(102<o?"inline-":"")+"box")+";"+c.replace(s,"-webkit-"+s)+";"+c.replace(s,"-ms-"+s+"box")+";"+c}return c+";";case 938:if(45===c.charCodeAt(5))switch(c.charCodeAt(6)){case 105:return s=c.replace("-items",""),"-webkit-"+c+"-webkit-box-"+s+"-ms-flex-"+s+c;case 115:return"-webkit-"+c+"-ms-flex-item-"+c.replace(x,"")+c;default:return"-webkit-"+c+"-ms-flex-line-pack"+c.replace("align-content","").replace(x,"")+c}break;case 973:case 989:if(45!==c.charCodeAt(3)||122===c.charCodeAt(4))break;case 931:case 953:if(!0===A.test(e))return 115===(s=e.substring(e.indexOf(":")+1)).charCodeAt(0)?n(e.replace("stretch","fill-available"),t,r,i).replace(":fill-available",":stretch"):c.replace(s,"-webkit-"+s)+c.replace(s,"-moz-"+s.replace("fill-",""))+c;break;case 962:if(c="-webkit-"+c+(102===c.charCodeAt(5)?"-ms-"+c:"")+c,211===r+i&&105===c.charCodeAt(13)&&0<c.indexOf("transform",10))return c.substring(0,c.indexOf(";",27)+1).replace(h,"$1-webkit-$2")+c}return c}function a(e,t){var r=e.indexOf(1===t?":":"{"),n=e.substring(0,3!==t?r:10);return r=e.substring(r+1,e.length-1),z(2!==t?n:n.replace(C,"$1"),r,t)}function i(e,t){var r=n(t,t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2));return r!==t+";"?r.replace(k," or ($1)").substring(4):"("+t+")"}function c(e,t,r,n,a,i,c,o,u,l){for(var f,p=0,h=t;p<I;++p)switch(f=R[p].call(s,e,h,r,n,a,i,c,o,u,l)){case void 0:case!1:case!0:case null:break;default:h=f}if(h!==t)return h}function o(e){return void 0!==(e=e.prefix)&&(z=null,e?"function"!=typeof e?P=1:(P=2,z=e):P=0),o}function s(e,r){var o=e;if(33>o.charCodeAt(0)&&(o=o.trim()),o=[o],0<I){var s=c(-1,r,o,o,S,j,0,0,0,0);void 0!==s&&"string"==typeof s&&(r=s)}var f=function e(r,o,s,f,p){for(var h,d,b,g,k,x=0,C=0,A=0,O=0,R=0,z=0,$=b=h=0,U=0,D=0,F=0,M=0,G=s.length,H=G-1,T="",V="",L="",W="";U<G;){if(d=s.charCodeAt(U),U===H&&0!==C+O+A+x&&(0!==C&&(d=47===C?10:47),O=A=x=0,G++,H++),0===C+O+A+x){if(U===H&&(0<D&&(T=T.replace(l,"")),0<T.trim().length)){switch(d){case 32:case 9:case 59:case 13:case 10:break;default:T+=s.charAt(U)}d=59}switch(d){case 123:for(h=(T=T.trim()).charCodeAt(0),b=1,M=++U;U<G;){switch(d=s.charCodeAt(U)){case 123:b++;break;case 125:b--;break;case 47:switch(d=s.charCodeAt(U+1)){case 42:case 47:e:{for($=U+1;$<H;++$)switch(s.charCodeAt($)){case 47:if(42===d&&42===s.charCodeAt($-1)&&U+2!==$){U=$+1;break e}break;case 10:if(47===d){U=$+1;break e}}U=$}}break;case 91:d++;case 40:d++;case 34:case 39:for(;U++<H&&s.charCodeAt(U)!==d;);}if(0===b)break;U++}switch(b=s.substring(M,U),0===h&&(h=(T=T.replace(u,"").trim()).charCodeAt(0)),h){case 64:switch(0<D&&(T=T.replace(l,"")),d=T.charCodeAt(1)){case 100:case 109:case 115:case 45:D=o;break;default:D=E}if(M=(b=e(o,D,b,d,p+1)).length,0<I&&(k=c(3,b,D=t(E,T,F),o,S,j,M,d,p,f),T=D.join(""),void 0!==k&&0===(M=(b=k.trim()).length)&&(d=0,b="")),0<M)switch(d){case 115:T=T.replace(y,i);case 100:case 109:case 45:b=T+"{"+b+"}";break;case 107:b=(T=T.replace(v,"$1 $2"))+"{"+b+"}",b=1===P||2===P&&a("@"+b,3)?"@-webkit-"+b+"@"+b:"@"+b;break;default:b=T+b,112===f&&(V+=b,b="")}else b="";break;default:b=e(o,t(o,T,F),b,f,p+1)}L+=b,b=F=D=$=h=0,T="",d=s.charCodeAt(++U);break;case 125:case 59:if(1<(M=(T=(0<D?T.replace(l,""):T).trim()).length))switch(0===$&&(h=T.charCodeAt(0),45===h||96<h&&123>h)&&(M=(T=T.replace(" ",":")).length),0<I&&void 0!==(k=c(1,T,o,r,S,j,V.length,f,p,f))&&0===(M=(T=k.trim()).length)&&(T="\0\0"),h=T.charCodeAt(0),d=T.charCodeAt(1),h){case 0:break;case 64:if(105===d||99===d){W+=T+s.charAt(U);break}default:58!==T.charCodeAt(M-1)&&(V+=n(T,h,d,T.charCodeAt(2)))}F=D=$=h=0,T="",d=s.charCodeAt(++U)}}switch(d){case 13:case 10:47===C?C=0:0===1+h&&107!==f&&0<T.length&&(D=1,T+="\0"),0<I*N&&c(0,T,o,r,S,j,V.length,f,p,f),j=1,S++;break;case 59:case 125:if(0===C+O+A+x){j++;break}default:switch(j++,g=s.charAt(U),d){case 9:case 32:if(0===O+x+C)switch(R){case 44:case 58:case 9:case 32:g="";break;default:32!==d&&(g=" ")}break;case 0:g="\\0";break;case 12:g="\\f";break;case 11:g="\\v";break;case 38:0===O+C+x&&(D=F=1,g="\f"+g);break;case 108:if(0===O+C+x+_&&0<$)switch(U-$){case 2:112===R&&58===s.charCodeAt(U-3)&&(_=R);case 8:111===z&&(_=z)}break;case 58:0===O+C+x&&($=U);break;case 44:0===C+A+O+x&&(D=1,g+="\r");break;case 34:case 39:0===C&&(O=O===d?0:0===O?d:O);break;case 91:0===O+C+A&&x++;break;case 93:0===O+C+A&&x--;break;case 41:0===O+C+x&&A--;break;case 40:if(0===O+C+x){if(0===h)switch(2*R+3*z){case 533:break;default:h=1}A++}break;case 64:0===C+A+O+x+$+b&&(b=1);break;case 42:case 47:if(!(0<O+x+A))switch(C){case 0:switch(2*d+3*s.charCodeAt(U+1)){case 235:C=47;break;case 220:M=U,C=42}break;case 42:47===d&&42===R&&M+2!==U&&(33===s.charCodeAt(M+2)&&(V+=s.substring(M,U+1)),g="",C=0)}}0===C&&(T+=g)}z=R,R=d,U++}if(0<(M=V.length)){if(D=o,0<I&&(void 0!==(k=c(2,V,D,r,S,j,M,f,p,f))&&0===(V=k).length))return W+V+L;if(V=D.join(",")+"{"+V+"}",0!=P*_){switch(2!==P||a(V,2)||(_=0),_){case 111:V=V.replace(w,":-moz-$1")+V;break;case 112:V=V.replace(m,"::-webkit-input-$1")+V.replace(m,"::-moz-$1")+V.replace(m,":-ms-input-$1")+V}_=0}}return W+V+L}(E,o,r,0,0);return 0<I&&(void 0!==(s=c(-2,f,o,o,S,j,f.length,0,0,0))&&(f=s)),"",_=0,j=S=1,f}var u=/^\0+/g,l=/[\0\r\f]/g,f=/: */g,p=/zoo|gra/,h=/([,: ])(transform)/g,d=/,\r+?/g,b=/([\t\r\n ])*\f?&/g,v=/@(k\w+)\s*(\S*)\s*/,m=/::(place)/g,w=/:(read-only)/g,g=/[svh]\w+-[tblr]{2}/,y=/\(\s*(.*)\s*\)/g,k=/([\s\S]*?);/g,x=/-self|flex-/g,C=/[^]*?(:[rp][el]a[\w-]+)[^]*/,A=/stretch|:\s*\w+\-(?:conte|avail)/,O=/([^-])(image-set\()/,j=1,S=1,_=0,P=1,E=[],R=[],I=0,z=null,N=0;return s.use=function e(t){switch(t){case void 0:case null:I=R.length=0;break;default:if("function"==typeof t)R[I++]=t;else if("object"==typeof t)for(var r=0,n=t.length;r<n;++r)e(t[r]);else N=0|!!t}return e},s.set=o,void 0!==e&&o(e),s};function w(e){e&&g.current.insert(e+"}")}var g={current:null},y=function(e,t,r,n,a,i,c,o,s,u){switch(e){case 1:switch(t.charCodeAt(0)){case 64:return g.current.insert(t+";"),"";case 108:if(98===t.charCodeAt(2))return""}break;case 2:if(0===o)return t+"/*|*/";break;case 3:switch(o){case 102:case 112:return g.current.insert(r[0]+t),"";default:return t+(0===u?"/*|*/":"")}case-2:t.split("/*|*/}").forEach(w)}},k=function(e){void 0===e&&(e={});var t,r=e.key||"css";void 0!==e.prefix&&(t={prefix:e.prefix});var n=new m(t);var a,i={};a=e.container||document.head;var c,o=document.querySelectorAll("style[data-emotion-"+r+"]");Array.prototype.forEach.call(o,(function(e){e.getAttribute("data-emotion-"+r).split(" ").forEach((function(e){i[e]=!0})),e.parentNode!==a&&a.appendChild(e)})),n.use(e.stylisPlugins)(y),c=function(e,t,r,a){var i=t.name;g.current=r,n(e,t.styles),a&&(s.inserted[i]=!0)};var s={key:r,sheet:new v({key:r,container:a,nonce:e.nonce,speedy:e.speedy}),nonce:e.nonce,inserted:i,registered:{},insert:c};return s};var x=function(e){for(var t,r=0,n=0,a=e.length;a>=4;++n,a-=4)t=1540483477*(65535&(t=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+(59797*(t>>>16)<<16),r=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&r)+(59797*(r>>>16)<<16);switch(a){case 3:r^=(255&e.charCodeAt(n+2))<<16;case 2:r^=(255&e.charCodeAt(n+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(n)))+(59797*(r>>>16)<<16)}return(((r=1540483477*(65535&(r^=r>>>13))+(59797*(r>>>16)<<16))^r>>>15)>>>0).toString(36)},C={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};var A=/[A-Z]|^ms/g,O=/_EMO_([^_]+?)_([^]*?)_EMO_/g,j=function(e){return 45===e.charCodeAt(1)},S=function(e){return null!=e&&"boolean"!=typeof e},_=function(e){var t={};return function(r){return void 0===t[r]&&(t[r]=e(r)),t[r]}}((function(e){return j(e)?e:e.replace(A,"-$&").toLowerCase()})),P=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(O,(function(e,t,r){return R={name:t,styles:r,next:R},t}))}return 1===C[e]||j(e)||"number"!=typeof t||0===t?t:t+"px"};function E(e,t,r,n){if(null==r)return"";if(void 0!==r.__emotion_styles)return r;switch(typeof r){case"boolean":return"";case"object":if(1===r.anim)return R={name:r.name,styles:r.styles,next:R},r.name;if(void 0!==r.styles){var a=r.next;if(void 0!==a)for(;void 0!==a;)R={name:a.name,styles:a.styles,next:R},a=a.next;return r.styles+";"}return function(e,t,r){var n="";if(Array.isArray(r))for(var a=0;a<r.length;a++)n+=E(e,t,r[a],!1);else for(var i in r){var c=r[i];if("object"!=typeof c)null!=t&&void 0!==t[c]?n+=i+"{"+t[c]+"}":S(c)&&(n+=_(i)+":"+P(i,c)+";");else if(!Array.isArray(c)||"string"!=typeof c[0]||null!=t&&void 0!==t[c[0]]){var o=E(e,t,c,!1);switch(i){case"animation":case"animationName":n+=_(i)+":"+o+";";break;default:n+=i+"{"+o+"}"}}else for(var s=0;s<c.length;s++)S(c[s])&&(n+=_(i)+":"+P(i,c[s])+";")}return n}(e,t,r);case"function":if(void 0!==e){var i=R,c=r(e);return R=i,E(e,t,c,n)}break;case"string":}if(null==t)return r;var o=t[r];return void 0===o||n?r:o}var R,I=/label:\s*([^\s;\n{]+)\s*;/g;var z=function(e,t,r){if(1===e.length&&"object"==typeof e[0]&&null!==e[0]&&void 0!==e[0].styles)return e[0];var n=!0,a="";R=void 0;var i=e[0];null==i||void 0===i.raw?(n=!1,a+=E(r,t,i,!1)):a+=i[0];for(var c=1;c<e.length;c++)a+=E(r,t,e[c],46===a.charCodeAt(a.length-1)),n&&(a+=i[c]);I.lastIndex=0;for(var o,s="";null!==(o=I.exec(a));)s+="-"+o[1];return{name:x(a)+s,styles:a,next:R}};function N(e,t,r){var n="";return r.split(" ").forEach((function(r){void 0!==e[r]?t.push(e[r]):n+=r+" "})),n}var $=function(e,t,r){var n=e.key+"-"+t.name;if(!1===r&&void 0===e.registered[n]&&(e.registered[n]=t.styles),void 0===e.inserted[t.name]){var a=t;do{e.insert("."+n,a,e.sheet,!0);a=a.next}while(void 0!==a)}};function U(e,t){if(void 0===e.inserted[t.name])return e.insert("",t,e.sheet,!0)}function D(e,t,r){var n=[],a=N(e,n,r);return n.length<2?r:a+t(n)}var F=function e(t){for(var r="",n=0;n<t.length;n++){var a=t[n];if(null!=a){var i=void 0;switch(typeof a){case"boolean":break;case"object":if(Array.isArray(a))i=e(a);else for(var c in i="",a)a[c]&&c&&(i&&(i+=" "),i+=c);break;default:i=a}i&&(r&&(r+=" "),r+=i)}}return r},M=function(e){var t=k(e);t.sheet.speedy=function(e){this.isSpeedy=e},t.compat=!0;var r=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=z(r,t.registered,void 0);return $(t,a,!1),t.key+"-"+a.name};return{css:r,cx:function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];return D(t.registered,r,F(n))},injectGlobal:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=z(r,t.registered);U(t,a)},keyframes:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=z(r,t.registered),i="animation-"+a.name;return U(t,{name:a.name,styles:"@keyframes "+i+"{"+a.styles+"}"}),i},hydrate:function(e){e.forEach((function(e){t.inserted[e]=!0}))},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:N.bind(null,t.registered),merge:D.bind(null,t.registered,r)}}(),G=(M.flush,M.hydrate,M.cx,M.merge,M.getRegisteredStyles,M.injectGlobal,M.keyframes,M.css),H=(M.sheet,M.cache,r(0)),T=r(13),V=r(1),L=r(2),W=r(6),q=r(7),B=r(4);function Z(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b()(e);if(t){var a=b()(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return h()(this,r)}}var J=window,K=J.ajaxurl,Q=J.DSPublicPostPreviewData,X=G({name:"v3x9uo",styles:"flex-direction:column;align-items:stretch;margin-top:10px;"}),Y=G({name:"69ytpn",styles:"width:100%;margin-right:12px;"}),ee=G({name:"xtpryr",styles:"font-style:italic;color:#666;margin:0.2em 0 0 !important;"}),te=G({name:"9vxan6",styles:"display:flex;justify-content:flex-start;align-items:center;margin:0;"}),re=Object(H.createElement)(L.SVG,{width:"20",height:"20",viewBox:"0 0 14 16",xmlns:"http://www.w3.org/2000/svg"},Object(H.createElement)(L.Path,{fillRule:"evenodd",d:"M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"})),ne=function(e){f()(r,e);var t=Z(r);function r(e){var n;return i()(this,r),(n=t.call(this,e)).state={previewEnabled:Q.previewEnabled,previewUrl:Q.previewUrl,hasCopied:!1},n.previewUrlInput=Object(H.createRef)(),n.onChange=n.onChange.bind(u()(n)),n.onPreviewUrlInputFocus=n.onPreviewUrlInputFocus.bind(u()(n)),n}return o()(r,[{key:"onChange",value:function(e){var t=this,r=new window.FormData;r.append("checked",e),r.append("post_ID",this.props.postId),this.sendRequest(r).then((function(e){if(e.status>=200&&e.status<300)return e;throw e})).then((function(e){return e.json()})).then((function(e){if(!e.success)throw e;var r=!t.state.previewEnabled;t.setState({previewEnabled:r}),t.props.createNotice("info",r?Object(V.__)("Public preview enabled.","public-post-preview"):Object(V.__)("Public preview disabled.","public-post-preview"),{id:"public-post-preview",isDismissible:!0,type:"snackbar"})})).catch((function(){t.props.createNotice("error",Object(V.__)("Error while changing the public preview status.","public-post-preview"),{id:"public-post-preview",isDismissible:!0,type:"snackbar"})}))}},{key:"onPreviewUrlInputFocus",value:function(){this.previewUrlInput.current.focus(),this.previewUrlInput.current.select()}},{key:"sendRequest",value:function(e){return e.append("action","public-post-preview"),e.append("_ajax_nonce",Q.nonce),window.fetch(K,{method:"POST",body:e})}},{key:"render",value:function(){var e=this,t=this.state,r=t.previewEnabled,n=t.previewUrl,a=t.hasCopied,i=a?Object(V.__)("Preview URL copied","public-post-preview"):Object(V.__)("Copy the preview URL","public-post-preview");return Object(H.createElement)(H.Fragment,null,Object(H.createElement)(q.PluginPostStatusInfo,null,Object(H.createElement)(L.CheckboxControl,{label:Object(V.__)("Enable public preview","public-post-preview"),checked:r,onChange:this.onChange})),r&&Object(H.createElement)(q.PluginPostStatusInfo,{className:X},Object(H.createElement)("p",{className:te},Object(H.createElement)("label",{htmlFor:"public-post-preview-url",className:"screen-reader-text"},Object(V.__)("Preview URL","public-post-preview")),Object(H.createElement)("input",{ref:this.previewUrlInput,type:"text",id:"public-post-preview-url",className:Y,value:n,readOnly:!0,onFocus:this.onPreviewUrlInputFocus}),Object(H.createElement)(L.ClipboardButton,{text:n,label:i,onCopy:function(){return e.setState({hasCopied:!0})},onFinishCopy:function(){return e.setState({hasCopied:!1})},"aria-disabled":a,icon:re})),Object(H.createElement)("p",{className:ee},Object(V.__)("Copy and share this preview URL.","public-post-preview"))))}}]),r}(H.Component),ae=Object(B.compose)([Object(W.withSelect)((function(e){var t=e("core").getPostType,r=e("core/editor"),n=r.getCurrentPostId,a=r.getEditedPostAttribute,i=t(a("type"));return{postId:n(),status:a("status"),isViewable:Object(T.get)(i,["viewable"],!1)}})),Object(B.ifCondition)((function(e){return e.isViewable})),Object(B.ifCondition)((function(e){var t=e.status;return-1===["auto-draft","publish","private"].indexOf(t)})),Object(W.withDispatch)((function(e){return{createNotice:e("core/notices").createNotice}}))])(ne);Object(n.registerPlugin)("public-post-preview",{render:ae})}]);
1
+ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=16)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.components},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t){e.exports=window.wp.compose},function(e,t){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},r(t)}e.exports=r},function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.wp.editPost},function(e,t){e.exports=window.wp.plugins},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}},function(e,t,r){var n=r(14);e.exports=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&&n(e,t)}},function(e,t,r){var n=r(15),a=r(3);e.exports=function(e,t){return!t||"object"!==n(t)&&"function"!=typeof t?a(e):t}},function(e,t){e.exports=window.lodash},function(e,t){function r(t,n){return e.exports=r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},r(t,n)}e.exports=r},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=r=function(e){return typeof e}:e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(t)}e.exports=r},function(e,t,r){"use strict";r.r(t);var n=r(8),a=r(9),i=r.n(a),o=r(10),c=r.n(o),s=r(3),u=r.n(s),l=r(11),f=r.n(l),p=r(12),d=r.n(p),h=r(5),v=r.n(h),b=r(0),y=r(13),w=function(){function e(e){var t=this;this._insertTag=function(e){var r;r=0===t.tags.length?t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,r),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}(t);try{r.insertRule(e,r.cssRules.length)}catch(e){}}else t.appendChild(document.createTextNode(e));this.ctr++},t.flush=function(){this.tags.forEach((function(e){return e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0},e}(),m="-ms-",g="-moz-",x="-webkit-",k="comm",O="rule",j="decl",C=Math.abs,_=String.fromCharCode;function S(e){return e.trim()}function P(e,t,r){return e.replace(t,r)}function $(e,t){return e.indexOf(t)}function A(e,t){return 0|e.charCodeAt(t)}function E(e,t,r){return e.slice(t,r)}function R(e){return e.length}function I(e){return e.length}function z(e,t){return t.push(e),e}var N=1,U=1,M=0,D=0,F=0,T="";function G(e,t,r,n,a,i,o){return{value:e,root:t,parent:r,type:n,props:a,children:i,line:N,column:U,length:o,return:""}}function H(e,t,r){return G(e,t.root,t.parent,r,t.props,t.children,0)}function V(){return F=D<M?A(T,D++):0,U++,10===F&&(U=1,N++),F}function q(){return A(T,D)}function L(){return D}function W(e,t){return E(T,e,t)}function B(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Z(e){return N=U=1,M=R(T=e),D=0,[]}function J(e){return T="",e}function K(e){return S(W(D-1,function e(t){for(;V();)switch(F){case t:return D;case 34:case 39:return e(34===t||39===t?t:F);case 40:41===t&&e(t);break;case 92:V()}return D}(91===e?e+2:40===e?e+1:e)))}function Q(e){for(;(F=q())&&F<33;)V();return B(e)>2||B(F)>3?"":" "}function X(e,t){for(;V()&&e+F!==57&&(e+F!==84||47!==q()););return"/*"+W(t,D-1)+"*"+_(47===e?e:V())}function Y(e){for(;!B(q());)V();return W(e,D)}function ee(e,t,r,n,a,i,o,c,s,u,l){for(var f=a-1,p=0===a?i:[""],d=I(p),h=0,v=0,b=0;h<n;++h)for(var y=0,w=E(e,f+1,f=C(v=o[h])),m=e;y<d;++y)(m=S(v>0?p[y]+" "+w:P(w,/&\f/g,p[y])))&&(s[b++]=m);return G(e,t,r,0===a?O:c,s,u,l)}function te(e,t,r){return G(e,t,r,k,_(F),E(e,2,-2),0)}function re(e,t,r,n){return G(e,t,r,j,E(e,0,n),E(e,n+1,-1),n)}function ne(e,t){for(var r="",n=I(e),a=0;a<n;a++)r+=t(e[a],a,e,t)||"";return r}function ae(e,t,r,n){switch(e.type){case"@import":case j:return e.return=e.return||e.value;case k:return"";case O:e.value=e.props.join(",")}return R(r=ne(e.children,n))?e.return=e.value+"{"+r+"}":""}function ie(e){return function(t){t.root||(t=t.return)&&e(t)}}var oe=function(e){var t={};return function(r){return void 0===t[r]&&(t[r]=e(r)),t[r]}},ce=new WeakMap,se=function(e){if("rule"===e.type&&e.parent&&e.length){for(var t=e.value,r=e.parent,n=e.column===r.column&&e.line===r.line;"rule"!==r.type;)if(!(r=r.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||ce.get(r))&&!n){ce.set(e,!0);for(var a=[],i=function(e,t){return J(function(e,t){var r=-1,n=44;do{switch(B(n)){case 0:38===n&&12===q()&&(t[r]=1),e[r]+=Y(D-1);break;case 2:e[r]+=K(n);break;case 4:if(44===n){e[++r]=58===q()?"&\f":"",t[r]=e[r].length;break}default:e[r]+=_(n)}}while(n=V());return e}(Z(e),t))}(t,a),o=r.props,c=0,s=0;c<i.length;c++)for(var u=0;u<o.length;u++,s++)e.props[s]=a[c]?i[c].replace(/&\f/g,o[u]):o[u]+" "+i[c]}}},ue=function(e){if("decl"===e.type){var t=e.value;108===t.charCodeAt(0)&&98===t.charCodeAt(2)&&(e.return="",e.value="")}},le=[function(e,t,r,n){if(!e.return)switch(e.type){case j:e.return=function e(t,r){switch(function(e,t){return(((t<<2^A(e,0))<<2^A(e,1))<<2^A(e,2))<<2^A(e,3)}(t,r)){case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return x+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return x+t+g+t+m+t+t;case 6828:case 4268:return x+t+m+t+t;case 6165:return x+t+m+"flex-"+t+t;case 5187:return x+t+P(t,/(\w+).+(:[^]+)/,x+"box-$1$2"+m+"flex-$1$2")+t;case 5443:return x+t+m+"flex-item-"+P(t,/flex-|-self/,"")+t;case 4675:return x+t+m+"flex-line-pack"+P(t,/align-content|flex-|-self/,"")+t;case 5548:return x+t+m+P(t,"shrink","negative")+t;case 5292:return x+t+m+P(t,"basis","preferred-size")+t;case 6060:return x+"box-"+P(t,"-grow","")+x+t+m+P(t,"grow","positive")+t;case 4554:return x+P(t,/([^-])(transform)/g,"$1"+x+"$2")+t;case 6187:return P(P(P(t,/(zoom-|grab)/,x+"$1"),/(image-set)/,x+"$1"),t,"")+t;case 5495:case 3959:return P(t,/(image-set\([^]*)/,x+"$1$`$1");case 4968:return P(P(t,/(.+:)(flex-)?(.*)/,x+"box-pack:$3"+m+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+x+t+t;case 4095:case 3583:case 4068:case 2532:return P(t,/(.+)-inline(.+)/,x+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(R(t)-1-r>6)switch(A(t,r+1)){case 102:r=A(t,r+3);case 109:return P(t,/(.+:)(.+)-([^]+)/,"$1"+x+"$2-$3$1"+g+(108==r?"$3":"$2-$3"))+t;case 115:return~$(t,"stretch")?e(P(t,"stretch","fill-available"),r)+t:t}break;case 4949:if(115!==A(t,r+1))break;case 6444:switch(A(t,R(t)-3-(~$(t,"!important")&&10))){case 107:case 111:return P(t,t,x+t)+t;case 101:return P(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+x+(45===A(t,14)?"inline-":"")+"box$3$1"+x+"$2$3$1"+m+"$2box$3")+t}break;case 5936:switch(A(t,r+11)){case 114:return x+t+m+P(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return x+t+m+P(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return x+t+m+P(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return x+t+m+t+t}return t}(e.value,e.length);break;case"@keyframes":return ne([H(P(e.value,"@","@"+x),e,"")],n);case O:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=/(::plac\w+|:read-\w+)/.exec(e))?e[0]:e}(t)){case":read-only":case":read-write":return ne([H(P(t,/:(read-\w+)/,":-moz-$1"),e,"")],n);case"::placeholder":return ne([H(P(t,/:(plac\w+)/,":"+x+"input-$1"),e,""),H(P(t,/:(plac\w+)/,":-moz-$1"),e,""),H(P(t,/:(plac\w+)/,m+"input-$1"),e,"")],n)}return""}))}}],fe=function(e){var t=e.key;if("css"===t){var r=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(r,(function(e){document.head.appendChild(e),e.setAttribute("data-s","")}))}var n,a,i=e.stylisPlugins||le,o={},c=[];n=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll("style[data-emotion]"),(function(e){var r=e.getAttribute("data-emotion").split(" ");if(r[0]===t){for(var n=1;n<r.length;n++)o[r[n]]=!0;c.push(e)}}));var s,u=[se,ue],l=[ae,ie((function(e){s.insert(e)}))],f=function(e){var t=I(e);return function(r,n,a,i){for(var o="",c=0;c<t;c++)o+=e[c](r,n,a,i)||"";return o}}(u.concat(i,l));a=function(e,t,r,n){s=r,ne(function(e){return J(function e(t,r,n,a,i,o,c,s,u){for(var l=0,f=0,p=c,d=0,h=0,v=0,b=1,y=1,w=1,m=0,g="",x=i,k=o,O=a,j=g;y;)switch(v=m,m=V()){case 34:case 39:case 91:case 40:j+=K(m);break;case 9:case 10:case 13:case 32:j+=Q(v);break;case 47:switch(q()){case 42:case 47:z(te(X(V(),L()),r,n),u);break;default:j+="/"}break;case 123*b:s[l++]=R(j)*w;case 125*b:case 59:case 0:switch(m){case 0:case 125:y=0;case 59+f:h>0&&z(h>32?re(j+";",a,n,p-1):re(P(j," ","")+";",a,n,p-2),u);break;case 59:j+=";";default:if(z(O=ee(j,r,n,l,f,i,s,g,x=[],k=[],p),o),123===m)if(0===f)e(j,r,O,O,x,o,p,s,k);else switch(d){case 100:case 109:case 115:e(t,O,O,a&&z(ee(t,O,O,0,0,i,s,g,i,x=[],p),k),i,k,p,s,a?x:k);break;default:e(j,O,O,O,[""],k,p,s,k)}}l=f=h=0,b=w=1,g=j="",p=c;break;case 58:p=1+R(j),h=v;default:switch(j+=_(m),m*b){case 38:w=f>0?1:(j+="\f",-1);break;case 44:s[l++]=(R(j)-1)*w,w=1;break;case 64:45===q()&&(j+=K(V())),d=q(),f=R(g=j+=Y(L())),m++;break;case 45:45===v&&2==R(j)&&(b=0)}}return o}("",null,null,null,[""],e=Z(e),0,[0],e))}(e?e+"{"+t.styles+"}":t.styles),f),n&&(p.inserted[t.name]=!0)};var p={key:t,sheet:new w({key:t,container:n,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend}),nonce:e.nonce,inserted:o,registered:{},insert:a};return p.sheet.hydrate(c),p},pe=function(e){for(var t,r=0,n=0,a=e.length;a>=4;++n,a-=4)t=1540483477*(65535&(t=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+(59797*(t>>>16)<<16),r=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&r)+(59797*(r>>>16)<<16);switch(a){case 3:r^=(255&e.charCodeAt(n+2))<<16;case 2:r^=(255&e.charCodeAt(n+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(n)))+(59797*(r>>>16)<<16)}return(((r=1540483477*(65535&(r^=r>>>13))+(59797*(r>>>16)<<16))^r>>>15)>>>0).toString(36)},de={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},he=/[A-Z]|^ms/g,ve=/_EMO_([^_]+?)_([^]*?)_EMO_/g,be=function(e){return 45===e.charCodeAt(1)},ye=function(e){return null!=e&&"boolean"!=typeof e},we=oe((function(e){return be(e)?e:e.replace(he,"-$&").toLowerCase()})),me=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(ve,(function(e,t,r){return xe={name:t,styles:r,next:xe},t}))}return 1===de[e]||be(e)||"number"!=typeof t||0===t?t:t+"px"};function ge(e,t,r){if(null==r)return"";if(void 0!==r.__emotion_styles)return r;switch(typeof r){case"boolean":return"";case"object":if(1===r.anim)return xe={name:r.name,styles:r.styles,next:xe},r.name;if(void 0!==r.styles){var n=r.next;if(void 0!==n)for(;void 0!==n;)xe={name:n.name,styles:n.styles,next:xe},n=n.next;return r.styles+";"}return function(e,t,r){var n="";if(Array.isArray(r))for(var a=0;a<r.length;a++)n+=ge(e,t,r[a])+";";else for(var i in r){var o=r[i];if("object"!=typeof o)null!=t&&void 0!==t[o]?n+=i+"{"+t[o]+"}":ye(o)&&(n+=we(i)+":"+me(i,o)+";");else if(!Array.isArray(o)||"string"!=typeof o[0]||null!=t&&void 0!==t[o[0]]){var c=ge(e,t,o);switch(i){case"animation":case"animationName":n+=we(i)+":"+c+";";break;default:n+=i+"{"+c+"}"}}else for(var s=0;s<o.length;s++)ye(o[s])&&(n+=we(i)+":"+me(i,o[s])+";")}return n}(e,t,r);case"function":if(void 0!==e){var a=xe,i=r(e);return xe=a,ge(e,t,i)}}if(null==t)return r;var o=t[r];return void 0!==o?o:r}var xe,ke=/label:\s*([^\s;\n{]+)\s*;/g,Oe=function(e,t,r){if(1===e.length&&"object"==typeof e[0]&&null!==e[0]&&void 0!==e[0].styles)return e[0];var n=!0,a="";xe=void 0;var i=e[0];null==i||void 0===i.raw?(n=!1,a+=ge(r,t,i)):a+=i[0];for(var o=1;o<e.length;o++)a+=ge(r,t,e[o]),n&&(a+=i[o]);ke.lastIndex=0;for(var c,s="";null!==(c=ke.exec(a));)s+="-"+c[1];return{name:pe(a)+s,styles:a,next:xe}};function je(e,t,r){var n="";return r.split(" ").forEach((function(r){void 0!==e[r]?t.push(e[r]+";"):n+=r+" "})),n}var Ce=function(e,t,r){var n=e.key+"-"+t.name;if(!1===r&&void 0===e.registered[n]&&(e.registered[n]=t.styles),void 0===e.inserted[t.name]){var a=t;do{e.insert(t===a?"."+n:"",a,e.sheet,!0),a=a.next}while(void 0!==a)}};function _e(e,t){if(void 0===e.inserted[t.name])return e.insert("",t,e.sheet,!0)}function Se(e,t,r){var n=[],a=je(e,n,r);return n.length<2?r:a+t(n)}var Pe=function e(t){for(var r="",n=0;n<t.length;n++){var a=t[n];if(null!=a){var i=void 0;switch(typeof a){case"boolean":break;case"object":if(Array.isArray(a))i=e(a);else for(var o in i="",a)a[o]&&o&&(i&&(i+=" "),i+=o);break;default:i=a}i&&(r&&(r+=" "),r+=i)}}return r},$e=function(e){var t=fe({key:"css"});t.sheet.speedy=function(e){this.isSpeedy=e},t.compat=!0;var r=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=Oe(r,t.registered,void 0);return Ce(t,a,!1),t.key+"-"+a.name};return{css:r,cx:function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];return Se(t.registered,r,Pe(n))},injectGlobal:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=Oe(r,t.registered);_e(t,a)},keyframes:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=Oe(r,t.registered),i="animation-"+a.name;return _e(t,{name:a.name,styles:"@keyframes "+i+"{"+a.styles+"}"}),i},hydrate:function(e){e.forEach((function(e){t.inserted[e]=!0}))},flush:function(){t.registered={},t.inserted={},t.sheet.flush()},sheet:t.sheet,cache:t,getRegisteredStyles:je.bind(null,t.registered),merge:Se.bind(null,t.registered,r)}}(),Ae=($e.flush,$e.hydrate,$e.cx,$e.merge,$e.getRegisteredStyles,$e.injectGlobal,$e.keyframes,$e.css),Ee=($e.sheet,$e.cache,r(1)),Re=r(2),Ie=r(6),ze=r(7),Ne=r(4);var Ue=window,Me=Ue.ajaxurl,De=Ue.DSPublicPostPreviewData,Fe=Ae({name:"pzaqto",styles:"flex-direction:column;align-items:stretch;margin-top:10px"}),Te=Ae({name:"1gqzxr1",styles:"width:100%;margin-right:12px"}),Ge=Ae({name:"iijanu",styles:"font-style:italic;color:#666;margin:0.2em 0 0!important"}),He=Ae({name:"gqlj34",styles:"display:flex;justify-content:flex-start;align-items:center;margin:0"}),Ve=Object(b.createElement)(Re.SVG,{width:"20",height:"20",viewBox:"0 0 14 16",xmlns:"http://www.w3.org/2000/svg"},Object(b.createElement)(Re.Path,{fillRule:"evenodd",d:"M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"})),qe=function(e){f()(a,e);var t,r,n=(t=a,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=v()(t);if(r){var a=v()(this).constructor;e=Reflect.construct(n,arguments,a)}else e=n.apply(this,arguments);return d()(this,e)});function a(e){var t;return i()(this,a),(t=n.call(this,e)).state={previewEnabled:De.previewEnabled,previewUrl:De.previewUrl,hasCopied:!1},t.previewUrlInput=Object(b.createRef)(),t.onChange=t.onChange.bind(u()(t)),t.onPreviewUrlInputFocus=t.onPreviewUrlInputFocus.bind(u()(t)),t}return c()(a,[{key:"onChange",value:function(e){var t=this,r=new window.FormData;r.append("checked",e),r.append("post_ID",this.props.postId),this.sendRequest(r).then((function(e){if(e.status>=200&&e.status<300)return e;throw e})).then((function(e){return e.json()})).then((function(e){var r;if(!e.success)throw e;var n=!t.state.previewEnabled;t.setState({previewEnabled:n,previewUrl:(null==e||null===(r=e.data)||void 0===r?void 0:r.preview_url)||""}),t.props.createNotice("info",n?Object(Ee.__)("Public preview enabled.","public-post-preview"):Object(Ee.__)("Public preview disabled.","public-post-preview"),{id:"public-post-preview",isDismissible:!0,type:"snackbar"})})).catch((function(){t.props.createNotice("error",Object(Ee.__)("Error while changing the public preview status.","public-post-preview"),{id:"public-post-preview",isDismissible:!0,type:"snackbar"})}))}},{key:"onPreviewUrlInputFocus",value:function(){this.previewUrlInput.current.focus(),this.previewUrlInput.current.select()}},{key:"sendRequest",value:function(e){return e.append("action","public-post-preview"),e.append("_ajax_nonce",De.nonce),window.fetch(Me,{method:"POST",body:e})}},{key:"render",value:function(){var e=this,t=this.state,r=t.previewEnabled,n=t.previewUrl,a=t.hasCopied,i=a?Object(Ee.__)("Preview URL copied","public-post-preview"):Object(Ee.__)("Copy the preview URL","public-post-preview");return Object(b.createElement)(b.Fragment,null,Object(b.createElement)(ze.PluginPostStatusInfo,null,Object(b.createElement)(Re.CheckboxControl,{label:Object(Ee.__)("Enable public preview","public-post-preview"),checked:r,onChange:this.onChange})),r&&Object(b.createElement)(ze.PluginPostStatusInfo,{className:Fe},Object(b.createElement)("p",{className:He},Object(b.createElement)("label",{htmlFor:"public-post-preview-url",className:"screen-reader-text"},Object(Ee.__)("Preview URL","public-post-preview")),Object(b.createElement)("input",{ref:this.previewUrlInput,type:"text",id:"public-post-preview-url",className:Te,value:n,readOnly:!0,onFocus:this.onPreviewUrlInputFocus}),Object(b.createElement)(Re.ClipboardButton,{text:n,label:i,onCopy:function(){return e.setState({hasCopied:!0})},onFinishCopy:function(){return e.setState({hasCopied:!1})},"aria-disabled":a,icon:Ve})),Object(b.createElement)("p",{className:Ge},Object(Ee.__)("Copy and share this preview URL.","public-post-preview"))))}}]),a}(b.Component),Le=Object(Ne.compose)([Object(Ie.withSelect)((function(e){var t=e("core").getPostType,r=e("core/editor"),n=r.getCurrentPostId,a=r.getEditedPostAttribute,i=t(a("type"));return{postId:n(),status:a("status"),isViewable:Object(y.get)(i,["viewable"],!1)}})),Object(Ne.ifCondition)((function(e){return e.isViewable})),Object(Ne.ifCondition)((function(e){var t=e.status;return-1===["auto-draft","publish","private"].indexOf(t)})),Object(Ie.withDispatch)((function(e){return{createNotice:e("core/notices").createNotice}}))])(qe);Object(n.registerPlugin)("public-post-preview",{render:Le})}]);
js/public-post-preview.js CHANGED
@@ -11,6 +11,7 @@
11
 
12
  t.checkbox = $( '#public-post-preview' );
13
  t.link = $( '#public-post-preview-link' );
 
14
  t.nonce = $( '#public_post_preview_wpnonce' );
15
  t.status = $( '#public-post-preview-ajax' );
16
 
@@ -20,7 +21,7 @@
20
  t.change();
21
  } );
22
 
23
- t.link.find( 'input' ).on( 'focus', function () {
24
  $( this ).select();
25
  } );
26
  },
@@ -34,9 +35,6 @@
34
  var t = this,
35
  checked = t.checkbox.prop( 'checked' ) ? 'true' : 'false';
36
 
37
- // Toggle visibility of the link
38
- t.link.toggle();
39
-
40
  // Disable the checkbox, to prevent double AJAX requests
41
  t.checkbox.prop( 'disabled', 'disabled' );
42
 
@@ -46,8 +44,8 @@
46
  checked: checked,
47
  post_ID: $( '#post_ID' ).val(),
48
  },
49
- function ( data ) {
50
- if ( data.success ) {
51
  if ( 'true' === checked ) {
52
  t.status.text( l10n.enabled );
53
  t._pulsate( t.status, 'green' );
@@ -55,6 +53,16 @@
55
  t.status.text( l10n.disabled );
56
  t._pulsate( t.status, 'red' );
57
  }
 
 
 
 
 
 
 
 
 
 
58
  }
59
 
60
  // Enable the checkbox again
11
 
12
  t.checkbox = $( '#public-post-preview' );
13
  t.link = $( '#public-post-preview-link' );
14
+ t.linkInput = t.link.find( 'input' );
15
  t.nonce = $( '#public_post_preview_wpnonce' );
16
  t.status = $( '#public-post-preview-ajax' );
17
 
21
  t.change();
22
  } );
23
 
24
+ t.linkInput.on( 'focus', function () {
25
  $( this ).select();
26
  } );
27
  },
35
  var t = this,
36
  checked = t.checkbox.prop( 'checked' ) ? 'true' : 'false';
37
 
 
 
 
38
  // Disable the checkbox, to prevent double AJAX requests
39
  t.checkbox.prop( 'disabled', 'disabled' );
40
 
44
  checked: checked,
45
  post_ID: $( '#post_ID' ).val(),
46
  },
47
+ function ( response ) {
48
+ if ( response.success ) {
49
  if ( 'true' === checked ) {
50
  t.status.text( l10n.enabled );
51
  t._pulsate( t.status, 'green' );
53
  t.status.text( l10n.disabled );
54
  t._pulsate( t.status, 'red' );
55
  }
56
+
57
+ // Add preview link
58
+ if ( response.data && response.data.preview_url ) {
59
+ t.linkInput.val( response.data.preview_url );
60
+ } else {
61
+ t.linkInput.val( '' );
62
+ }
63
+
64
+ // Toggle visibility of the link
65
+ t.link.toggle();
66
  }
67
 
68
  // Enable the checkbox again
js/public-post-preview.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t,i){var n={initialize:function(){var t=this;t.checkbox=e("#public-post-preview"),t.link=e("#public-post-preview-link"),t.nonce=e("#public_post_preview_wpnonce"),t.status=e("#public-post-preview-ajax"),t.status.css("opacity",0),t.checkbox.bind("change",(function(){t.change()})),t.link.find("input").on("focus",(function(){e(this).select()}))},change:function(){var t=this,n=t.checkbox.prop("checked")?"true":"false";t.link.toggle(),t.checkbox.prop("disabled","disabled"),t.request({_ajax_nonce:t.nonce.val(),checked:n,post_ID:e("#post_ID").val()},(function(e){e.success&&("true"===n?(t.status.text(i.enabled),t._pulsate(t.status,"green")):(t.status.text(i.disabled),t._pulsate(t.status,"red"))),t.checkbox.prop("disabled","")}))},request:function(i,n){e.ajax({type:"POST",url:t,data:e.extend(i,{action:"public-post-preview"}),success:n})},_pulsate:function(e,t){e.css("color",t).animate({opacity:1},600,"linear").animate({opacity:0},600,"linear",(function(){e.empty()}))}};e(n.initialize())}(window.jQuery,window.ajaxurl,window.DSPublicPostPreviewL10n);
1
+ !function(e,t,i){var n={initialize:function(){var t=this;t.checkbox=e("#public-post-preview"),t.link=e("#public-post-preview-link"),t.linkInput=t.link.find("input"),t.nonce=e("#public_post_preview_wpnonce"),t.status=e("#public-post-preview-ajax"),t.status.css("opacity",0),t.checkbox.bind("change",(function(){t.change()})),t.linkInput.on("focus",(function(){e(this).select()}))},change:function(){var t=this,n=t.checkbox.prop("checked")?"true":"false";t.checkbox.prop("disabled","disabled"),t.request({_ajax_nonce:t.nonce.val(),checked:n,post_ID:e("#post_ID").val()},(function(e){e.success&&("true"===n?(t.status.text(i.enabled),t._pulsate(t.status,"green")):(t.status.text(i.disabled),t._pulsate(t.status,"red")),e.data&&e.data.preview_url?t.linkInput.val(e.data.preview_url):t.linkInput.val(""),t.link.toggle()),t.checkbox.prop("disabled","")}))},request:function(i,n){e.ajax({type:"POST",url:t,data:e.extend(i,{action:"public-post-preview"}),success:n})},_pulsate:function(e,t){e.css("color",t).animate({opacity:1},600,"linear").animate({opacity:0},600,"linear",(function(){e.empty()}))}};e(n.initialize())}(window.jQuery,window.ajaxurl,window.DSPublicPostPreviewL10n);
js/src/components/preview-toggle/index.js CHANGED
@@ -2,7 +2,7 @@
2
  * External dependencies
3
  */
4
  import { get } from 'lodash';
5
- import { css } from 'emotion';
6
 
7
  /**
8
  * WordPress dependencies
@@ -95,7 +95,10 @@ class PreviewToggle extends Component {
95
  }
96
 
97
  const previewEnabled = ! this.state.previewEnabled;
98
- this.setState( { previewEnabled } );
 
 
 
99
 
100
  this.props.createNotice(
101
  'info',
2
  * External dependencies
3
  */
4
  import { get } from 'lodash';
5
+ import { css } from '@emotion/css';
6
 
7
  /**
8
  * WordPress dependencies
95
  }
96
 
97
  const previewEnabled = ! this.state.previewEnabled;
98
+ this.setState( {
99
+ previewEnabled,
100
+ previewUrl: response?.data?.preview_url || '',
101
+ } );
102
 
103
  this.props.createNotice(
104
  'info',
public-post-preview.php CHANGED
@@ -1,19 +1,20 @@
1
  <?php
2
  /**
3
  * Plugin Name: Public Post Preview
4
- * Version: 2.9.2
5
  * Description: Allow anonymous users to preview a post before it is published.
6
  * Author: Dominik Schilling
7
  * Author URI: https://dominikschilling.de/
8
  * Plugin URI: https://dominikschilling.de/wp-plugins/public-post-preview/en/
9
  * Text Domain: public-post-preview
10
  * Requires at least: 5.0
 
11
  * Requires PHP: 5.6
12
  * License: GPLv2 or later
13
  *
14
  * Previously (2009-2011) maintained by Jonathan Dingman and Matt Martz.
15
  *
16
- * Copyright (C) 2012-2020 Dominik Schilling
17
  *
18
  * This program is free software; you can redistribute it and/or
19
  * modify it under the terms of the GNU General Public License
@@ -54,7 +55,7 @@ class DS_Public_Post_Preview {
54
  add_action( 'post_updated', array( __CLASS__, 'unregister_public_preview_on_edit' ), 20, 2 );
55
 
56
  if ( ! is_admin() ) {
57
- add_filter( 'pre_get_posts', array( __CLASS__, 'show_public_preview' ) );
58
  add_filter( 'query_vars', array( __CLASS__, 'add_query_var' ) );
59
  // Add the query var to WordPress SEO by Yoast whitelist.
60
  add_filter( 'wpseo_whitelist_permalink_vars', array( __CLASS__, 'add_query_var' ) );
@@ -97,13 +98,14 @@ class DS_Public_Post_Preview {
97
 
98
  wp_set_script_translations( 'public-post-preview-gutenberg', 'public-post-preview' );
99
 
100
- $post = get_post();
 
101
  wp_localize_script(
102
  'public-post-preview-gutenberg',
103
  'DSPublicPostPreviewData',
104
  array(
105
- 'previewEnabled' => self::is_public_preview_enabled( $post ),
106
- 'previewUrl' => self::get_preview_link( $post ),
107
  'nonce' => wp_create_nonce( 'public-post-preview_' . $post->ID ),
108
  )
109
  );
@@ -216,7 +218,7 @@ class DS_Public_Post_Preview {
216
 
217
  <div id="public-post-preview-link" style="margin-top:6px"<?php echo $enabled ? '' : ' class="hidden"'; ?>>
218
  <label>
219
- <input type="text" name="public_post_preview_link" class="regular-text" value="<?php echo esc_attr( self::get_preview_link( $post ) ); ?>" style="width:99%" readonly />
220
  <span class="description"><?php _e( 'Copy and share this preview URL.', 'public-post-preview' ); ?></span>
221
  </label>
222
  </div>
@@ -391,7 +393,12 @@ class DS_Public_Post_Preview {
391
  * @since 2.0.0
392
  */
393
  public static function ajax_register_public_preview() {
 
 
 
 
394
  $preview_post_id = (int) $_POST['post_ID'];
 
395
 
396
  check_ajax_referer( 'public-post-preview_' . $preview_post_id );
397
 
@@ -407,9 +414,9 @@ class DS_Public_Post_Preview {
407
 
408
  $preview_post_ids = self::get_preview_post_ids();
409
 
410
- if ( 'false' === $_POST['checked'] && in_array( $preview_post_id, $preview_post_ids, true ) ) {
411
  $preview_post_ids = array_diff( $preview_post_ids, (array) $preview_post_id );
412
- } elseif ( 'true' === $_POST['checked'] && ! in_array( $preview_post_id, $preview_post_ids, true ) ) {
413
  $preview_post_ids = array_merge( $preview_post_ids, (array) $preview_post_id );
414
  } else {
415
  wp_send_json_error( 'unknown_status' );
@@ -421,7 +428,12 @@ class DS_Public_Post_Preview {
421
  wp_send_json_error( 'not_saved' );
422
  }
423
 
424
- wp_send_json_success();
 
 
 
 
 
425
  }
426
 
427
  /**
@@ -447,7 +459,6 @@ class DS_Public_Post_Preview {
447
  * @since 2.0.0
448
  *
449
  * @param object $query The WP_Query object.
450
- * @return object The WP_Query object, unchanged.
451
  */
452
  public static function show_public_preview( $query ) {
453
  if (
@@ -460,12 +471,14 @@ class DS_Public_Post_Preview {
460
  nocache_headers();
461
  header( 'X-Robots-Tag: noindex' );
462
  }
463
- add_action( 'wp_head', 'wp_no_robots' );
 
 
 
 
464
 
465
  add_filter( 'posts_results', array( __CLASS__, 'set_post_to_publish' ), 10, 2 );
466
  }
467
-
468
- return $query;
469
  }
470
 
471
  /**
1
  <?php
2
  /**
3
  * Plugin Name: Public Post Preview
4
+ * Version: 2.9.3
5
  * Description: Allow anonymous users to preview a post before it is published.
6
  * Author: Dominik Schilling
7
  * Author URI: https://dominikschilling.de/
8
  * Plugin URI: https://dominikschilling.de/wp-plugins/public-post-preview/en/
9
  * Text Domain: public-post-preview
10
  * Requires at least: 5.0
11
+ * Tested up to: 6.0
12
  * Requires PHP: 5.6
13
  * License: GPLv2 or later
14
  *
15
  * Previously (2009-2011) maintained by Jonathan Dingman and Matt Martz.
16
  *
17
+ * Copyright (C) 2012-2022 Dominik Schilling
18
  *
19
  * This program is free software; you can redistribute it and/or
20
  * modify it under the terms of the GNU General Public License
55
  add_action( 'post_updated', array( __CLASS__, 'unregister_public_preview_on_edit' ), 20, 2 );
56
 
57
  if ( ! is_admin() ) {
58
+ add_action( 'pre_get_posts', array( __CLASS__, 'show_public_preview' ) );
59
  add_filter( 'query_vars', array( __CLASS__, 'add_query_var' ) );
60
  // Add the query var to WordPress SEO by Yoast whitelist.
61
  add_filter( 'wpseo_whitelist_permalink_vars', array( __CLASS__, 'add_query_var' ) );
98
 
99
  wp_set_script_translations( 'public-post-preview-gutenberg', 'public-post-preview' );
100
 
101
+ $post = get_post();
102
+ $preview_enabled = self::is_public_preview_enabled( $post );
103
  wp_localize_script(
104
  'public-post-preview-gutenberg',
105
  'DSPublicPostPreviewData',
106
  array(
107
+ 'previewEnabled' => $preview_enabled,
108
+ 'previewUrl' => $preview_enabled ? self::get_preview_link( $post ) : '',
109
  'nonce' => wp_create_nonce( 'public-post-preview_' . $post->ID ),
110
  )
111
  );
218
 
219
  <div id="public-post-preview-link" style="margin-top:6px"<?php echo $enabled ? '' : ' class="hidden"'; ?>>
220
  <label>
221
+ <input type="text" name="public_post_preview_link" class="regular-text" value="<?php echo esc_attr( $enabled ? self::get_preview_link( $post ) : '' ); ?>" style="width:99%" readonly />
222
  <span class="description"><?php _e( 'Copy and share this preview URL.', 'public-post-preview' ); ?></span>
223
  </label>
224
  </div>
393
  * @since 2.0.0
394
  */
395
  public static function ajax_register_public_preview() {
396
+ if ( ! isset( $_POST['post_ID'], $_POST['checked'] ) ) {
397
+ wp_send_json_error( 'incomplete_data' );
398
+ }
399
+
400
  $preview_post_id = (int) $_POST['post_ID'];
401
+ $checked = (string) $_POST['checked'];
402
 
403
  check_ajax_referer( 'public-post-preview_' . $preview_post_id );
404
 
414
 
415
  $preview_post_ids = self::get_preview_post_ids();
416
 
417
+ if ( 'false' === $checked && in_array( $preview_post_id, $preview_post_ids, true ) ) {
418
  $preview_post_ids = array_diff( $preview_post_ids, (array) $preview_post_id );
419
+ } elseif ( 'true' === $checked && ! in_array( $preview_post_id, $preview_post_ids, true ) ) {
420
  $preview_post_ids = array_merge( $preview_post_ids, (array) $preview_post_id );
421
  } else {
422
  wp_send_json_error( 'unknown_status' );
428
  wp_send_json_error( 'not_saved' );
429
  }
430
 
431
+ $data = null;
432
+ if ( 'true' === $checked ) {
433
+ $data = array( 'preview_url' => self::get_preview_link( $post ) );
434
+ }
435
+
436
+ wp_send_json_success( $data );
437
  }
438
 
439
  /**
459
  * @since 2.0.0
460
  *
461
  * @param object $query The WP_Query object.
 
462
  */
463
  public static function show_public_preview( $query ) {
464
  if (
471
  nocache_headers();
472
  header( 'X-Robots-Tag: noindex' );
473
  }
474
+ if ( function_exists( 'wp_robots_no_robots' ) ) { // WordPress 5.7+
475
+ add_filter( 'wp_robots', 'wp_robots_no_robots' );
476
+ } else {
477
+ add_action( 'wp_head', 'wp_no_robots' );
478
+ }
479
 
480
  add_filter( 'posts_results', array( __CLASS__, 'set_post_to_publish' ), 10, 2 );
481
  }
 
 
482
  }
483
 
484
  /**
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: ocean90
3
  Tags: public, preview, posts, anonymous, drafts
4
  Requires at least: 5.0
5
- Tested up to: 5.6
6
  Requires PHP: 5.6
7
- Stable tag: 2.9.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -73,26 +73,15 @@ Or use the [Public Post Preview Configurator](https://wordpress.org/plugins/publ
73
 
74
  == Change Log ==
75
 
 
 
 
 
 
76
  = 2.9.2 (2020-10-03): =
77
- * Fixes saving of preview status without a previous Ajax request.
78
 
79
  = 2.9.1 (2020-07-25): =
80
  * Improve HTTP status codes for expired/invalid preview links.
81
 
82
- = 2.9.0 (2019-07-20): =
83
- * Requires WordPress 5.0
84
- * Requires PHP 5.6
85
- * Adds notice (as Snackbar if supported) when changing preview status in block editor.
86
- * Fixes incorrect status message in classic editor.
87
- * Fixes grammar in expired link notice. Props [@garrett-eclipse](https://github.com/garrett-eclipse).
88
- * Improves internal checks to be more strict. Props [@PatelUtkarsh](https://github.com/PatelUtkarsh).
89
- * Removes deprecated i18n compatibility layer from Gutenberg plugin.
90
-
91
- = 2.8.0 (2018-11-27): =
92
- * Add support for WordPress 5.0 and the new block editor.
93
-
94
- = 2.7.0 (2018-09-14): =
95
- * Initial support for Gutenberg.
96
- * Block robots for public post previews. Props [@westonruter](https://github.com/westonruter).
97
-
98
  For more see [CHANGELOG.md](https://github.com/ocean90/public-post-preview/blob/master/CHANGELOG.md).
2
  Contributors: ocean90
3
  Tags: public, preview, posts, anonymous, drafts
4
  Requires at least: 5.0
5
+ Tested up to: 6.0
6
  Requires PHP: 5.6
7
+ Stable tag: 2.9.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
73
 
74
  == Change Log ==
75
 
76
+ = 2.9.3 (2021-03-12): =
77
+ * Compatibility with WordPress 5.7.
78
+ * Create a fresh preview URL when enabling public preview.
79
+ * Add check for possibly undefined PHP "superglobals". Props [@waviaei](https://github.com/waviaei).
80
+
81
  = 2.9.2 (2020-10-03): =
82
+ * Fix saving of preview status without a previous Ajax request.
83
 
84
  = 2.9.1 (2020-07-25): =
85
  * Improve HTTP status codes for expired/invalid preview links.
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  For more see [CHANGELOG.md](https://github.com/ocean90/public-post-preview/blob/master/CHANGELOG.md).