diff --git a/Gruntfile.js b/Gruntfile.js index 6bdedad0225c3e72c237ae43c2915aee96780391..f92594255df5e7519c3d5d106f16798a2b05c2f6 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,7 +7,7 @@ module.exports = function ( grunt ) { addtextdomain: { options: { - textdomain: 'wp_revisions_control', + textdomain: 'wp-revisions-control', }, update_all_domains: { options: { diff --git a/assets/build/gutenberg.asset.php b/assets/build/gutenberg.asset.php index 951faa5405590216510a600a1cceb928261bdf44..f5ed77a170a6b77db1db0e0623b617ef9542edfd 100644 --- a/assets/build/gutenberg.asset.php +++ b/assets/build/gutenberg.asset.php @@ -1 +1 @@ -<?php return array('dependencies' => array('wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => '7f1755eabefc886809fd'); +<?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'); diff --git a/assets/build/gutenberg.js b/assets/build/gutenberg.js index c904ff14ac42899b20e22ca4c063ae74c0372d9d..d86c7831c0ab0147970a61ed80a89d3a8c2752d7 100644 --- a/assets/build/gutenberg.js +++ b/assets/build/gutenberg.js @@ -1,3 +1,3 @@ -!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),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( /* 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(v,{render:m,icon:"backup"})}()}(); \ No newline at end of file diff --git a/assets/src/gutenberg.js b/assets/src/gutenberg.js index 097eb7b97c687d105c3b3c3645df2961b44139ef..69eeb275c40bf279dcede27a1c29c57a424f1cc7 100644 --- a/assets/src/gutenberg.js +++ b/assets/src/gutenberg.js @@ -25,17 +25,17 @@ const slug = 'wp-revisions-control'; const Render = ( { limit, manualPurge, showPurgeButton, updateMeta } ) => ( <PluginDocumentSettingPanel name={ slug } - title={ __( 'WP Revisions Control', 'wp_revisions_control' ) } + title={ __( 'WP Revisions Control', 'wp-revisions-control' ) } className={ slug } > <TextControl label={ __( 'Number of revisions to retain:', - 'wp_revisions_control' + 'wp-revisions-control' ) } help={ __( 'Leave blank to keep all revisions.', - 'wp_revisions_control' + 'wp-revisions-control' ) } value={ limit } onChange={ updateMeta } @@ -65,7 +65,7 @@ const PurgeModal = ( limit, manualPurge ) => { const modalText = 0 === parsedLimit - ? __( 'This will remove all revisions.', 'wp_revisions_control' ) + ? __( 'This will remove all revisions.', 'wp-revisions-control' ) : // eslint-disable-next-line @wordpress/valid-sprintf sprintf( /* translators: 1. Number of revisions to keep. */ @@ -73,7 +73,7 @@ const PurgeModal = ( limit, manualPurge ) => { 'This will remove all but the most-recent revision.', 'This will remove all but the %1$d most-recent revisions.', parsedLimit, - 'wp_revisions_control' + 'wp-revisions-control' ), limit ); @@ -81,25 +81,25 @@ const PurgeModal = ( limit, manualPurge ) => { return ( <> <Button isSecondary onClick={ openModal }> - { __( 'Purge excess revisions', 'wp_revisions_control' ) } + { __( 'Purge excess revisions', 'wp-revisions-control' ) } </Button> { isOpen && ( <Modal title={ __( 'Purge excess revisions', - 'wp_revisions_control' + 'wp-revisions-control' ) } contentLabel={ modalText } onRequestClose={ closeModal } > <p>{ modalText }</p> <Button isPrimary onClick={ closeModalAndPurge }> - { __( 'Purge', 'wp_revisions_control' ) } + { __( 'Purge', 'wp-revisions-control' ) } </Button> <Button isSecondary onClick={ closeModal }> - { __( 'Cancel', 'wp_revisions_control' ) } + { __( 'Cancel', 'wp-revisions-control' ) } </Button> </Modal> ) } @@ -143,13 +143,13 @@ const RevisionsControl = compose( [ noticeType = 'success'; noticeText = __( 'Excess revisions scheduled for removal.', - 'wp_revisions_control' + 'wp-revisions-control' ); } else { noticeType = 'error'; noticeText = __( 'Failed to schedule excess revisions for removal.', - 'wp_revisions_control' + 'wp-revisions-control' ); } diff --git a/inc/class-block-editor.php b/inc/class-block-editor.php index 52cbd6c1310cfa12e9a75d3ad30763b1837d2ad3..b68b3e6341ed5cab47d62b4dbefed9e63246e2d1 100644 --- a/inc/class-block-editor.php +++ b/inc/class-block-editor.php @@ -57,7 +57,7 @@ class Block_Editor { 'show_in_rest' => true, 'description' => __( 'Number of revisions to retain.', - 'wp_revisions_control' + 'wp-revisions-control' ), ) ); diff --git a/inc/class-wp-revisions-control-bulk-actions.php b/inc/class-wp-revisions-control-bulk-actions.php index 1e31d3b143b8503c29a5eff83e9af56aff7fbe92..fbda623ae91d0bea43a1c99cd59f1e4733e1de61 100644 --- a/inc/class-wp-revisions-control-bulk-actions.php +++ b/inc/class-wp-revisions-control-bulk-actions.php @@ -58,12 +58,12 @@ class WP_Revisions_Control_Bulk_Actions { $actions[ $this->action_base . 'purge_excess' ] = __( 'Purge excess revisions', - 'wp_revisions_control' + 'wp-revisions-control' ); $actions[ $this->action_base . 'purge_all' ] = __( 'Purge ALL revisions', - 'wp_revisions_control' + 'wp-revisions-control' ); $this->actions = $actions; @@ -241,14 +241,14 @@ class WP_Revisions_Control_Bulk_Actions { case 'purge_all': $message = __( 'Purged all revisions.', - 'wp_revisions_control' + 'wp-revisions-control' ); break; case 'purge_excess': $message = __( 'Purged excess revisions.', - 'wp_revisions_control' + 'wp-revisions-control' ); break; @@ -259,7 +259,7 @@ class WP_Revisions_Control_Bulk_Actions { case 'missing': $message = __( 'WP Revisions Control encountered an unspecified error.', - 'wp_revisions_control' + 'wp-revisions-control' ); $type = 'error'; break; diff --git a/inc/class-wp-revisions-control.php b/inc/class-wp-revisions-control.php index 75d4c04e61eea093b5a80e12f6d792c378968daa..9191b03a87743265fab10a6d7b9c1ddca956c139 100644 --- a/inc/class-wp-revisions-control.php +++ b/inc/class-wp-revisions-control.php @@ -84,7 +84,7 @@ class WP_Revisions_Control { */ public function action_plugins_loaded() { load_plugin_textdomain( - 'wp_revisions_control', + 'wp-revisions-control', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' ); @@ -135,8 +135,8 @@ class WP_Revisions_Control { */ public function settings_section_intro() { ?> - <p><?php esc_html_e( 'Set the number of revisions to save for each post type listed. To retain all revisions for a given post type, leave the field empty.', 'wp_revisions_control' ); ?></p> - <p><?php esc_html_e( 'If a post type isn\'t listed, revisions are not enabled for that post type.', 'wp_revisions_control' ); ?></p> + <p><?php esc_html_e( 'Set the number of revisions to save for each post type listed. To retain all revisions for a given post type, leave the field empty.', 'wp-revisions-control' ); ?></p> + <p><?php esc_html_e( 'If a post type isn\'t listed, revisions are not enabled for that post type.', 'wp-revisions-control' ); ?></p> <?php // Display a note if the plugin priority is other than the default. @@ -149,7 +149,7 @@ class WP_Revisions_Control { /* translators: 1. Filter tag. */ esc_html__( 'A local change is causing this plugin\'s functionality to run at a priority other than the default. If you experience difficulties with the plugin, please unhook any functions from the %1$s filter.', - 'wp_revisions_control' + 'wp-revisions-control' ), '<code>wp_revisions_control_priority</code>' ); @@ -277,7 +277,7 @@ class WP_Revisions_Control { 'revisionsdiv-wp-rev-ctl', __( 'Revisions', - 'wp_revisions_control' + 'wp-revisions-control' ), array( $this, @@ -307,11 +307,11 @@ class WP_Revisions_Control { array( 'namespace' => $this->settings_section, 'action_base' => $this->settings_section, - 'processing_text' => __( 'Processing…', 'wp_revisions_control' ), - 'ays' => __( 'Are you sure you want to remove revisions from this post?', 'wp_revisions_control' ), - 'autosave' => __( 'Autosave', 'wp_revisions_control' ), - 'nothing_text' => wpautop( __( 'There are no revisions to remove.', 'wp_revisions_control' ) ), - 'error' => __( 'An error occurred. Please refresh the page and try again.', 'wp_revisions_control' ), + 'processing_text' => __( 'Processing…', 'wp-revisions-control' ), + 'ays' => __( 'Are you sure you want to remove revisions from this post?', 'wp-revisions-control' ), + 'autosave' => __( 'Autosave', 'wp-revisions-control' ), + 'nothing_text' => wpautop( __( 'There are no revisions to remove.', 'wp-revisions-control' ) ), + 'error' => __( 'An error occurred. Please refresh the page and try again.', 'wp-revisions-control' ), ) ); @@ -331,7 +331,7 @@ class WP_Revisions_Control { <div id="<?php echo esc_attr( $this->settings_section ); ?>"> <h4>WP Revisions Control</h4> - <p class="button purge" data-postid="<?php the_ID(); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( $this->settings_section . '_purge' ) ); ?>"><?php _e( 'Purge these revisions', 'wp_revisions_control' ); ?></p> + <p class="button purge" data-postid="<?php the_ID(); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( $this->settings_section . '_purge' ) ); ?>"><?php _e( 'Purge these revisions', 'wp-revisions-control' ); ?></p> <p> <?php @@ -339,7 +339,7 @@ class WP_Revisions_Control { /* translators: 1. Text input field. */ esc_html__( 'Limit this post to %1$s revisions. Leave this field blank for default behavior.', - 'wp_revisions_control' + 'wp-revisions-control' ), '<input type="text" name="' . esc_attr( $this->settings_section ) . '_qty" value="' . esc_attr( $this->get_post_revisions_to_keep( $post->ID ) ) . '" id="' . esc_attr( $this->settings_section ) . '_qty" size="2" />' ); @@ -362,11 +362,11 @@ class WP_Revisions_Control { // Check for necessary data and capabilities. if ( ! $post_id ) { - $response['error'] = __( 'No post ID was provided. Please refresh the page and try again.', 'wp_revisions_control' ); + $response['error'] = __( 'No post ID was provided. Please refresh the page and try again.', 'wp-revisions-control' ); } elseif ( ! check_ajax_referer( $this->settings_section . '_purge', 'nonce', false ) ) { - $response['error'] = __( 'Invalid request. Please refresh the page and try again.', 'wp_revisions_control' ); + $response['error'] = __( 'Invalid request. Please refresh the page and try again.', 'wp-revisions-control' ); } elseif ( ! current_user_can( 'edit_post', $post_id ) ) { - $response['error'] = __( 'You are not allowed to edit this post.', 'wp_revisions_control' ); + $response['error'] = __( 'You are not allowed to edit this post.', 'wp-revisions-control' ); } // Request is valid if $response is still empty, as no errors arose above. @@ -400,7 +400,7 @@ class WP_Revisions_Control { /* translators: 1. Number of removed revisions, already formatted for locale. */ esc_html__( 'Removed %1$s revisions associated with this post.', - 'wp_revisions_control' + 'wp-revisions-control' ), number_format_i18n( $count, 0 ) ); @@ -430,7 +430,7 @@ class WP_Revisions_Control { if ( $to_keep < 0 ) { $response['success'] = __( 'No revisions to remove.', - 'wp_revisions_control' + 'wp-revisions-control' ); return $response; @@ -442,7 +442,7 @@ class WP_Revisions_Control { if ( $starting_count <= $to_keep ) { $response['success'] = __( 'No revisions to remove.', - 'wp_revisions_control' + 'wp-revisions-control' ); return $response; diff --git a/languages/wp_revisions_control-es_ES.mo b/languages/wp-revisions-control-es_ES.mo similarity index 100% rename from languages/wp_revisions_control-es_ES.mo rename to languages/wp-revisions-control-es_ES.mo diff --git a/languages/wp_revisions_control-es_ES.pot b/languages/wp-revisions-control-es_ES.pot similarity index 100% rename from languages/wp_revisions_control-es_ES.pot rename to languages/wp-revisions-control-es_ES.pot