-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherror-logger.php
131 lines (108 loc) · 4.07 KB
/
error-logger.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/*
Plugin Name: Error Logger
Description: Log and Review your WordPress Errors.
Plugin URI: https://wpmanageninja.com/
Version: 1.0
Author: WPManageNinja LLC
Author URI: https://wpmanageninja.com/
Text Domain: error_logger
*/
/**
* @copyright Copyright (c) 2017. All rights reserved.
*
* @license Released under the GPL license http://www.opensource.org/licenses/gpl-license.php
*
* **********************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* **********************************************************************
*
*/
if (!defined('ABSPATH')) {
exit;
}
define( 'NINJA_ERROR_LOGGER_VERSION', '1.0' );
if( ! class_exists( 'NinjaErrorLogger' ) ) {
class NinjaErrorLogger
{
/**
* @var NinjaErrorLogger The only instance
* @since 1.0
*/
private static $instance;
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof NinjaErrorLogger ) ) {
self::$instance = new NinjaErrorLogger;
self::$instance->loadDependecies();
self::$instance->boot();
}
return self::$instance;
}
public function boot()
{
if(is_admin()) {
$this->loadAdminHooks();
}
$this->loadPublicHooks();
}
public function loadAdminHooks()
{
$adminHandlder = new \NinjaErrorLogger\Classes\AdminHandler();
$adminHandlder->register();
}
public function loadPublicHooks()
{
$errorHandler = new \NinjaErrorLogger\Classes\ErrorHandler();
$errorHandler->register();
$notificationHandler = new \NinjaErrorLogger\Classes\NotificationHandler();
$notificationHandler->register();
}
public function loadDependecies()
{
if(!defined('NINJA_ERROR_LOGGER_DIR_PATH')) {
define('NINJA_ERROR_LOGGER_DIR_PATH', plugin_dir_path(__FILE__));
}
if(!defined('NINJA_ERROR_LOGGER_DIR_URL')) {
define('NINJA_ERROR_LOGGER_DIR_URL', plugin_dir_url(__FILE__));
}
include_once NINJA_ERROR_LOGGER_DIR_PATH.'Classes/GeneralSettings.php';
include_once NINJA_ERROR_LOGGER_DIR_PATH.'Classes/AdminHandler.php';
include_once NINJA_ERROR_LOGGER_DIR_PATH.'Classes/AjaxHandler.php';
include_once NINJA_ERROR_LOGGER_DIR_PATH.'Classes/ErrorHandler.php';
include_once NINJA_ERROR_LOGGER_DIR_PATH.'Classes/NotificationHandler.php';
}
public function db()
{
if(function_exists('wpFluent')) {
return wpFluent();
}
include_once NINJA_ERROR_LOGGER_DIR_PATH.'Classes/libs/wp-fluent/wp-fluent.php';
return wpFluent();
}
}
function ninja_error_logger_app() {
return NinjaErrorLogger::instance();
}
ninja_error_logger_app();
register_activation_hook(__FILE__, function ($newWorkWide) {
require_once(plugin_dir_path(__FILE__) . 'Classes/Activator.php');
$activator = new \NinjaErrorLogger\Classes\Activator();
$activator->migrateDatabases($newWorkWide);
});
// Handle Newtwork new Site Activation
add_action( 'wpmu_new_blog', function ($blogId) {
require_once(plugin_dir_path(__FILE__) . 'Classes/Activator.php');
switch_to_blog( $blogId );
$activator = new \NinjaErrorLogger\Classes\Activator();
$activator->migrate();
restore_current_blog();
} );
}