Injects mu-plugin deactivate-wp.php
which turns off front end of WordPress. Customize header
, description
and message
variables at the top before running.
header="Website Deactivated"
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/deactivate-wp.php" ]; then
echo "Removing ${wp_content}/mu-plugins/deactivate-wp.php"
rm "${wp_content}/mu-plugins/deactivate-wp.php"
fi
# Must use WordPress deactivate plugin
cat <<EOF > deactivate-wp.php
<?php
function deactivate_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', 'deactivate_wp_template_redirect' );
EOF
mv deactivate-wp.php $wp_content/mu-plugins/
home=$( wp option get home )
echo "Generated $wp_content/mu-plugins/deactivate-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/deactivate-wp.php