Repository navigation
Expand file tree
/
Copy pathPlugin.php
More file actions
124 lines (109 loc) · 2.73 KB
/
Copy pathPlugin.php
File metadata and controls
124 lines (109 loc) · 2.73 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
115
116
117
118
119
120
121
122
123
124
<?php
namespace Perform;
use Perform\Admin;
use Perform\Admin\Settings;
use Perform\Modules;
use Perform\Includes\Helpers;
// Bailout, if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Loads and registers plugin functionality through WordPress hooks.
*
* @since 1.0.0
*/
final class Plugin {
/**
* Registers functionality with WordPress hooks.
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function register() {
// Handle plugin activation and deactivation.
register_activation_hook( PERFORM_PLUGIN_FILE, [ $this, 'activate' ] );
register_deactivation_hook( PERFORM_PLUGIN_FILE, [ $this, 'deactivate' ] );
// Register services used throughout the plugin.
add_action( 'plugins_loaded', [ $this, 'register_services' ] );
}
/**
* Registers the individual services of the plugin.
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function register_services() {
// Load Freemius SDK.
$this->load_freemius();
// Ensure legacy settings are migrated to perform_settings.
Settings\Migrator::maybe_migrate_legacy_settings();
// Load Admin Files.
new Settings\Menu();
new Admin\Actions();
new Admin\Filters();
// Load Frontend Files.
new Includes\Actions();
new Includes\Filters();
// Centralized module loader - preserves backward compatibility with
// modules that still register hooks in their constructors while
// supporting new modules implementing ModuleInterface.
$settings = Helpers::get_settings();
$settings = is_array( $settings ) ? $settings : [];
$loader = new Modules\Loader( $settings );
$loader->register_modules( Modules\Registry::all() );
}
/**
* Loads the Freemius SDK.
*
* @since 1.4.0
* @access public
*
* @return void
*/
public function load_freemius() {
// Include Freemius SDK.
$perform_fs = fs_dynamic_init(
[
'id' => '18658',
'slug' => 'perform',
'type' => 'plugin',
'public_key' => 'pk_d4518e758d9fc19cb25ffe77371fa',
'is_premium' => false,
'has_addons' => false,
'has_paid_plans' => false,
'menu' => [
'slug' => 'perform_settings',
'parent' => [
'slug' => 'options-general.php',
],
],
]
);
}
/**
* Handles activation procedures during installation and updates.
*
* @since 1.0.0
* @access public
*
* @param bool $network_wide Optional. Whether the plugin is being enabled on
* all network sites or a single site. Default false.
*
* @return void
*/
public function activate( $network_wide = false ) {}
/**
* Handles deactivation procedures.
*
* @since 1.0.0
* @access public
*
* @return void
*/
public function deactivate() {}
}