forked from nicolas-leclerc/shortcodes-ultimate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass-shortcodes-ultimate.php
More file actions
171 lines (136 loc) · 4.78 KB
/
Copy pathclass-shortcodes-ultimate.php
File metadata and controls
171 lines (136 loc) · 4.78 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/**
* The core plugin class.
*
* This is used to define internationalization and hooks.
*
* @since 5.0.0
* @package Shortcodes_Ultimate
* @subpackage Shortcodes_Ultimate/includes
*/
class Shortcodes_Ultimate {
/**
* The path to the main plugin file.
*
* @since 5.0.0
* @access private
* @var string $plugin_file The path to the main plugin file.
*/
private $plugin_file;
/**
* The current version of the plugin.
*
* @since 5.0.0
* @access private
* @var string $plugin_version The current version of the plugin.
*/
private $plugin_version;
/**
* The path to the plugin folder.
*
* @since 5.0.0
* @access private
* @var string $plugin_path The path to the plugin folder.
*/
private $plugin_path;
/**
* The plugin text domain.
*
* @since 5.0.0
* @access private
* @var string $textdomain The plugin text domain.
*/
private $textdomain;
/**
* Define the core functionality of the plugin.
*
* @since 5.0.0
* @param string $plugin_file The path to the main plugin file.
* @param string $plugin_version The current version of the plugin.
*/
public function __construct( $plugin_file, $plugin_version ) {
$this->plugin_file = $plugin_file;
$this->plugin_version = $plugin_version;
$this->plugin_path = plugin_dir_path( $plugin_file );
$this->textdomain = 'shortcodes-ultimate';
$this->load_dependencies();
$this->define_admin_hooks();
}
/**
* Load the required dependencies for the plugin.
*
*
* @since 5.0.0
* @access private
*/
private function load_dependencies() {
/**
* The class responsible for plugin upgrades.
*/
require_once $this->plugin_path . 'includes/class-shortcodes-ultimate-upgrade.php';
/**
* Classes responsible for defining admin menus.
*/
require_once $this->plugin_path . 'admin/class-shortcodes-ultimate-admin.php';
require_once $this->plugin_path . 'admin/class-shortcodes-ultimate-admin-top-level.php';
require_once $this->plugin_path . 'admin/class-shortcodes-ultimate-admin-shortcodes.php';
require_once $this->plugin_path . 'admin/class-shortcodes-ultimate-admin-settings.php';
require_once $this->plugin_path . 'admin/class-shortcodes-ultimate-admin-addons.php';
/**
* Classes responsible for displaying admin notices.
*/
require_once $this->plugin_path . 'admin/class-shortcodes-ultimate-notice.php';
require_once $this->plugin_path . 'admin/class-shortcodes-ultimate-notice-rate.php';
}
/**
* Register all of the hooks related to the admin area functionality of the
* plugin.
*
* @since 5.0.0
* @access private
*/
private function define_admin_hooks() {
/**
* Run upgrades.
*/
$upgrade = new Shortcodes_Ultimate_Upgrade( $this->plugin_file, $this->plugin_version );
add_action( 'admin_init', array( $upgrade, 'maybe_upgrade' ) );
/**
* Top-level menu: Shortcodes
* admin.php?page=shortcodes-ultimate
*/
$top_level = new Shortcodes_Ultimate_Admin_Top_Level( $this->plugin_file, $this->plugin_version );
add_action( 'admin_menu', array( $top_level, 'admin_menu' ), 5 );
/**
* Submenu: Available shortcodes
* admin.php?page=shortcodes-ultimate
*/
$shortcodes = new Shortcodes_Ultimate_Admin_Shortcodes( $this->plugin_file, $this->plugin_version );
add_action( 'admin_menu', array( $shortcodes, 'admin_menu' ), 5 );
add_action( 'current_screen', array( $shortcodes, 'add_help_tab' ) );
add_action( 'admin_enqueue_scripts', array( $shortcodes, 'enqueue_scripts' ) );
/**
* Submenu: Settings
* admin.php?page=shortcodes-ultimate-settings
*/
$settings = new Shortcodes_Ultimate_Admin_Settings( $this->plugin_file, $this->plugin_version );
add_action( 'admin_menu', array( $settings, 'admin_menu' ), 20 );
add_action( 'admin_init', array( $settings, 'register_settings' ) );
add_action( 'current_screen', array( $settings, 'add_help_tab' ) );
/**
* Submenu: Add-ons
* admin.php?page=shortcodes-ultimate-addons
*/
$addons = new Shortcodes_Ultimate_Admin_Addons( $this->plugin_file, $this->plugin_version );
add_action( 'admin_menu', array( $addons, 'admin_menu' ), 30 );
add_action( 'admin_enqueue_scripts', array( $addons, 'enqueue_scripts' ) );
add_action( 'current_screen', array( $addons, 'add_help_tab' ) );
/**
* Notice: Rate plugin
*/
$rate = new Shortcodes_Ultimate_Notice_Rate( 'rate', $this->plugin_path . 'admin/partials/notices/rate.php' );
add_action( 'load-plugins.php', array( $rate, 'defer_first_time' ) );
add_action( 'admin_notices', array( $rate, 'display_notice' ) );
add_action( 'admin_post_su_dismiss_notice', array( $rate, 'dismiss_notice' ) );
}
}