post_type == 'profile_article') { clear_template_cache('template-parts/home/list-items'); clear_template_cache('template-parts/home/main-item'); clear_template_cache('template-parts/home/colon-item'); } elseif ($post->post_type == 'anew' || $post->post_type == 'yellow') { clear_template_cache('template-parts/home/news'); } // Сброс главной $main_item = get_post_meta($post_id, 'main_item', true); if ($main_item === 'true' || $main_item === '1') { clear_template_cache('template-parts/home/main-item'); } // Сброс колонки $colon_item = get_post_meta($post_id, 'colon_item', true); if ($colon_item === 'true' || $colon_item === '1') { clear_template_cache('template-parts/home/colon-item'); } // Обновляем сигнальный файл $fpc_signal = WP_CONTENT_DIR . '/uploads/fpcache/.last_modified'; touch($fpc_signal); } // Хук для обычного сохранения add_action('save_post', function($post_id, $post, $update) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; if (wp_is_post_revision($post_id)) return; if (!current_user_can('edit_post', $post_id)) return; if ($post->post_status !== 'publish') return; clear_post_cache_based_on_conditions($post_id, $post); // Передаем только $post }, 10, 3); // Хук для запланированных публикаций add_action('transition_post_status', function($new_status, $old_status, $post) { if ($new_status !== 'publish') return; if (!current_user_can('edit_post', $post->ID)) return; // Используем $post->ID clear_post_cache_based_on_conditions($post->ID, $post); // Передаем только $post }, 10, 3);