Filters how Jetpack treats each feature on this site. Keys are module slugs for `activation`. For `visibility`, keys are anything the My Jetpack Features page answers to: product, module, or feature slugs. Each value is an array with either or both of: – `activation`: ‘forced-on’ or ‘forced-off’ pin the module on every request, the same as `jetpack_active_modules`. ‘default-on’ or ‘default-off’ change what Jetpack turns on when it activates its default modules, which happens at connection and upgrade, not on an existing site. ‘default’ leaves it alone. A ‘forced-on’ slug this site has no module for still reads as active, but calls `_doing_it_wrong()` since nothing will load it. – `visibility`: ‘hidden’ keeps the item off the My Jetpack Features page and out of the wp-admin sidebar, ‘visible’ shows it in both. A sidebar entry matches on its item key or on the product or module gate it declares. The policy runs last, so ‘visible’ overrides a ‘hidden’ another callback set. Standalone plugin products (Akismet, Boost, CRM, Protect) take `visibility` only: WordPress decides which plugins load before Jetpack runs, so forcing one needs `option_active_plugins` in an mu-plugin. Register the policy before `after_setup_theme`, from an mu-plugin, plugin, or theme: `Jetpack::load_modules()` runs there at priority -2, so a later policy (on `init`, say) misses module loading while My Jetpack still honors it — the module runs on a page saying it is off.
Parameters
- $policy
array Map of slug to policy, empty until a host adds to it.
Changelog
- Introduced in Jetpack 7.1.0