Commit 9872eb65 authored by Erick Hitter's avatar Erick Hitter
Browse files

Merge branch 'fix/24-dynamic-key' into 'master'

Remove unnecessary dynamic meta key

Closes #24

See merge request !24
parents 740bccb0 51e6a4a4
Pipeline #5120 passed with stages
in 3 minutes and 17 seconds
<?php return array('dependencies' => array('wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => '4fb62ef836a783d428cc');
<?php return array('dependencies' => array('wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => 'bd5ae5b661174c1a9835');
!function(){"use strict";var e={989:function(e){e.exports=window.wp.apiFetch},609:function(e){e.exports=window.wp.components},333:function(e){e.exports=window.wp.compose},818:function(e){e.exports=window.wp.data},67:function(e){e.exports=window.wp.editPost},307:function(e){e.exports=window.wp.element},736:function(e){e.exports=window.wp.i18n},817:function(e){e.exports=window.wp.plugins}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,o),i.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e=o(307);const t=o(989),{Button:n,Modal:r,TextControl:i}=o(609),{compose:s}=o(333),{withSelect:l,withDispatch:c}=o(818),{PluginDocumentSettingPanel:a}=o(67),{useState:u}=o(307),{__:__,_n:_n,sprintf:p}=o(736),{registerPlugin:w}=o(817),d=window.wpRevisionsControlBlockEditorSettings.metaKey,v="wp-revisions-control",m=s([l((e=>{const{getCurrentPostRevisionsCount:t,getEditedPostAttribute:o}=e("core/editor"),n=t(),r=o("meta")[d];return{limit:r,showPurgeButton:Boolean(r)&&n>parseInt(r)}})),c(((e,o,n)=>{let{limit:r}=o,{select:i}=n;return{manualPurge:()=>{const o=i("core/editor").getCurrentPostId();t({path:`/wp-revisions-control/v1/schedule/${o}/${parseInt(r,10)}`,method:"PUT"}).then((t=>{let o,n;t?(o="success",n=__("Excess revisions scheduled for removal.","wp-revisions-control")):(o="error",n=__("Failed to schedule excess revisions for removal.","wp-revisions-control")),e("core/notices").createNotice(o,n,{id:"wp-revisions-control-scheduled-purge",isDismissible:!0,type:"snackbar"})}))},updateMeta:t=>{e("core/editor").editPost({meta:{[d]:t}})}}}))])((t=>{let{limit:o,manualPurge:s,showPurgeButton:l,updateMeta:c}=t;return(0,e.createElement)(a,{name:v,title:__("WP Revisions Control","wp-revisions-control"),className:v},(0,e.createElement)(i,{label:__("Number of revisions to retain:","wp-revisions-control"),help:__("Leave blank to keep all revisions.","wp-revisions-control"),value:o,onChange:c}),l&&((t,o)=>{const[i,s]=u(!1),l=()=>s(!1),c=parseInt(t,10),a=0===c?__("This will remove all revisions.","wp-revisions-control"):p(
!function(){"use strict";var e={989:function(e){e.exports=window.wp.apiFetch},609:function(e){e.exports=window.wp.components},333:function(e){e.exports=window.wp.compose},818:function(e){e.exports=window.wp.data},67:function(e){e.exports=window.wp.editPost},307:function(e){e.exports=window.wp.element},736:function(e){e.exports=window.wp.i18n},817:function(e){e.exports=window.wp.plugins}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,o),i.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e=o(307);const t=o(989),{Button:n,Modal:r,TextControl:i}=o(609),{compose:s}=o(333),{withSelect:l,withDispatch:c}=o(818),{PluginDocumentSettingPanel:a}=o(67),{useState:u}=o(307),{__:__,_n:_n,sprintf:p}=o(736),{registerPlugin:w}=o(817),v="_wp_rev_ctl_limit",d="wp-revisions-control",m=s([l((e=>{const{getCurrentPostRevisionsCount:t,getEditedPostAttribute:o}=e("core/editor"),n=t(),r=o("meta")[v];return{limit:r,showPurgeButton:Boolean(r)&&n>parseInt(r)}})),c(((e,o,n)=>{let{limit:r}=o,{select:i}=n;return{manualPurge:()=>{const o=i("core/editor").getCurrentPostId();t({path:`/wp-revisions-control/v1/schedule/${o}/${parseInt(r,10)}`,method:"PUT"}).then((t=>{let o,n;t?(o="success",n=__("Excess revisions scheduled for removal.","wp-revisions-control")):(o="error",n=__("Failed to schedule excess revisions for removal.","wp-revisions-control")),e("core/notices").createNotice(o,n,{id:"wp-revisions-control-scheduled-purge",isDismissible:!0,type:"snackbar"})}))},updateMeta:t=>{e("core/editor").editPost({meta:{[v]:t}})}}}))])((t=>{let{limit:o,manualPurge:s,showPurgeButton:l,updateMeta:c}=t;return(0,e.createElement)(a,{name:d,title:__("WP Revisions Control","wp-revisions-control"),className:d},(0,e.createElement)(i,{label:__("Number of revisions to retain:","wp-revisions-control"),help:__("Leave blank to keep all revisions.","wp-revisions-control"),value:o,onChange:c}),l&&((t,o)=>{const[i,s]=u(!1),l=()=>s(!1),c=parseInt(t,10),a=0===c?__("This will remove all revisions.","wp-revisions-control"):p(
/* translators: 1. Number of revisions to keep. */
_n("This will remove all but the most-recent revision.","This will remove all but the %1$d most-recent revisions.",c,"wp-revisions-control"),t);return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,{isSecondary:!0,onClick:()=>s(!0)},__("Purge excess revisions","wp-revisions-control")),i&&(0,e.createElement)(r,{title:__("Purge excess revisions","wp-revisions-control"),contentLabel:a,onRequestClose:l},(0,e.createElement)("p",null,a),(0,e.createElement)(n,{isPrimary:!0,onClick:()=>{l(),o()}},__("Purge","wp-revisions-control"))," ",(0,e.createElement)(n,{isSecondary:!0,onClick:l},__("Cancel","wp-revisions-control"))))})(o,s))}));w(v,{render:m,icon:"backup"})}()}();
\ No newline at end of file
_n("This will remove all but the most-recent revision.","This will remove all but the %1$d most-recent revisions.",c,"wp-revisions-control"),t);return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(n,{isSecondary:!0,onClick:()=>s(!0)},__("Purge excess revisions","wp-revisions-control")),i&&(0,e.createElement)(r,{title:__("Purge excess revisions","wp-revisions-control"),contentLabel:a,onRequestClose:l},(0,e.createElement)("p",null,a),(0,e.createElement)(n,{isPrimary:!0,onClick:()=>{l(),o()}},__("Purge","wp-revisions-control"))," ",(0,e.createElement)(n,{isSecondary:!0,onClick:l},__("Cancel","wp-revisions-control"))))})(o,s))}));w(d,{render:m,icon:"backup"})}()}();
\ No newline at end of file
......@@ -7,7 +7,7 @@ const { useState } = require( '@wordpress/element' );
const { __, _n, sprintf } = require( '@wordpress/i18n' );
const { registerPlugin } = require( '@wordpress/plugins' );
const metaKey = window.wpRevisionsControlBlockEditorSettings.metaKey;
const metaKey = '_wp_rev_ctl_limit';
const slug = 'wp-revisions-control';
/**
......
......@@ -168,14 +168,6 @@ class Block_Editor {
$asset_data['version']
);
wp_localize_script(
$handle,
'wpRevisionsControlBlockEditorSettings',
array(
'metaKey' => WP_REVISIONS_CONTROL_LIMIT_META_KEY,
)
);
wp_set_script_translations(
$handle,
'wp-revisions-control',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment