{"id":312163,"date":"2026-05-17T09:08:21","date_gmt":"2026-05-17T09:08:21","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/block-when\/"},"modified":"2026-05-17T09:08:03","modified_gmt":"2026-05-17T09:08:03","slug":"renderwhen","status":"publish","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/renderwhen\/","author":10038395,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0.0","stable_tag":"1.0.0","tested":"6.9.4","requires":"6.5","requires_php":"7.4","requires_plugins":null,"header_name":"RenderWhen for Blocks","header_author":"Abhishek","header_description":"Show or hide any block when conditions match. Three built-in conditions, an extensible developer API, and true server-side rendering \u2014 hidden blocks are never sent to the browser.","assets_banners_color":"d9e9f3","last_updated":"2026-05-17 09:08:03","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/github.com\/abhishekfdd\/renderwhen","header_author_uri":"https:\/\/confusedblogger.com","rating":0,"author_block_rating":0,"active_installs":0,"downloads":21,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.0.0":{"tag":"1.0.0","author":"abhishekfdd","date":"2026-05-17 09:08:03"}},"upgrade_notice":{"1.0.0":"<p>Initial release.<\/p>"},"ratings":[],"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":3534394,"resolution":"128x128","location":"assets","locale":"","width":128,"height":128},"icon-256x256.png":{"filename":"icon-256x256.png","revision":3534394,"resolution":"256x256","location":"assets","locale":"","width":256,"height":256}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":3534394,"resolution":"1544x500","location":"assets","locale":"","width":1544,"height":500},"banner-772x250.png":{"filename":"banner-772x250.png","revision":3534394,"resolution":"772x250","location":"assets","locale":"","width":772,"height":250}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":3534394,"resolution":"1","location":"assets","locale":"","width":2874,"height":1312},"screenshot-2.png":{"filename":"screenshot-2.png","revision":3534394,"resolution":"2","location":"assets","locale":"","width":2888,"height":1416},"screenshot-3.png":{"filename":"screenshot-3.png","revision":3534394,"resolution":"3","location":"assets","locale":"","width":2868,"height":1736},"screenshot-4.png":{"filename":"screenshot-4.png","revision":3534394,"resolution":"4","location":"assets","locale":"","width":2878,"height":1620},"screenshot-5.png":{"filename":"screenshot-5.png","revision":3534394,"resolution":"5","location":"assets","locale":"","width":2872,"height":1492}},"screenshots":{"1":"The Visibility panel in the block inspector","2":"User State condition with role selector","3":"Date Range condition with start\/end pickers","4":"Device type condition with three checkboxes","5":"Editor indicator showing dashed border on rule-bearing blocks","6":"Preview-as sidebar with audience controls"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[148857,4121,4060,148076,6309],"plugin_category":[],"plugin_contributors":[88103],"plugin_business_model":[],"class_list":["post-312163","plugin","type-plugin","status-publish","hentry","plugin_tags-block-editor","plugin_tags-blocks","plugin_tags-conditional","plugin_tags-gutenberg","plugin_tags-visibility","plugin_contributors-abhishekfdd","plugin_committers-abhishekfdd"],"banners":{"banner":"https:\/\/ps.w.org\/renderwhen\/assets\/banner-772x250.png?rev=3534394","banner_2x":"https:\/\/ps.w.org\/renderwhen\/assets\/banner-1544x500.png?rev=3534394","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/renderwhen\/assets\/icon-128x128.png?rev=3534394","icon_2x":"https:\/\/ps.w.org\/renderwhen\/assets\/icon-256x256.png?rev=3534394","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/renderwhen\/assets\/screenshot-1.png?rev=3534394","caption":"The Visibility panel in the block inspector"},{"src":"https:\/\/ps.w.org\/renderwhen\/assets\/screenshot-2.png?rev=3534394","caption":"User State condition with role selector"},{"src":"https:\/\/ps.w.org\/renderwhen\/assets\/screenshot-3.png?rev=3534394","caption":"Date Range condition with start\/end pickers"},{"src":"https:\/\/ps.w.org\/renderwhen\/assets\/screenshot-4.png?rev=3534394","caption":"Device type condition with three checkboxes"},{"src":"https:\/\/ps.w.org\/renderwhen\/assets\/screenshot-5.png?rev=3534394","caption":"Editor indicator showing dashed border on rule-bearing blocks"}],"raw_content":"<!--section=description-->\n<p>RenderWhen for Blocks adds conditional visibility to every block in the WordPress block editor. Decide who sees what, and when, with a panel that reads exactly how you'd say it out loud:<\/p>\n\n<blockquote>\n  <p><em>Show this block when the user is logged in.<\/em>\n  <em>Show this block when the date is between March 1 and March 31.<\/em>\n  <em>Show this block when the device is mobile.<\/em><\/p>\n<\/blockquote>\n\n<p>RenderWhen is built around two ideas that set it apart from other visibility plugins:<\/p>\n\n<ul>\n<li><strong>Server-side rendering only.<\/strong> When a block is hidden by a condition, it is not rendered into the page output at all. No CSS <code>display: none<\/code>, no DOM bloat, no leaked content in view-source. Search engines, screen readers, and your page weight all benefit.<\/li>\n<li><strong>Public Conditions API.<\/strong> The three built-in conditions are registered through the same public API your plugin or theme can use to add your own. No hacks, no internal-only code paths.<\/li>\n<\/ul>\n\n<p>In the editor, a subtle dashed border marks every block that carries a visibility rule, so a rule-bearing block never disappears from the published page as a surprise. A \"Preview as audience\" sidebar lets you simulate a logged-out visitor, a specific role, or a different device class right in the editor \u2014 blocks whose rule would hide them fade out with a clear badge, no save-and-reload cycle required.<\/p>\n\n<h4>Built-in conditions (v1.0)<\/h4>\n\n<ul>\n<li><strong>User state<\/strong> \u2014 show to logged-in users, logged-out users, or specific roles<\/li>\n<li><strong>Date range<\/strong> \u2014 show between two datetimes, timezone-aware<\/li>\n<li><strong>Device type<\/strong> \u2014 show on desktop, tablet, or mobile<\/li>\n<\/ul>\n\n<h4>Designed for<\/h4>\n\n<ul>\n<li>Agencies and freelancers building client sites who want a clean, predictable visibility tool<\/li>\n<li>Developers who need an extension point, not another walled garden<\/li>\n<li>Anyone who cares about page weight and SEO hygiene<\/li>\n<\/ul>\n\n<h4>What this plugin deliberately does NOT do<\/h4>\n\n<p>It does one thing well rather than ten things adequately. Out of scope in v1.0:<\/p>\n\n<ul>\n<li>Multi-condition AND\/OR groups (planned for v1.1)<\/li>\n<li>URL \/ cookie \/ referrer \/ geolocation conditions<\/li>\n<li>WooCommerce, ACF, or membership integrations<\/li>\n<li>A settings dashboard<\/li>\n<\/ul>\n\n<p>If you need those today, <a href=\"https:\/\/wordpress.org\/plugins\/conditional-blocks\/\">Conditional Blocks<\/a> and <a href=\"https:\/\/wordpress.org\/plugins\/block-visibility\/\">Block Visibility<\/a> are excellent and well-established choices.<\/p>\n\n<h4>For developers<\/h4>\n\n<p>Register a custom condition in three steps. Implement the interface, add it to the registry, ship.<\/p>\n\n<pre><code>add_action( 'renderwhen_register_conditions', function ( $registry ) {\n    $registry-&gt;register( new My_Plugin\\\\Conditions\\\\Country_Condition() );\n} );\n<\/code><\/pre>\n\n<p>Your condition class implements <code>RenderWhen\\Conditions\\Interface_Condition<\/code>:<\/p>\n\n<pre><code>namespace My_Plugin\\Conditions;\n\nuse RenderWhen\\Conditions\\Interface_Condition;\n\nclass Country_Condition implements Interface_Condition {\n    public function get_id(): string {\n        return 'country';\n    }\n\n    public function get_label(): string {\n        return __( 'Visitor country', 'my-plugin' );\n    }\n\n    public function get_schema(): array {\n        return array(\n            'type'       =&gt; 'object',\n            'properties' =&gt; array(\n                'countries' =&gt; array(\n                    'type'  =&gt; 'array',\n                    'items' =&gt; array( 'type' =&gt; 'string' ),\n                ),\n            ),\n        );\n    }\n\n    public function evaluate( array $settings, array $context ): bool {\n        $current = my_plugin_detect_country();\n        return in_array( $current, $settings['countries'] ?? array(), true );\n    }\n}\n<\/code><\/pre>\n\n<p>The full set of public filters:<\/p>\n\n<ul>\n<li><code>renderwhen_register_conditions<\/code> \u2014 register your conditions here<\/li>\n<li><code>renderwhen_evaluate_{condition_id}<\/code> \u2014 last-mile override of any condition's result<\/li>\n<li><code>renderwhen_render_block_hidden<\/code> \u2014 fires when a block is hidden, useful for cache busters and SEO tools<\/li>\n<li><code>renderwhen_device_type<\/code> \u2014 swap in your own device detection<\/li>\n<\/ul>\n\n<p>The plugin is developed openly on GitHub. Issues, PRs, and architecture discussions welcome: https:\/\/github.com\/abhishekfdd\/renderwhen<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload the <code>renderwhen<\/code> folder to <code>\/wp-content\/plugins\/<\/code>, or install through the <strong>Plugins \u2192 Add New<\/strong> screen<\/li>\n<li>Activate the plugin<\/li>\n<li>Edit any post or page, select a block, and find the <strong>Visibility<\/strong> panel in the block inspector<\/li>\n<\/ol>\n\n<p>There is no settings page. By design.<\/p>\n\n<!--section=faq-->\n<dl>\n<dt id=\"does%20this%20work%20with%20the%20site%20editor%3F\"><h3>Does this work with the Site Editor?<\/h3><\/dt>\n<dd><p>Yes. Conditions apply to blocks anywhere they render \u2014 posts, pages, template parts, navigation menus, and patterns.<\/p><\/dd>\n<dt id=\"does%20this%20work%20with%20third-party%20blocks%3F\"><h3>Does this work with third-party blocks?<\/h3><\/dt>\n<dd><p>Yes. The visibility attribute is registered on every registered block, including blocks from other plugins (ACF Blocks, GenerateBlocks, Stackable, etc.).<\/p><\/dd>\n<dt id=\"will%20hidden%20blocks%20affect%20seo%3F\"><h3>Will hidden blocks affect SEO?<\/h3><\/dt>\n<dd><p>Hidden blocks are never rendered into the page HTML. Search engines see what your visitors see \u2014 not the hidden content. This is the opposite of CSS-based hiding, where the content is still in the DOM.<\/p><\/dd>\n<dt id=\"can%20i%20combine%20multiple%20conditions%20on%20one%20block%3F\"><h3>Can I combine multiple conditions on one block?<\/h3><\/dt>\n<dd><p>Not in v1.0 \u2014 one rule per block. AND\/OR condition groups are planned for v1.1.<\/p><\/dd>\n<dt id=\"what%20does%20the%20dashed%20border%20on%20some%20blocks%20mean%3F\"><h3>What does the dashed border on some blocks mean?<\/h3><\/dt>\n<dd><p>The dashed left border indicates a block has a visibility rule attached. It's editor-only \u2014 visitors never see it. The cue helps prevent confusion when blocks disappear from the published version.<\/p><\/dd>\n<dt id=\"why%20do%20role-restricted%20blocks%20appear%20hidden%20when%20i%20preview%20as%20%22any%20role%22%3F\"><h3>Why do role-restricted blocks appear hidden when I preview as \"Any role\"?<\/h3><\/dt>\n<dd><p>The preview can't know which roles an arbitrary visitor would have. When you preview as \"Any role,\" role-restricted blocks appear hidden because the safest assumption is that an unknown visitor doesn't have the required role. To verify a role-restricted block actually shows for that role, pick the specific role from the preview dropdown.<\/p><\/dd>\n<dt id=\"how%20does%20this%20compare%20to%20block%20visibility%20or%20conditional%20blocks%3F\"><h3>How does this compare to Block Visibility or Conditional Blocks?<\/h3><\/dt>\n<dd><p>Both are excellent, mature plugins with broader feature sets. RenderWhen is intentionally smaller in surface area, server-side-only in rendering, and built around a public extension API. If you need ACF\/WooCommerce\/cookie conditions today, use one of those. If you want a small, fast, extensible foundation, this is for you.<\/p><\/dd>\n<dt id=\"how%20does%20device%20detection%20work%3F\"><h3>How does device detection work?<\/h3><\/dt>\n<dd><p>By default, via <code>wp_is_mobile()<\/code> plus a user-agent check for tablets. The result is filterable via <code>renderwhen_device_type<\/code> so you can plug in a more sophisticated library.<\/p><\/dd>\n<dt id=\"is%20this%20caching-friendly%3F\"><h3>Is this caching-friendly?<\/h3><\/dt>\n<dd><p>Mostly yes \u2014 visibility is evaluated at render time, so server-side page caches will cache whatever was rendered for that request. For varying-by-user content (login state, role), you'll want a cache layer that varies on cookies. The <code>renderwhen_render_block_hidden<\/code> action is provided so cache plugins and edge integrations can hook in.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>Initial release.<\/li>\n<li>Three built-in conditions: user state, date range, device type.<\/li>\n<li>Public Conditions API.<\/li>\n<li>Editor indicator and \"Preview as...\" mode.<\/li>\n<\/ul>","raw_excerpt":"Show or hide any block when conditions match. Developer-first API and true server-side rendering \u2014 hidden blocks never reach the browser.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/312163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=312163"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/abhishekfdd"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=312163"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=312163"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=312163"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=312163"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=312163"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=312163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}