← All recipes

Suspend WordPress

Injects mu-plugin suspend-wp.php which turns off front end of WordPress. Customize header, description and message variables at the top before running.

header="Website Suspended"
description="This website is no longer active."
message="Site owners contact <a href=\"https://<link-to-business>\">Business Name</a>"
wp_content=""

if [[ "$wp_content" == "" ]]; then
	wp_content="wp-content"
fi

if [ -f "${wp_content}/mu-plugins/suspend-wp.php" ]; then
    echo "Removing ${wp_content}/mu-plugins/suspend-wp.php"
    rm "${wp_content}/mu-plugins/suspend-wp.php"
fi

# Must use WordPress suspend plugin
cat <<EOF > suspend-wp.php
<?php

function suspend_wp_template_redirect() { ?><html>
  <head>
	<meta charset="utf-8">
	<title>${header}</title>

	<!-- Compiled and minified CSS -->
	<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

	<!-- Compiled and minified JavaScript -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

	<style>
		@import url('https://fonts.googleapis.com/css?family=Roboto');
		body {
			text-align: center;
			margin: 10% auto;
			padding: 0%;
			font-family: 'Roboto', sans-serif;
			overflow: hidden;
			display: block;
			max-width: 450px;
			background: #eeeeee;
		}
		p {
		  margin-top: 3%;
		  line-height: 1.4em;
		  display: block;
		}
		img {
		  margin-top: 1%;
		}
		a {
			color:#27c3f3;
		}
	</style>
  </head>
  <body>
	<div class="row">
	<div class="col s12">
	  <div class="card">
		<div class="card-content">
			<span class="card-title">${header}</span>
			<p>${description}</p>
		</div>
		<div class="card-content grey lighten-4">
			<p>${message}</p>
		</div>
	  </div>
	</div>
  </div>
  </body>
</html>
<?php
  die();
}
add_action( 'template_redirect', 'suspend_wp_template_redirect' );
EOF

mv suspend-wp.php $wp_content/mu-plugins/
home=$( wp option get home )
echo "Generated $wp_content/mu-plugins/suspend-wp.php on $home"
wp cache flush
if [ -f "${wp_content}/mu-plugins/kinsta-mu-plugins.php" ]; then
	wp kinsta cache purge --all --skip-themes
fi

To re-enable simply remove the mu-plugin.

rm wp-content/mu-plugins/suspend-wp.php
Run it across a fleet

Open the console in CaptainCore Manager, pick the target sites, choose this recipe from the Cookbook picker and press run. The CLI streams each site's output back to the dock.

About the console →