feat: flush-cache button auto-installs memcached drop-in

- Button copies wp-content/plugins/memcached/object-cache.php
  to wp-content/object-cache.php if not present
- Reports status: installed, failed, or plugin missing
- Updated page description
This commit is contained in:
Dekart Deploy Bot 2026-07-17 20:49:51 +00:00
parent 6a7064209b
commit 60a0847501

View File

@ -2323,7 +2323,8 @@ function dekart_flush_cache_page() {
?>
<div class="wrap">
<h1>🗄️ Сброс кеша</h1>
<p class="desc" style="margin:16px 0;color:#646970;font-size:13px">Полная очистка объектного кеша (Memcached/Redis), инвалидация versioned cache ключей, сброс транзиентов.</p>
<p class="desc" style="margin:16px 0;color:#646970;font-size:13px">Полная очистка объектного кеша (Memcached/Redis), инвалидация versioned cache ключей, сброс транзиентов.<br><br>
Если drop-in Memcached ещё не установлен кнопка автоматически скопирует его из плагина. Активировать плагин Memcached не нужно.</p>
<button type="button" id="dekart-flush-cache-btn" class="button button-hero button-secondary" style="display:inline-flex;align-items:center;gap:8px">
<span class="dashicons dashicons-update" style="font-size:20px;width:20px;height:20px"></span> Сбросить кэш сейчас
</button>
@ -2437,6 +2438,21 @@ function dekart_ajax_flush_cache() {
$messages = array();
// 0. Установка Memcached drop-in (если ещё не скопирован)
$source = WP_CONTENT_DIR . '/plugins/memcached/object-cache.php';
$target = WP_CONTENT_DIR . '/object-cache.php';
if ( ! file_exists( $target ) ) {
if ( file_exists( $source ) ) {
if ( copy( $source, $target ) ) {
$messages[] = 'drop-in installed';
} else {
$messages[] = '⚠ drop-in copy failed (permissions?)';
}
} else {
$messages[] = '⚠ plugin memcached not found';
}
}
// 1. Versioned cache bump (MU-плагин)
if ( function_exists( 'my_cache_bump_version' ) ) {
my_cache_bump_version();