Skip to content

Code structure

The theme renders. A must-use plugin enforces environment rules and keeps the theme active. A call into a plugin checks that the plugin is loaded.

The theme registers supports, styles, blocks, and patterns. It does not decide whether the site is production.

One file in wp-content/mu-plugins/ does four things:

  1. Switches to the theme after setup, when it is not already active.
  2. Forces blog_public to 0 off production, by filtering option_blog_public. The stored option is 0 as well. The filter covers reads. The stored value covers anything that ignores the filter.
  3. Answers /robots.txt: Disallow: / off production, Allow: / on production.
  4. Stops mail off production. A non-null return from pre_wp_mail short-circuits wp_mail. PHPMailer recipients are cleared as well, for anything that sends mail without wp_mail.
mu-plugin.php
add_filter( 'pre_wp_mail', static function ( $short_circuit ) {
if ( wp_get_environment_type() === 'production' ) {
return $short_circuit;
}
return false;
} );

wp_get_environment_type() reads WP_ENVIRONMENT_TYPE. That value is set in the environment. PHP does not branch on the hostname.

Functions and globals use the theme slug as a prefix (acme_) so they do not collide with plugins.

A linter that needs to see concatenated class strings gets them through one helper that returns the string unchanged. The helper is not a styling system.