-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsafety-exit.php
73 lines (67 loc) · 1.89 KB
/
safety-exit.php
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
<?php
/**
* Safety Exit
*
* @package SafetyExit
* @author Tomas Cordero
* @copyright Copyright (c) 2021 Tomas Cordero
* @license GPL-2.0+
*
* @wordpress-plugin
* Plugin Name: Safety Exit
* Plugin URI:
* Description: This plugin will inject a button on your website that will allow a website user to quickly navigate away from your website.
* Version: 1.8.0
* Author: Tomas Cordero
* Author URI: https://tomascordero.com
* License: GPL-2.0+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: safety-exit
*/
require plugin_dir_path( __FILE__ ) . '/vendor/autoload.php';
use SafetyExit\Frontend;
use SafetyExit\Admin;
$path = realpath(dirname(__FILE__) . '/../../../')."/wp-includes/pluggable.php";
// This adds support for bedrock, ABSPATH is set by bedrock as part of the config.
if(defined('ABSPATH')){
$path = ABSPATH . '/wp-includes/pluggable.php';
}
$errors = false;
// Check to see if required file exists. If not do not initialize plugin
try {
if( !file_exists( $path ) ) {
throw new Exception ('Unable to load pluggable.php in: ' . $path . ' Safety Exit is disabled until this error is fixed.');
}else{
require_once($path);
}
}catch(Exception $e){
if ( is_admin() ){
?>
<div class="error notice">
<p><?= $e->getMessage(); ?></p>
</div>
<?php
}
$errors = true;
}
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if( !$errors ) {
$url_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
if ( is_admin() ){
if(current_user_can('administrator')){
$admin = new Admin(__FILE__);
$admin->init();
}
} else if (
$url_path !== '/wp-login.php'
&& $url_path !== '/admin'
&& $url_path !== '/wp-admin'
&& $url_path !== '/login'
){
$frontend = new Frontend(__FILE__);
$frontend->init();
}
}