-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorewebvitalsmonitor.php
92 lines (71 loc) · 2.48 KB
/
corewebvitalsmonitor.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
<?php
namespace corewebvitalsmonitor;
/**
* Plugin Name: Core Web Vitals Monitor
* Description: Get page speed statistics for real users who visit your site.
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 7.4.0
* Author: Web Results Direct
* Author URI: https://wrd.studio
* License: GPL v3 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: cwvm
* Domain Path: /languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Plugin_Manager {
const DIR = __DIR__;
const FILE = __FILE__;
const VERSION = '1.0.0';
public Assets_Manager $asset_manager;
public Admin_Dashboard $admin_dashboard;
public Metabox $metabox;
public Routes_Manager $routes_manager;
function __construct() {
require_once plugin_dir_path( static::FILE ) . '/src/class-metrics-table.php';
register_activation_hook( __FILE__, array( static::class, 'activate' ) );
register_uninstall_hook( __FILE__, array( static::class, 'uninstall' ) );
if ( ! is_admin() ) {
add_action( 'init', array( $this, 'init_public' ) );
}
add_action( 'init', array( $this, 'init' ) );
add_action( 'admin_init', array( $this, 'init_admin' ) );
add_action( 'rest_api_init', array( $this, 'init_rest' ) );
}
function init() {
require_once plugin_dir_path( static::FILE ) . '/src/class-assets-manager.php';
$this->asset_manager = new Assets_Manager();
require_once plugin_dir_path( static::FILE ) . '/src/class-admin-dashboard.php';
$this->admin_dashboard = new Admin_Dashboard();
}
function init_admin() {
require_once plugin_dir_path( static::FILE ) . '/src/class-metabox.php';
$this->metabox = new Metabox();
}
function init_public() { }
function init_rest() {
require_once plugin_dir_path( static::FILE ) . '/src/class-routes-manager.php';
$this->routes_manager = new Routes_Manager();
}
static function activate() {
$metrics_table = Metrics_Table::get_instance();
$metrics_table->create_table();
update_option( 'corewebvitalsmonitor_version', static::VERSION );
}
static function uninstall() {
$metrics_table = Metrics_Table::get_instance();
$metrics_table->drop_table();
delete_option( 'corewebvitalsmonitor_version' );
}
}
function corewebvitalsmonitor() {
global $corewebvitalsmonitor;
if ( ! isset( $corewebvitalsmonitor ) ) {
$corewebvitalsmonitor = new Plugin_Manager();
}
return $corewebvitalsmonitor;
}
corewebvitalsmonitor();