home
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Plugin Name: Disable Post Revision
|
||||
* Plugin URI: https://wordpress.org/plugins/disable-post-revision/
|
||||
* Description: Light weight plugin to disable post revisions for any post type to reduce database load. You can disable revisions by post type.
|
||||
* Version: 1.0.1
|
||||
* Author: Joel James
|
||||
* Author URI: https://thefoxe.com/
|
||||
* Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
|
||||
* License: GPL-2.0+
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
* Text Domain: disable-post-revision
|
||||
* Domain Path: /languages
|
||||
*
|
||||
* Disable Post Revision is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* Disable Post Revision is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Disable Post Revision. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @category Core
|
||||
* @package JJ4T3
|
||||
* @author Joel James <me@joelsays.com>
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
defined( 'ABSPATH' ) or exit;
|
||||
|
||||
if ( ! class_exists( 'Disable_Post_Revision' ) ) :
|
||||
|
||||
/**
|
||||
* The public-facing functionality of the plugin.
|
||||
*
|
||||
* This class contains the public side functionalities like,
|
||||
* logging, redirecting etc.
|
||||
*
|
||||
* @category Core
|
||||
* @package DPR
|
||||
* @subpackage Public
|
||||
* @author Joel James <me@joelsays.com>
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License
|
||||
* @link https://thefoxe.com/products/disable-post-revision
|
||||
*/
|
||||
class Disable_Post_Revision {
|
||||
|
||||
/**
|
||||
* Initialize the class and set its properties.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
add_action( 'admin_init', array( $this, 'disable_revisions' ) );
|
||||
add_action( 'admin_init', array( $this, 'options_page' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove post revision support for the selected types.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @uses get_option() To get the option value.
|
||||
* @uses remove_post_type_support() To remove the revision feature.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disable_revisions() {
|
||||
|
||||
$post_types = get_option( 'dpr_disabled_types', array() );
|
||||
|
||||
if ( !is_array( $post_types ) || empty( $post_types ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $post_types as $post_type ) {
|
||||
|
||||
remove_post_type_support( $post_type, 'revisions' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new options field to the writing settings page.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @uses register_setting() To register new setting.
|
||||
* @uses add_settings_field() To add new field to for the setting.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function options_page() {
|
||||
|
||||
register_setting( 'writing', 'dpr_disabled_types' );
|
||||
|
||||
// If options not found, set an empty array.
|
||||
if ( !get_option( 'dpr_disabled_types' ) ) {
|
||||
update_option( 'dpr_disabled_types', array() );
|
||||
}
|
||||
|
||||
add_settings_field(
|
||||
'dpr_label', '<label for="dpr">' . __( 'Disable Post Revisions', 'disable-post-revision' ) . '</label>', array( &$this, 'fields' ), 'writing'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new options field to the writing settings page.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @uses get_option() To get the option value.
|
||||
* @uses get_post_types() To get the available post types.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
// Get settings value.
|
||||
$value = get_option( 'dpr_disabled_types', '' );
|
||||
// Get available post types.
|
||||
$post_types = get_post_types( array(), 'objects' );
|
||||
|
||||
echo '<select id="dpr" name="dpr_disabled_types[]" multiple="multiple">';
|
||||
|
||||
foreach ( $post_types as $post_type => $post ) {
|
||||
echo '<option value="' . esc_attr( $post_type ) . '" ' . selected( true, in_array( $post_type, $value ), false ) . ' />' . esc_attr( $post->label ) . '</option>';
|
||||
}
|
||||
|
||||
echo '</select>';
|
||||
echo '<p class="description">' . __( 'To select multiple post types, hold ctrl key while selecting', 'disable-post-revision' ) . '</p>';
|
||||
echo '<p class="description"><strong>' . __( 'Note', '' ) . ':</strong> ' . __( 'Do not select a post type if you are not sure about it', 'disable-post-revision' ) . '</p>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Begins execution of the plugin.
|
||||
new Disable_Post_Revision();
|
||||
|
||||
endif;
|
||||
|
||||
// *** Thank you for your interest in Disable Post Revisions - Developed and managed by Joel James *** //
|
||||
@@ -0,0 +1,93 @@
|
||||
=== Disable Post Revision ===
|
||||
Contributors: joelcj91,duckdev
|
||||
Tags: post revision, disable revision, revisions, disable auto save, auto save, page revision
|
||||
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XUVWY8HUBUXY4
|
||||
Requires at least: 3.0
|
||||
Tested up to: 6.9
|
||||
Stable tag: 1.0.1
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Light weight plugin to disable post revisions for selected post types to reduce database and server load.
|
||||
|
||||
== Description ==
|
||||
|
||||
WordPress uses post revisions by default to save each post revision in your database. If you're concerned about server and database size, these post revisions can be a burden.
|
||||
|
||||
While you can't simply disable the post revision feature for a specific post type from the settings page, this plugin makes it easy to do so.
|
||||
|
||||
= What is Disable Post Revision? =
|
||||
|
||||
*Disabling unwanted post revisions in WordPress should be straightforward. This plugin makes it a simple process.*
|
||||
|
||||
> ### Disable Post Revision - Features
|
||||
>
|
||||
> - Disable post revisions for all available post types, including Posts and Pages<br />
|
||||
> - Reduce database load<br />
|
||||
> - Reduce server load while editing a post<br />
|
||||
> - Translation-ready<br />
|
||||
> - Extremely lightweight<br />
|
||||
> - Adheres to WordPress coding standards<br />
|
||||
> - Available on [GitHub](https://github.com/joel-james/disable-post-revision)<br />
|
||||
>
|
||||
> [Installation](https://wordpress.org/plugins/disable-post-revision/installation/) | [Support](http://wordpress.org/support/plugin/disable-post-revision/) | [Screenshots](https://wordpress.org/plugins/disable-post-revision/screenshots/)
|
||||
|
||||
|
||||
**WordPress Post Revision - [More Details](https://codex.wordpress.org/Revisions)**
|
||||
|
||||
If you're unsure about what post revisions are, please [refer to this page](https://codex.wordpress.org/Revisions) for more information.
|
||||
|
||||
|
||||
== Installation ==
|
||||
|
||||
|
||||
= Installing the plugin - Simple =
|
||||
1. In your WordPress admin panel, go to *Plugins > New Plugin*, search for **Disable Post Revision** and click "*Install now*"
|
||||
2. Alternatively, download the plugin and upload the contents of `disable-post-revision.zip` to your plugins directory, which usually is `/wp-content/plugins/`.
|
||||
3. Activate the plugin
|
||||
4. Go to Writing Setting tab under WordPress settings menu.
|
||||
5. Find the "Disable Post Revision" option and select the post types from the dropdown and save.
|
||||
|
||||
|
||||
= Need more help? =
|
||||
Please feel free to [open a support request](http://wordpress.org/support/plugin/disable-post-revision/).
|
||||
|
||||
= Missing something? =
|
||||
If you'd like to request an additional feature for this plugin, please [let me know](https://duckdev.com/contact/).
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= What is the use of Disable Post Revision? =
|
||||
|
||||
This simple plugin helps reduce your database load by disabling unnecessary post revision data.
|
||||
|
||||
= What is a post revision? =
|
||||
|
||||
Ok, here is the [link](https://codex.wordpress.org/Revisions).
|
||||
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. **Settings** - Select post types to disable post revisions. You can select multiple types.
|
||||
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.0.1 (15/09/2016) =
|
||||
|
||||
- Compatibility with WordPress 4.6.
|
||||
- PHP Coding standard fixes.
|
||||
- Fixed wrong stable version number.
|
||||
|
||||
= 1.0.0 (20/05/2016) =
|
||||
|
||||
- Initial version release.
|
||||
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 1.0.1 (15/09/2016) =
|
||||
|
||||
- Compatibility with WordPress 4.6.
|
||||
- PHP Coding standard fixes.
|
||||
- Fixed wrong stable version number.
|
||||
Reference in New Issue
Block a user