-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
91 lines (82 loc) · 2.55 KB
/
index.php
File metadata and controls
91 lines (82 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link https://github.com/Mill3/Mill3-Theme-Dev-Mode/
* @since 1.0.1
* @package Mill3_Theme_Dev_Mode
*
* @wordpress-plugin
* Plugin Name: Mill3 Theme Dev Mode 🔒
* Plugin URI: https://github.com/Mill3/Mill3-Theme-Dev-Mode/
* Description: This plugin prevent non-connected admin users to visit the public site, also prevents robots indexing.
* Version: 1.0.1
* Author: Mill3 Studio
* Author URI: https://mill3.studio//
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: mill3-theme-dev-mode
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* Currently plugin version.
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'MILL3_THEME_DEV_MODE_VERSION', '1.0.1' );
/**
* Begins execution of the plugin.
*
* @since 1.0.0
*
*/
function run_mill3_theme_dev_mode() {
// if is a CLI command, do nothing
if( defined('WP_CLI') && WP_CLI ) return;
// if user is logged in or at login page, do nothing
if( is_admin() || $GLOBALS['pagenow'] == 'wp-login.php' ) return;
// if function does not exist, do nothing, prevent error if called using an early hook
if( !function_exists("get_current_user_id") ) return;
// get current user
$user = get_current_user_id();
// if user is not logged in, display a message and die
if( !$user ) {
$body = <<<HEREDOC_BODY
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MILL3</title>
<style>
body {
padding: 0.25em;
font-size: 2.5em;
text-align: center;
font-family: Helvetica; sans-serif;
background-color: #000;
color: #fff;
}
h1 {
margin: 0;
}
</style>
</head>
<body>
<h1>MILL3 🔒</h1>
</body>
</html>
HEREDOC_BODY;
exit($body);
}
}
// run the function when the user is set
add_action( 'set_current_user', 'run_mill3_theme_dev_mode');