Plugin Directory

Changeset 3375411


Ignore:
Timestamp:
10/09/2025 02:29:28 AM (6 months ago)
Author:
brainywpbd
Message:

Limit revision number added

Location:
minifly
Files:
291 added
4 edited

Legend:

Unmodified
Added
Removed
  • minifly/trunk/minifly.php

    r3372739 r3375411  
    55 * Plugin URI:        https://brainywp.com/minifly/
    66 * Description:       Minifly is your favorite, lightweight companion for better performance. Supercharge your site with tiny tools that make a big difference.
    7  * Version:           1.0.23
     7 * Version:           1.0.24
    88 * Requires at least: 5.2
    99 * Requires PHP:      7.2
  • minifly/trunk/readme.txt

    r3372739 r3375411  
    44Requires at least: 5.2
    55Tested up to: 6.8
    6 Stable tag: 1.0.23
     6Stable tag: 1.0.24
    77Requires PHP: 7.2
    88License: GPLv2 or later
     
    4747* **Add progress bar in full site** - You can add a site wide progress bar. It improve user experience and increase user's session in the website. You can also customize progress bar color and height with Minifly pro.
    4848* **Hide User Toolbar (Pro)** You can website toolbar to make your site more professional.
     49* **Limit Revision Number** - Keep necessary revision while making database clean is now possible with Minifly. Just toggle on and you will set 5 revisions for post and page. [Minifly pro](https://brainywp.com/minifly/) unlocked you custom post revisions.
    4950
    5051## WordPress white label solution features at Minifly
  • minifly/trunk/templates/admin/admin-settings.php

    r3372734 r3375411  
    4848            $disable_plugin_update = isset($_POST['sapmfly_disable_plugin_update']) ? 'yes' : 'no';
    4949            update_option('sapmfly_disable_plugin_update', $disable_plugin_update);
     50
     51
     52            $limit_revision_number = isset($_POST['sapmfly_limit_revision_number']) ? 'yes' : 'no';
     53            update_option('sapmfly_limit_revision_number', $limit_revision_number);
    5054
    5155            $global_toggle_value = isset($_POST['sapmfly_widgets_toggle']) ? 'yes' : 'no';
     
    6872    $disable_theme_update = get_option('sapmfly_disable_theme_update', 'no');
    6973    $disable_plugin_update = get_option('sapmfly_disable_plugin_update', 'no');
     74    $limit_revision_number = get_option('sapmfly_limit_revision_number', 'no');
    7075
    7176    // Save global save option
     
    199204                                ?>
    200205
     206                                <!-- Disable all plugin update -->
     207                                <?php
     208                                $sapmfly_limit_revision_number = SAPMFLY_TEMPLATES . 'admin/features/limited-revision-number.php';
     209                                if (file_exists($sapmfly_limit_revision_number)) {
     210                                    require_once $sapmfly_limit_revision_number;
     211                                }
     212                                ?>
     213
    201214                                <!-- Hidden Modal Popup -->
    202215                                <div id="minifly-premium-popup" class="minifly-pro-popup">
  • minifly/trunk/templates/admin/all-admin-hooks.php

    r3372734 r3375411  
    448448    return $transient;
    449449});
     450
     451// Limit revision number for post and page
     452add_action('admin_init', function() {
     453    $limit_revision_number = get_option('sapmfly_limit_revision_number', 'no');
     454   
     455    if ($limit_revision_number === 'yes') {
     456        $post_types = array('post', 'page');
     457
     458        foreach ($post_types as $post_type) {
     459            $posts = get_posts(array(
     460                'post_type'      => $post_type,
     461                'post_status'    => 'publish',
     462                'posts_per_page' => -1,
     463                'fields'         => 'ids'
     464            ));
     465
     466            foreach ($posts as $post_id) {
     467                $revisions = wp_get_post_revisions($post_id);
     468
     469                if (count($revisions) > 5) {
     470                    // Sort oldest first
     471                    usort($revisions, function ($a, $b) {
     472                        return strtotime($a->post_date) - strtotime($b->post_date);
     473                    });
     474
     475                    // Remove older ones
     476                    $revisions_to_delete = array_slice($revisions, 0, count($revisions) - 5);
     477                    foreach ($revisions_to_delete as $revision) {
     478                        wp_delete_post($revision->ID, true);
     479                    }
     480                }
     481            }
     482        }
     483    }
     484});
     485
Note: See TracChangeset for help on using the changeset viewer.