WP Manifestindependent plugin directory
manifest / utilities / boros-closed-site

Boros Closed Site or Redirect

Close site for non-logged users. Show maintenance HTML message or redirect to another url.

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/alexkoti/boros-closed-site/archive/refs/heads/master.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Description

Close site for non-logged users. Show maintenance HTML message or redirect to another url.

Installation

Add the constant 'CLOSED_SITE' in wp-config.php with value true or absolute url.

If the constant value is a absolute url, the visitor will redirected to url, with 302 code. If the value is true, the will show a pre-made maintenance message, or use a custom HTML from 'boros_closed_site_html' hook.

The hook 'boros_closed_site_html' need to be in functions.php in the active theme or inside a any active plugin.

Examples

// custom HTML message
add_filter('boros_closed_site_html', function(){
    return '
<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Closed</title>
</head>
<body>
<h1>Closed</h1>
<p>Maintenance</p>
</body>
</html>
    ';
});

// show predefined message (or custom HTML if 'boros_closed_site_html' hook used):
define( 'CLOSED_SITE', true );

// simple redirect 302:
define( 'CLOSED_SITE', 'https://google.com' );

// set url and redirect status
define( 'CLOSED_SITE', array('https://google.com', 301) );
define( 'CLOSED_SITE', array('https://google.com', 302) );