Plugin Directory

Changeset 3847088


Ignore:
Timestamp:
12/06/2026 03:13:19 AM (less than one hour ago)
Author:
ethitter
Message:

Update to version 1.5.0 from GitLab (​https://git.ethitter.com/wp-plugins/wp-revisions-control; ​https://git.ethitter.com/wp-plugins/wp-revisions-control/-/jobs/48900)

Location:
wp-revisions-control
Files:
2 added
20 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-revisions-control/tags/1.5.0/assets/build/classic-editor.asset.php

    r2737775 r3847088  
    1 <?php return array('dependencies' => array('jquery'), 'version' => '60fb0f1e9e40b24c7794');
     1<?php return array(
     2        'dependencies' => array(
     3                'jquery'
     4        ),
     5        'version' => '711ac1e6444300a66dc3'
     6);
  • wp-revisions-control/tags/1.5.0/assets/build/classic-editor.js

    r2737775 r3847088  
    1 !function(){"use strict";var t,e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},n=window.jQuery;(t=e.n(n)())(document).ready((function(){const e=t("#"+wp_revisions_control.namespace+" .button.purge");let n=null,o=null;function r(o){if(o.error)alert(o.error),t(e).text(n);else if(o.success){const n=t("ul.post-revisions > li");t(n).each((function(){t(this).text().match(wp_revisions_control.autosave)||t(this).slideUp("slow").remove()})),t(e).fadeOut("slow").after(wp_revisions_control.nothing_text)}}function s(){alert(wp_revisions_control.error),t(e).text(n)}n=t(e).text(),t(e).on("click",(function(){o=parseInt(t(this).data("postid")),t(e).text(wp_revisions_control.processing_text),confirm(wp_revisions_control.ays)&&o?t.ajax({url:ajaxurl,cache:!1,data:{action:wp_revisions_control.action_base+"_purge",post_id:o,nonce:t(this).data("nonce")},type:"post",dataType:"json",success:r,error:s}):t(e).text(n)}))}))}();
     1(()=>{"use strict";const t={n:e=>{const o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:(t,e)=>Object.hasOwn(t,e)},e=window.jQuery;var o;(o=t.n(e)())(document).ready(function(){const t=o("#"+wp_revisions_control.namespace+" .button.purge");let e=null,n=null;function s(n){if(n.error)alert(n.error),o(t).text(e);else if(n.success){const e=o("ul.post-revisions > li");o(e).each(function(){o(this).text().match(wp_revisions_control.autosave)||o(this).slideUp("slow").remove()}),o(t).fadeOut("slow").after(wp_revisions_control.nothing_text)}}function r(){alert(wp_revisions_control.error),o(t).text(e)}e=o(t).text(),o(t).on("click",function(){n=parseInt(o(this).data("postid")),o(t).text(wp_revisions_control.processing_text),confirm(wp_revisions_control.ays)&&n?o.ajax({url:ajaxurl,cache:!1,data:{action:wp_revisions_control.action_base+"_purge",post_id:n,nonce:o(this).data("nonce")},type:"post",dataType:"json",success:s,error:r}):o(t).text(e)})})})();
  • wp-revisions-control/tags/1.5.0/assets/build/gutenberg.asset.php

    r3322043 r3847088  
    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' => 'bd5ae5b661174c1a9835');
     1<?php return array(
     2        'dependencies' => array(
     3                'wp-api-fetch',
     4                'wp-components',
     5                'wp-data',
     6                'wp-edit-post',
     7                'wp-editor',
     8                'wp-element',
     9                'wp-i18n',
     10                'wp-plugins'
     11        ),
     12        'version' => 'ac37942390b375e031ad'
     13);
  • wp-revisions-control/tags/1.5.0/assets/build/gutenberg.js

    r3322043 r3847088  
    1 !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(
    2 /* translators: 1. Number of revisions to keep. */
    3 _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"})}()}();
     1(()=>{"use strict";const e={n:t=>{const n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.hasOwn(e,t)},t=window.wp.apiFetch;var n=e.n(t);const o=window.wp.components,i=window.wp.data,r=window.wp.editPost,s=window.wp.editor,l=window.wp.element,c=window.wp.i18n,a=window.wp.plugins,p="wp_revisions_control_limit",u="wp-revisions-control",w=s.PluginDocumentSettingPanel||r.PluginDocumentSettingPanel,m=({children:e,onClick:t,primary:n=!1})=>wp.element.createElement(o.Button,{variant:n?"primary":"secondary",isPrimary:n,isSecondary:!n,onClick:t},e),d=e=>{if("function"==typeof e.getCurrentPostRevisionsCount)return e.getCurrentPostRevisionsCount()||0;const t=((e.getCurrentPost()||{})._links||{})["version-history"]||[];return t[0]&&t[0].count||0},v=({limit:e,manualPurge:t})=>{const[n,i]=(0,l.useState)(!1),r=()=>i(!1),s=0===e?(0,c.__)("This will remove all revisions.","wp-revisions-control"):(0,c.sprintf)(/* translators: 1. Number of revisions to keep. */ /* translators: 1. Number of revisions to keep. */
     2(0,c._n)("This will remove all but the most-recent revision.","This will remove all but the %1$d most-recent revisions.",e,"wp-revisions-control"),e);return wp.element.createElement(wp.element.Fragment,null,wp.element.createElement(m,{onClick:()=>i(!0)},(0,c.__)("Purge excess revisions","wp-revisions-control")),n&&wp.element.createElement(o.Modal,{title:(0,c.__)("Purge excess revisions","wp-revisions-control"),onRequestClose:r},wp.element.createElement("p",null,s),wp.element.createElement(m,{primary:!0,onClick:()=>{r(),t()}},(0,c.__)("Purge","wp-revisions-control"))," ",wp.element.createElement(m,{onClick:r},(0,c.__)("Cancel","wp-revisions-control"))))};w&&(0,a.registerPlugin)(u,{render:()=>{const{count:e,postId:t,storedLimit:r}=(0,i.useSelect)(e=>{const t=e("core/editor");return{count:d(t),postId:t.getCurrentPostId(),storedLimit:t.getEditedPostAttribute(p)}},[]),{editPost:s}=(0,i.useDispatch)("core/editor"),{createNotice:l}=(0,i.useDispatch)("core/notices");if(null==r)return null;const a=String(r),m=parseInt(a,10),_=!isNaN(m)&&e>m,g=(e,t)=>{l(e,t,{id:"wp-revisions-control-scheduled-purge",isDismissible:!0,type:"snackbar"})},h=()=>g("error",(0,c.__)("Failed to schedule excess revisions for removal.","wp-revisions-control"));return wp.element.createElement(w,{name:u,title:(0,c.__)("WP Revisions Control","wp-revisions-control"),className:u},wp.element.createElement(o.TextControl,{label:(0,c.__)("Number of revisions to retain:","wp-revisions-control"),help:(0,c.__)("Leave blank to keep all revisions.","wp-revisions-control"),value:a,onChange:e=>{s({[p]:String(e).replace(/\D/g,"")})},__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),_&&wp.element.createElement(v,{limit:m,manualPurge:()=>{n()({path:`/wp-revisions-control/v1/schedule/${t}/${m}`,method:"PUT"}).then(e=>{e?g("success",(0,c.__)("Excess revisions scheduled for removal.","wp-revisions-control")):h()}).catch(h)}}))},icon:"backup"})})();
  • wp-revisions-control/tags/1.5.0/inc/class-block-editor.php

    r3322043 r3847088  
    88namespace WP_Revisions_Control;
    99
     10use WP_Post;
    1011use WP_REST_Response;
    1112use WP_REST_Request;
    … …  
    1920
    2021        /**
     22         * Name of REST field holding a post's revisions limit.
     23         *
     24         * Used instead of the registered meta because the REST API only exposes
     25         * meta for post types that support `custom-fields`.
     26         *
     27         * @var string
     28         */
     29        const REST_FIELD = 'wp_revisions_control_limit';
     30
     31        /**
     32         * First WordPress release with the APIs the sidebar panel needs.
     33         *
     34         * @var string
     35         */
     36        const MINIMUM_WP_VERSION = '5.3';
     37
     38        /**
    2139         * Name of action used to clean up post's revisions via cron.
    2240         *
    … …  
    5169                                WP_REVISIONS_CONTROL_LIMIT_META_KEY,
    5270                                array(
    53                                         'object_subtype' => $post_type,
    54                                         'type'           => 'string', // Can be empty, so must be string.
    55                                         'default'        => '',
    56                                         'single'         => true,
    57                                         'show_in_rest'   => true,
    58                                         'description'    => __(
     71                                        'object_subtype'    => $post_type,
     72                                        'type'              => 'string', // Can be empty, so must be string.
     73                                        'default'           => '',
     74                                        'single'            => true,
     75                                        'show_in_rest'      => true,
     76                                        'sanitize_callback' => array( $this, 'sanitize_limit' ),
     77                                        'auth_callback'     => array( $this, 'meta_auth_callback' ),
     78                                        'description'       => __(
    5979                                                'Number of revisions to retain.',
    6080                                                'wp-revisions-control'
    … …  
    6282                                )
    6383                        );
     84
     85                        if ( function_exists( 'register_rest_field' ) ) {
     86                                register_rest_field(
     87                                        $post_type,
     88                                        self::REST_FIELD,
     89                                        array(
     90                                                'get_callback'    => array( $this, 'rest_field_get' ),
     91                                                'update_callback' => array( $this, 'rest_field_update' ),
     92                                                'schema'          => array(
     93                                                        'description' => __(
     94                                                                'Number of revisions to retain.',
     95                                                                'wp-revisions-control'
     96                                                        ),
     97                                                        'type'        => 'string', // Can be empty, so must be string.
     98                                                        'context'     => array( 'edit' ),
     99                                                ),
     100                                        )
     101                                );
     102                        }
    64103                }
    65104
    … …  
    90129
    91130        /**
     131         * Whether this WordPress release supports the sidebar panel.
     132         *
     133         * The block editor shipped in 5.0, but the panel and the data hooks the
     134         * script relies on arrived in 5.3. Earlier releases use the classic
     135         * meta box instead.
     136         *
     137         * @return bool
     138         */
     139        public function supports_sidebar_panel() {
     140                return version_compare( get_bloginfo( 'version' ), self::MINIMUM_WP_VERSION, '>=' );
     141        }
     142
     143        /**
     144         * Sanitize a post's revisions limit.
     145         *
     146         * @param mixed $limit Unsanitized limit.
     147         * @return string Non-negative integer as a string, or an empty string for
     148         *                no post-specific limit.
     149         */
     150        public function sanitize_limit( $limit ) {
     151                if ( ! is_scalar( $limit ) ) {
     152                        return '';
     153                }
     154
     155                $limit = trim( (string) $limit );
     156
     157                if ( '' === $limit || ! ctype_digit( $limit ) ) {
     158                        return '';
     159                }
     160
     161                return (string) absint( $limit );
     162        }
     163
     164        /**
     165         * Limit who can change a post's revisions limit via its meta.
     166         *
     167         * @param bool   $allowed   Whether the user can change the meta.
     168         * @param string $meta_key  Meta key.
     169         * @param int    $object_id Post ID.
     170         * @param int    $user_id   User ID.
     171         * @return bool
     172         */
     173        public function meta_auth_callback( $allowed, $meta_key, $object_id, $user_id ) {
     174                return user_can( $user_id, 'edit_post', $object_id );
     175        }
     176
     177        /**
     178         * Provide a post's revisions limit to the REST API.
     179         *
     180         * @param array $post Prepared post data.
     181         * @return string
     182         */
     183        public function rest_field_get( $post ) {
     184                if ( ! is_array( $post ) || empty( $post['id'] ) ) {
     185                        return '';
     186                }
     187
     188                return $this->sanitize_limit(
     189                        get_post_meta( $post['id'], WP_REVISIONS_CONTROL_LIMIT_META_KEY, true )
     190                );
     191        }
     192
     193        /**
     194         * Update a post's revisions limit from the REST API.
     195         *
     196         * The posts controller confirms that the user can edit the post before
     197         * additional fields are updated.
     198         *
     199         * @param mixed   $value Submitted limit.
     200         * @param WP_Post $post  Post object.
     201         * @return bool
     202         */
     203        public function rest_field_update( $value, $post ) {
     204                if ( ! is_object( $post ) || empty( $post->ID ) ) {
     205                        return false;
     206                }
     207
     208                $limit = $this->sanitize_limit( $value );
     209
     210                if ( '' === $limit ) {
     211                        delete_post_meta( $post->ID, WP_REVISIONS_CONTROL_LIMIT_META_KEY );
     212                } else {
     213                        update_post_meta( $post->ID, WP_REVISIONS_CONTROL_LIMIT_META_KEY, $limit );
     214                }
     215
     216                return true;
     217        }
     218
     219        /**
    92220         * Permissions callback for REST endpoint.
    93221         *
    … …  
    156284                }
    157285
    158                 if ( ! post_type_supports( $typenow, 'revisions' ) ) {
     286                if ( ! $typenow || ! post_type_supports( $typenow, 'revisions' ) ) {
    159287                        return;
    160288                }
    161289
    162                 $handle     = 'wp-revisions-control-block-editor';
    163                 $asset_data = require_once dirname( __DIR__ ) . '/assets/build/gutenberg.asset.php';
     290                if ( ! $this->supports_sidebar_panel() ) {
     291                        return;
     292                }
     293
     294                $handle = 'wp-revisions-control-block-editor';
     295                // Not `require_once`, which returns `true` if this runs a second time.
     296                $asset_data = require dirname( __DIR__ ) . '/assets/build/gutenberg.asset.php';
    164297
    165298                wp_enqueue_script(
  • wp-revisions-control/tags/1.5.0/inc/class-wp-revisions-control-bulk-actions.php

    r2737792 r3847088  
    8484                }
    8585
    86                 $post_type_caps = get_post_type_object( $screen->post_type )->cap;
    87                 $user_can       = (
    88                         current_user_can( $post_type_caps->edit_posts ) &&
    89                         current_user_can( $post_type_caps->edit_published_posts ) &&
    90                         current_user_can( $post_type_caps->edit_others_posts )
    91                 );
    92                 $user_can       = apply_filters(
     86                $post_type_object = get_post_type_object( $screen->post_type );
     87
     88                if ( null === $post_type_object ) {
     89                        return;
     90                }
     91
     92                // Some capabilities, such as `edit_published_posts`, only exist for
     93                // post types registered with `map_meta_cap`.
     94                $user_can = true;
     95
     96                foreach ( array( 'edit_posts', 'edit_published_posts', 'edit_others_posts' ) as $cap ) {
     97                        if ( isset( $post_type_object->cap->$cap ) && ! current_user_can( $post_type_object->cap->$cap ) ) {
     98                                $user_can = false;
     99                                break;
     100                        }
     101                }
     102
     103                $user_can = apply_filters(
    93104                        'wp_revisions_control_current_user_can_bulk_actions',
    94105                        $user_can,
  • wp-revisions-control/tags/1.5.0/inc/class-wp-revisions-control.php

    r2737792 r3847088  
    183183                if ( is_array( $options ) ) {
    184184                        foreach ( $options as $post_type => $to_keep ) {
    185                                 $type_length = strlen( $to_keep );
     185                                // Malformed input, and a TypeError in PHP 8.
     186                                if ( is_array( $to_keep ) || is_object( $to_keep ) ) {
     187                                        continue;
     188                                }
     189
     190                                $type_length = strlen( (string) $to_keep );
    186191
    187192                                if ( 0 === $type_length ) {
    … …  
    266271                                function_exists( 'use_block_editor_for_post' )
    267272                                && use_block_editor_for_post( $post )
     273                                && Block_Editor::get_instance()->supports_sidebar_panel()
    268274                        )
    269275                        || count( wp_get_post_revisions( $post ) ) < 1
    … …  
    291297                // A bit of JS for us.
    292298                $handle     = 'wp-revisions-control-post';
    293                 $asset_data = require_once dirname( __DIR__ ) . '/assets/build/classic-editor.asset.php';
     299                $asset_data = require dirname( __DIR__ ) . '/assets/build/classic-editor.asset.php';
    294300                wp_enqueue_script(
    295301                        $handle,
    … …  
    424430                );
    425431
    426                 $to_keep = null !== $limit_override
    427                         ? $limit_override
    428                         : wp_revisions_to_keep( get_post( $post_id ) );
     432                if ( null !== $limit_override ) {
     433                        $to_keep = (int) $limit_override;
     434                } else {
     435                        $post = get_post( $post_id );
     436
     437                        // The post may be gone by the time a scheduled purge runs.
     438                        if ( ! $post ) {
     439                                return $response;
     440                        }
     441
     442                        $to_keep = (int) wp_revisions_to_keep( $post );
     443                }
    429444
    430445                if ( $to_keep < 0 ) {
  • wp-revisions-control/tags/1.5.0/languages/wp-revisions-control.pot

    r3322043 r3847088  
    1 # Copyright (C) 2025 Erick Hitter
    2 # This file is distributed under the same license as the WP Revisions Control package.
     1# Copyright (C) 2026 Erick Hitter
     2# This file is distributed under the same license as the WP Revisions Control plugin.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: WP Revisions Control 1.4.4\n"
    6 "Report-Msgid-Bugs-To: "
    7 "https://wordpress.org/support/plugin/wp-revisions-control\n"
    8 "POT-Creation-Date: 2025-07-03 22:22:28+00:00\n"
    9 "MIME-Version: 1.0\n"
    10 "Content-Type: text/plain; charset=utf-8\n"
    11 "Content-Transfer-Encoding: 8bit\n"
    12 "PO-Revision-Date: 2025-MO-DA HO:MI+ZONE\n"
     5"Project-Id-Version: WP Revisions Control 1.4.5\n"
     6"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-revisions-control\n"
    137"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    148"Language-Team: LANGUAGE <LL@li.org>\n"
    15 "Language: en\n"
    16 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
    17 "X-Poedit-Country: United States\n"
    18 "X-Poedit-SourceCharset: UTF-8\n"
    19 "X-Poedit-KeywordsList: "
    20 "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
    21 "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
    22 "X-Poedit-Basepath: ../\n"
    23 "X-Poedit-SearchPath-0: .\n"
    24 "X-Poedit-Bookmarks: \n"
    25 "X-Textdomain-Support: yes\n"
    26 "X-Generator: grunt-wp-i18n 1.0.3\n"
     9"MIME-Version: 1.0\n"
     10"Content-Type: text/plain; charset=UTF-8\n"
     11"Content-Transfer-Encoding: 8bit\n"
     12"POT-Creation-Date: 2026-04-11T21:45:18+00:00\n"
     13"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     14"X-Generator: WP-CLI 2.12.0\n"
     15"X-Domain: wp-revisions-control\n"
     16
     17#. Plugin Name of the plugin
     18#: wp-revisions-control.php
     19#: assets/build/gutenberg.js:1
     20#: assets/src/gutenberg.js:28
     21msgid "WP Revisions Control"
     22msgstr ""
     23
     24#. Plugin URI of the plugin
     25#: wp-revisions-control.php
     26msgid "https://ethitter.com/plugins/wp-revisions-control/"
     27msgstr ""
     28
     29#. Description of the plugin
     30#: wp-revisions-control.php
     31msgid "Control how many revisions are stored for each post type"
     32msgstr ""
     33
     34#. Author of the plugin
     35#: wp-revisions-control.php
     36msgid "Erick Hitter"
     37msgstr ""
     38
     39#. Author URI of the plugin
     40#: wp-revisions-control.php
     41msgid "https://ethitter.com/"
     42msgstr ""
    2743
    2844#: inc/class-block-editor.php:58
    … …  
    3147
    3248#: inc/class-wp-revisions-control-bulk-actions.php:59
     49#: assets/build/gutenberg.js:2
     50#: assets/src/gutenberg.js:84
     51#: assets/src/gutenberg.js:89
    3352msgid "Purge excess revisions"
    3453msgstr ""
    … …  
    5170
    5271#: inc/class-wp-revisions-control.php:138
    53 msgid ""
    54 "Set the number of revisions to save for each post type listed. To retain "
    55 "all revisions for a given post type, leave the field empty."
     72msgid "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."
    5673msgstr ""
    5774
    … …  
    6077msgstr ""
    6178
     79#. translators: 1. Filter tag.
    6280#: inc/class-wp-revisions-control.php:150
    63 #. translators: 1. Filter tag.
    64 msgid ""
    65 "A local change is causing this plugin's functionality to run at a priority "
    66 "other than the default. If you experience difficulties with the plugin, "
    67 "please unhook any functions from the %1$s filter."
     81#, php-format
     82msgid "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."
    6883msgstr ""
    6984
    … …  
    96111msgstr ""
    97112
     113#. translators: 1. Text input field.
    98114#: inc/class-wp-revisions-control.php:340
    99 #. translators: 1. Text input field.
    100 msgid ""
    101 "Limit this post to %1$s revisions. Leave this field blank for default "
    102 "behavior."
     115#, php-format
     116msgid "Limit this post to %1$s revisions. Leave this field blank for default behavior."
    103117msgstr ""
    104118
    … …  
    115129msgstr ""
    116130
     131#. translators: 1. Number of removed revisions, already formatted for locale.
    117132#: inc/class-wp-revisions-control.php:401
    118 #. translators: 1. Number of removed revisions, already formatted for locale.
     133#, php-format
    119134msgid "Removed %1$s revisions associated with this post."
    120135msgstr ""
    … …  
    125140msgstr ""
    126141
    127 #. Plugin Name of the plugin/theme
    128 msgid "WP Revisions Control"
     142#: assets/build/gutenberg.js:1
     143#: assets/src/gutenberg.js:144
     144msgid "Excess revisions scheduled for removal."
    129145msgstr ""
    130146
    131 #. Plugin URI of the plugin/theme
    132 msgid "https://ethitter.com/plugins/wp-revisions-control/"
     147#: assets/build/gutenberg.js:1
     148#: assets/src/gutenberg.js:150
     149msgid "Failed to schedule excess revisions for removal."
    133150msgstr ""
    134151
    135 #. Description of the plugin/theme
    136 msgid "Control how many revisions are stored for each post type"
     152#: assets/build/gutenberg.js:1
     153#: assets/src/gutenberg.js:32
     154msgid "Number of revisions to retain:"
    137155msgstr ""
    138156
    139 #. Author of the plugin/theme
    140 msgid "Erick Hitter"
     157#: assets/build/gutenberg.js:1
     158#: assets/src/gutenberg.js:36
     159msgid "Leave blank to keep all revisions."
    141160msgstr ""
    142161
    143 #. Author URI of the plugin/theme
    144 msgid "https://ethitter.com/"
     162#: assets/build/gutenberg.js:1
     163#: assets/src/gutenberg.js:68
     164msgid "This will remove all revisions."
    145165msgstr ""
     166
     167#. translators: 1. Number of revisions to keep.
     168#: assets/build/gutenberg.js:2
     169#: assets/src/gutenberg.js:72
     170msgid "This will remove all but the most-recent revision."
     171msgid_plural "This will remove all but the %1$d most-recent revisions."
     172msgstr[0] ""
     173msgstr[1] ""
     174
     175#: assets/build/gutenberg.js:2
     176#: assets/src/gutenberg.js:98
     177msgid "Purge"
     178msgstr ""
     179
     180#: assets/build/gutenberg.js:2
     181#: assets/src/gutenberg.js:102
     182msgid "Cancel"
     183msgstr ""
  • wp-revisions-control/tags/1.5.0/readme.txt

    r3322043 r3847088  
    44Tags: revision, revisions, admin
    55Requires at least: 3.6
    6 Tested up to: 6.8
    7 Stable tag: 1.4.4
     6Tested up to: 7.2
     7Stable tag: 1.5.0
    88Requires PHP: 5.6
    99License: GPLv2 or later
    … …  
    3636
    3737== Changelog ==
     38
     39= 1.5.0 =
     40* Update block-editor sidebar for current WordPress releases, removing its use of deprecated APIs.
     41* Fix block-editor error for post types that support revisions but not custom fields.
     42* Use the Classic Editor meta box in WordPress 5.0 through 5.2, which lack the APIs the sidebar requires.
     43* Fix PHP warning in bulk actions for post types registered without `map_meta_cap`.
     44* Report a failed purge request in the block editor.
     45* Harden handling of malformed settings and of posts deleted before a scheduled purge.
     46
     47= 1.4.5 =
     48* Update build process and rebuild plugin assets.
    3849
    3950= 1.4.4 =
    … …  
    6980== Upgrade Notice ==
    7081
     82= 1.5.0 =
     83
     84Updates the block-editor sidebar for current WordPress releases and fixes errors with some custom post types.
     85
     86= 1.4.5 =
     87
     88Updates build process and rebuild plugin assets.
     89
    7190= 1.4.4 =
    7291
  • wp-revisions-control/tags/1.5.0/wp-revisions-control.php

    r3322043 r3847088  
    55 * Description: Control how many revisions are stored for each post type
    66 * Author: Erick Hitter
    7  * Version: 1.4.4
     7 * Version: 1.5.0
    88 * Author URI: https://ethitter.com/
    99 * Text Domain: wp-revisions-control
  • wp-revisions-control/trunk/assets/build/classic-editor.asset.php

    r2737775 r3847088  
    1 <?php return array('dependencies' => array('jquery'), 'version' => '60fb0f1e9e40b24c7794');
     1<?php return array(
     2        'dependencies' => array(
     3                'jquery'
     4        ),
     5        'version' => '711ac1e6444300a66dc3'
     6);
  • wp-revisions-control/trunk/assets/build/classic-editor.js

    r2737775 r3847088  
    1 !function(){"use strict";var t,e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},n=window.jQuery;(t=e.n(n)())(document).ready((function(){const e=t("#"+wp_revisions_control.namespace+" .button.purge");let n=null,o=null;function r(o){if(o.error)alert(o.error),t(e).text(n);else if(o.success){const n=t("ul.post-revisions > li");t(n).each((function(){t(this).text().match(wp_revisions_control.autosave)||t(this).slideUp("slow").remove()})),t(e).fadeOut("slow").after(wp_revisions_control.nothing_text)}}function s(){alert(wp_revisions_control.error),t(e).text(n)}n=t(e).text(),t(e).on("click",(function(){o=parseInt(t(this).data("postid")),t(e).text(wp_revisions_control.processing_text),confirm(wp_revisions_control.ays)&&o?t.ajax({url:ajaxurl,cache:!1,data:{action:wp_revisions_control.action_base+"_purge",post_id:o,nonce:t(this).data("nonce")},type:"post",dataType:"json",success:r,error:s}):t(e).text(n)}))}))}();
     1(()=>{"use strict";const t={n:e=>{const o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:(t,e)=>Object.hasOwn(t,e)},e=window.jQuery;var o;(o=t.n(e)())(document).ready(function(){const t=o("#"+wp_revisions_control.namespace+" .button.purge");let e=null,n=null;function s(n){if(n.error)alert(n.error),o(t).text(e);else if(n.success){const e=o("ul.post-revisions > li");o(e).each(function(){o(this).text().match(wp_revisions_control.autosave)||o(this).slideUp("slow").remove()}),o(t).fadeOut("slow").after(wp_revisions_control.nothing_text)}}function r(){alert(wp_revisions_control.error),o(t).text(e)}e=o(t).text(),o(t).on("click",function(){n=parseInt(o(this).data("postid")),o(t).text(wp_revisions_control.processing_text),confirm(wp_revisions_control.ays)&&n?o.ajax({url:ajaxurl,cache:!1,data:{action:wp_revisions_control.action_base+"_purge",post_id:n,nonce:o(this).data("nonce")},type:"post",dataType:"json",success:s,error:r}):o(t).text(e)})})})();
  • wp-revisions-control/trunk/assets/build/gutenberg.asset.php

    r3322043 r3847088  
    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' => 'bd5ae5b661174c1a9835');
     1<?php return array(
     2        'dependencies' => array(
     3                'wp-api-fetch',
     4                'wp-components',
     5                'wp-data',
     6                'wp-edit-post',
     7                'wp-editor',
     8                'wp-element',
     9                'wp-i18n',
     10                'wp-plugins'
     11        ),
     12        'version' => 'ac37942390b375e031ad'
     13);
  • wp-revisions-control/trunk/assets/build/gutenberg.js

    r3322043 r3847088  
    1 !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(
    2 /* translators: 1. Number of revisions to keep. */
    3 _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"})}()}();
     1(()=>{"use strict";const e={n:t=>{const n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.hasOwn(e,t)},t=window.wp.apiFetch;var n=e.n(t);const o=window.wp.components,i=window.wp.data,r=window.wp.editPost,s=window.wp.editor,l=window.wp.element,c=window.wp.i18n,a=window.wp.plugins,p="wp_revisions_control_limit",u="wp-revisions-control",w=s.PluginDocumentSettingPanel||r.PluginDocumentSettingPanel,m=({children:e,onClick:t,primary:n=!1})=>wp.element.createElement(o.Button,{variant:n?"primary":"secondary",isPrimary:n,isSecondary:!n,onClick:t},e),d=e=>{if("function"==typeof e.getCurrentPostRevisionsCount)return e.getCurrentPostRevisionsCount()||0;const t=((e.getCurrentPost()||{})._links||{})["version-history"]||[];return t[0]&&t[0].count||0},v=({limit:e,manualPurge:t})=>{const[n,i]=(0,l.useState)(!1),r=()=>i(!1),s=0===e?(0,c.__)("This will remove all revisions.","wp-revisions-control"):(0,c.sprintf)(/* translators: 1. Number of revisions to keep. */ /* translators: 1. Number of revisions to keep. */
     2(0,c._n)("This will remove all but the most-recent revision.","This will remove all but the %1$d most-recent revisions.",e,"wp-revisions-control"),e);return wp.element.createElement(wp.element.Fragment,null,wp.element.createElement(m,{onClick:()=>i(!0)},(0,c.__)("Purge excess revisions","wp-revisions-control")),n&&wp.element.createElement(o.Modal,{title:(0,c.__)("Purge excess revisions","wp-revisions-control"),onRequestClose:r},wp.element.createElement("p",null,s),wp.element.createElement(m,{primary:!0,onClick:()=>{r(),t()}},(0,c.__)("Purge","wp-revisions-control"))," ",wp.element.createElement(m,{onClick:r},(0,c.__)("Cancel","wp-revisions-control"))))};w&&(0,a.registerPlugin)(u,{render:()=>{const{count:e,postId:t,storedLimit:r}=(0,i.useSelect)(e=>{const t=e("core/editor");return{count:d(t),postId:t.getCurrentPostId(),storedLimit:t.getEditedPostAttribute(p)}},[]),{editPost:s}=(0,i.useDispatch)("core/editor"),{createNotice:l}=(0,i.useDispatch)("core/notices");if(null==r)return null;const a=String(r),m=parseInt(a,10),_=!isNaN(m)&&e>m,g=(e,t)=>{l(e,t,{id:"wp-revisions-control-scheduled-purge",isDismissible:!0,type:"snackbar"})},h=()=>g("error",(0,c.__)("Failed to schedule excess revisions for removal.","wp-revisions-control"));return wp.element.createElement(w,{name:u,title:(0,c.__)("WP Revisions Control","wp-revisions-control"),className:u},wp.element.createElement(o.TextControl,{label:(0,c.__)("Number of revisions to retain:","wp-revisions-control"),help:(0,c.__)("Leave blank to keep all revisions.","wp-revisions-control"),value:a,onChange:e=>{s({[p]:String(e).replace(/\D/g,"")})},__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),_&&wp.element.createElement(v,{limit:m,manualPurge:()=>{n()({path:`/wp-revisions-control/v1/schedule/${t}/${m}`,method:"PUT"}).then(e=>{e?g("success",(0,c.__)("Excess revisions scheduled for removal.","wp-revisions-control")):h()}).catch(h)}}))},icon:"backup"})})();
  • wp-revisions-control/trunk/inc/class-block-editor.php

    r3322043 r3847088  
    88namespace WP_Revisions_Control;
    99
     10use WP_Post;
    1011use WP_REST_Response;
    1112use WP_REST_Request;
    … …  
    1920
    2021        /**
     22         * Name of REST field holding a post's revisions limit.
     23         *
     24         * Used instead of the registered meta because the REST API only exposes
     25         * meta for post types that support `custom-fields`.
     26         *
     27         * @var string
     28         */
     29        const REST_FIELD = 'wp_revisions_control_limit';
     30
     31        /**
     32         * First WordPress release with the APIs the sidebar panel needs.
     33         *
     34         * @var string
     35         */
     36        const MINIMUM_WP_VERSION = '5.3';
     37
     38        /**
    2139         * Name of action used to clean up post's revisions via cron.
    2240         *
    … …  
    5169                                WP_REVISIONS_CONTROL_LIMIT_META_KEY,
    5270                                array(
    53                                         'object_subtype' => $post_type,
    54                                         'type'           => 'string', // Can be empty, so must be string.
    55                                         'default'        => '',
    56                                         'single'         => true,
    57                                         'show_in_rest'   => true,
    58                                         'description'    => __(
     71                                        'object_subtype'    => $post_type,
     72                                        'type'              => 'string', // Can be empty, so must be string.
     73                                        'default'           => '',
     74                                        'single'            => true,
     75                                        'show_in_rest'      => true,
     76                                        'sanitize_callback' => array( $this, 'sanitize_limit' ),
     77                                        'auth_callback'     => array( $this, 'meta_auth_callback' ),
     78                                        'description'       => __(
    5979                                                'Number of revisions to retain.',
    6080                                                'wp-revisions-control'
    … …  
    6282                                )
    6383                        );
     84
     85                        if ( function_exists( 'register_rest_field' ) ) {
     86                                register_rest_field(
     87                                        $post_type,
     88                                        self::REST_FIELD,
     89                                        array(
     90                                                'get_callback'    => array( $this, 'rest_field_get' ),
     91                                                'update_callback' => array( $this, 'rest_field_update' ),
     92                                                'schema'          => array(
     93                                                        'description' => __(
     94                                                                'Number of revisions to retain.',
     95                                                                'wp-revisions-control'
     96                                                        ),
     97                                                        'type'        => 'string', // Can be empty, so must be string.
     98                                                        'context'     => array( 'edit' ),
     99                                                ),
     100                                        )
     101                                );
     102                        }
    64103                }
    65104
    … …  
    90129
    91130        /**
     131         * Whether this WordPress release supports the sidebar panel.
     132         *
     133         * The block editor shipped in 5.0, but the panel and the data hooks the
     134         * script relies on arrived in 5.3. Earlier releases use the classic
     135         * meta box instead.
     136         *
     137         * @return bool
     138         */
     139        public function supports_sidebar_panel() {
     140                return version_compare( get_bloginfo( 'version' ), self::MINIMUM_WP_VERSION, '>=' );
     141        }
     142
     143        /**
     144         * Sanitize a post's revisions limit.
     145         *
     146         * @param mixed $limit Unsanitized limit.
     147         * @return string Non-negative integer as a string, or an empty string for
     148         *                no post-specific limit.
     149         */
     150        public function sanitize_limit( $limit ) {
     151                if ( ! is_scalar( $limit ) ) {
     152                        return '';
     153                }
     154
     155                $limit = trim( (string) $limit );
     156
     157                if ( '' === $limit || ! ctype_digit( $limit ) ) {
     158                        return '';
     159                }
     160
     161                return (string) absint( $limit );
     162        }
     163
     164        /**
     165         * Limit who can change a post's revisions limit via its meta.
     166         *
     167         * @param bool   $allowed   Whether the user can change the meta.
     168         * @param string $meta_key  Meta key.
     169         * @param int    $object_id Post ID.
     170         * @param int    $user_id   User ID.
     171         * @return bool
     172         */
     173        public function meta_auth_callback( $allowed, $meta_key, $object_id, $user_id ) {
     174                return user_can( $user_id, 'edit_post', $object_id );
     175        }
     176
     177        /**
     178         * Provide a post's revisions limit to the REST API.
     179         *
     180         * @param array $post Prepared post data.
     181         * @return string
     182         */
     183        public function rest_field_get( $post ) {
     184                if ( ! is_array( $post ) || empty( $post['id'] ) ) {
     185                        return '';
     186                }
     187
     188                return $this->sanitize_limit(
     189                        get_post_meta( $post['id'], WP_REVISIONS_CONTROL_LIMIT_META_KEY, true )
     190                );
     191        }
     192
     193        /**
     194         * Update a post's revisions limit from the REST API.
     195         *
     196         * The posts controller confirms that the user can edit the post before
     197         * additional fields are updated.
     198         *
     199         * @param mixed   $value Submitted limit.
     200         * @param WP_Post $post  Post object.
     201         * @return bool
     202         */
     203        public function rest_field_update( $value, $post ) {
     204                if ( ! is_object( $post ) || empty( $post->ID ) ) {
     205                        return false;
     206                }
     207
     208                $limit = $this->sanitize_limit( $value );
     209
     210                if ( '' === $limit ) {
     211                        delete_post_meta( $post->ID, WP_REVISIONS_CONTROL_LIMIT_META_KEY );
     212                } else {
     213                        update_post_meta( $post->ID, WP_REVISIONS_CONTROL_LIMIT_META_KEY, $limit );
     214                }
     215
     216                return true;
     217        }
     218
     219        /**
    92220         * Permissions callback for REST endpoint.
    93221         *
    … …  
    156284                }
    157285
    158                 if ( ! post_type_supports( $typenow, 'revisions' ) ) {
     286                if ( ! $typenow || ! post_type_supports( $typenow, 'revisions' ) ) {
    159287                        return;
    160288                }
    161289
    162                 $handle     = 'wp-revisions-control-block-editor';
    163                 $asset_data = require_once dirname( __DIR__ ) . '/assets/build/gutenberg.asset.php';
     290                if ( ! $this->supports_sidebar_panel() ) {
     291                        return;
     292                }
     293
     294                $handle = 'wp-revisions-control-block-editor';
     295                // Not `require_once`, which returns `true` if this runs a second time.
     296                $asset_data = require dirname( __DIR__ ) . '/assets/build/gutenberg.asset.php';
    164297
    165298                wp_enqueue_script(
  • wp-revisions-control/trunk/inc/class-wp-revisions-control-bulk-actions.php

    r2737792 r3847088  
    8484                }
    8585
    86                 $post_type_caps = get_post_type_object( $screen->post_type )->cap;
    87                 $user_can       = (
    88                         current_user_can( $post_type_caps->edit_posts ) &&
    89                         current_user_can( $post_type_caps->edit_published_posts ) &&
    90                         current_user_can( $post_type_caps->edit_others_posts )
    91                 );
    92                 $user_can       = apply_filters(
     86                $post_type_object = get_post_type_object( $screen->post_type );
     87
     88                if ( null === $post_type_object ) {
     89                        return;
     90                }
     91
     92                // Some capabilities, such as `edit_published_posts`, only exist for
     93                // post types registered with `map_meta_cap`.
     94                $user_can = true;
     95
     96                foreach ( array( 'edit_posts', 'edit_published_posts', 'edit_others_posts' ) as $cap ) {
     97                        if ( isset( $post_type_object->cap->$cap ) && ! current_user_can( $post_type_object->cap->$cap ) ) {
     98                                $user_can = false;
     99                                break;
     100                        }
     101                }
     102
     103                $user_can = apply_filters(
    93104                        'wp_revisions_control_current_user_can_bulk_actions',
    94105                        $user_can,
  • wp-revisions-control/trunk/inc/class-wp-revisions-control.php

    r2737792 r3847088  
    183183                if ( is_array( $options ) ) {
    184184                        foreach ( $options as $post_type => $to_keep ) {
    185                                 $type_length = strlen( $to_keep );
     185                                // Malformed input, and a TypeError in PHP 8.
     186                                if ( is_array( $to_keep ) || is_object( $to_keep ) ) {
     187                                        continue;
     188                                }
     189
     190                                $type_length = strlen( (string) $to_keep );
    186191
    187192                                if ( 0 === $type_length ) {
    … …  
    266271                                function_exists( 'use_block_editor_for_post' )
    267272                                && use_block_editor_for_post( $post )
     273                                && Block_Editor::get_instance()->supports_sidebar_panel()
    268274                        )
    269275                        || count( wp_get_post_revisions( $post ) ) < 1
    … …  
    291297                // A bit of JS for us.
    292298                $handle     = 'wp-revisions-control-post';
    293                 $asset_data = require_once dirname( __DIR__ ) . '/assets/build/classic-editor.asset.php';
     299                $asset_data = require dirname( __DIR__ ) . '/assets/build/classic-editor.asset.php';
    294300                wp_enqueue_script(
    295301                        $handle,
    … …  
    424430                );
    425431
    426                 $to_keep = null !== $limit_override
    427                         ? $limit_override
    428                         : wp_revisions_to_keep( get_post( $post_id ) );
     432                if ( null !== $limit_override ) {
     433                        $to_keep = (int) $limit_override;
     434                } else {
     435                        $post = get_post( $post_id );
     436
     437                        // The post may be gone by the time a scheduled purge runs.
     438                        if ( ! $post ) {
     439                                return $response;
     440                        }
     441
     442                        $to_keep = (int) wp_revisions_to_keep( $post );
     443                }
    429444
    430445                if ( $to_keep < 0 ) {
  • wp-revisions-control/trunk/languages/wp-revisions-control.pot

    r3322043 r3847088  
    1 # Copyright (C) 2025 Erick Hitter
    2 # This file is distributed under the same license as the WP Revisions Control package.
     1# Copyright (C) 2026 Erick Hitter
     2# This file is distributed under the same license as the WP Revisions Control plugin.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: WP Revisions Control 1.4.4\n"
    6 "Report-Msgid-Bugs-To: "
    7 "https://wordpress.org/support/plugin/wp-revisions-control\n"
    8 "POT-Creation-Date: 2025-07-03 22:22:28+00:00\n"
    9 "MIME-Version: 1.0\n"
    10 "Content-Type: text/plain; charset=utf-8\n"
    11 "Content-Transfer-Encoding: 8bit\n"
    12 "PO-Revision-Date: 2025-MO-DA HO:MI+ZONE\n"
     5"Project-Id-Version: WP Revisions Control 1.4.5\n"
     6"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-revisions-control\n"
    137"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    148"Language-Team: LANGUAGE <LL@li.org>\n"
    15 "Language: en\n"
    16 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
    17 "X-Poedit-Country: United States\n"
    18 "X-Poedit-SourceCharset: UTF-8\n"
    19 "X-Poedit-KeywordsList: "
    20 "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
    21 "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
    22 "X-Poedit-Basepath: ../\n"
    23 "X-Poedit-SearchPath-0: .\n"
    24 "X-Poedit-Bookmarks: \n"
    25 "X-Textdomain-Support: yes\n"
    26 "X-Generator: grunt-wp-i18n 1.0.3\n"
     9"MIME-Version: 1.0\n"
     10"Content-Type: text/plain; charset=UTF-8\n"
     11"Content-Transfer-Encoding: 8bit\n"
     12"POT-Creation-Date: 2026-04-11T21:45:18+00:00\n"
     13"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     14"X-Generator: WP-CLI 2.12.0\n"
     15"X-Domain: wp-revisions-control\n"
     16
     17#. Plugin Name of the plugin
     18#: wp-revisions-control.php
     19#: assets/build/gutenberg.js:1
     20#: assets/src/gutenberg.js:28
     21msgid "WP Revisions Control"
     22msgstr ""
     23
     24#. Plugin URI of the plugin
     25#: wp-revisions-control.php
     26msgid "https://ethitter.com/plugins/wp-revisions-control/"
     27msgstr ""
     28
     29#. Description of the plugin
     30#: wp-revisions-control.php
     31msgid "Control how many revisions are stored for each post type"
     32msgstr ""
     33
     34#. Author of the plugin
     35#: wp-revisions-control.php
     36msgid "Erick Hitter"
     37msgstr ""
     38
     39#. Author URI of the plugin
     40#: wp-revisions-control.php
     41msgid "https://ethitter.com/"
     42msgstr ""
    2743
    2844#: inc/class-block-editor.php:58
    … …  
    3147
    3248#: inc/class-wp-revisions-control-bulk-actions.php:59
     49#: assets/build/gutenberg.js:2
     50#: assets/src/gutenberg.js:84
     51#: assets/src/gutenberg.js:89
    3352msgid "Purge excess revisions"
    3453msgstr ""
    … …  
    5170
    5271#: inc/class-wp-revisions-control.php:138
    53 msgid ""
    54 "Set the number of revisions to save for each post type listed. To retain "
    55 "all revisions for a given post type, leave the field empty."
     72msgid "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."
    5673msgstr ""
    5774
    … …  
    6077msgstr ""
    6178
     79#. translators: 1. Filter tag.
    6280#: inc/class-wp-revisions-control.php:150
    63 #. translators: 1. Filter tag.
    64 msgid ""
    65 "A local change is causing this plugin's functionality to run at a priority "
    66 "other than the default. If you experience difficulties with the plugin, "
    67 "please unhook any functions from the %1$s filter."
     81#, php-format
     82msgid "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."
    6883msgstr ""
    6984
    … …  
    96111msgstr ""
    97112
     113#. translators: 1. Text input field.
    98114#: inc/class-wp-revisions-control.php:340
    99 #. translators: 1. Text input field.
    100 msgid ""
    101 "Limit this post to %1$s revisions. Leave this field blank for default "
    102 "behavior."
     115#, php-format
     116msgid "Limit this post to %1$s revisions. Leave this field blank for default behavior."
    103117msgstr ""
    104118
    … …  
    115129msgstr ""
    116130
     131#. translators: 1. Number of removed revisions, already formatted for locale.
    117132#: inc/class-wp-revisions-control.php:401
    118 #. translators: 1. Number of removed revisions, already formatted for locale.
     133#, php-format
    119134msgid "Removed %1$s revisions associated with this post."
    120135msgstr ""
    … …  
    125140msgstr ""
    126141
    127 #. Plugin Name of the plugin/theme
    128 msgid "WP Revisions Control"
     142#: assets/build/gutenberg.js:1
     143#: assets/src/gutenberg.js:144
     144msgid "Excess revisions scheduled for removal."
    129145msgstr ""
    130146
    131 #. Plugin URI of the plugin/theme
    132 msgid "https://ethitter.com/plugins/wp-revisions-control/"
     147#: assets/build/gutenberg.js:1
     148#: assets/src/gutenberg.js:150
     149msgid "Failed to schedule excess revisions for removal."
    133150msgstr ""
    134151
    135 #. Description of the plugin/theme
    136 msgid "Control how many revisions are stored for each post type"
     152#: assets/build/gutenberg.js:1
     153#: assets/src/gutenberg.js:32
     154msgid "Number of revisions to retain:"
    137155msgstr ""
    138156
    139 #. Author of the plugin/theme
    140 msgid "Erick Hitter"
     157#: assets/build/gutenberg.js:1
     158#: assets/src/gutenberg.js:36
     159msgid "Leave blank to keep all revisions."
    141160msgstr ""
    142161
    143 #. Author URI of the plugin/theme
    144 msgid "https://ethitter.com/"
     162#: assets/build/gutenberg.js:1
     163#: assets/src/gutenberg.js:68
     164msgid "This will remove all revisions."
    145165msgstr ""
     166
     167#. translators: 1. Number of revisions to keep.
     168#: assets/build/gutenberg.js:2
     169#: assets/src/gutenberg.js:72
     170msgid "This will remove all but the most-recent revision."
     171msgid_plural "This will remove all but the %1$d most-recent revisions."
     172msgstr[0] ""
     173msgstr[1] ""
     174
     175#: assets/build/gutenberg.js:2
     176#: assets/src/gutenberg.js:98
     177msgid "Purge"
     178msgstr ""
     179
     180#: assets/build/gutenberg.js:2
     181#: assets/src/gutenberg.js:102
     182msgid "Cancel"
     183msgstr ""
  • wp-revisions-control/trunk/readme.txt

    r3322043 r3847088  
    44Tags: revision, revisions, admin
    55Requires at least: 3.6
    6 Tested up to: 6.8
    7 Stable tag: 1.4.4
     6Tested up to: 7.2
     7Stable tag: 1.5.0
    88Requires PHP: 5.6
    99License: GPLv2 or later
    … …  
    3636
    3737== Changelog ==
     38
     39= 1.5.0 =
     40* Update block-editor sidebar for current WordPress releases, removing its use of deprecated APIs.
     41* Fix block-editor error for post types that support revisions but not custom fields.
     42* Use the Classic Editor meta box in WordPress 5.0 through 5.2, which lack the APIs the sidebar requires.
     43* Fix PHP warning in bulk actions for post types registered without `map_meta_cap`.
     44* Report a failed purge request in the block editor.
     45* Harden handling of malformed settings and of posts deleted before a scheduled purge.
     46
     47= 1.4.5 =
     48* Update build process and rebuild plugin assets.
    3849
    3950= 1.4.4 =
    … …  
    6980== Upgrade Notice ==
    7081
     82= 1.5.0 =
     83
     84Updates the block-editor sidebar for current WordPress releases and fixes errors with some custom post types.
     85
     86= 1.4.5 =
     87
     88Updates build process and rebuild plugin assets.
     89
    7190= 1.4.4 =
    7291
  • wp-revisions-control/trunk/wp-revisions-control.php

    r3322043 r3847088  
    55 * Description: Control how many revisions are stored for each post type
    66 * Author: Erick Hitter
    7  * Version: 1.4.4
     7 * Version: 1.5.0
    88 * Author URI: https://ethitter.com/
    99 * Text Domain: wp-revisions-control
Note: See TracChangeset for help on using the changeset viewer.