Skip to content
Snippets Groups Projects
Commit 116d65f8 authored by Erick Hitter's avatar Erick Hitter
Browse files

Fix private meta

parent f97c02b3
No related branches found
No related tags found
Loading
......@@ -114,34 +114,13 @@ class WP_Revisions_Control {
* Register actions and filters.
*/
public function action_init() {
add_action( 'rest_api_init', array( $this, 'action_rest_api_init' ) );
add_action( 'admin_init', array( $this, 'action_admin_init' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'action_enqueue_block_editor_assets' ) );
add_filter( 'wp_revisions_to_keep', array( $this, 'filter_wp_revisions_to_keep' ), $this->plugin_priority(), 2 );
}
/**
* Register meta for Gutenberg UI.
*/
public function action_rest_api_init() {
foreach ( array_keys( $this->get_post_types() ) as $post_type ) {
register_meta(
'post',
$this->meta_key_limit,
array(
'object_subtype' => $post_type,
'type' => 'integer',
'default' => -1,
'single' => true,
'show_in_rest' => true,
'description' => __(
'Number of revisions to retain.',
'wp_revisions_control'
),
)
);
}
add_action( 'rest_api_init', array( $this, 'action_rest_api_init' ) );
add_filter( 'is_protected_meta', array( $this, 'filter_is_protected_meta' ), 10, 2 );
add_action( 'enqueue_block_editor_assets', array( $this, 'action_enqueue_block_editor_assets' ) );
}
/**
......@@ -170,28 +149,6 @@ class WP_Revisions_Control {
WP_Revisions_Control_Bulk_Actions::get_instance( $post_types );
}
/**
* Register Gutenberg script.
*/
public function action_enqueue_block_editor_assets() {
wp_enqueue_script(
$this->settings_section,
plugins_url(
'dist/js/gutenberg.js',
__DIR__
),
array(
'wp-components',
'wp-compose',
'wp-data',
'wp-edit-post',
'wp-i18n',
'wp-plugins',
),
2021032701
);
}
/**
* PLUGIN SETTINGS SECTION
* FOUND UNDER SETTINGS > WRITING
......@@ -560,6 +517,70 @@ class WP_Revisions_Control {
<?php
}
/**
* GUTENBERG SUPPORT.
*/
/**
* Register meta for Gutenberg UI.
*/
public function action_rest_api_init() {
foreach ( array_keys( $this->get_post_types() ) as $post_type ) {
register_meta(
'post',
$this->meta_key_limit,
array(
'object_subtype' => $post_type,
'type' => 'string', // Can be empty, so must be string.
'default' => '',
'single' => true,
'show_in_rest' => true,
'description' => __(
'Number of revisions to retain.',
'wp_revisions_control'
),
)
);
}
}
/**
* Allow our meta to be edited from Gutenberg.
*
* @param bool $protected If meta is protected.
* @param string $meta_key Meta key being checked.
* @return false
*/
public function filter_is_protected_meta( $protected, $meta_key ) {
if ( $meta_key === $this->meta_key_limit ) {
return false;
}
return $protected;
}
/**
* Register Gutenberg script.
*/
public function action_enqueue_block_editor_assets() {
wp_enqueue_script(
$this->settings_section,
plugins_url(
'dist/js/gutenberg.js',
__DIR__
),
array(
'wp-components',
'wp-compose',
'wp-data',
'wp-edit-post',
'wp-i18n',
'wp-plugins',
),
2021032701
);
}
/**
* PLUGIN UTILITIES.
*/
......
......@@ -5,7 +5,7 @@ msgstr ""
"Project-Id-Version: WP Revisions Control 1.3\n"
"Report-Msgid-Bugs-To: "
"https://wordpress.org/support/plugin/wp-revisions-control\n"
"POT-Creation-Date: 2021-03-28 02:03:56+00:00\n"
"POT-Creation-Date: 2021-03-28 02:34:59+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
......@@ -45,21 +45,17 @@ msgstr ""
msgid "WP Revisions Control encountered an unspecified error."
msgstr ""
#: inc/class-wp-revisions-control.php:138
msgid "Number of revisions to retain."
msgstr ""
#: inc/class-wp-revisions-control.php:205
#: inc/class-wp-revisions-control.php:162
msgid ""
"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."
msgstr ""
#: inc/class-wp-revisions-control.php:206
#: inc/class-wp-revisions-control.php:163
msgid "If a post type isn't listed, revisions are not enabled for that post type."
msgstr ""
#: inc/class-wp-revisions-control.php:217
#: inc/class-wp-revisions-control.php:174
#. translators: 1. Filter tag.
msgid ""
"A local change is causing this plugin's functionality to run at a priority "
......@@ -67,63 +63,67 @@ msgid ""
"please unhook any functions from the %1$s filter."
msgstr ""
#: inc/class-wp-revisions-control.php:342
#: inc/class-wp-revisions-control.php:299
msgid "Revisions"
msgstr ""
#: inc/class-wp-revisions-control.php:375
#: inc/class-wp-revisions-control.php:332
msgid "Processing&hellip;"
msgstr ""
#: inc/class-wp-revisions-control.php:376
#: inc/class-wp-revisions-control.php:333
msgid "Are you sure you want to remove revisions from this post?"
msgstr ""
#: inc/class-wp-revisions-control.php:377
#: inc/class-wp-revisions-control.php:334
msgid "Autosave"
msgstr ""
#: inc/class-wp-revisions-control.php:378
#: inc/class-wp-revisions-control.php:335
msgid "There are no revisions to remove."
msgstr ""
#: inc/class-wp-revisions-control.php:379
#: inc/class-wp-revisions-control.php:336
msgid "An error occurred. Please refresh the page and try again."
msgstr ""
#: inc/class-wp-revisions-control.php:399
#: inc/class-wp-revisions-control.php:356
msgid "Purge these revisions"
msgstr ""
#: inc/class-wp-revisions-control.php:405
#: inc/class-wp-revisions-control.php:362
#. translators: 1. Text input field.
msgid ""
"Limit this post to %1$s revisions. Leave this field blank for default "
"behavior."
msgstr ""
#: inc/class-wp-revisions-control.php:430
#: inc/class-wp-revisions-control.php:387
msgid "No post ID was provided. Please refresh the page and try again."
msgstr ""
#: inc/class-wp-revisions-control.php:432
#: inc/class-wp-revisions-control.php:389
msgid "Invalid request. Please refresh the page and try again."
msgstr ""
#: inc/class-wp-revisions-control.php:434
#: inc/class-wp-revisions-control.php:391
msgid "You are not allowed to edit this post."
msgstr ""
#: inc/class-wp-revisions-control.php:466
#: inc/class-wp-revisions-control.php:423
#. translators: 1. Number of removed revisions, already formatted for locale.
msgid "Removed %1$s revisions associated with this post."
msgstr ""
#: inc/class-wp-revisions-control.php:492
#: inc/class-wp-revisions-control.php:504
#: inc/class-wp-revisions-control.php:449
#: inc/class-wp-revisions-control.php:461
msgid "No revisions to remove."
msgstr ""
#: inc/class-wp-revisions-control.php:538
msgid "Number of revisions to retain."
msgstr ""
#. Plugin Name of the plugin/theme
msgid "WP Revisions Control"
msgstr ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment