Show or hide any block when conditions match. Developer-first API and true server-side rendering — hidden blocks never reach the browser.
RenderWhen for Blocks adds conditional visibility to every block in the WordPress block editor. v1.0 ships three built-in conditions — user state, date range, and device type — registered through a public API your plugin or theme can use to add your own.
For end-user docs and screenshots, see readme.txt. For the
full architecture and design decisions, see PLAN.md.
Two things set RenderWhen apart from existing options:
- Server-side rendering only. Hidden blocks return
''fromrender_blockand are never sent to the browser. No CSSdisplay: none, no DOM bloat, no leaked content in view-source. - The Conditions API is public, not internal. The three built-in conditions are registered through the same registry your code uses. The extension surface is how the plugin works.
If you need URL parameters, cookies, geolocation, ACF, WooCommerce, or membership integrations today, Conditional Blocks and Block Visibility cover that ground well.
Register a custom condition:
add_action( 'renderwhen_register_conditions', function ( $registry ) {
$registry->register( new My_Plugin\Conditions\Country_Condition() );
} );Implement RenderWhen\Conditions\Interface_Condition:
class Country_Condition implements Interface_Condition {
public function get_id(): string { return 'country'; }
public function get_label(): string { return __( 'Visitor country', 'my-plugin' ); }
public function get_schema(): array { /* JSON Schema */ }
public function evaluate( array $settings, array $context ): bool {
return in_array( my_detect_country(), $settings['countries'] ?? [], true );
}
}Filters: renderwhen_register_conditions,
renderwhen_evaluate_{condition_id}, renderwhen_render_block_hidden,
renderwhen_device_type. These are part of the public contract — semver
applies.
Requires Node 20+, PHP 7.4+, Composer 2.x, and Local.
git clone https://github.com/abhishekfdd/renderwhen.git
cd renderwhen
npm install
composer install
npm run buildSymlink into your Local site:
# macOS / Linux
ln -s "$(pwd)" "/path/to/Local Sites/<site>/app/public/wp-content/plugins/renderwhen"# Windows — run PowerShell as Administrator
New-Item -ItemType SymbolicLink `
-Path "C:\Users\you\Local Sites\<site>\app\public\wp-content\plugins\renderwhen" `
-Target "C:\path\to\renderwhen"Activate in wp-admin → Plugins. Right-click the site in Local →
Open site shell for a terminal with wp on PATH. Add to
app/public/wp-config.php for debugging:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'SCRIPT_DEBUG', true );npm run start # Watch mode
npm run build # Production build
npm run lint:js
npm run test:e2e # Playwright
composer run phpcs # WordPress-VIP-Go ruleset
composer run phpcbf # Auto-fixPHPUnit runs in CI on every push — see
.github/workflows/test.yml. The matrix
covers PHP 7.4 through 8.3.
WordPress-VIP-Go for PHP, @wordpress/eslint-plugin/recommended for JS.
Zero warnings on either before pushing. All user-facing strings
internationalized with text domain renderwhen. Output late-escaped at
the point of output.
Read PLAN.md first — several features are deliberately out
of scope for v1.0. For larger changes, open an issue before a PR.
GPL-2.0-or-later. See LICENSE.