xwp/block-visibility-edge-cache 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xwp/block-visibility-edge-cache

Composer 安装命令:

composer require xwp/block-visibility-edge-cache

包简介

Handles edge cache invalidation for blocks with time-based visibility settings.

README 文档

README

Test

A WordPress plugin that integrates the Block Visibility plugin with WordPress.com VIP edge caching. It ensures that edge caches are automatically purged at the exact moment a block's visibility is scheduled to change.

How it Works

When using edge caching, page content is cached at the "edge" (servers closer to the user). Traditional "Date/Time" visibility rules in the Block Visibility plugin usually rely on PHP executing during the page load to decide whether to show or hide a block. With edge caching, PHP might not run for every request, leading to stale content being served even after a visibility transition should have occurred.

This plugin solves this by:

  1. Parsing the blocks in a post when it is saved or published.
  2. Calculating all future "transition" timestamps (when a block should appear or disappear) based on the Date/Time settings.
  3. Scheduling background tasks using Action Scheduler to purge the post's edge cache at those specific timestamps.

Requirements

Installation

Via Composer (Recommended)

composer require xwp/block-visibility-edge-cache

Manual

  1. Upload the plugin folder to the /wp-content/plugins/ directory.
  2. Activate the plugin through the 'Plugins' menu in WordPress.
  3. Ensure the Block Visibility plugin is also active.

Supported Visibility Controls

To maintain compatibility with edge caching, only time-based visibility controls are supported:

  • Date Range: Specific start and end dates/times.
  • Seasonal: Recurring date ranges every year.
  • Day of Week: Showing/hiding blocks on specific days.
  • Time of Day: Showing/hiding blocks during specific hours.

Disabled Controls

The following controls are automatically disabled because they depend on dynamic request data (visitor-specific) which is incompatible with static edge caching:

  • Browser / Device
  • Cookie
  • Location
  • Role / User
  • Screen Size
  • URL Path / Query String
  • Referral Source
  • WooCommerce / EDD / WP Fusion integration
  • ACF fields

Developer Hooks

xwp_block_visibility_edge_cache_purged

Triggered after a post's edge cache has been purged. Useful for adding custom purging logic for other cache layers.

add_action( 'xwp_block_visibility_edge_cache_purged', function( $post_id ) {
    // Custom purging logic here.
} );

Local Development & Testing

Installation

composer install
pnpm install

Running Tests

The project includes a comprehensive test suite using PHPUnit via wp-env.

# Start the WordPress environment
pnpm wp-env start

# Run PHPUnit tests
pnpm test:php

# Run PHP Code Sniffer
composer lint

# Run PHPStan
composer phpstan

License

GPLv2 or later.

xwp/block-visibility-edge-cache 适用场景与选型建议

xwp/block-visibility-edge-cache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 02 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 xwp/block-visibility-edge-cache 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 xwp/block-visibility-edge-cache 我们能提供哪些服务?
定制开发 / 二次开发

基于 xwp/block-visibility-edge-cache 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 28
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-02-10