Version Description
Download this release
Release Info
Developer | ocean90 |
Plugin | Public Post Preview |
Version | 2.10.0 |
Comparing to | |
See all releases |
Code changes from version 2.9.3 to 2.10.0
- .npmrc +0 -2
- .nvmrc +0 -1
- CHANGELOG.md +4 -0
- js/dist/gutenberg-integration.asset.php +1 -1
- js/dist/gutenberg-integration.js +1 -1
- js/public-post-preview.js +4 -4
- js/src/components/preview-toggle/index.js +13 -52
- public-post-preview.php +52 -7
- readme.txt +8 -10
.npmrc
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
save-exact = true
|
2 |
-
engine-strict = true
|
|
|
|
.nvmrc
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
lts/*
|
|
CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
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.
|
1 |
# Changelog
|
2 |
|
3 |
+
## 2.10.0 (2022-11-19)
|
4 |
+
* Compatibility with WordPress 6.1.
|
5 |
+
* Integrate with [User Switching](https://wordpress.org/plugins/user-switching/): Direct the user to the public preview of a post when they switch off from the post editing screen. Props [@johnbillion](https://github.com/johnbillion).
|
6 |
+
|
7 |
## 2.9.3 (2021-03-12)
|
8 |
* Compatibility with WordPress 5.7.
|
9 |
* Create a fresh preview URL when enabling public preview.
|
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'
|
1 |
+
<?php return array('dependencies' => array('lodash', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => 'cc95da5a20e04227eb45');
|
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){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})}]);
|
1 |
+
(()=>{"use strict";const e=window.wp.plugins,t=window.wp.element,r=window.lodash;var n=function(){function e(e){var t=this;this._insertTag=function(e){var r;r=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling: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.insertionPoint=e.insertionPoint,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&&e.parentNode.removeChild(e)})),this.tags=[],this.ctr=0},e}(),a=Math.abs,i=String.fromCharCode,s=Object.assign;function c(e){return e.trim()}function o(e,t,r){return e.replace(t,r)}function u(e,t){return e.indexOf(t)}function l(e,t){return 0|e.charCodeAt(t)}function p(e,t,r){return e.slice(t,r)}function f(e){return e.length}function h(e){return e.length}function d(e,t){return t.push(e),e}var v=1,w=1,m=0,b=0,g=0,y="";function k(e,t,r,n,a,i,s){return{value:e,root:t,parent:r,type:n,props:a,children:i,line:v,column:w,length:s,return:""}}function x(e,t){return s(k("",null,null,"",null,null,0),e,{length:-e.length},t)}function C(){return g=b>0?l(y,--b):0,w--,10===g&&(w=1,v--),g}function $(){return g=b<m?l(y,b++):0,w++,10===g&&(w=1,v++),g}function A(){return l(y,b)}function S(){return b}function _(e,t){return p(y,e,t)}function E(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 P(e){return v=w=1,m=f(y=e),b=0,[]}function I(e){return y="",e}function z(e){return c(_(b-1,N(91===e?e+2:40===e?e+1:e)))}function R(e){for(;(g=A())&&g<33;)$();return E(e)>2||E(g)>3?"":" "}function j(e,t){for(;--t&&$()&&!(g<48||g>102||g>57&&g<65||g>70&&g<97););return _(e,S()+(t<6&&32==A()&&32==$()))}function N(e){for(;$();)switch(g){case e:return b;case 34:case 39:34!==e&&39!==e&&N(g);break;case 40:41===e&&N(e);break;case 92:$()}return b}function O(e,t){for(;$()&&e+g!==57&&(e+g!==84||47!==A()););return"/*"+_(t,b-1)+"*"+i(47===e?e:$())}function U(e){for(;!E(A());)$();return _(e,b)}var F="-ms-",G="-webkit-",H="comm",D="rule",M="decl",V="@keyframes";function q(e,t){for(var r="",n=h(e),a=0;a<n;a++)r+=t(e[a],a,e,t)||"";return r}function T(e,t,r,n){switch(e.type){case"@import":case M:return e.return=e.return||e.value;case H:return"";case V:return e.return=e.value+"{"+q(e.children,n)+"}";case D:e.value=e.props.join(",")}return f(r=q(e.children,n))?e.return=e.value+"{"+r+"}":""}function L(e){return I(W("",null,null,null,[""],e=P(e),0,[0],e))}function W(e,t,r,n,a,s,c,p,h){for(var v=0,w=0,m=c,b=0,g=0,y=0,k=1,x=1,_=1,E=0,P="",I=a,N=s,F=n,G=P;x;)switch(y=E,E=$()){case 40:if(108!=y&&58==l(G,m-1)){-1!=u(G+=o(z(E),"&","&\f"),"&\f")&&(_=-1);break}case 34:case 39:case 91:G+=z(E);break;case 9:case 10:case 13:case 32:G+=R(y);break;case 92:G+=j(S()-1,7);continue;case 47:switch(A()){case 42:case 47:d(Z(O($(),S()),t,r),h);break;default:G+="/"}break;case 123*k:p[v++]=f(G)*_;case 125*k:case 59:case 0:switch(E){case 0:case 125:x=0;case 59+w:g>0&&f(G)-m&&d(g>32?J(G+";",n,r,m-1):J(o(G," ","")+";",n,r,m-2),h);break;case 59:G+=";";default:if(d(F=B(G,t,r,v,w,a,p,P,I=[],N=[],m),s),123===E)if(0===w)W(G,t,F,F,I,s,m,p,N);else switch(99===b&&110===l(G,3)?100:b){case 100:case 109:case 115:W(e,F,F,n&&d(B(e,F,F,0,0,a,p,P,a,I=[],m),N),a,N,m,p,n?I:N);break;default:W(G,F,F,F,[""],N,0,p,N)}}v=w=g=0,k=_=1,P=G="",m=c;break;case 58:m=1+f(G),g=y;default:if(k<1)if(123==E)--k;else if(125==E&&0==k++&&125==C())continue;switch(G+=i(E),E*k){case 38:_=w>0?1:(G+="\f",-1);break;case 44:p[v++]=(f(G)-1)*_,_=1;break;case 64:45===A()&&(G+=z($())),b=A(),w=m=f(P=G+=U(S())),E++;break;case 45:45===y&&2==f(G)&&(k=0)}}return s}function B(e,t,r,n,i,s,u,l,f,d,v){for(var w=i-1,m=0===i?s:[""],b=h(m),g=0,y=0,x=0;g<n;++g)for(var C=0,$=p(e,w+1,w=a(y=u[g])),A=e;C<b;++C)(A=c(y>0?m[C]+" "+$:o($,/&\f/g,m[C])))&&(f[x++]=A);return k(e,t,r,0===i?D:l,f,d,v)}function Z(e,t,r){return k(e,t,r,H,i(g),p(e,2,-2),0)}function J(e,t,r,n){return k(e,t,r,M,p(e,0,n),p(e,n+1,-1),n)}var K=function(e,t,r){for(var n=0,a=0;n=a,a=A(),38===n&&12===a&&(t[r]=1),!E(a);)$();return _(e,b)},Q=new WeakMap,X=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){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)||Q.get(r))&&!n){Q.set(e,!0);for(var a=[],s=function(e,t){return I(function(e,t){var r=-1,n=44;do{switch(E(n)){case 0:38===n&&12===A()&&(t[r]=1),e[r]+=K(b-1,t,r);break;case 2:e[r]+=z(n);break;case 4:if(44===n){e[++r]=58===A()?"&\f":"",t[r]=e[r].length;break}default:e[r]+=i(n)}}while(n=$());return e}(P(e),t))}(t,a),c=r.props,o=0,u=0;o<s.length;o++)for(var l=0;l<c.length;l++,u++)e.props[u]=a[o]?s[o].replace(/&\f/g,c[l]):c[l]+" "+s[o]}}},Y=function(e){if("decl"===e.type){var t=e.value;108===t.charCodeAt(0)&&98===t.charCodeAt(2)&&(e.return="",e.value="")}};function ee(e,t){switch(function(e,t){return 45^l(e,0)?(((t<<2^l(e,0))<<2^l(e,1))<<2^l(e,2))<<2^l(e,3):0}(e,t)){case 5103:return"-webkit-print-"+e+e;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 G+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return G+e+"-moz-"+e+F+e+e;case 6828:case 4268:return G+e+F+e+e;case 6165:return G+e+F+"flex-"+e+e;case 5187:return G+e+o(e,/(\w+).+(:[^]+)/,"-webkit-box-$1$2-ms-flex-$1$2")+e;case 5443:return G+e+F+"flex-item-"+o(e,/flex-|-self/,"")+e;case 4675:return G+e+F+"flex-line-pack"+o(e,/align-content|flex-|-self/,"")+e;case 5548:return G+e+F+o(e,"shrink","negative")+e;case 5292:return G+e+F+o(e,"basis","preferred-size")+e;case 6060:return"-webkit-box-"+o(e,"-grow","")+G+e+F+o(e,"grow","positive")+e;case 4554:return G+o(e,/([^-])(transform)/g,"$1-webkit-$2")+e;case 6187:return o(o(o(e,/(zoom-|grab)/,"-webkit-$1"),/(image-set)/,"-webkit-$1"),e,"")+e;case 5495:case 3959:return o(e,/(image-set\([^]*)/,"-webkit-$1$`$1");case 4968:return o(o(e,/(.+:)(flex-)?(.*)/,"-webkit-box-pack:$3-ms-flex-pack:$3"),/s.+-b[^;]+/,"justify")+G+e+e;case 4095:case 3583:case 4068:case 2532:return o(e,/(.+)-inline(.+)/,"-webkit-$1$2")+e;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(f(e)-1-t>6)switch(l(e,t+1)){case 109:if(45!==l(e,t+4))break;case 102:return o(e,/(.+:)(.+)-([^]+)/,"$1-webkit-$2-$3$1-moz-"+(108==l(e,t+3)?"$3":"$2-$3"))+e;case 115:return~u(e,"stretch")?ee(o(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==l(e,t+1))break;case 6444:switch(l(e,f(e)-3-(~u(e,"!important")&&10))){case 107:return o(e,":",":-webkit-")+e;case 101:return o(e,/(.+:)([^;!]+)(;|!.+)?/,"$1-webkit-"+(45===l(e,14)?"inline-":"")+"box$3$1-webkit-$2$3$1-ms-$2box$3")+e}break;case 5936:switch(l(e,t+11)){case 114:return G+e+F+o(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return G+e+F+o(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return G+e+F+o(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return G+e+F+e+e}return e}var te=[function(e,t,r,n){if(e.length>-1&&!e.return)switch(e.type){case M:e.return=ee(e.value,e.length);break;case V:return q([x(e,{value:o(e.value,"@","@-webkit-")})],n);case D: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 q([x(e,{props:[o(t,/:(read-\w+)/,":-moz-$1")]})],n);case"::placeholder":return q([x(e,{props:[o(t,/:(plac\w+)/,":-webkit-input-$1")]}),x(e,{props:[o(t,/:(plac\w+)/,":-moz-$1")]}),x(e,{props:[o(t,/:(plac\w+)/,"-ms-input-$1")]})],n)}return""}))}}];const re=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)},ne={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 ae=/[A-Z]|^ms/g,ie=/_EMO_([^_]+?)_([^]*?)_EMO_/g,se=function(e){return 45===e.charCodeAt(1)},ce=function(e){return null!=e&&"boolean"!=typeof e},oe=function(e){var t=Object.create(null);return function(r){return void 0===t[r]&&(t[r]=e(r)),t[r]}}((function(e){return se(e)?e:e.replace(ae,"-$&").toLowerCase()})),ue=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(ie,(function(e,t,r){return pe={name:t,styles:r,next:pe},t}))}return 1===ne[e]||se(e)||"number"!=typeof t||0===t?t:t+"px"};function le(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 pe={name:r.name,styles:r.styles,next:pe},r.name;if(void 0!==r.styles){var n=r.next;if(void 0!==n)for(;void 0!==n;)pe={name:n.name,styles:n.styles,next:pe},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+=le(e,t,r[a])+";";else for(var i in r){var s=r[i];if("object"!=typeof s)null!=t&&void 0!==t[s]?n+=i+"{"+t[s]+"}":ce(s)&&(n+=oe(i)+":"+ue(i,s)+";");else if(!Array.isArray(s)||"string"!=typeof s[0]||null!=t&&void 0!==t[s[0]]){var c=le(e,t,s);switch(i){case"animation":case"animationName":n+=oe(i)+":"+c+";";break;default:n+=i+"{"+c+"}"}}else for(var o=0;o<s.length;o++)ce(s[o])&&(n+=oe(i)+":"+ue(i,s[o])+";")}return n}(e,t,r);case"function":if(void 0!==e){var a=pe,i=r(e);return pe=a,le(e,t,i)}}if(null==t)return r;var s=t[r];return void 0!==s?s:r}var pe,fe=/label:\s*([^\s;\n{]+)\s*(;|$)/g,he=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="";pe=void 0;var i=e[0];null==i||void 0===i.raw?(n=!1,a+=le(r,t,i)):a+=i[0];for(var s=1;s<e.length;s++)a+=le(r,t,e[s]),n&&(a+=i[s]);fe.lastIndex=0;for(var c,o="";null!==(c=fe.exec(a));)o+="-"+c[1];return{name:re(a)+o,styles:a,next:pe}};function de(e,t,r){var n="";return r.split(" ").forEach((function(r){void 0!==e[r]?t.push(e[r]+";"):n+=r+" "})),n}var ve=function(e,t,r){!function(e,t,r){var n=e.key+"-"+t.name;!1===r&&void 0===e.registered[n]&&(e.registered[n]=t.styles)}(e,t,r);var n=e.key+"-"+t.name;if(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 we(e,t){if(void 0===e.inserted[t.name])return e.insert("",t,e.sheet,!0)}function me(e,t,r){var n=[],a=de(e,n,r);return n.length<2?r:a+t(n)}var be=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 s in i="",a)a[s]&&s&&(i&&(i+=" "),i+=s);break;default:i=a}i&&(r&&(r+=" "),r+=i)}}return r};var ge=function(e){var t=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){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var a,i,s=e.stylisPlugins||te,c={},o=[];a=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),r=1;r<t.length;r++)c[t[r]]=!0;o.push(e)}));var u,l,p,f,d=[T,(f=function(e){u.insert(e)},function(e){e.root||(e=e.return)&&f(e)})],v=(l=[X,Y].concat(s,d),p=h(l),function(e,t,r,n){for(var a="",i=0;i<p;i++)a+=l[i](e,t,r,n)||"";return a});i=function(e,t,r,n){u=r,q(L(e?e+"{"+t.styles+"}":t.styles),v),n&&(w.inserted[t.name]=!0)};var w={key:t,sheet:new n({key:t,container:a,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:c,registered:{},insert:i};return w.sheet.hydrate(o),w}(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=he(r,t.registered,void 0);return ve(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 me(t.registered,r,be(n))},injectGlobal:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=he(r,t.registered);we(t,a)},keyframes:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var a=he(r,t.registered),i="animation-"+a.name;return we(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:de.bind(null,t.registered),merge:me.bind(null,t.registered,r)}}({key:"css"}),ye=(ge.flush,ge.hydrate,ge.cx,ge.merge,ge.getRegisteredStyles,ge.injectGlobal,ge.keyframes,ge.css);ge.sheet,ge.cache;const ke=window.wp.i18n,xe=window.wp.components,Ce=window.wp.data,$e=window.wp.editPost,Ae=window.wp.compose,{ajaxurl:Se,DSPublicPostPreviewData:_e}=window,Ee=ye({name:"pzaqto",styles:"flex-direction:column;align-items:stretch;margin-top:10px"}),Pe=ye({name:"1gqzxr1",styles:"width:100%;margin-right:12px"}),Ie=ye({name:"iijanu",styles:"font-style:italic;color:#666;margin:0.2em 0 0!important"}),ze=ye({name:"gqlj34",styles:"display:flex;justify-content:flex-start;align-items:center;margin:0"}),Re=(0,t.createElement)(xe.SVG,{width:"20",height:"20",viewBox:"0 0 14 16",xmlns:"http://www.w3.org/2000/svg"},(0,t.createElement)(xe.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"}));class je extends t.Component{constructor(e){super(e),this.state={previewEnabled:_e.previewEnabled,previewUrl:_e.previewUrl,hasCopied:!1},this.previewUrlInput=(0,t.createRef)(),this.onChange=this.onChange.bind(this),this.onPreviewUrlInputFocus=this.onPreviewUrlInputFocus.bind(this)}onChange(e){const t=new window.FormData;t.append("checked",e),t.append("post_ID",this.props.postId),this.sendRequest(t).then((e=>{if(e.status>=200&&e.status<300)return e;throw e})).then((e=>e.json())).then((e=>{if(!e.success)throw e;const t=!this.state.previewEnabled;this.setState({previewEnabled:t,previewUrl:e?.data?.preview_url||""}),this.props.createNotice("info",t?(0,ke.__)("Public preview enabled.","public-post-preview"):(0,ke.__)("Public preview disabled.","public-post-preview"),{id:"public-post-preview",isDismissible:!0,type:"snackbar"})})).catch((()=>{this.props.createNotice("error",(0,ke.__)("Error while changing the public preview status.","public-post-preview"),{id:"public-post-preview",isDismissible:!0,type:"snackbar"})}))}onPreviewUrlInputFocus(){this.previewUrlInput.current.focus(),this.previewUrlInput.current.select()}sendRequest(e){return e.append("action","public-post-preview"),e.append("_ajax_nonce",_e.nonce),window.fetch(Se,{method:"POST",body:e})}render(){const{previewEnabled:e,previewUrl:r,hasCopied:n}=this.state,a=n?(0,ke.__)("Preview URL copied","public-post-preview"):(0,ke.__)("Copy the preview URL","public-post-preview");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)($e.PluginPostStatusInfo,null,(0,t.createElement)(xe.CheckboxControl,{label:(0,ke.__)("Enable public preview","public-post-preview"),checked:e,onChange:this.onChange})),e&&(0,t.createElement)($e.PluginPostStatusInfo,{className:Ee},(0,t.createElement)("p",{className:ze},(0,t.createElement)("label",{htmlFor:"public-post-preview-url",className:"screen-reader-text"},(0,ke.__)("Preview URL","public-post-preview")),(0,t.createElement)("input",{ref:this.previewUrlInput,type:"text",id:"public-post-preview-url",className:Pe,value:r,readOnly:!0,onFocus:this.onPreviewUrlInputFocus}),(0,t.createElement)(xe.ClipboardButton,{text:r,label:a,onCopy:()=>this.setState({hasCopied:!0}),onFinishCopy:()=>this.setState({hasCopied:!1}),"aria-disabled":n,icon:Re})),(0,t.createElement)("p",{className:Ie},(0,ke.__)("Copy and share this preview URL.","public-post-preview"))))}}const Ne=(0,Ae.compose)([(0,Ce.withSelect)((e=>{const{getPostType:t}=e("core"),{getCurrentPostId:n,getEditedPostAttribute:a}=e("core/editor"),i=t(a("type"));return{postId:n(),status:a("status"),isViewable:(0,r.get)(i,["viewable"],!1)}})),(0,Ae.ifCondition)((e=>{let{isViewable:t}=e;return t})),(0,Ae.ifCondition)((e=>{let{status:t}=e;return-1===["auto-draft","publish","private"].indexOf(t)})),(0,Ce.withDispatch)((e=>({createNotice:e("core/notices").createNotice})))])(je);(0,e.registerPlugin)("public-post-preview",{render:Ne})})();
|
js/public-post-preview.js
CHANGED
@@ -76,8 +76,8 @@
|
|
76 |
*
|
77 |
* @since 2.0.0
|
78 |
*
|
79 |
-
* @param
|
80 |
-
* @param
|
81 |
*/
|
82 |
request: function ( data, callback ) {
|
83 |
$.ajax( {
|
@@ -95,8 +95,8 @@
|
|
95 |
*
|
96 |
* @since 2.0.0
|
97 |
*
|
98 |
-
* @param
|
99 |
-
* @param
|
100 |
*/
|
101 |
_pulsate: function ( e, color ) {
|
102 |
e.css( 'color', color )
|
76 |
*
|
77 |
* @since 2.0.0
|
78 |
*
|
79 |
+
* @param {Object} data The data to send.
|
80 |
+
* @param {Object} callback Callback function for a successful request.
|
81 |
*/
|
82 |
request: function ( data, callback ) {
|
83 |
$.ajax( {
|
95 |
*
|
96 |
* @since 2.0.0
|
97 |
*
|
98 |
+
* @param {Object} e The element.
|
99 |
+
* @param {string} color The text color of the element.
|
100 |
*/
|
101 |
_pulsate: function ( e, color ) {
|
102 |
e.css( 'color', color )
|
js/src/components/preview-toggle/index.js
CHANGED
@@ -8,12 +8,7 @@ import { css } from '@emotion/css';
|
|
8 |
* WordPress dependencies
|
9 |
*/
|
10 |
import { __ } from '@wordpress/i18n';
|
11 |
-
import {
|
12 |
-
CheckboxControl,
|
13 |
-
ClipboardButton,
|
14 |
-
Path,
|
15 |
-
SVG,
|
16 |
-
} from '@wordpress/components';
|
17 |
import { Component, createRef } from '@wordpress/element';
|
18 |
import { withSelect, withDispatch } from '@wordpress/data';
|
19 |
import { PluginPostStatusInfo } from '@wordpress/edit-post';
|
@@ -46,12 +41,7 @@ const pluginPostStatusInfoPreviewUrlInputWrapper = css`
|
|
46 |
`;
|
47 |
|
48 |
const ClipboardIcon = (
|
49 |
-
<SVG
|
50 |
-
width="20"
|
51 |
-
height="20"
|
52 |
-
viewBox="0 0 14 16"
|
53 |
-
xmlns="http://www.w3.org/2000/svg"
|
54 |
-
>
|
55 |
<Path
|
56 |
fillRule="evenodd"
|
57 |
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"
|
@@ -104,10 +94,7 @@ class PreviewToggle extends Component {
|
|
104 |
'info',
|
105 |
previewEnabled
|
106 |
? __( 'Public preview enabled.', 'public-post-preview' )
|
107 |
-
: __(
|
108 |
-
'Public preview disabled.',
|
109 |
-
'public-post-preview'
|
110 |
-
),
|
111 |
{
|
112 |
id: 'public-post-preview',
|
113 |
isDismissible: true,
|
@@ -118,10 +105,7 @@ class PreviewToggle extends Component {
|
|
118 |
.catch( () => {
|
119 |
this.props.createNotice(
|
120 |
'error',
|
121 |
-
__(
|
122 |
-
'Error while changing the public preview status.',
|
123 |
-
'public-post-preview'
|
124 |
-
),
|
125 |
{
|
126 |
id: 'public-post-preview',
|
127 |
isDismissible: true,
|
@@ -156,36 +140,22 @@ class PreviewToggle extends Component {
|
|
156 |
<>
|
157 |
<PluginPostStatusInfo>
|
158 |
<CheckboxControl
|
159 |
-
label={ __(
|
160 |
-
'Enable public preview',
|
161 |
-
'public-post-preview'
|
162 |
-
) }
|
163 |
checked={ previewEnabled }
|
164 |
onChange={ this.onChange }
|
165 |
/>
|
166 |
</PluginPostStatusInfo>
|
167 |
{ previewEnabled && (
|
168 |
-
<PluginPostStatusInfo
|
169 |
-
className={
|
170 |
-
|
171 |
-
<p
|
172 |
-
className={
|
173 |
-
pluginPostStatusInfoPreviewUrlInputWrapper
|
174 |
-
}
|
175 |
-
>
|
176 |
-
<label
|
177 |
-
htmlFor="public-post-preview-url"
|
178 |
-
className="screen-reader-text"
|
179 |
-
>
|
180 |
{ __( 'Preview URL', 'public-post-preview' ) }
|
181 |
</label>
|
182 |
<input
|
183 |
ref={ this.previewUrlInput }
|
184 |
type="text"
|
185 |
id="public-post-preview-url"
|
186 |
-
className={
|
187 |
-
pluginPostStatusInfoPreviewUrlInput
|
188 |
-
}
|
189 |
value={ previewUrl }
|
190 |
readOnly
|
191 |
onFocus={ this.onPreviewUrlInputFocus }
|
@@ -193,21 +163,14 @@ class PreviewToggle extends Component {
|
|
193 |
<ClipboardButton
|
194 |
text={ previewUrl }
|
195 |
label={ ariaCopyLabel }
|
196 |
-
onCopy={ () =>
|
197 |
-
|
198 |
-
}
|
199 |
-
onFinishCopy={ () =>
|
200 |
-
this.setState( { hasCopied: false } )
|
201 |
-
}
|
202 |
aria-disabled={ hasCopied }
|
203 |
icon={ ClipboardIcon }
|
204 |
/>
|
205 |
</p>
|
206 |
<p className={ pluginPostStatusInfoPreviewDescription }>
|
207 |
-
{ __(
|
208 |
-
'Copy and share this preview URL.',
|
209 |
-
'public-post-preview'
|
210 |
-
) }
|
211 |
</p>
|
212 |
</PluginPostStatusInfo>
|
213 |
) }
|
@@ -219,9 +182,7 @@ class PreviewToggle extends Component {
|
|
219 |
export default compose( [
|
220 |
withSelect( ( select ) => {
|
221 |
const { getPostType } = select( 'core' );
|
222 |
-
const { getCurrentPostId, getEditedPostAttribute } = select(
|
223 |
-
'core/editor'
|
224 |
-
);
|
225 |
const postType = getPostType( getEditedPostAttribute( 'type' ) );
|
226 |
|
227 |
return {
|
8 |
* WordPress dependencies
|
9 |
*/
|
10 |
import { __ } from '@wordpress/i18n';
|
11 |
+
import { CheckboxControl, ClipboardButton, Path, SVG } from '@wordpress/components';
|
|
|
|
|
|
|
|
|
|
|
12 |
import { Component, createRef } from '@wordpress/element';
|
13 |
import { withSelect, withDispatch } from '@wordpress/data';
|
14 |
import { PluginPostStatusInfo } from '@wordpress/edit-post';
|
41 |
`;
|
42 |
|
43 |
const ClipboardIcon = (
|
44 |
+
<SVG width="20" height="20" viewBox="0 0 14 16" xmlns="http://www.w3.org/2000/svg">
|
|
|
|
|
|
|
|
|
|
|
45 |
<Path
|
46 |
fillRule="evenodd"
|
47 |
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"
|
94 |
'info',
|
95 |
previewEnabled
|
96 |
? __( 'Public preview enabled.', 'public-post-preview' )
|
97 |
+
: __( 'Public preview disabled.', 'public-post-preview' ),
|
|
|
|
|
|
|
98 |
{
|
99 |
id: 'public-post-preview',
|
100 |
isDismissible: true,
|
105 |
.catch( () => {
|
106 |
this.props.createNotice(
|
107 |
'error',
|
108 |
+
__( 'Error while changing the public preview status.', 'public-post-preview' ),
|
|
|
|
|
|
|
109 |
{
|
110 |
id: 'public-post-preview',
|
111 |
isDismissible: true,
|
140 |
<>
|
141 |
<PluginPostStatusInfo>
|
142 |
<CheckboxControl
|
143 |
+
label={ __( 'Enable public preview', 'public-post-preview' ) }
|
|
|
|
|
|
|
144 |
checked={ previewEnabled }
|
145 |
onChange={ this.onChange }
|
146 |
/>
|
147 |
</PluginPostStatusInfo>
|
148 |
{ previewEnabled && (
|
149 |
+
<PluginPostStatusInfo className={ pluginPostStatusInfoPreviewUrl }>
|
150 |
+
<p className={ pluginPostStatusInfoPreviewUrlInputWrapper }>
|
151 |
+
<label htmlFor="public-post-preview-url" className="screen-reader-text">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
{ __( 'Preview URL', 'public-post-preview' ) }
|
153 |
</label>
|
154 |
<input
|
155 |
ref={ this.previewUrlInput }
|
156 |
type="text"
|
157 |
id="public-post-preview-url"
|
158 |
+
className={ pluginPostStatusInfoPreviewUrlInput }
|
|
|
|
|
159 |
value={ previewUrl }
|
160 |
readOnly
|
161 |
onFocus={ this.onPreviewUrlInputFocus }
|
163 |
<ClipboardButton
|
164 |
text={ previewUrl }
|
165 |
label={ ariaCopyLabel }
|
166 |
+
onCopy={ () => this.setState( { hasCopied: true } ) }
|
167 |
+
onFinishCopy={ () => this.setState( { hasCopied: false } ) }
|
|
|
|
|
|
|
|
|
168 |
aria-disabled={ hasCopied }
|
169 |
icon={ ClipboardIcon }
|
170 |
/>
|
171 |
</p>
|
172 |
<p className={ pluginPostStatusInfoPreviewDescription }>
|
173 |
+
{ __( 'Copy and share this preview URL.', 'public-post-preview' ) }
|
|
|
|
|
|
|
174 |
</p>
|
175 |
</PluginPostStatusInfo>
|
176 |
) }
|
182 |
export default compose( [
|
183 |
withSelect( ( select ) => {
|
184 |
const { getPostType } = select( 'core' );
|
185 |
+
const { getCurrentPostId, getEditedPostAttribute } = select( 'core/editor' );
|
|
|
|
|
186 |
const postType = getPostType( getEditedPostAttribute( 'type' ) );
|
187 |
|
188 |
return {
|
public-post-preview.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Public Post Preview
|
4 |
-
* Version: 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://
|
9 |
* Text Domain: public-post-preview
|
10 |
* Requires at least: 5.0
|
11 |
-
* Tested up to: 6.
|
12 |
* Requires PHP: 5.6
|
13 |
* License: GPLv2 or later
|
14 |
*
|
@@ -57,8 +57,7 @@ class DS_Public_Post_Preview {
|
|
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 |
-
|
61 |
-
add_filter( 'wpseo_whitelist_permalink_vars', array( __CLASS__, 'add_query_var' ) );
|
62 |
} else {
|
63 |
add_action( 'post_submitbox_misc_actions', array( __CLASS__, 'post_submitbox_misc_actions' ) );
|
64 |
add_action( 'save_post', array( __CLASS__, 'register_public_preview' ), 20, 2 );
|
@@ -116,7 +115,7 @@ class DS_Public_Post_Preview {
|
|
116 |
'public-post-preview',
|
117 |
plugins_url( "js/public-post-preview$suffix.js", __FILE__ ),
|
118 |
array( 'jquery' ),
|
119 |
-
'
|
120 |
true
|
121 |
);
|
122 |
|
@@ -148,6 +147,43 @@ class DS_Public_Post_Preview {
|
|
148 |
return $post_states;
|
149 |
}
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
/**
|
152 |
* Adds the checkbox to the submit meta box.
|
153 |
*
|
@@ -677,8 +713,17 @@ class DS_Public_Post_Preview {
|
|
677 |
public static function uninstall() {
|
678 |
delete_option( 'public_post_preview' );
|
679 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
}
|
681 |
|
682 |
add_action( 'plugins_loaded', array( 'DS_Public_Post_Preview', 'init' ) );
|
683 |
|
684 |
-
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Public Post Preview
|
4 |
+
* Version: 2.10.0
|
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://github.com/ocean90/public-post-preview
|
9 |
* Text Domain: public-post-preview
|
10 |
* Requires at least: 5.0
|
11 |
+
* Tested up to: 6.1
|
12 |
* Requires PHP: 5.6
|
13 |
* License: GPLv2 or later
|
14 |
*
|
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_filter( 'user_switching_redirect_to', array( __CLASS__, 'user_switching_redirect_to' ), 10, 4 );
|
|
|
61 |
} else {
|
62 |
add_action( 'post_submitbox_misc_actions', array( __CLASS__, 'post_submitbox_misc_actions' ) );
|
63 |
add_action( 'save_post', array( __CLASS__, 'register_public_preview' ), 20, 2 );
|
115 |
'public-post-preview',
|
116 |
plugins_url( "js/public-post-preview$suffix.js", __FILE__ ),
|
117 |
array( 'jquery' ),
|
118 |
+
'20221611',
|
119 |
true
|
120 |
);
|
121 |
|
147 |
return $post_states;
|
148 |
}
|
149 |
|
150 |
+
/**
|
151 |
+
* Filters the redirect location after a user switches to another account or switches off with the User Switching plugin.
|
152 |
+
*
|
153 |
+
* This is used to direct the user to the public preview of a post when they switch off from the post editing screen.
|
154 |
+
*
|
155 |
+
* @since 2.10.0
|
156 |
+
*
|
157 |
+
* @param string $redirect_to The target redirect location, or an empty string if none is specified.
|
158 |
+
* @param string|null $redirect_type The redirect type, see the `user_switching::REDIRECT_*` constants.
|
159 |
+
* @param WP_User|null $new_user The user being switched to, or null if there is none.
|
160 |
+
* @param WP_User|null $old_user The user being switched from, or null if there is none.
|
161 |
+
* @return string The target redirect location.
|
162 |
+
*/
|
163 |
+
public static function user_switching_redirect_to( $redirect_to, $redirect_type, $new_user, $old_user ) {
|
164 |
+
$post_id = isset( $_GET['redirect_to_post'] ) ? (int) $_GET['redirect_to_post'] : 0;
|
165 |
+
|
166 |
+
if ( ! $post_id ) {
|
167 |
+
return $redirect_to;
|
168 |
+
}
|
169 |
+
|
170 |
+
$post = get_post( $post_id );
|
171 |
+
|
172 |
+
if ( ! $post ) {
|
173 |
+
return $redirect_to;
|
174 |
+
}
|
175 |
+
|
176 |
+
if ( ! $old_user || ! user_can( $old_user, 'edit_post', $post->ID ) ) {
|
177 |
+
return $redirect_to;
|
178 |
+
}
|
179 |
+
|
180 |
+
if ( ! self::is_public_preview_enabled( $post ) ) {
|
181 |
+
return $redirect_to;
|
182 |
+
}
|
183 |
+
|
184 |
+
return self::get_preview_link( $post );
|
185 |
+
}
|
186 |
+
|
187 |
/**
|
188 |
* Adds the checkbox to the submit meta box.
|
189 |
*
|
713 |
public static function uninstall() {
|
714 |
delete_option( 'public_post_preview' );
|
715 |
}
|
716 |
+
|
717 |
+
/**
|
718 |
+
* Performs actions on plugin activation.
|
719 |
+
*
|
720 |
+
* @since 2.9.4
|
721 |
+
*/
|
722 |
+
public static function activate() {
|
723 |
+
register_uninstall_hook( __FILE__, array( 'DS_Public_Post_Preview', 'uninstall' ) );
|
724 |
+
}
|
725 |
}
|
726 |
|
727 |
add_action( 'plugins_loaded', array( 'DS_Public_Post_Preview', 'init' ) );
|
728 |
|
729 |
+
register_activation_hook( __FILE__, array( 'DS_Public_Post_Preview', 'activate' ) );
|
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: 6.
|
6 |
Requires PHP: 5.6
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -66,22 +66,20 @@ Yes, of course. You can use the filter `ppp_nonce_life`. Example for 5 days:
|
|
66 |
|
67 |
`add_filter( 'ppp_nonce_life', 'my_nonce_life' );
|
68 |
function my_nonce_life() {
|
69 |
-
return
|
70 |
}`
|
71 |
|
72 |
Or use the [Public Post Preview Configurator](https://wordpress.org/plugins/public-post-preview-configurator/).
|
73 |
|
74 |
-
==
|
|
|
|
|
|
|
|
|
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).
|
2 |
Contributors: ocean90
|
3 |
Tags: public, preview, posts, anonymous, drafts
|
4 |
Requires at least: 5.0
|
5 |
+
Tested up to: 6.1
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 2.10.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
66 |
|
67 |
`add_filter( 'ppp_nonce_life', 'my_nonce_life' );
|
68 |
function my_nonce_life() {
|
69 |
+
return 5 * DAY_IN_SECONDS;
|
70 |
}`
|
71 |
|
72 |
Or use the [Public Post Preview Configurator](https://wordpress.org/plugins/public-post-preview-configurator/).
|
73 |
|
74 |
+
== Changelog ==
|
75 |
+
|
76 |
+
= 2.10.0 (2022-11-19): =
|
77 |
+
* Compatibility with WordPress 6.1.
|
78 |
+
* Integrate with [User Switching](https://wordpress.org/plugins/user-switching/): Direct the user to the public preview of a post when they switch off from the post editing screen. Props [@johnbillion](https://github.com/johnbillion).
|
79 |
|
80 |
= 2.9.3 (2021-03-12): =
|
81 |
* Compatibility with WordPress 5.7.
|
82 |
* Create a fresh preview URL when enabling public preview.
|
83 |
* Add check for possibly undefined PHP "superglobals". Props [@waviaei](https://github.com/waviaei).
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
For more see [CHANGELOG.md](https://github.com/ocean90/public-post-preview/blob/master/CHANGELOG.md).
|