Plugin Directory

Changeset 2989822


Ignore:
Timestamp:
11/06/2023 11:41:11 AM (2 years ago)
Author:
fpuenteonline
Message:

2.2 - 2023-11-06

Added Memcached server flush functionality. You can now easily flush your Memcached server's cache directly from the plugin. Click the "Flush cache" link in the plugin description to clear the cache.
Added WordPress 6.4 compatibility. The plugin has been updated to ensure seamless compatibility with the latest version of WordPress, version 6.4.

Location:
object-cache-4-everyone/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • object-cache-4-everyone/trunk/object-cache-4-everyone.php

    r2977365 r2989822  
    66 * Plugin URI: https://wordpress.org/plugins/object-cache-4-everyone
    77 * Author: fpuenteonline
    8  * Version: 2.1.2
     8 * Version: 2.2
    99 * Author URI: https://twitter.com/fpuenteonline
    1010 * License:     GPLv2 or later
     
    272272            error_log('Object Cache 4 everyone::Memcached Server running');
    273273        }
    274         $links_array[count($links_array) - 1] = $links_array[count($links_array) - 1] .
     274        $nonce = wp_create_nonce('flush_memcached_nonce');
     275
     276        $links_array[] = '<a href="' . esc_url(admin_url('admin-post.php?action=oc4flush_memcached&nonce=' . $nonce)) . '"><strong>' . esc_html__('Flush cache') . '</strong></a>' .
    275277            '<br/><br/>' .
    276278            esc_html__('Memcached Server running:') . ' <strong><code style="background-color: inherit;">' . OC4EVERYONE_PREDEFINED_SERVER . '</code></strong>' . '<br/>' .
    277279            esc_html__('Cache Hit Ratio') . ' <strong><code style="background-color: inherit;">' . $found . '%</code></strong>' . '<br/>' .
    278280            esc_html__('Uptime:')  . ' <strong><code style="background-color: inherit;">' . secondsToHumanReadable($wp_object_cache->getStats()[OC4EVERYONE_PREDEFINED_SERVER]['uptime']) . '</strong></code>' . '<br/>' .
    279             esc_html__('Unique Items / Total Items:') . ' <strong><code style="background-color: inherit;">' . $wp_object_cache->getStats()[OC4EVERYONE_PREDEFINED_SERVER]['curr_items'] . ' / ' . $wp_object_cache->getStats()[OC4EVERYONE_PREDEFINED_SERVER]['total_items'] . '</strong></code>';
     281            esc_html__('Current Unique Items / Total Items:') . ' <strong><code style="background-color: inherit;">' . $wp_object_cache->getStats()[OC4EVERYONE_PREDEFINED_SERVER]['curr_items'] . ' / ' . $wp_object_cache->getStats()[OC4EVERYONE_PREDEFINED_SERVER]['total_items'] . '</strong></code>' . '<br/>';
    280282    }
    281283
     
    283285}
    284286add_filter('plugin_row_meta', 'oc4everyone_add_server_info', PHP_INT_MAX, 4);
     287
     288
     289add_action('admin_post_oc4flush_memcached', 'oc4flush_memcached');
     290function oc4flush_memcached() {
     291    if (!class_exists('Memcached')) {
     292        wp_die(esc_html__('Failed to flush Memcached server'));
     293    }
     294    // Verify the nonce
     295    if (isset($_GET['nonce']) && wp_verify_nonce($_GET['nonce'], 'flush_memcached_nonce')) {
     296        //flush cache
     297        global $wp_object_cache;
     298        error_log(print_r($wp_object_cache->getStats()[OC4EVERYONE_PREDEFINED_SERVER],true));       
     299        $wp_object_cache->flush();
     300
     301        $memcached = new Memcached();
     302        list($node, $port) = explode(':', OC4EVERYONE_PREDEFINED_SERVER);
     303        $memcached->addServer($node, $port, PHP_INT_MAX);
     304
     305        if ($memcached->flush(0)) {
     306            if (defined('WP_DEBUG') && WP_DEBUG) {
     307                error_log('Object Cache 4 everyone::Memcached server flushed.');
     308            }
     309            wp_redirect(admin_url('plugins.php'));
     310            exit;
     311        } else {
     312            wp_die(esc_html__('Failed to flush Memcached server'));
     313        }
     314    } else {
     315        wp_die(esc_html__('Nonce verification failed. Access denied.'));
     316    }
     317}
    285318
    286319
  • object-cache-4-everyone/trunk/readme.txt

    r2977365 r2989822  
    33Tags: Memcached, cache, object cache, WPO
    44Requires at least: 5.0
    5 Tested up to: 6.3
    6 Stable tag: 2.1.2
     5Tested up to: 6.5
     6Stable tag: 2.2
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    4444
    4545== Changelog ==
     46= 2.2 - 2023-11-06 =
     47Added Memcached server flush functionality. You can now easily flush your Memcached server's cache directly from the plugin. Click the "Flush cache" link in the plugin description to clear the cache.
     48Added WordPress 6.4 compatibility. The plugin has been updated to ensure seamless compatibility with the latest version of WordPress, version 6.4.
     49
    4650= 2.1 - 2023-09-19 =
    4751Added functionality to enable the plugin in additional staging or development environments on the same server.
Note: See TracChangeset for help on using the changeset viewer.