-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-devtrace.php
More file actions
115 lines (97 loc) · 2.5 KB
/
Copy pathwp-devtrace.php
File metadata and controls
115 lines (97 loc) · 2.5 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* Plugin Name: WP DevTrace
* Plugin URI:
* Description: Developer debugging toolkit. Pretty error pages, crash logger, query profiler and plugin conflict tester.
* Version: 1.0.0
* Requires at least: 6.0
* Requires PHP: 8.0
* Author: hmrisad
* Author URI:
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wp-devtrace
* Domain Path: /languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/src/bootstrap.php';
use DevTrace\Admin\Settings;
use DevTrace\Database;
use DevTrace\Modules\CrashLogger;
final class WpDevTrace {
/**
* Plugin version.
*
* @var string
*/
const VERSION = '1.0.0';
/**
* Class constructor.
*
* @access private
*/
private function __construct() {
// define constants
$this->defineConstants();
// register plugin activation hook
register_activation_hook( __FILE__, [ self::class, 'activate' ] );
// uninstall plugin hook
register_uninstall_hook( __FILE__, [ self::class, 'uninstall' ] );
// hook run on plugins loaded
add_action( 'plugins_loaded', [ $this, 'init' ] );
}
/**
* Initialize singleton instance.
*
* @return WpDevTrace
*/
public static function getInstance(): WpDevTrace {
static $instance = false;
if ( ! $instance ) {
$instance = new self();
}
return $instance;
}
/**
* Define plugin constants.
*
* @return void
*/
private function defineConstants(): void {
define( 'DEVTRACE_VERSION', self::VERSION );
define( 'DEVTRACE_FILE', __FILE__ );
define( 'DEVTRACE_PATH', __DIR__ );
define( 'DEVTRACE_URL', plugins_url( '', __FILE__ ) );
}
/**
* Create table when activate plugin
*
* @return void
*/
public static function activate(): void {
Database::createTables();
}
/**
* Delete table when uninstall plugin
*
* @return void
*/
public function uninstall(): void {
Database::dropTables();
delete_option( 'devtrace_active' );
}
/**
* Boot plugin modules.
*
* @return void
*/
public function init(): void {
if( is_admin() ){
( new Settings() )->register();
}
}
}
WpDevTrace::getInstance();