PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.3
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.3
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
← All changes | class/class-mainwp-system.php +1042 -1209 5.2.24.3 View file →
@@ -8,8 +8,16 @@
8 8 namespace MainWP\Dashboard;
9 9
10 10 // phpcs:disable Generic.Metrics.CyclomaticComplexity -- complexity.
11 11
12 +/**
13 + * Defines MainWP Twitter Max Seconds.
14 + *
15 + * @const ( string ) 60 * 5
16 + * @source https://github.com/mainwp/mainwp/blob/master/cron/bootstrap.php
17 + */
18 +define( 'MAINWP_TWITTER_MAX_SECONDS', 60 * 5 );
19 +
12 20 const MAINWP_VIEW_PER_SITE = 1;
13 21 const MAINWP_VIEW_PER_PLUGIN_THEME = 0;
14 22 const MAINWP_VIEW_PER_GROUP = 2;
15 23
@@ -19,1361 +27,1186 @@
19 27 * Class MainWP_System
20 28 *
21 29 * @package MainWP\Dashboard
22 30 */
23 -class MainWP_System { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
31 +class MainWP_System {
24 32
25 - /**
26 - * Public static variable to hold the current plugin version.
27 - *
28 - * @var string Current plugin version.
29 - */
30 - public static $version = '5.2.2'; // NOSONAR.
33 + /**
34 + * Public static variable to hold the current plugin version.
35 + *
36 + * @var string Current plugin version.
37 + */
38 + public static $version = '4.3';
31 39
32 - /**
33 - * Private static variable to hold the single instance of the class.
34 - *
35 - * @var mixed Default null
36 - */
37 - private static $instance = null;
40 + /**
41 + * Private static variable to hold the single instance of the class.
42 + *
43 + * @var mixed Default null
44 + */
45 + private static $instance = null;
38 46
39 - /**
40 - * Public variable to hold the Metaboxes instance.
41 - *
42 - * @var object Metaboxes.
43 - */
44 - public $metaboxes;
47 + /**
48 + * Public variable to hold the Metaboxes instance.
49 + *
50 + * @var object Metaboxes.
51 + */
52 + public $metaboxes;
45 53
46 - /**
47 - * Private variable to hold the current version.
48 - *
49 - * @var string The plugin current version.
50 - */
51 - private $current_version = null;
54 + /**
55 + * Private variable to hold the current version.
56 + *
57 + * @var string The plugin current version.
58 + */
59 + private $current_version = null;
52 60
61 + /**
62 + * Private variable to hold the plugin slug (mainwp/mainwp.php)
63 + *
64 + * @var string Plugin slug.
65 + */
66 + private $plugin_slug;
53 67
54 - /**
55 - * Private variable to hold the check update version number.
56 - *
57 - * @var string The plugin current update version.
58 - */
59 - private $check_ver_update = '0.0.5';
68 + /**
69 + * Method instance()
70 + *
71 + * Create a public static instance.
72 + *
73 + * @static
74 + * @return MainWP_System
75 + */
76 + public static function instance() {
77 + return self::$instance;
78 + }
60 79
61 - /**
62 - * Private variable to hold the plugin slug (mainwp/mainwp.php)
63 - *
64 - * @var string Plugin slug.
65 - */
66 - private $plugin_slug;
80 + /**
81 + * MainWP_System constructor.
82 + *
83 + * Runs any time class is called.
84 + *
85 + * @param string $mainwp_plugin_file Plugn slug.
86 + *
87 + * @uses \MainWP\Dashboard\MainWP_Bulk_Post
88 + * @uses \MainWP\Dashboard\MainWP_Hooks
89 + * @uses \MainWP\Dashboard\MainWP_Menu::get_class_name()
90 + * @uses \MainWP\Dashboard\MainWP_Menu
91 + * @uses \MainWP\Dashboard\MainWP_Meta_Boxes
92 + * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::init_cron_jobs()
93 + * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs
94 + * @uses \MainWP\Dashboard\MainWP_System_Handler
95 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_class_name()
96 + * @uses \MainWP\Dashboard\MainWP_System_View::get_class_name()
97 + * @uses \MainWP\Dashboard\MainWP_UI::get_class_name()
98 + * @uses \MainWP\Dashboard\MainWP_WP_CLI_Command::init()
99 + * @uses \MainWP\Dashboard\MainWP_Updates_Overview::init()
100 + * @uses \MainWP\Dashboard\MainWP_Extensions::init()
101 + * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_class_name()
102 + * @uses \MainWP\Dashboard\MainWP_Install_Bulk::init()
103 + * @uses \MainWP\Dashboard\MainWP_Manage_Backups::init()
104 + * @uses \MainWP\Dashboard\MainWP_Manage_Sites::init()
105 + * @uses \MainWP\Dashboard\MainWP_Overview::get()
106 + * @uses \MainWP\Dashboard\MainWP_Page::init()
107 + * @uses \MainWP\Dashboard\MainWP_Plugins::init()
108 + * @uses \MainWP\Dashboard\MainWP_Post::init()
109 + * @uses \MainWP\Dashboard\MainWP_Settings::init()
110 + * @uses \MainWP\Dashboard\MainWP_Themes::init()
111 + * @uses \MainWP\Dashboard\MainWP_Updates::init()
112 + * @uses \MainWP\Dashboard\MainWP_User::init()
113 + * @uses \MainWP\Dashboard\MainWP_Updates::init()
114 + * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
115 + */
116 + public function __construct( $mainwp_plugin_file ) {
117 + self::$instance = $this;
118 + $this->load_all_options();
119 + $this->update_install();
120 + $this->plugin_slug = plugin_basename( $mainwp_plugin_file );
67 121
68 - /**
69 - * Method instance()
70 - *
71 - * Create a public static instance.
72 - *
73 - * @static
74 - * @return MainWP_System
75 - */
76 - public static function instance() {
77 - return static::$instance;
78 - }
122 + // includes rest api work.
123 + require 'class-mainwp-rest-api.php';
124 + Rest_Api::instance()->init();
79 125
80 - /**
81 - * MainWP_System constructor.
82 - *
83 - * Runs any time class is called.
84 - *
85 - * @param string $mainwp_plugin_file Plugn slug.
86 - *
87 - * @uses \MainWP\Dashboard\MainWP_Bulk_Post
88 - * @uses \MainWP\Dashboard\MainWP_Hooks
89 - * @uses \MainWP\Dashboard\MainWP_Menu::get_class_name()
90 - * @uses \MainWP\Dashboard\MainWP_Menu
91 - * @uses \MainWP\Dashboard\MainWP_Meta_Boxes
92 - * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::init_cron_jobs()
93 - * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs
94 - * @uses \MainWP\Dashboard\MainWP_System_Handler
95 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_class_name()
96 - * @uses \MainWP\Dashboard\MainWP_System_View::get_class_name()
97 - * @uses \MainWP\Dashboard\MainWP_UI::get_class_name()
98 - * @uses \MainWP\Dashboard\MainWP_WP_CLI_Command::init()
99 - * @uses \MainWP\Dashboard\MainWP_Updates_Overview::init()
100 - * @uses \MainWP\Dashboard\MainWP_Extensions::init()
101 - * @uses \MainWP\Dashboard\MainWP_Extensions_Handler::get_class_name()
102 - * @uses \MainWP\Dashboard\MainWP_Install_Bulk::init()
103 - * @uses \MainWP\Dashboard\MainWP_Manage_Backups::init()
104 - * @uses \MainWP\Dashboard\MainWP_Manage_Sites::init()
105 - * @uses \MainWP\Dashboard\MainWP_Overview::get()
106 - * @uses \MainWP\Dashboard\MainWP_Page::init()
107 - * @uses \MainWP\Dashboard\MainWP_Plugins::init()
108 - * @uses \MainWP\Dashboard\MainWP_Post::init()
109 - * @uses \MainWP\Dashboard\MainWP_Settings::init()
110 - * @uses \MainWP\Dashboard\MainWP_Themes::init()
111 - * @uses \MainWP\Dashboard\MainWP_Updates::init()
112 - * @uses \MainWP\Dashboard\MainWP_User::init()
113 - * @uses \MainWP\Dashboard\MainWP_Updates::init()
114 - * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
115 - */
116 - public function __construct( $mainwp_plugin_file ) { //phpcs:ignore -- NOSONAR - complex.
117 - static::$instance = $this;
126 + if ( is_admin() ) {
127 + include_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'plugin.php';
128 + $pluginData = get_plugin_data( $mainwp_plugin_file );
129 + $this->current_version = $pluginData['Version'];
130 + $currentVersion = get_option( 'mainwp_plugin_version' );
118 131
119 - MainWP_Execution_Helper::instance()->init_exec_time();
132 + if ( ! empty( $currentVersion ) && version_compare( $currentVersion, '4.0', '<' ) && version_compare( $this->current_version, '4.0', '>=' ) ) {
133 + add_action( 'mainwp_before_header', array( MainWP_System_View::get_class_name(), 'mainwp_4_update_notice' ) );
134 + }
120 135
121 - $includer = new MainWP_Includes();
122 - $includer->includes();
136 + MainWP_Utility::update_option( 'mainwp_plugin_version', $this->current_version );
137 + }
123 138
124 - MainWP_Keys_Manager::auto_load_files();
139 + if ( ! defined( 'MAINWP_VERSION' ) ) {
125 140
126 - $this->load_all_options();
141 + /**
142 + * Defines MainWP Version.
143 + *
144 + * @const ( string )
145 + * @source https://code-reference.mainwp.com/classes/MainWP.Dashboard.MainWP_System.html
146 + */
147 + define( 'MAINWP_VERSION', $this->current_version );
148 + }
127 149
128 - $this->update_install();
129 - $this->plugin_slug = plugin_basename( $mainwp_plugin_file );
150 + $ssl_api_verifyhost = ( ( get_option( 'mainwp_api_sslVerifyCertificate' ) === false ) || ( get_option( 'mainwp_api_sslVerifyCertificate' ) == 1 ) ) ? 1 : 0;
151 + if ( 0 == $ssl_api_verifyhost ) {
152 + add_filter(
153 + 'http_request_args',
154 + array(
155 + MainWP_Extensions_Handler::get_class_name(),
156 + 'no_ssl_filter_extension_upgrade',
157 + ),
158 + 99,
159 + 2
160 + );
161 + }
130 162
131 - do_action( 'mainwp_system_init' );
163 + MainWP_Extensions::init();
132 164
133 - if ( is_admin() ) {
134 - include_once ABSPATH . 'wp-admin' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'plugin.php'; // NOSONAR - WP compatible.
135 - $pluginData = get_plugin_data( $mainwp_plugin_file, true, false ); // to fix issue of user language setting.
136 - $this->current_version = $pluginData['Version'];
137 - $currentVersion = get_option( 'mainwp_plugin_version' );
165 + $systemHandler = MainWP_System_Handler::instance();
138 166
139 - if ( ! empty( $currentVersion ) && version_compare( $currentVersion, '4.0', '<' ) && version_compare( $this->current_version, '4.0', '>=' ) ) {
140 - add_action( 'mainwp_after_header', array( MainWP_System_View::get_class_name(), 'mainwp_4_update_notice' ) );
141 - }
167 + add_action( 'parse_request', array( &$this, 'parse_request' ) );
168 + add_action( 'init', array( &$this, 'localization' ) );
169 + add_filter( 'site_transient_update_plugins', array( $systemHandler, 'check_update_custom' ) );
170 + add_filter( 'pre_set_site_transient_update_plugins', array( $systemHandler, 'pre_check_update_custom' ) );
171 + add_filter( 'plugins_api', array( $systemHandler, 'plugins_api_info' ), 10, 3 );
142 172
143 - if ( ! empty( $currentVersion ) && version_compare( $currentVersion, '5.0', '<' ) && version_compare( $this->current_version, '5.0', '>=' ) ) {
144 - add_action( 'mainwp_after_header', array( MainWP_System_View::get_class_name(), 'mainwp_ver5_update_notice' ) );
145 - }
173 + $this->metaboxes = new MainWP_Meta_Boxes();
146 174
147 - if ( ! empty( $currentVersion ) && version_compare( $currentVersion, '5.0.2', '<' ) && version_compare( $this->current_version, '5.0.2', '>=' ) ) {
148 - add_action( 'mainwp_after_header', array( MainWP_System_View::get_class_name(), 'mainwp_ver502_update_notice' ) );
149 - }
175 + MainWP_Overview::get();
176 + MainWP_Client_Overview::instance();
150 177
151 - MainWP_Utility::update_option( 'mainwp_plugin_version', $this->current_version );
152 - }
178 + MainWP_Manage_Sites::init();
179 + new MainWP_Hooks();
180 + new MainWP_Menu();
153 181
154 - if ( ! defined( 'MAINWP_VERSION' ) ) {
182 + add_action( 'admin_menu', array( MainWP_Menu::get_class_name(), 'init_mainwp_menus' ) );
183 + add_filter( 'admin_footer', array( &$this, 'admin_footer' ), 15 );
184 + add_action( 'admin_head', array( MainWP_System_View::get_class_name(), 'admin_head' ) );
185 + add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_styles' ) );
186 + add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
187 + add_action( 'admin_body_class', array( MainWP_System_View::get_class_name(), 'admin_body_class' ) );
155 188
156 - /**
157 - * Defines MainWP Version.
158 - *
159 - * @const ( string )
160 - * @source https://code-reference.mainwp.com/classes/MainWP.Dashboard.MainWP_System.html
161 - */
162 - define( 'MAINWP_VERSION', $this->current_version );
163 - }
189 + new MainWP_Bulk_Post();
164 190
165 - if ( get_option( 'mainwp_setting_demo_mode_enabled' ) && ! defined( 'MAINWP_DEMO_MODE' ) ) {
166 - define( 'MAINWP_DEMO_MODE', true );
167 - }
191 + add_action( 'admin_init', array( &$this, 'admin_init' ), 20 );
192 + add_action( 'after_setup_theme', array( &$this, 'after_setup_theme' ) );
168 193
169 - $ssl_api_verifyhost = ( ( get_option( 'mainwp_api_sslVerifyCertificate' ) === false ) || ( 1 === (int) get_option( 'mainwp_api_sslVerifyCertificate' ) ) ) ? 1 : 0;
170 - if ( empty( $ssl_api_verifyhost ) ) {
171 - add_filter(
172 - 'http_request_args',
173 - array(
174 - MainWP_Extensions_Handler::get_class_name(),
175 - 'no_ssl_filter_extension_upgrade',
176 - ),
177 - 99,
178 - 2
179 - );
180 - }
194 + add_action( 'init', array( &$this, 'parse_init' ) );
195 + add_action( 'init', array( &$this, 'init' ), 9999 );
196 + add_action( 'admin_init', array( $this, 'admin_redirects' ) );
197 + add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
198 + add_action( 'login_form', array( &$this, 'login_form_redirect' ) );
199 + add_action( 'admin_print_styles', array( MainWP_System_View::get_class_name(), 'admin_print_styles' ) );
181 200
182 - MainWP_Extensions::init();
183 - MainWP_Extensions_Groups::init();
201 + add_action( 'wp_logout', array( &$this, 'clear_sessions' ) );
184 202
185 - $systemHandler = MainWP_System_Handler::instance();
203 + MainWP_Install_Bulk::init();
186 204
187 - add_action( 'plugins_loaded', array( &$this, 'localization' ) );
188 - add_filter( 'site_transient_update_plugins', array( $systemHandler, 'check_update_custom' ) );
189 - add_filter( 'pre_set_site_transient_update_plugins', array( $systemHandler, 'pre_check_update_custom' ) );
190 - add_filter( 'plugins_api', array( $systemHandler, 'plugins_api_extension_info' ), 10, 3 );
191 - add_filter( 'plugins_api_result', array( $systemHandler, 'plugins_api_wp_plugins_api_result' ), 10, 3 );
205 + MainWP_System_Cron_Jobs::instance()->init_cron_jobs();
192 206
193 - $this->metaboxes = new MainWP_Meta_Boxes();
207 + add_action( 'mainwp_before_header', array( MainWP_System_View::get_class_name(), 'admin_notices' ) );
208 + add_action( 'admin_notices', array( MainWP_System_View::get_class_name(), 'wp_admin_notices' ) );
209 + add_action( 'wp_mail_failed', array( &$this, 'wp_mail_failed' ) );
194 210
195 - MainWP_Overview::get();
196 - MainWP_Client_Overview::instance();
211 + add_action( 'after_plugin_row', array( MainWP_System_View::get_class_name(), 'after_extensions_plugin_row' ), 10, 3 );
197 212
198 - MainWP_Manage_Sites::init();
213 + add_filter( 'mainwp-activated-check', array( &$this, 'activated_check' ) ); // @deprecated Use 'mainwp_activated_check' instead.
214 + add_filter( 'mainwp_activated_check', array( &$this, 'activated_check' ) );
199 215
200 - MainWP_Hooks::get_instance();
201 - MainWP_Menu::get_instance();
216 + do_action_deprecated( 'mainwp-activated', array(), '4.0.7.2', 'mainwp_activated' ); // @deprecated Use 'mainwp_activated' instead.
202 217
203 - add_action( 'admin_menu', array( MainWP_Menu::get_class_name(), 'init_mainwp_menus' ) );
204 - add_filter( 'admin_footer', array( &$this, 'admin_footer' ), 15 );
205 - add_action( 'admin_head', array( MainWP_System_View::get_class_name(), 'admin_head' ) );
206 - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_styles' ) );
207 - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
208 - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts_fix_conflict' ), 9 );
209 - add_action( 'admin_body_class', array( MainWP_System_View::get_class_name(), 'admin_body_class' ) );
218 + /**
219 + * Action: mainwp_activated
220 + *
221 + * Fires upon MainWP plugin activation.
222 + *
223 + * @since Unknown
224 + */
225 + do_action( 'mainwp_activated' );
210 226
211 - MainWP_Bulk_Post::get_instance();
227 + MainWP_Updates::init();
228 + MainWP_Post::init();
229 + MainWP_Settings::init();
230 + if ( get_option( 'mainwp_enableLegacyBackupFeature' ) ) {
231 + MainWP_Manage_Backups::init();
232 + }
233 + MainWP_User::init();
234 + MainWP_Page::init();
235 + MainWP_Themes::init();
236 + MainWP_Plugins::init();
237 + MainWP_Updates_Overview::init();
238 + MainWP_Client::init();
239 + if ( defined( 'WP_CLI' ) && WP_CLI ) {
240 + MainWP_WP_CLI_Command::init();
241 + }
242 + if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
243 + if ( isset( $_GET['mainwp_run'] ) && ! empty( $_GET['mainwp_run'] ) ) {
244 + add_action( 'init', array( MainWP_System_Cron_Jobs::instance(), 'cron_active' ), PHP_INT_MAX );
245 + }
246 + }
247 + }
212 248
213 - add_action( 'admin_init', array( &$this, 'admin_init' ), 20 );
214 - add_action( 'admin_init', array( $this, 'hook_admin_update_check' ) );
215 - add_action( 'after_setup_theme', array( &$this, 'after_setup_theme' ) );
249 + /**
250 + * Method load_all_options()
251 + *
252 + * Load all wp_options data.
253 + *
254 + * @return array $alloptions Array of all options.
255 + */
256 + public function load_all_options() {
216 257
217 - add_action( 'init', array( &$this, 'parse_init' ) );
218 - add_action( 'init', array( &$this, 'init' ), 9999 );
219 - add_action( 'admin_init', array( $this, 'admin_redirects' ) );
220 - add_action( 'current_screen', array( &$this, 'current_screen_redirects' ), 15 );
221 - add_filter( 'plugin_action_links', array( $this, 'hook_plugin_action_links' ), 10, 4 );
222 - add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
223 - add_action( 'admin_print_styles', array( MainWP_System_View::get_class_name(), 'admin_print_styles' ) );
258 + /**
259 + * WordPress Database instance.
260 + *
261 + * @global object $wpdb
262 + */
263 + global $wpdb;
224 264
225 - add_action( 'wp_logout', array( &$this, 'clear_sessions' ) );
265 + if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
266 + $alloptions = wp_cache_get( 'alloptions', 'options' );
267 + } else {
268 + $alloptions = false;
269 + }
226 270
227 - MainWP_Install_Bulk::init();
271 + if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
272 + $notoptions = wp_cache_get( 'notoptions', 'options' );
273 + } else {
274 + $notoptions = false;
275 + }
228 276
229 - MainWP_System_Cron_Jobs::instance()->init_cron_jobs();
277 + if ( ! isset( $alloptions['mainwp_db_version'] ) ) {
278 + $suppress = $wpdb->suppress_errors();
279 + $options = array(
280 + 'mainwp_db_version',
281 + 'mainwp_plugin_version',
282 + 'mainwp_upgradeVersionInfo',
283 + 'mainwp_extensions',
284 + 'mainwp_activated',
285 + 'mainwp_api_sslVerifyCertificate',
286 + 'mainwp_automaticDailyUpdate',
287 + 'mainwp_backup_before_upgrade',
288 + 'mainwp_enableLegacyBackupFeature',
289 + 'mainwp_hide_twitters_message',
290 + 'mainwp_maximumInstallUpdateRequests',
291 + 'mainwp_maximumSyncRequests',
292 + 'mainwp_primaryBackup',
293 + 'mainwp_security',
294 + 'mainwp_use_favicon',
295 + 'mainwp_wp_cron',
296 + 'mainwp_timeDailyUpdate',
297 + 'mainwp_frequencyDailyUpdate',
298 + 'mainwp_delay_autoupdate',
299 + 'mainwp_wpcreport_extension',
300 + 'mainwp_daily_digest_plain_text',
301 + 'mainwp_enable_managed_cr_for_wc',
302 + 'mainwp_hide_update_everything',
303 + 'mainwp_number_overview_columns',
304 + 'mainwp_number_clients_overview_columns',
305 + 'mainwp_disable_update_confirmations',
306 + 'mainwp_settings_show_widgets',
307 + 'mainwp_clients_show_widgets',
308 + 'mainwp_settings_show_manage_sites_columns',
309 + 'mainwp_disableSitesChecking',
310 + 'mainwp_disableSitesHealthMonitoring',
311 + 'mainwp_frequencySitesChecking',
312 + 'mainwp_sitehealthThreshold',
313 + 'mainwp_settings_notification_emails',
314 + 'mainwp_ignore_HTTP_response_status',
315 + 'mainwp_check_http_response',
316 + 'mainwp_extmenu',
317 + 'mainwp_opensslLibLocation',
318 + 'mwp_setup_opensslLibLocation',
319 + 'mainwp_notice_wp_mail_failed',
320 + 'mainwp_show_language_updates',
321 + 'mainwp_logger_check_daily',
322 + 'mainwp_site_actions_notification_enable',
323 + );
230 324
231 - add_action( 'mainwp_after_header', array( MainWP_System_View::get_class_name(), 'admin_notices' ) );
232 - add_action( 'admin_notices', array( MainWP_System_View::get_class_name(), 'wp_admin_notices' ) );
233 - add_action( 'wp_mail_failed', array( &$this, 'wp_mail_failed' ) );
325 + $query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in (";
326 + foreach ( $options as $option ) {
327 + $query .= "'" . $option . "', ";
328 + }
329 + $query = substr( $query, 0, strlen( $query ) - 2 );
330 + $query .= ")"; // phpcs:ignore -- ignore double quotes auto-correction.
331 + $alloptions_db = $wpdb->get_results( $query ); // phpcs:ignore -- unprepared SQL ok.
332 + $wpdb->suppress_errors( $suppress );
333 + if ( ! is_array( $alloptions ) ) {
334 + $alloptions = array();
335 + }
336 + if ( is_array( $alloptions_db ) ) {
337 + foreach ( (array) $alloptions_db as $o ) {
338 + $alloptions[ $o->option_name ] = $o->option_value;
339 + unset( $options[ array_search( $o->option_name, $options ) ] );
340 + }
341 + if ( ! is_array( $notoptions ) ) {
342 + $notoptions = array();
343 + }
344 + foreach ( $options as $option ) {
345 + $notoptions[ $option ] = true;
346 + }
347 + if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
348 + wp_cache_set( 'alloptions', $alloptions, 'options' );
349 + wp_cache_set( 'notoptions', $notoptions, 'options' );
350 + }
351 + }
352 + }
234 353
235 - add_action( 'after_plugin_row', array( MainWP_System_View::get_class_name(), 'after_extensions_plugin_row' ), 10, 3 );
354 + return $alloptions;
355 + }
236 356
237 - add_filter( 'mainwp-activated-check', array( &$this, 'activated_check' ) ); // @deprecated Use 'mainwp_activated_check' instead.
238 - add_filter( 'mainwp_activated_check', array( &$this, 'activated_check' ) );
357 + /**
358 + * Method parse_request()
359 + *
360 + * Includes api.php.
361 + */
362 + public function parse_request() {
363 + include_once MAINWP_PLUGIN_DIR . 'includes/api.php';
364 + }
239 365
240 - do_action_deprecated( 'mainwp-activated', array(), '4.0.7.2', 'mainwp_activated' ); // @deprecated Use 'mainwp_activated' instead. NOSONAR - not IP.
366 + /**
367 + * Method localization()
368 + *
369 + * Loads plugin language files.
370 + */
371 + public function localization() {
372 + $load = apply_filters( 'mainwp_load_text_domain', true );
373 + if ( $load ) {
374 + load_plugin_textdomain( 'mainwp', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
375 + }
376 + }
241 377
242 - /**
243 - * Action: mainwp_activated
244 - *
245 - * Fires upon MainWP plugin activation.
246 - *
247 - * @since Unknown
248 - */
249 - do_action( 'mainwp_activated' );
378 + /**
379 + * Method wp_mail_failed()
380 + *
381 + * Check if there has been a wp mail failer.
382 + *
383 + * @param string $error Array of error messages.
384 + *
385 + * @uses \MainWP\Dashboard\MainWP_Logger::debug()
386 + * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
387 + */
388 + public function wp_mail_failed( $error ) {
389 + $mail_failed = get_option( 'mainwp_notice_wp_mail_failed' );
390 + if ( is_object( $error ) && empty( $mail_failed ) ) {
391 + MainWP_Utility::update_option( 'mainwp_notice_wp_mail_failed', 'yes' );
392 + $er = $error->get_error_message();
393 + if ( ! empty( $er ) ) {
394 + MainWP_Logger::instance()->debug( 'Error :: wp_mail :: [error=' . $er . ']' );
395 + }
396 + }
397 + }
250 398
251 - MainWP_Updates::init();
252 - MainWP_Post::init();
253 - MainWP_Settings::init();
254 - if ( get_option( 'mainwp_enableLegacyBackupFeature' ) ) {
255 - MainWP_Manage_Backups::init();
256 - }
257 - MainWP_Manage_Groups::init();
258 - MainWP_User::init();
259 - MainWP_Page::init();
260 - MainWP_Themes::init();
261 - MainWP_Plugins::init();
262 - MainWP_Updates_Overview::init();
263 - MainWP_Client::init();
264 - MainWP_Rest_Api_Page::init();
265 - MainWP_Non_MainWP_Actions::instance();
399 + /**
400 + * Method get_version()
401 + *
402 + * Get current plugin version.
403 + *
404 + * @return string Current plugin version.
405 + */
406 + public function get_version() {
407 + return $this->current_version;
408 + }
266 409
267 - if ( defined( 'WP_CLI' ) && WP_CLI ) {
268 - MainWP_WP_CLI_Command::init();
269 - }
270 - if ( defined( 'DOING_CRON' ) && DOING_CRON && isset( $_GET['mainwp_run'] ) && 'test' === $_GET['mainwp_run'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
271 - add_action( 'init', array( MainWP_System_Cron_Jobs::instance(), 'cron_active' ), PHP_INT_MAX );
272 - }
273 - }
410 + /**
411 + * Method mainwp_cronpingchilds_action()
412 + *
413 + * Run cron ping child's action.
414 + *
415 + * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_ping_childs()
416 + */
417 + public function mainwp_cronpingchilds_action() {
418 + MainWP_System_Cron_Jobs::instance()->cron_ping_childs();
419 + }
274 420
275 - /**
276 - * Method get_dashboard_version()
277 - *
278 - * Get dashboard version.
279 - *
280 - * @return string $version Version.
281 - */
282 - public function get_dashboard_version() {
283 - return static::$version;
284 - }
421 + /**
422 + * Method mainwp_cronbackups_continue_action()
423 + *
424 + * Run cron backups continue action.
425 + *
426 + * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_backups_continue()
427 + */
428 + public function mainwp_cronbackups_continue_action() {
429 + MainWP_System_Cron_Jobs::instance()->cron_backups_continue();
430 + }
285 431
286 - /**
287 - * Method load_all_options()
288 - *
289 - * Load all wp_options data.
290 - *
291 - * @return array $alloptions Array of all options.
292 - */
293 - public function load_all_options() { //phpcs:ignore -- NOSONAR - complex.
432 + /**
433 + * Method mainwp_cronbackups_action()
434 + *
435 + * Run cron backups action.
436 + *
437 + * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_backups()
438 + */
439 + public function mainwp_cronbackups_action() {
440 + MainWP_System_Cron_Jobs::instance()->cron_backups();
441 + }
294 442
295 - /**
296 - * WordPress Database instance.
297 - *
298 - * @global object $wpdb
299 - */
300 - global $wpdb;
443 + /**
444 + * Method mainwp_cronstats_action()
445 + *
446 + * Run cron stats action.
447 + *
448 + * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_stats()
449 + */
450 + public function mainwp_cronstats_action() {
451 + MainWP_System_Cron_Jobs::instance()->cron_stats();
452 + }
301 453
302 - if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
303 - $alloptions = wp_cache_get( 'alloptions', 'options' );
304 - } else {
305 - $alloptions = false;
306 - }
454 + /**
455 + * Method mainwp_cronupdatescheck_action()
456 + *
457 + * Run cron updates check action.
458 + *
459 + * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_updates_check()
460 + */
461 + public function mainwp_cronupdatescheck_action() {
462 + MainWP_System_Cron_Jobs::instance()->cron_updates_check();
463 + }
307 464
308 - if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
309 - $notoptions = wp_cache_get( 'notoptions', 'options' );
310 - } else {
311 - $notoptions = false;
312 - }
465 + /**
466 + * Method mainwp_croncheckstatus_action()
467 + *
468 + * Run cron check sites status action.
469 + *
470 + * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_check_websites_status()
471 + */
472 + public function mainwp_croncheckstatus_action() {
473 + MainWP_System_Cron_Jobs::instance()->cron_check_websites_status();
474 + }
313 475
314 - if ( ! isset( $alloptions['mainwp_db_version'] ) ) {
315 - $suppress = $wpdb->suppress_errors();
316 - $options = array(
317 - 'mainwp_db_version',
318 - 'mainwp_plugin_version',
319 - 'mainwp_upgradeVersionInfo',
320 - 'mainwp_extensions',
321 - 'mainwp_activated',
322 - 'mainwp_api_sslVerifyCertificate',
323 - 'mainwp_automaticDailyUpdate',
324 - 'mainwp_pluginAutomaticDailyUpdate',
325 - 'mainwp_themeAutomaticDailyUpdate',
326 - 'mainwp_backup_before_upgrade',
327 - 'mainwp_enableLegacyBackupFeature',
328 - 'mainwp_maximumInstallUpdateRequests',
329 - 'mainwp_maximumSyncRequests',
330 - 'mainwp_primaryBackup',
331 - 'mainwp_security',
332 - 'mainwp_use_favicon',
333 - 'mainwp_wp_cron',
334 - 'mainwp_timeDailyUpdate',
335 - 'mainwp_frequencyDailyUpdate',
336 - 'mainwp_delay_autoupdate',
337 - 'mainwp_wpcreport_extension',
338 - 'mainwp_daily_digest_plain_text',
339 - 'mainwp_hide_update_everything',
340 - 'mainwp_disable_update_confirmations',
341 - 'mainwp_settings_show_widgets',
342 - 'mainwp_clients_show_widgets',
343 - 'mainwp_settings_show_manage_sites_columns',
344 - 'mainwp_disableSitesChecking',
345 - 'mainwp_disableSitesHealthMonitoring',
346 - 'mainwp_frequencySitesChecking',
347 - 'mainwp_sitehealthThreshold',
348 - 'mainwp_settings_notification_emails',
349 - 'mainwp_ignore_HTTP_response_status',
350 - 'mainwp_check_http_response',
351 - 'mainwp_extmenu',
352 - 'mainwp_opensslLibLocation',
353 - 'mainwp_notice_wp_mail_failed',
354 - 'mainwp_show_language_updates',
355 - 'mainwp_logger_check_daily',
356 - 'mainwp_site_actions_notification_enable',
357 - 'mainwp_update_check_version',
358 - 'mainwp_setting_demo_mode_enabled',
359 - 'mainwp_log_wait_lasttime',
360 - 'mainwp_updatescheck_start_last_schedule_timestamp',
361 - 'mainwp_cron_license_deactivated_alert_lasttime',
362 - 'mainwp_updatescheck_is_running',
363 - 'mainwp_automatic_updates_is_running',
364 - 'mainwp_frequency_AutoUpdate',
365 - 'mainwp_batch_updates_is_running',
366 - 'mainwp_batch_individual_updates_is_running',
476 + /**
477 + * Method mainwp_cronchecksitehealth_action()
478 + *
479 + * Run cron check sites health action.
480 + *
481 + * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_check_websites_health()
482 + */
483 + public function mainwp_cronchecksitehealth_action() {
484 + MainWP_System_Cron_Jobs::instance()->cron_check_websites_health();
485 + }
367 486
368 - );
487 + /**
488 + * Method is_mainwp_pages()
489 + *
490 + * Get the current page and check it for "mainwp_".
491 + *
492 + * @return boolean ture|false.
493 + */
494 + public static function is_mainwp_pages() {
495 + $screen = get_current_screen();
496 + if ( $screen && strpos( $screen->base, 'mainwp_' ) !== false && strpos( $screen->base, 'mainwp_child_tab' ) === false ) {
497 + return true;
498 + }
369 499
370 - $options = apply_filters( 'mainwp_init_load_all_options', $options );
500 + return false;
501 + }
371 502
372 - $query = "SELECT option_name, option_value FROM $wpdb->options WHERE option_name in (";
373 - foreach ( $options as $option ) {
374 - $query .= "'" . $option . "', ";
375 - }
376 - $query = substr( $query, 0, strlen( $query ) - 2 );
377 - $query .= ")"; // phpcs:ignore -- ignore double quotes auto-correction.
378 - $alloptions_db = $wpdb->get_results( $query ); // phpcs:ignore -- unprepared SQL ok.
379 - $wpdb->suppress_errors( $suppress );
380 - if ( ! is_array( $alloptions ) ) {
381 - $alloptions = array();
382 - }
383 - if ( is_array( $alloptions_db ) ) {
384 - foreach ( (array) $alloptions_db as $o ) {
385 - $alloptions[ $o->option_name ] = $o->option_value;
386 - unset( $options[ array_search( $o->option_name, $options ) ] );
387 - }
388 - if ( ! is_array( $notoptions ) ) {
389 - $notoptions = array();
390 - }
391 - foreach ( $options as $option ) {
392 - $notoptions[ $option ] = true;
393 - }
394 - if ( ! defined( 'WP_INSTALLING' ) || ! is_multisite() ) {
395 - wp_cache_set( 'alloptions', $alloptions, 'options' );
396 - wp_cache_set( 'notoptions', $notoptions, 'options' );
397 - }
398 - }
399 - }
503 + /**
504 + * Method init()
505 + *
506 + * Instantiate Plugin.
507 + */
508 + public function init() {
400 509
401 - return $alloptions;
402 - }
510 + /**
511 + * MainWP disabled menu items array.
512 + *
513 + * @global object $_mainwp_disable_menus_items
514 + */
515 + global $_mainwp_disable_menus_items;
403 516
404 - /**
405 - * Method localization()
406 - *
407 - * Loads plugin language files.
408 - */
409 - public function localization() {
410 - $load = apply_filters( 'mainwp_load_text_domain', true );
411 - if ( $load ) {
412 - load_plugin_textdomain( 'mainwp', false, dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' );
413 - }
414 - }
517 + $_mainwp_disable_menus_items = apply_filters( 'mainwp_disablemenuitems', $_mainwp_disable_menus_items );
415 518
416 - /**
417 - * Method wp_mail_failed()
418 - *
419 - * Check if there has been a wp mail failer.
420 - *
421 - * @param string $error Array of error messages.
422 - *
423 - * @uses \MainWP\Dashboard\MainWP_Logger::debug()
424 - * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
425 - */
426 - public function wp_mail_failed( $error ) {
427 - $mail_failed = get_option( 'mainwp_notice_wp_mail_failed' );
428 - if ( is_object( $error ) && empty( $mail_failed ) ) {
429 - MainWP_Utility::update_option( 'mainwp_notice_wp_mail_failed', 'yes' );
430 - $er = $error->get_error_message();
431 - if ( ! empty( $er ) ) {
432 - MainWP_Logger::instance()->debug( 'Error :: wp_mail :: [error=' . $er . ']' );
433 - }
434 - }
435 - }
519 + /**
520 + * Filter: mainwp_main_menu_disable_menu_items
521 + *
522 + * Filters disabled MainWP navigation items.
523 + *
524 + * @since Unknown
525 + */
526 + $_mainwp_disable_menus_items = apply_filters( 'mainwp_main_menu_disable_menu_items', $_mainwp_disable_menus_items );
436 527
437 - /**
438 - * Method get_version()
439 - *
440 - * Get current plugin version.
441 - *
442 - * @return string Current plugin version.
443 - */
444 - public function get_version() {
445 - return $this->current_version;
446 - }
528 + if ( ! function_exists( 'MainWP\Dashboard\mainwp_current_user_have_right' ) ) {
447 529
448 - /**
449 - * Method mainwp_cronpingchilds_action()
450 - *
451 - * Run cron ping child's action.
452 - *
453 - * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_ping_childs()
454 - */
455 - public function mainwp_cronpingchilds_action() {
456 - MainWP_System_Cron_Jobs::instance()->cron_ping_childs();
457 - }
530 + /**
531 + * Method mainwp_current_user_have_right()
532 + *
533 + * Check permission level by hook mainwp_currentusercan of Team Control extension.
534 + *
535 + * @param string $cap_type group or type of capabilities.
536 + * @param string $cap capabilities for current user.
537 + *
538 + * @return bool true|false
539 + *
540 + * @uses \MainWP\Dashboard\MainWP_System_Handler::handle_settings_post()
541 + */
542 + function mainwp_current_user_have_right( $cap_type = '', $cap = '' ) {
458 543
459 - /**
460 - * Method mainwp_cronbackups_continue_action()
461 - *
462 - * Run cron backups continue action.
463 - *
464 - * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_backups_continue()
465 - */
466 - public function mainwp_cronbackups_continue_action() {
467 - MainWP_System_Cron_Jobs::instance()->cron_backups_continue();
468 - }
544 + /**
545 + * Current user global.
546 + *
547 + * @global string
548 + */
549 + global $current_user;
469 550
470 - /**
471 - * Method mainwp_cronbackups_action()
472 - *
473 - * Run cron backups action.
474 - *
475 - * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_backups()
476 - */
477 - public function mainwp_cronbackups_action() {
478 - MainWP_System_Cron_Jobs::instance()->cron_backups();
479 - }
551 + if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
552 + return true;
553 + }
480 554
481 - /**
482 - * Method mainwp_cronreconnect_action()
483 - *
484 - * Run cron stats action.
485 - *
486 - * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_reconnect()
487 - */
488 - public function mainwp_cronreconnect_action() {
489 - MainWP_System_Cron_Jobs::instance()->cron_reconnect();
490 - }
555 + if ( defined( 'WP_CLI' ) && WP_CLI ) {
556 + return true;
557 + }
491 558
492 - /**
493 - * Method mainwp_cronupdatescheck_action()
494 - *
495 - * Run cron updates check action.
496 - *
497 - * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_updates_check()
498 - */
499 - public function mainwp_cronupdatescheck_action() {
500 - MainWP_System_Cron_Jobs::instance()->cron_updates_check();
501 - }
559 + if ( defined( 'MAINWP_REST_API' ) && MAINWP_REST_API ) {
560 + return true;
561 + }
502 562
503 - /**
504 - * Method mainwp_crondeactivatedlicensesalert_action()
505 - *
506 - * Run cron activated licenses alert action.
507 - */
508 - public function mainwp_crondeactivatedlicensesalert_action() {
509 - MainWP_System_Cron_Jobs::instance()->cron_deactivated_licenses_alert();
510 - }
563 + if ( empty( $current_user ) ) {
564 + if ( ! function_exists( 'wp_get_current_user' ) ) {
565 + require_once ABSPATH . WPINC . '/pluggable.php';
566 + }
567 + }
511 568
512 - /**
513 - * Method mainwp_croncheckstatus_action()
514 - *
515 - * Run cron check sites status action.
516 - *
517 - * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_check_websites_status()
518 - */
519 - public function mainwp_croncheckstatus_action() {
520 - MainWP_System_Cron_Jobs::instance()->cron_check_websites_status();
521 - }
569 + return apply_filters( 'mainwp_currentusercan', true, $cap_type, $cap );
570 + }
571 + }
522 572
523 - /**
524 - * Method mainwp_cronchecksitehealth_action()
525 - *
526 - * Run cron check sites health action.
527 - *
528 - * @uses \MainWP\Dashboard\MainWP_System_Cron_Jobs::cron_check_websites_health()
529 - */
530 - public function mainwp_cronchecksitehealth_action() {
531 - MainWP_System_Cron_Jobs::instance()->cron_check_websites_health();
532 - }
573 + MainWP_System_Handler::instance()->handle_settings_post();
574 + }
533 575
534 - /**
535 - * Method is_mainwp_pages()
536 - *
537 - * Get the current page and check it for "mainwp_".
538 - *
539 - * @return boolean ture|false.
540 - */
541 - public static function is_mainwp_pages() {
542 - $screen = get_current_screen();
543 - if ( $screen && strpos( $screen->base, 'mainwp_' ) !== false && strpos( $screen->base, 'mainwp_child_tab' ) === false ) {
544 - return true;
545 - }
576 + /**
577 + * Method parse_init()
578 + *
579 + * Initiate plugin installation & then run the Quick Setup Wizard.
580 + *
581 + * @uses \MainWP\Dashboard\MainWP_System_Handler::upload_file()
582 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_mainwp_dir()
583 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_wp_file_system()
584 + * @uses \MainWP\Dashboard\MainWP_System_Utility::is_admin()
585 + * @uses \MainWP\Dashboard\MainWP_Setup_Wizard()
586 + */
587 + public function parse_init() {
588 + if ( isset( $_GET['mwpdl'] ) && isset( $_GET['sig'] ) ) {
589 + $mwpDir = MainWP_System_Utility::get_mainwp_dir();
590 + $mwpDir = $mwpDir[0];
591 + $mwpdl = isset( $_REQUEST['mwpdl'] ) ? wp_unslash( $_REQUEST['mwpdl'] ) : '';
592 + $file = trailingslashit( $mwpDir ) . rawurldecode( $mwpdl );
546 593
547 - return false;
548 - }
594 + if ( stristr( rawurldecode( $mwpdl ), '..' ) ) {
595 + return;
596 + }
549 597
550 - /**
551 - * Method is_mainwp_site_page()
552 - *
553 - * Checks if the current page is under the site mode.
554 - *
555 - * @return boolean ture|false.
556 - */
557 - public static function is_mainwp_site_page() {
558 - //phpcs:disable WordPress.Security.NonceVerification.Recommended
559 - if ( isset( $_GET['page'] ) && 'CostTrackerAdd' !== $_GET['page'] && ( ( ( isset( $_GET['id'] ) && ! empty( $_GET['id'] ) ) || ( isset( $_GET['dashboard'] ) && ! empty( $_GET['dashboard'] ) ) || ( isset( $_GET['updateid'] ) && ! empty( $_GET['updateid'] ) ) || ( isset( $_GET['emailsettingsid'] ) && ! empty( $_GET['emailsettingsid'] ) ) || ( isset( $_GET['scanid'] ) && ! empty( $_GET['scanid'] ) ) ) || ( 'ServerInformation' === $_GET['page'] || 'ServerInformationCron' === $_GET['page'] || 'ErrorLog' === $_GET['page'] || 'ActionLogs' === $_GET['page'] || 'PluginPrivacy' === $_GET['page'] || 'Settings' === $_GET['page'] || 'SettingsAdvanced' === $_GET['page'] || 'SettingsEmail' === $_GET['page'] || 'MainWPTools' === $_GET['page'] || 'SettingsInsights' === $_GET['page'] || 'SettingsApiBackups' === $_GET['page'] ) ) ) {
560 - return true;
561 - }
562 - //phpcs:enable
563 - return false;
564 - }
598 + $hasWPFileSystem = MainWP_System_Utility::get_wp_file_system();
565 599
566 - /**
567 - * Method init()
568 - *
569 - * Instantiate Plugin.
570 - */
571 - public function init() { //phpcs:ignore -- NOSONAR - complex.
600 + /**
601 + * WordPress files system object.
602 + *
603 + * @global object
604 + */
605 + global $wp_filesystem;
606 + $sig_value = wp_unslash( $_GET['sig'] );
607 + $valid_sig = MainWP_System_Utility::valid_download_sig( $file, $sig_value );
572 608
573 - /**
574 - * MainWP disabled menu items array.
575 - *
576 - * @global object $_mainwp_disable_menus_items
577 - */
578 - global $_mainwp_disable_menus_items;
609 + if ( ! $valid_sig ) {
610 + MainWP_Logger::instance()->debug( ' :: download :: invalid sig :: ' . base64_decode( $sig_value ) ); // phpcs:ignore -- for debug logging.
611 + }
579 612
580 - $_mainwp_disable_menus_items = apply_filters( 'mainwp_disablemenuitems', $_mainwp_disable_menus_items );
613 + if ( $hasWPFileSystem && $wp_filesystem->exists( $file ) && $valid_sig ) {
614 + MainWP_System_Handler::instance()->upload_file( $file );
615 + exit();
616 + }
617 + } elseif ( isset( $_GET['page'] ) ) {
618 + if ( MainWP_System_Utility::is_admin() ) {
619 + switch ( $_GET['page'] ) {
620 + case 'mainwp-setup':
621 + new MainWP_Setup_Wizard();
622 + break;
623 + }
624 + }
625 + }
626 + }
581 627
582 - /**
583 - * Filter: mainwp_main_menu_disable_menu_items
584 - *
585 - * Filters disabled MainWP navigation items.
586 - *
587 - * @since Unknown
588 - */
589 - $_mainwp_disable_menus_items = apply_filters( 'mainwp_main_menu_disable_menu_items', $_mainwp_disable_menus_items );
628 + /**
629 + * Method login_form_redirect()
630 + *
631 + * Login redirect.
632 + */
633 + public function login_form_redirect() {
590 634
591 - if ( ! function_exists( 'MainWP\Dashboard\mainwp_current_user_have_right' ) ) {
635 + /**
636 + * Redirect to global.
637 + *
638 + * @global string $redirect_to
639 + */
640 + global $redirect_to;
641 + if ( ! isset( $_GET['redirect_to'] ) ) {
642 + $redirect_to = get_admin_url() . 'index.php';
643 + }
644 + }
592 645
593 - /**
594 - * Method mainwp_current_user_have_right()
595 - *
596 - * Check permission level by hook mainwp_currentusercan of Team Control extension.
597 - *
598 - * @param string $cap_type group or type of capabilities.
599 - * @param string $cap capabilities for current user.
600 - *
601 - * @return bool true|false
602 - *
603 - * @uses \MainWP\Dashboard\MainWP_System_Handler::handle_settings_post()
604 - */
605 - function mainwp_current_user_have_right( $cap_type = '', $cap = '' ) {
646 + /**
647 + * Method after_setup_theme()
648 + *
649 + * After setup theme hook, to support post thumbnails.
650 + */
651 + public function after_setup_theme() {
652 + add_theme_support( 'post-thumbnails' );
653 + }
606 654
607 - /**
608 - * Current user global.
609 - *
610 - * @global string
611 - */
612 - global $current_user;
655 + /**
656 + * Method admin_init()
657 + *
658 + * Do nothing if current user is not an Admin else display the page.
659 + *
660 + * @uses \MainWP\Dashboard\MainWP_Post_Backup_Handler::init()
661 + * @uses \MainWP\Dashboard\MainWP_Post_Extension_Handler::init()
662 + * @uses \MainWP\Dashboard\MainWP_Post_Handler::init()
663 + * @uses \MainWP\Dashboard\MainWP_Post_Plugin_Theme_Handler::init()
664 + * @uses \MainWP\Dashboard\MainWP_Post_Site_Handler::init()
665 + * @uses \MainWP\Dashboard\MainWP_System_Handler::activate_extension()
666 + * @uses \MainWP\Dashboard\MainWP_System_Utility::is_admin()
667 + * @uses \MainWP\Dashboard\MainWP_System_View::get_class_name()
668 + * @uses \MainWP\Dashboard\MainWP_System_View::get_mainwp_translations()
669 + * @uses \MainWP\Dashboard\MainWP_Twitter::enabled_twitter_messages()
670 + */
671 + public function admin_init() { // phpcs:ignore -- complex function.
613 672
614 - if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
615 - return true;
616 - }
673 + if ( ! MainWP_System_Utility::is_admin() ) {
674 + return;
675 + }
617 676
618 - if ( defined( 'WP_CLI' ) && WP_CLI ) {
619 - return true;
620 - }
677 + add_action( 'mainwp_activate_extention', array( MainWP_System_Handler::instance(), 'activate_extension' ), 10, 2 ); // @deprecated Use 'mainwp_activate_extension' instead.
678 + add_action( 'mainwp_deactivate_extention', array( MainWP_System_Handler::instance(), 'deactivate_extension' ), 10, 1 ); // @deprecated Use 'mainwp_deactivate_extension' instead.
621 679
622 - if ( defined( 'MAINWP_REST_API_DOING' ) && MAINWP_REST_API_DOING ) {
623 - return true;
624 - }
680 + add_action( 'mainwp_activate_extension', array( MainWP_System_Handler::instance(), 'activate_extension' ), 10, 2 );
681 + add_action( 'mainwp_deactivate_extension', array( MainWP_System_Handler::instance(), 'deactivate_extension' ), 10, 1 );
625 682
626 - if ( empty( $current_user ) && ! function_exists( 'wp_get_current_user' ) ) {
627 - require_once ABSPATH . WPINC . '/pluggable.php'; // NOSONAR - WP compatible.
628 - }
683 + /**
684 + * MainWP use external primary backup method.
685 + *
686 + * @global string
687 + */
688 + global $mainwpUseExternalPrimaryBackupsMethod;
629 689
630 - return apply_filters( 'mainwp_currentusercan', true, $cap_type, $cap );
631 - }
632 - }
690 + if ( null === $mainwpUseExternalPrimaryBackupsMethod ) {
691 + $return = '';
633 692
634 - MainWP_System_Handler::instance()->handle_settings_post();
635 - }
693 + /*
694 + * @deprecated Use 'mainwp_getprimarybackup_activated' instead.
695 + *
696 + */
697 + $return = apply_filters_deprecated( 'mainwp-getprimarybackup-activated', array( $return ), '4.0.7.2', 'mainwp_getprimarybackup_activated' );
698 + $mainwpUseExternalPrimaryBackupsMethod = apply_filters( 'mainwp_getprimarybackup_activated', $return );
699 + }
636 700
637 - /**
638 - * Method parse_init()
639 - *
640 - * Initiate plugin installation & then run the Quick Setup Wizard.
641 - *
642 - * @uses \MainWP\Dashboard\MainWP_System_Handler::upload_file()
643 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_mainwp_dir()
644 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_wp_file_system()
645 - * @uses \MainWP\Dashboard\MainWP_System_Utility::is_admin()
646 - * @uses \MainWP\Dashboard\MainWP_Setup_Wizard()
647 - */
648 - public function parse_init() {
649 - // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
650 - if ( isset( $_GET['mwpdl'] ) && isset( $_GET['sig'] ) ) {
651 - $mwpDir = MainWP_System_Utility::get_mainwp_dir();
652 - $mwpDir = $mwpDir[0];
653 - $mwpdl = isset( $_REQUEST['mwpdl'] ) ? wp_unslash( $_REQUEST['mwpdl'] ) : '';
654 - $file = trailingslashit( $mwpDir ) . rawurldecode( $mwpdl );
701 + add_action( 'mainwp_before_header', array( MainWP_System_View::get_class_name(), 'mainwp_warning_notice' ) );
655 702
656 - if ( stristr( rawurldecode( $mwpdl ), '..' ) ) {
657 - return;
658 - }
703 + MainWP_Post_Handler::instance()->init();
704 + MainWP_Post_Site_Handler::instance()->init();
705 + MainWP_Post_Plugin_Theme_Handler::instance()->init();
706 + MainWP_Post_Extension_Handler::instance()->init();
707 + MainWP_Post_Backup_Handler::instance()->init();
659 708
660 - $hasWPFileSystem = MainWP_System_Utility::get_wp_file_system();
709 + /**
710 + * Initiate MainWP Cache Control Class.
711 + *
712 + * @since 4.2
713 + */
714 + MainWP_Auto_Cache_Purge_View::instance()->init();
661 715
662 - /**
663 - * WordPress files system object.
664 - *
665 - * @global object
666 - */
667 - global $wp_filesystem;
668 - $sig_value = wp_unslash( $_GET['sig'] );
669 - $valid_sig = MainWP_System_Utility::valid_download_sig( $file, $sig_value );
716 + /**
717 + * Filter: mainwp_ui_use_wp_calendar
718 + *
719 + * Filters whether default jQuery datepicker should be used to avoid potential problems with Senatic UI Calendar library.
720 + *
721 + * @since 4.0.5
722 + */
723 + $use_wp_datepicker = apply_filters( 'mainwp_ui_use_wp_calendar', false );
724 + if ( $use_wp_datepicker ) {
725 + wp_enqueue_script( 'jquery-ui-datepicker' );
726 + }
727 + wp_enqueue_script( 'jquery-ui-dialog' );
728 + $en_params = array( 'jquery-ui-dialog' );
729 + if ( $use_wp_datepicker ) {
730 + $en_params[] = 'jquery-ui-datepicker';
731 + }
732 + wp_enqueue_script( 'mainwp', MAINWP_PLUGIN_URL . 'assets/js/mainwp.js', $en_params, $this->current_version, true );
670 733
671 - if ( ! $valid_sig ) {
672 - MainWP_Logger::instance()->debug( ' :: download :: invalid sig :: ' . base64_decode( $sig_value ) ); // phpcs:ignore -- for debug logging.
673 - }
734 + $enableLegacyBackupFeature = get_option( 'mainwp_enableLegacyBackupFeature' );
735 + $primaryBackup = get_option( 'mainwp_primaryBackup' );
736 + $disable_backup_checking = true; // removed option.
674 737
675 - if ( $hasWPFileSystem && $wp_filesystem->exists( $file ) && $valid_sig ) {
676 - MainWP_System_Handler::instance()->upload_file( $file );
677 - exit();
678 - }
679 - } elseif ( isset( $_GET['page'] ) ) {
680 - if ( MainWP_System_Utility::is_admin() && 'mainwp-setup' === $_GET['page'] ) {
681 - MainWP_Setup_Wizard::get_instance();
682 - }
683 - }
684 - // phpcs:enable
685 - }
738 + $mainwpParams = array(
739 + 'image_url' => MAINWP_PLUGIN_URL . 'assets/images/',
740 + 'backup_before_upgrade' => ( get_option( 'mainwp_backup_before_upgrade' ) == 1 ),
741 + 'disable_checkBackupBeforeUpgrade' => $disable_backup_checking,
742 + 'admin_url' => admin_url(),
743 + 'use_wp_datepicker' => $use_wp_datepicker ? 1 : 0,
744 + 'date_format' => get_option( 'date_format' ),
745 + 'time_format' => get_option( 'time_format' ),
746 + 'enabledTwit' => MainWP_Twitter::enabled_twitter_messages(),
747 + 'maxSecondsTwit' => MAINWP_TWITTER_MAX_SECONDS,
748 + 'installedBulkSettingsManager' => is_plugin_active( 'mainwp-bulk-settings-manager/mainwp-bulk-settings-manager.php' ) ? 1 : 0,
749 + 'maximumSyncRequests' => ( get_option( 'mainwp_maximumSyncRequests' ) === false ) ? 8 : get_option( 'mainwp_maximumSyncRequests' ),
750 + 'maximumInstallUpdateRequests' => ( get_option( 'mainwp_maximumInstallUpdateRequests' ) === false ) ? 3 : get_option( 'mainwp_maximumInstallUpdateRequests' ),
751 + '_wpnonce' => wp_create_nonce( 'mainwp-admin-nonce' ),
752 + );
753 + wp_localize_script( 'mainwp', 'mainwpParams', $mainwpParams );
686 754
687 - /**
688 - * Method after_setup_theme()
689 - *
690 - * After setup theme hook, to support post thumbnails.
691 - */
692 - public function after_setup_theme() {
693 - add_theme_support( 'post-thumbnails' );
694 - }
755 + $mainwpTranslations = MainWP_System_View::get_mainwp_translations();
695 756
757 + wp_localize_script( 'mainwp', 'mainwpTranslations', $mainwpTranslations );
696 758
697 - /**
698 - * Method hook_admin_update_check()
699 - */
700 - public function hook_admin_update_check() {
701 - $current_ver = $this->check_ver_update;
702 - $saved_ver = get_option( 'mainwp_update_check_version', false );
759 + $security_nonces = MainWP_Post_Handler::instance()->create_security_nonces(); // to fix conflict with Post S M T P plugin.
760 + $nonces_filter = apply_filters( 'mainwp_security_nonces', array() );
761 + if ( is_array( $nonces_filter ) && ! empty( $nonces_filter ) ) {
762 + $security_nonces = array_merge( $security_nonces, $nonces_filter );
763 + }
764 + wp_localize_script( 'mainwp', 'security_nonces', $security_nonces );
703 765
704 - if ( false === $saved_ver ) {
705 - return;
706 - }
766 + wp_enqueue_script( 'thickbox' );
767 + wp_enqueue_script( 'user-profile' );
768 + wp_enqueue_style( 'thickbox' );
707 769
708 - if ( version_compare( $saved_ver, $current_ver, '=' ) ) {
709 - return;
710 - }
770 + $load_dragula = false;
711 771
712 - if ( version_compare( $saved_ver, '0.0.4', '<' ) ) {
713 - $sched = wp_next_scheduled( 'mainwp_cronstats_action' );
714 - if ( ! empty( $sched ) ) {
715 - wp_unschedule_event( $sched, 'mainwp_cronstats_action' );
716 - }
717 - global $wpdb;
718 - $wpdb->query( 'DELETE FROM ' . $wpdb->usermeta . ' WHERE meta_key = "mainwp_widgets_sorted_toplevel_page_mainwp_tab" OR meta_key="mainwp_settings_show_widgets"' );//phpcs:ignore -- safe.
719 - }
772 + if ( isset( $_GET['page'] ) && ( 'mainwp_tab' === $_GET['page'] || ( 'managesites' === $_GET['page'] && isset( $_GET['dashboard'] ) ) ) ) {
773 + $load_dragula = true;
774 + } elseif ( isset( $_GET['page'] ) && 'ManageClients' === $_GET['page'] && isset( $_GET['client_id'] ) ) {
775 + $load_dragula = true;
776 + } elseif ( isset( $_GET['page'] ) && 0 === strpos( $_GET['page'], 'ManageSites' ) ) { // individual page.
777 + $load_dragula = true;
778 + }
720 779
721 - if ( version_compare( $saved_ver, '0.0.5', '<' ) ) {
722 - $all_ext = MainWP_Extensions_View::get_available_extensions();
723 - foreach ( $all_ext as $slug => $info ) {
724 - $data = MainWP_Api_Manager::instance()->get_activation_info( $slug );
725 - if ( is_array( $data ) && isset( $data['api_key'] ) ) {
726 - $data['api_key'] = '';
727 - $data['activated_key'] = 'Deactivated';
728 - MainWP_Api_Manager::instance()->set_activation_info( $slug, $data );
729 - }
730 - }
731 - update_option( 'mainwp_extensions_all_activation_cached', '' );
732 - }
780 + if ( $load_dragula ) {
781 + wp_enqueue_script( 'dragula', MAINWP_PLUGIN_URL . 'assets/js/dragula/dragula.min.js', array(), $this->current_version, true );
782 + wp_enqueue_style( 'dragula', MAINWP_PLUGIN_URL . 'assets/js/dragula/dragula.min.css', array(), $this->current_version );
783 + }
733 784
734 - MainWP_Utility::update_option( 'mainwp_update_check_version', $current_ver );
735 - }
785 + if ( isset( $_GET['page'] ) && ( 'managesites' === $_GET['page'] || 'MonitoringSites' === $_GET['page'] || 'ManageGroups' === $_GET['page'] ) ) {
786 + wp_enqueue_script( 'preview', MAINWP_PLUGIN_URL . 'assets/js/preview.js', array(), $this->current_version, true );
787 + wp_enqueue_style( 'preview', MAINWP_PLUGIN_URL . 'assets/css/preview.css', array(), $this->current_version );
788 + }
736 789
737 - /**
738 - * Method admin_init()
739 - *
740 - * Do nothing if current user is not an Admin else display the page.
741 - *
742 - * @uses \MainWP\Dashboard\MainWP_Post_Backup_Handler::init()
743 - * @uses \MainWP\Dashboard\MainWP_Post_Extension_Handler::init()
744 - * @uses \MainWP\Dashboard\MainWP_Post_Handler::init()
745 - * @uses \MainWP\Dashboard\MainWP_Post_Plugin_Theme_Handler::init()
746 - * @uses \MainWP\Dashboard\MainWP_Post_Site_Handler::init()
747 - * @uses \MainWP\Dashboard\MainWP_System_Handler::activate_extension()
748 - * @uses \MainWP\Dashboard\MainWP_System_Utility::is_admin()
749 - * @uses \MainWP\Dashboard\MainWP_System_View::get_class_name()
750 - * @uses \MainWP\Dashboard\MainWP_System_View::get_mainwp_translations()
751 - */
752 - public function admin_init() { // phpcs:ignore -- NOSONAR - complex function.
790 + $this->init_session();
753 791
754 - if ( ! MainWP_System_Utility::is_admin() ) {
755 - return;
756 - }
792 + if ( ! current_user_can( 'update_core' ) ) {
793 + remove_action( 'admin_notices', 'update_nag', 3 );
794 + }
795 + }
757 796
758 - add_action( 'mainwp_activate_extention', array( MainWP_System_Handler::instance(), 'activate_extension' ), 10, 2 ); // @deprecated Use 'mainwp_activate_extension' instead.
759 - add_action( 'mainwp_deactivate_extention', array( MainWP_System_Handler::instance(), 'deactivate_extension' ), 10, 3 ); // @deprecated Use 'mainwp_deactivate_extension' instead.
797 + /**
798 + * Method admin_redirects()
799 + *
800 + * MainWP admin redirects.
801 + */
802 + public function admin_redirects() {
803 + if ( ( defined( 'DOING_CRON' ) && DOING_CRON ) || defined( 'DOING_AJAX' ) ) {
804 + return;
805 + }
760 806
761 - add_action( 'mainwp_activate_extension', array( MainWP_System_Handler::instance(), 'activate_extension' ), 10, 2 );
762 - add_action( 'mainwp_deactivate_extension', array( MainWP_System_Handler::instance(), 'deactivate_extension' ), 10, 3 );
807 + if ( ! empty( $_GET['page'] ) && in_array( $_GET['page'], array( 'mainwp-setup' ) ) ) {
808 + return;
809 + }
763 810
764 - /**
765 - * MainWP use external primary backup method.
766 - *
767 - * @global string
768 - */
769 - global $mainwpUseExternalPrimaryBackupsMethod;
811 + $quick_setup = get_option( 'mainwp_run_quick_setup', false );
812 + if ( 'yes' === $quick_setup ) {
813 + wp_safe_redirect( admin_url( 'admin.php?page=mainwp-setup' ) );
814 + exit;
815 + }
770 816
771 - if ( null === $mainwpUseExternalPrimaryBackupsMethod ) {
772 - $return = '';
817 + if ( 'yes' === get_option( 'mainwp_activated' ) ) {
818 + delete_option( 'mainwp_activated' );
819 + wp_cache_delete( 'mainwp_activated', 'options' );
820 + wp_cache_delete( 'alloptions', 'options' );
821 + wp_safe_redirect( admin_url( 'admin.php?page=mainwp_tab' ) );
773 822
774 - /*
775 - * @deprecated Use 'mainwp_getprimarybackup_activated' instead.
776 - *
777 - */
778 - $return = apply_filters_deprecated( 'mainwp-getprimarybackup-activated', array( $return ), '4.0.7.2', 'mainwp_getprimarybackup_activated' ); // NOSONAR - not IP.
779 - $mainwpUseExternalPrimaryBackupsMethod = apply_filters( 'mainwp_getprimarybackup_activated', $return );
780 - }
823 + return;
824 + }
781 825
782 - add_action( 'mainwp_after_header', array( MainWP_System_View::get_class_name(), 'mainwp_warning_notice' ) );
826 + $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '';
827 + $_pos = strlen( $request_uri ) - strlen( '/wp-admin/' );
828 + if ( ! empty( $request_uri ) && strpos( $request_uri, '/wp-admin/' ) !== false && strpos( $request_uri, '/wp-admin/' ) == $_pos ) {
829 + $referer = wp_get_referer();
830 + if ( ! empty( $referer ) && strpos( $referer, 'wp-login.php?redirect_to' ) !== false && strpos( $referer, '&reauth=1' ) !== false ) {
831 + if ( mainwp_current_user_have_right( 'dashboard', 'access_global_dashboard' ) ) {
832 + wp_safe_redirect( admin_url( 'admin.php?page=mainwp_tab' ) );
833 + die();
834 + }
835 + }
836 + }
783 837
784 - MainWP_Post_Handler::instance()->init();
785 - MainWP_Post_Site_Handler::instance()->init();
786 - MainWP_Post_Plugin_Theme_Handler::instance()->init();
787 - MainWP_Post_Extension_Handler::instance()->init();
788 - MainWP_Post_Backup_Handler::instance()->init();
789 - MainWP_Manage_Sites_Filter_Segment::get_instance()->admin_init();
838 + MainWP_Logger::instance()->check_log_daily();
839 + }
790 840
791 - /**
792 - * Filter: mainwp_ui_use_wp_calendar
793 - *
794 - * Filters whether default jQuery datepicker should be used to avoid potential problems with Senatic UI Calendar library.
795 - *
796 - * @since 4.0.5
797 - */
798 - $use_wp_datepicker = apply_filters( 'mainwp_ui_use_wp_calendar', false );
799 - if ( $use_wp_datepicker ) {
800 - wp_enqueue_script( 'jquery-ui-datepicker' );
801 - }
802 - wp_enqueue_script( 'jquery-ui-dialog' );
803 - $en_params = array( 'jquery-ui-dialog' );
804 - if ( $use_wp_datepicker ) {
805 - $en_params[] = 'jquery-ui-datepicker';
806 - }
807 - wp_enqueue_script( 'mainwp', MAINWP_PLUGIN_URL . 'assets/js/mainwp.js', $en_params, $this->current_version, true );
808 - $disable_backup_checking = true; // removed option.
809 - $mainwpParams = array(
810 - 'image_url' => MAINWP_PLUGIN_URL . 'assets/images/',
811 - 'backup_before_upgrade' => 1 === (int) get_option( 'mainwp_backup_before_upgrade' ),
812 - 'disable_checkBackupBeforeUpgrade' => $disable_backup_checking,
813 - 'admin_url' => admin_url(),
814 - 'use_wp_datepicker' => $use_wp_datepicker ? 1 : 0,
815 - 'date_format' => get_option( 'date_format' ),
816 - 'time_format' => get_option( 'time_format' ),
817 - 'installedBulkSettingsManager' => is_plugin_active( 'mainwp-bulk-settings-manager/mainwp-bulk-settings-manager.php' ) ? 1 : 0,
818 - 'maximumSyncRequests' => ( get_option( 'mainwp_maximumSyncRequests' ) === false ) ? 8 : get_option( 'mainwp_maximumSyncRequests' ),
819 - 'maximumInstallUpdateRequests' => ( get_option( 'mainwp_maximumInstallUpdateRequests' ) === false ) ? 3 : get_option( 'mainwp_maximumInstallUpdateRequests' ),
820 - '_wpnonce' => wp_create_nonce( 'mainwp-admin-nonce' ),
821 - 'demoMode' => MainWP_Demo_Handle::is_demo_mode() ? 1 : 0,
822 - 'roll_ui_icon' => MainWP_Updates_Helper::get_roll_icon( '', true ),
823 - );
824 - wp_localize_script( 'mainwp', 'mainwpParams', $mainwpParams );
841 + /**
842 + * Method init_session()
843 + *
844 + * Check current page & initiate a session.
845 + *
846 + * @uses \MainWP\Dashboard\MainWP_Cache::init_session()
847 + */
848 + public function init_session() {
849 + if ( isset( $_GET['page'] ) && in_array(
850 + $_GET['page'],
851 + array(
852 + 'PostBulkManage',
853 + 'PageBulkManage',
854 + 'PluginsManage',
855 + 'PluginsAutoUpdate',
856 + 'ThemesManage',
857 + 'ThemesAutoUpdate',
858 + 'UserBulkManage',
859 + )
860 + )
861 + ) {
862 + MainWP_Cache::init_session();
863 + }
864 + }
825 865
826 - $mainwpTranslations = MainWP_System_View::get_mainwp_translations();
866 + /**
867 + * Method clear_sessions()
868 + *
869 + * When logout clear the sessions to reset.
870 + */
871 + public function clear_sessions() {
872 + MainWP_Cache::init_session();
873 + $clear_cached = array(
874 + 'Post',
875 + 'Page',
876 + );
877 + foreach ( $clear_cached as $ca ) {
878 + MainWP_Cache::init_cache( $ca ); // to re-set cache.
879 + }
880 + }
827 881
828 - wp_localize_script( 'mainwp', 'mainwpTranslations', $mainwpTranslations );
882 + /**
883 + * Method admin_enqueue_scripts()
884 + *
885 + * Enqueue all Mainwp Admin Scripts.
886 + *
887 + * @param mixed $hook Enqueue hook.
888 + */
889 + public function admin_enqueue_scripts( $hook ) {
829 890
830 - $security_nonces = MainWP_Post_Handler::instance()->create_security_nonces(); // to fix conflict with Post S M T P plugin.
831 - $nonces_filter = apply_filters( 'mainwp_security_nonces', array() );
832 - if ( is_array( $nonces_filter ) && ! empty( $nonces_filter ) ) {
833 - $security_nonces = array_merge( $security_nonces, $nonces_filter );
834 - }
835 - wp_localize_script( 'mainwp', 'security_nonces', $security_nonces );
891 + $load_cust_scripts = false;
836 892
837 - wp_enqueue_script( 'thickbox' );
838 - wp_enqueue_script( 'user-profile' );
839 - wp_enqueue_style( 'thickbox' );
893 + /**
894 + * Current pagenow.
895 + *
896 + * @global string
897 + */
898 + global $pagenow;
840 899
841 - $load_gridster = false;
900 + if ( is_plugin_active( 'mainwp-custom-post-types/mainwp-custom-post-types.php' ) && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) {
901 + $load_cust_scripts = true;
902 + }
842 903
843 - // phpcs:disable WordPress.Security.NonceVerification
844 - if ( ( isset( $_GET['page'] ) && ( 'mainwp_tab' === $_GET['page'] || ( 'managesites' === $_GET['page'] && isset( $_GET['dashboard'] ) ) ) ) || ( isset( $_GET['page'] ) && 'ManageClients' === $_GET['page'] && isset( $_GET['client_id'] ) ) || ( isset( $_GET['page'] ) && 0 === strpos( wp_unslash( $_GET['page'] ), 'ManageSites' ) ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- individual page.
845 - $load_gridster = true;
846 - }
904 + if ( self::is_mainwp_pages() ) {
905 + wp_enqueue_script( 'jquery-migrate' );
906 + wp_enqueue_script( 'mainwp-updates', MAINWP_PLUGIN_URL . 'assets/js/mainwp-updates.js', array(), $this->current_version, true );
907 + wp_enqueue_script( 'mainwp-managesites-action', MAINWP_PLUGIN_URL . 'assets/js/mainwp-managesites-action.js', array(), $this->current_version, true );
908 + wp_enqueue_script( 'mainwp-managesites-update', MAINWP_PLUGIN_URL . 'assets/js/mainwp-managesites-update.js', array(), $this->current_version, true );
909 + wp_enqueue_script( 'mainwp-managesites-import', MAINWP_PLUGIN_URL . 'assets/js/mainwp-managesites-import.js', array(), $this->current_version, true );
910 + wp_enqueue_script( 'mainwp-plugins-themes', MAINWP_PLUGIN_URL . 'assets/js/mainwp-plugins-themes.js', array(), $this->current_version, true );
911 + wp_enqueue_script( 'mainwp-backups', MAINWP_PLUGIN_URL . 'assets/js/mainwp-backups.js', array(), $this->current_version, true );
912 + wp_enqueue_script( 'mainwp-posts', MAINWP_PLUGIN_URL . 'assets/js/mainwp-posts.js', array(), $this->current_version, true );
913 + wp_enqueue_script( 'mainwp-users', MAINWP_PLUGIN_URL . 'assets/js/mainwp-users.js', array(), $this->current_version, true );
914 + wp_enqueue_script( 'mainwp-clients', MAINWP_PLUGIN_URL . 'assets/js/mainwp-clients.js', array(), $this->current_version, true );
915 + wp_enqueue_script( 'mainwp-extensions', MAINWP_PLUGIN_URL . 'assets/js/mainwp-extensions.js', array(), $this->current_version, true );
916 + wp_enqueue_script( 'mainwp-moment', MAINWP_PLUGIN_URL . 'assets/js/moment/moment.min.js', array(), $this->current_version, true );
917 + wp_enqueue_script( 'fomantic-ui', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.js', array( 'jquery' ), $this->current_version, false );
847 918
848 - $load_gridster = apply_filters( 'mainwp_enqueue_script_gridster', $load_gridster );
919 + wp_enqueue_script( 'datatables', MAINWP_PLUGIN_URL . 'assets/js/datatables/jquery.dataTables.js', array( 'jquery' ), $this->current_version, false );
920 + wp_enqueue_script( 'datatables-semanticui', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.semanticui.js', array( 'jquery' ), $this->current_version, false );
921 + wp_enqueue_script( 'datatables-fixedColumns', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.fixedColumns.min.js', array( 'jquery' ), $this->current_version, false );
922 + wp_enqueue_script( 'datatables-scroller', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.scroller.js', array( 'jquery' ), $this->current_version, false );
923 + wp_enqueue_script( 'datatables-colreorder', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.colReorder.min.js', array( 'jquery' ), $this->current_version, false );
924 + wp_enqueue_script( 'datatables-responsive', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.responsive.min.js', array( 'jquery' ), $this->current_version, true );
849 925
850 - if ( $load_gridster ) {
851 - wp_enqueue_script( 'gridster', MAINWP_PLUGIN_URL . 'assets/js/gridster/jquery.dsmorse-gridster.js', array(), $this->current_version, true );
852 - wp_enqueue_style( 'gridster', MAINWP_PLUGIN_URL . 'assets/js/gridster/jquery.gridster.min.css', array(), $this->current_version );
853 - }
926 + wp_enqueue_script( 'hamburger', MAINWP_PLUGIN_URL . 'assets/js/hamburger/hamburger.js', array( 'jquery' ), $this->current_version, true );
927 + wp_enqueue_script( 'datatables-natural-sorting', MAINWP_PLUGIN_URL . 'assets/js/sorting/natural.js', array( 'jquery' ), $this->current_version, true );
854 928
855 - if ( isset( $_GET['page'] ) && ( 'managesites' === $_GET['page'] || 'MonitoringSites' === $_GET['page'] || 'ManageGroups' === $_GET['page'] ) ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
856 - wp_enqueue_script( 'preview', MAINWP_PLUGIN_URL . 'assets/js/preview.js', array(), $this->current_version, true );
857 - wp_enqueue_style( 'preview', MAINWP_PLUGIN_URL . 'assets/css/preview.css', array(), $this->current_version );
858 - }
859 - // phpcs:enable
929 + wp_enqueue_script( 'mainwp-clipboard', MAINWP_PLUGIN_URL . 'assets/js/clipboard/clipboard.min.js', array( 'jquery' ), $this->current_version, true );
930 + wp_enqueue_script( 'mainwp-rest-api', MAINWP_PLUGIN_URL . 'assets/js/mainwp-rest-api.js', array(), $this->current_version, true );
860 931
861 - wp_enqueue_style( 'wp-color-picker' );
862 - wp_enqueue_script( 'wp-color-picker' );
932 + if ( isset( $_GET['page'] ) && 'ManageGroups' === $_GET['page'] ) {
933 + wp_enqueue_script( 'mainwp-groups', MAINWP_PLUGIN_URL . 'assets/js/mainwp-groups.js', array(), $this->current_version, true );
934 + }
935 + }
863 936
864 - $this->init_session();
937 + if ( $load_cust_scripts ) {
938 + wp_enqueue_script( 'fomantic-ui', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.js', array( 'jquery' ), $this->current_version, true );
939 + }
865 940
866 - if ( ! current_user_can( 'update_core' ) ) {
867 - remove_action( 'admin_notices', 'update_nag', 3 );
868 - }
869 - }
941 + wp_enqueue_script( 'mainwp-ui', MAINWP_PLUGIN_URL . 'assets/js/mainwp-ui.js', array(), $this->current_version, true );
942 + wp_enqueue_script( 'mainwp-js-popup', MAINWP_PLUGIN_URL . 'assets/js/mainwp-popup.js', array(), $this->current_version, true );
943 + wp_enqueue_script( 'mainwp-fileuploader', MAINWP_PLUGIN_URL . 'assets/js/fileuploader.js', array(), $this->current_version ); // phpcs:ignore -- fileuploader scripts need to load at header.
944 + wp_enqueue_script( 'mainwp-date', MAINWP_PLUGIN_URL . 'assets/js/date.js', array(), $this->current_version, true );
945 + wp_enqueue_script( 'mainwp-filesaver', MAINWP_PLUGIN_URL . 'assets/js/FileSaver.js', array(), $this->current_version, true );
946 + }
870 947
871 - /**
872 - * Method hook_plugin_action_links()
873 - *
874 - * @param string[] $actions An array of plugin action links. By default this can include
875 - * 'activate', 'deactivate', and 'delete'. With Multisite active
876 - * this can also include 'network_active' and 'network_only' items.
877 - * @param string $plugin_file Path to the plugin file relative to the plugins directory.
878 - * @param array $plugin_data An array of plugin data. See get_plugin_data()
879 - * and the {@see 'plugin_row_meta'} filter for the list
880 - * of possible values.
881 - */
882 - public function hook_plugin_action_links( $actions, $plugin_file, $plugin_data ) {
883 - unset( $plugin_file ); // not use, compatible.
884 - if ( is_array( $plugin_data ) && ! empty( $plugin_data['slug'] ) && ! empty( $plugin_data['plugin'] ) && 'mainwp' === $plugin_data['slug'] && 'mainwp/mainwp.php' === $plugin_data['plugin'] ) {
885 - $tmp = array(
886 - 'mainwp-setup' => '<a href="admin.php?page=mainwp-setup" id="mainwp-setup" aria-label="' . esc_html__( 'MainWP Dashboard Setup Wizard', 'mainwp' ) . '">' . esc_html__( 'Setup Wizard', 'mainwp' ) . '</a>',
887 - );
888 - if ( is_array( $actions ) ) {
889 - foreach ( $actions as $key => $val ) {
890 - $tmp[ $key ] = $val;
948 + /**
949 + * Method admin_enqueue_styles()
950 + *
951 + * Enqueue all Mainwp Admin Styles.
952 + *
953 + * @param mixed $hook Enqueue hook.
954 + */
955 + public function admin_enqueue_styles( $hook ) {
891 956
892 - }
893 - }
894 - return $tmp;
895 - }
896 - return $actions;
897 - }
957 + wp_enqueue_style( 'mainwp', MAINWP_PLUGIN_URL . 'assets/css/mainwp.css', array(), $this->current_version );
958 + wp_enqueue_style( 'mainwp-responsive-layouts', MAINWP_PLUGIN_URL . 'assets/css/mainwp-responsive-layouts.css', array(), $this->current_version );
898 959
899 - /**
900 - * Method current_screen_redirects()
901 - *
902 - * MainWP current screen redirects.
903 - */
904 - public function current_screen_redirects() {
960 + if ( isset( $_GET['hideall'] ) && 1 === $_GET['hideall'] ) {
961 + remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
962 + }
905 963
906 - if ( ( defined( 'DOING_CRON' ) && DOING_CRON ) || defined( 'DOING_AJAX' ) ) {
907 - return;
908 - }
909 - if ( static::is_mainwp_pages() ) {
910 - $quick_setup = get_option( 'mainwp_run_quick_setup', false );
911 - if ( 'yes' === $quick_setup ) {
912 - delete_option( 'mainwp_run_quick_setup' );
913 - wp_safe_redirect( admin_url( 'admin.php?page=mainwp-setup' ) );
914 - exit;
915 - }
916 - }
964 + /**
965 + * Current pagenow.
966 + *
967 + * @global string
968 + */
969 + global $pagenow;
917 970
918 - if ( ! empty( $_GET['page'] ) && in_array( $_GET['page'], array( 'mainwp-setup' ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
919 - return;
920 - }
971 + $load_cust_scripts = false;
972 + if ( is_plugin_active( 'mainwp-custom-post-types/mainwp-custom-post-types.php' ) && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) {
973 + $load_cust_scripts = true;
974 + }
921 975
922 - if ( static::is_mainwp_pages() && 'yes' === get_option( 'mainwp_activated' ) ) {
923 - delete_option( 'mainwp_activated' );
924 - wp_cache_delete( 'mainwp_activated', 'options' );
925 - wp_cache_delete( 'alloptions', 'options' );
926 - wp_safe_redirect( admin_url( 'admin.php?page=mainwp_tab' ) );
927 - exit;
928 - }
929 - }
976 + if ( self::is_mainwp_pages() ) {
977 + wp_enqueue_style( 'mainwp-fonts', MAINWP_PLUGIN_URL . 'assets/css/mainwp-fonts.css', array(), $this->current_version );
978 + wp_enqueue_style( 'fomantic-ui', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.css', array(), $this->current_version );
979 + wp_enqueue_style( 'mainwp-fomantic', MAINWP_PLUGIN_URL . 'assets/css/mainwp-fomantic.css', array(), $this->current_version );
930 980
931 - /**
932 - * Method admin_redirects()
933 - *
934 - * MainWP admin redirects.
935 - */
936 - public function admin_redirects() {
937 - if ( ( defined( 'DOING_CRON' ) && DOING_CRON ) || defined( 'DOING_AJAX' ) ) {
938 - return;
939 - }
981 + wp_enqueue_style( 'datatables', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.semanticui.css', array(), $this->current_version );
982 + wp_enqueue_style( 'datatables-colreorder', MAINWP_PLUGIN_URL . 'assets/js/datatables/colReorder.dataTables.min.css', array(), $this->current_version );
983 + wp_enqueue_style( 'datatables-fixedColumns', MAINWP_PLUGIN_URL . 'assets/js/datatables/fixedColumns.dataTables.min.css', array(), $this->current_version );
984 + wp_enqueue_style( 'datatables-scroller', MAINWP_PLUGIN_URL . 'assets/js/datatables/scroller.semanticui.css', array(), $this->current_version );
985 + wp_enqueue_style( 'datatables-responsive', MAINWP_PLUGIN_URL . 'assets/js/datatables/responsive.dataTables.min.css', array(), $this->current_version );
940 986
941 - if ( ! empty( $_GET['page'] ) && in_array( $_GET['page'], array( 'mainwp-setup' ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
942 - return;
943 - }
987 + wp_enqueue_style( 'hamburger', MAINWP_PLUGIN_URL . 'assets/js/hamburger/hamburger.css', array(), $this->current_version );
988 + // to fix conflict layout.
989 + wp_enqueue_style( 'jquery-ui-style', MAINWP_PLUGIN_URL . 'assets/css/1.11.1/jquery-ui.min.css', array(), '1.11.1' );
944 990
945 - $quick_setup = get_option( 'mainwp_run_quick_setup', false );
946 - if ( 'yes' === $quick_setup ) {
947 - wp_safe_redirect( admin_url( 'admin.php?page=mainwp-setup' ) );
948 - exit;
949 - }
991 + // load custom MainWP theme.
992 + $selected_theme = MainWP_Settings::get_instance()->get_selected_theme();
993 + if ( ! empty( $selected_theme ) ) {
994 + if ( 'dark' == $selected_theme ) {
995 + wp_enqueue_style( 'mainwp-custom-dashboard-extension-dark-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-dark-theme.css', array(), $this->current_version );
996 + } elseif ( 'wpadmin' == $selected_theme ) {
997 + wp_enqueue_style( 'mainwp-custom-dashboard-extension-wp-admin-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-wpadmin-theme.css', array(), $this->current_version );
998 + } elseif ( 'minimalistic' == $selected_theme ) {
999 + wp_enqueue_style( 'mainwp-custom-dashboard-extension-minimalistic-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-minimalistic-theme.css', array(), $this->current_version );
1000 + } elseif ( 'default' == $selected_theme ) {
1001 + wp_enqueue_style( 'mainwp-custom-dashboard-extension-default-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-default-theme.css', array(), $this->current_version );
1002 + } else {
1003 + $dirs = MainWP_Settings::get_instance()->get_custom_theme_folder();
1004 + $theme_dir = $dirs[0];
1005 + wp_enqueue_style( 'mainwp-custom-dashboard-theme', $theme_dir . $selected_theme, array(), $this->current_version );
1006 + }
1007 + }
1008 + }
950 1009
951 - $request_uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
952 - $_pos = strlen( $request_uri ) - strlen( '/wp-admin/' );
953 - if ( ! empty( $request_uri ) && strpos( $request_uri, '/wp-admin/' ) !== false && strpos( $request_uri, '/wp-admin/' ) === $_pos ) {
954 - $referer = wp_get_referer();
955 - if ( ! empty( $referer ) && strpos( $referer, 'wp-login.php?redirect_to' ) !== false && strpos( $referer, '&reauth=1' ) !== false && mainwp_current_user_have_right( 'dashboard', 'access_global_dashboard' ) ) {
956 - wp_safe_redirect( admin_url( 'admin.php?page=mainwp_tab' ) );
957 - die();
958 - }
959 - }
1010 + if ( $load_cust_scripts ) {
1011 + wp_enqueue_style( 'mainwp-fonts', MAINWP_PLUGIN_URL . 'assets/css/mainwp-fonts.css', array(), $this->current_version );
1012 + wp_enqueue_style( 'fomantic-ui', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.css', array(), $this->current_version );
1013 + }
1014 + }
960 1015
961 - MainWP_Logger::instance()->check_log_daily();
962 - }
1016 + /**
1017 + * Method admin_menu()
1018 + *
1019 + * Add Bulk Post/Pages menue.
1020 + */
1021 + public function admin_menu() {
963 1022
964 - /**
965 - * Method init_session()
966 - *
967 - * Check current page & initiate a session.
968 - *
969 - * @uses \MainWP\Dashboard\MainWP_Cache::init_session()
970 - */
971 - public function init_session() {
972 - $page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
973 - if ( ! empty( $page ) && in_array(
974 - $page,
975 - array(
976 - 'PostBulkManage',
977 - 'PageBulkManage',
978 - 'PluginsManage',
979 - 'PluginsAutoUpdate',
980 - 'ThemesManage',
981 - 'ThemesAutoUpdate',
982 - 'UserBulkManage',
983 - )
984 - )
985 - ) {
986 - MainWP_Cache::init_session();
987 - }
988 - }
1023 + /**
1024 + * Admin menu array.
1025 + *
1026 + * @global object
1027 + */
1028 + global $menu;
989 1029
990 - /**
991 - * Method clear_sessions()
992 - *
993 - * When logout clear the sessions to reset.
994 - */
995 - public function clear_sessions() {
996 - MainWP_Cache::init_session();
997 - $clear_cached = array(
998 - 'Post',
999 - 'Page',
1000 - );
1001 - foreach ( $clear_cached as $ca ) {
1002 - MainWP_Cache::init_cache( $ca ); // to re-set cache.
1003 - }
1004 - }
1030 + foreach ( $menu as $k => $item ) {
1031 + if ( 'edit.php?post_type=bulkpost' === $item[2] ) {
1032 + unset( $menu[ $k ] );
1033 + } elseif ( 'edit.php?post_type=bulkpage' === $item[2] ) {
1034 + unset( $menu[ $k ] );
1035 + }
1036 + }
1037 + }
1005 1038
1006 - /**
1007 - * Method admin_enqueue_scripts()
1008 - *
1009 - * Enqueue all Mainwp Admin Scripts.
1010 - */
1011 - public function admin_enqueue_scripts() {
1039 + /**
1040 + * Method enqueue_postbox_scripts()
1041 + *
1042 + * Enqueue postbox scripts.
1043 + */
1044 + public static function enqueue_postbox_scripts() {
1045 + wp_enqueue_script( 'common' );
1046 + wp_enqueue_script( 'wp-lists' );
1047 + wp_enqueue_script( 'postbox' );
1048 + }
1012 1049
1013 - $load_cust_scripts = false;
1050 + /**
1051 + * Method admin_footer()
1052 + *
1053 + * Create MainWP admin footer.
1054 + *
1055 + * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id()
1056 + * @uses \MainWP\Dashboard\MainWP_DB::query()
1057 + * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1058 + * @uses \MainWP\Dashboard\MainWP_DB::free_result()
1059 + * @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_menu()
1060 + * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
1061 + * @uses \MainWP\Dashboard\MainWP_System_View::render_footer_content()
1062 + * @uses \MainWP\Dashboard\MainWP_System_View::admin_footer()
1063 + */
1064 + public function admin_footer() {
1065 + if ( ! self::is_mainwp_pages() ) {
1066 + return;
1067 + }
1014 1068
1015 - /**
1016 - * Current pagenow.
1017 - *
1018 - * @global string
1019 - */
1020 - global $pagenow;
1069 + ?>
1070 + <div class="ui large modal" id="mainwp-response-data-modal">
1071 + <div class="header"><?php esc_html_e( 'Child Site Response', 'mainwp' ); ?></div>
1072 + <div class="content">
1073 + <div class="ui info message"><?php esc_html_e( 'To see the response in a more readable way, you can copy it and paste it into some HTML render tool, such as Codepen.io.', 'mainwp' ); ?>
1074 + </div>
1075 + </div>
1076 + <div class="scrolling content content-response"></div>
1077 + <div class="actions">
1078 + <button class="ui green button mainwp-response-copy-button"><?php esc_html_e( 'Copy Response', 'mainwp' ); ?></button>
1079 + <div class="ui cancel button"><?php esc_html_e( 'Close', 'mainwp' ); ?></div>
1080 + </div>
1081 + </div>
1082 + <div id="mainwp-response-data-container" resp-data=""></div>
1083 + <?php
1021 1084
1022 - if ( is_plugin_active( 'mainwp-custom-post-types/mainwp-custom-post-types.php' ) && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) {
1023 - $load_cust_scripts = true;
1024 - }
1085 + if ( isset( $_GET['hideall'] ) && 1 === $_GET['hideall'] ) {
1086 + return;
1087 + }
1088 + $current_wpid = MainWP_System_Utility::get_current_wpid();
1089 + if ( $current_wpid ) {
1090 + $website = MainWP_DB::instance()->get_website_by_id( $current_wpid );
1091 + $websites = array( $website );
1092 + } else {
1093 + $is_staging = 'no';
1094 + if ( isset( $_GET['page'] ) ) {
1095 + if ( ( 'managesites' == $_GET['page'] ) && ! isset( $_GET['id'] ) && ! isset( $_GET['do'] ) && ! isset( $_GET['dashboard'] ) ) {
1096 + $group_ids = get_user_option( 'mainwp_managesites_filter_group' );
1097 + if ( ! empty( $group_ids ) ) {
1098 + $group_ids = explode( ',', $group_ids ); // convert to array.
1099 + }
1100 + if ( $group_ids ) {
1101 + $staging_group = get_option( 'mainwp_stagingsites_group_id' );
1102 + }
1103 + } elseif ( 'UpdatesManage' == $_GET['page'] || 'mainwp_tab' == $_GET['page'] ) {
1104 + $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) ? true : false;
1105 + if ( $staging_enabled ) {
1106 + $staging_view = get_user_option( 'mainwp_staging_options_updates_view' ) == 'staging' ? true : false;
1107 + if ( $staging_view ) {
1108 + $is_staging = 'yes';
1109 + }
1110 + }
1111 + }
1112 + }
1113 + $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp_sync.dtsSync DESC, wp.url ASC', false, false, null, false, array(), $is_staging ) );
1114 + }
1025 1115
1026 - if ( static::is_mainwp_pages() ) {
1027 - wp_enqueue_script( 'jquery-migrate' );
1028 - wp_enqueue_script( 'mainwp-updates', MAINWP_PLUGIN_URL . 'assets/js/mainwp-updates.js', array(), $this->current_version, true );
1029 - wp_enqueue_script( 'mainwp-managesites-action', MAINWP_PLUGIN_URL . 'assets/js/mainwp-managesites-action.js', array(), $this->current_version, true );
1030 - wp_enqueue_script( 'mainwp-managesites-update', MAINWP_PLUGIN_URL . 'assets/js/mainwp-managesites-update.js', array(), $this->current_version, true );
1031 - wp_enqueue_script( 'mainwp-managesites-import', MAINWP_PLUGIN_URL . 'assets/js/mainwp-managesites-import.js', array(), $this->current_version, true );
1032 - wp_enqueue_script( 'mainwp-plugins-themes', MAINWP_PLUGIN_URL . 'assets/js/mainwp-plugins-themes.js', array(), $this->current_version, true );
1033 - wp_enqueue_script( 'mainwp-backups', MAINWP_PLUGIN_URL . 'assets/js/mainwp-backups.js', array(), $this->current_version, true );
1034 - wp_enqueue_script( 'mainwp-posts', MAINWP_PLUGIN_URL . 'assets/js/mainwp-posts.js', array(), $this->current_version, true );
1035 - wp_enqueue_script( 'mainwp-users', MAINWP_PLUGIN_URL . 'assets/js/mainwp-users.js', array(), $this->current_version, true );
1036 - wp_enqueue_script( 'mainwp-clients', MAINWP_PLUGIN_URL . 'assets/js/mainwp-clients.js', array(), $this->current_version, true );
1037 - wp_enqueue_script( 'mainwp-extensions', MAINWP_PLUGIN_URL . 'assets/js/mainwp-extensions.js', array(), $this->current_version, true );
1038 - wp_enqueue_script( 'mainwp-moment', MAINWP_PLUGIN_URL . 'assets/js/moment/moment.min.js', array(), $this->current_version, true );
1039 - wp_enqueue_script( 'fomantic-ui', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.js', array( 'jquery' ), $this->current_version, false );
1116 + MainWP_System_View::render_footer_content( $websites, $current_wpid );
1117 + if ( empty( $current_wpid ) ) {
1118 + MainWP_DB::free_result( $websites );
1119 + }
1040 1120
1041 - wp_enqueue_script( 'datatables', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.js', array( 'jquery' ), $this->current_version, false );
1042 - wp_enqueue_script( 'datatables-semanticui', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.semanticui.js', array( 'datatables' ), $this->current_version, false );
1043 - wp_enqueue_script( 'datatables-select', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.select.min.js', array( 'datatables' ), $this->current_version, false );
1044 - wp_enqueue_script( 'datatables-add-ons', MAINWP_PLUGIN_URL . 'assets/js/datatables/datatables.min.js', array( 'datatables' ), $this->current_version, false );
1121 + MainWP_System_View::admin_footer();
1122 + MainWP_Menu::init_sub_pages();
1045 1123
1046 - wp_enqueue_script( 'hamburger', MAINWP_PLUGIN_URL . 'assets/js/hamburger/hamburger.js', array( 'jquery' ), $this->current_version, true );
1047 - wp_enqueue_script( 'datatables-natural-sorting', MAINWP_PLUGIN_URL . 'assets/js/sorting/natural.js', array( 'jquery' ), $this->current_version, true );
1124 + /**
1125 + * MainWP disabled menu items array.
1126 + *
1127 + * @global object
1128 + */
1129 + global $_mainwp_disable_menus_items;
1048 1130
1049 - wp_enqueue_script( 'mainwp-clipboard', MAINWP_PLUGIN_URL . 'assets/js/clipboard/clipboard.min.js', array( 'jquery' ), $this->current_version, true );
1050 - wp_enqueue_script( 'mainwp-rest-api', MAINWP_PLUGIN_URL . 'assets/js/mainwp-rest-api.js', array(), $this->current_version, true );
1131 + $_mainwp_disable_menus_items = apply_filters( 'mainwp_all_disablemenuitems', $_mainwp_disable_menus_items );
1132 + }
1051 1133
1052 - if ( isset( $_GET['page'] ) && 'ManageGroups' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1053 - wp_enqueue_script( 'mainwp-groups', MAINWP_PLUGIN_URL . 'assets/js/mainwp-groups.js', array(), $this->current_version, true );
1054 - }
1055 - $enqueue_scripts = apply_filters( 'mainwp_admin_enqueue_scripts', array() );
1056 - if ( is_array( $enqueue_scripts ) && ! empty( $enqueue_scripts['apexcharts'] ) ) {
1057 - wp_enqueue_script(
1058 - 'mainwp-apexcharts',
1059 - MAINWP_PLUGIN_URL . 'assets/js/apexcharts/apexcharts.js',
1060 - array(
1061 - 'jquery',
1062 - 'mainwp',
1063 - ),
1064 - $this->current_version,
1065 - true
1066 - );
1067 - }
1068 - wp_enqueue_script( 'mainwp-dropzone', MAINWP_PLUGIN_URL . 'assets/js/dropzone/dropzone.min.js', array(), $this->current_version, true );
1069 - }
1134 + /**
1135 + * Method activated_check()
1136 + *
1137 + * Activated check.
1138 + *
1139 + * @uses \MainWP\Dashboard\MainWP_Deprecated_Hooks::maybe_handle_deprecated_hook()
1140 + */
1141 + public function activated_check() {
1142 + MainWP_Deprecated_Hooks::maybe_handle_deprecated_hook();
1143 + return $this->get_version();
1144 + }
1070 1145
1071 - if ( $load_cust_scripts ) {
1072 - wp_enqueue_script( 'fomantic-ui', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.js', array( 'jquery' ), $this->current_version, true );
1073 - }
1146 + /**
1147 + * Method activation()
1148 + *
1149 + * Activate MainWP.
1150 + *
1151 + * @uses \MainWP\Dashboard\MainWP_Install::install()
1152 + * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
1153 + */
1154 + public function activation() {
1155 + $this->update_install();
1156 + MainWP_Utility::update_option( 'mainwp_activated', 'yes' );
1157 + }
1074 1158
1075 - wp_enqueue_script( 'mainwp-ui', MAINWP_PLUGIN_URL . 'assets/js/mainwp-ui.js', array(), $this->current_version, true );
1076 - wp_enqueue_script( 'mainwp-js-popup', MAINWP_PLUGIN_URL . 'assets/js/mainwp-popup.js', array(), $this->current_version, true );
1077 - // to support extension uploader.
1078 - wp_enqueue_script( 'mainwp-fileuploader', MAINWP_PLUGIN_URL . 'assets/js/fileuploader.js', array(), $this->current_version ); // phpcs:ignore -- fileuploader scripts need to load at header.
1079 - wp_enqueue_script( 'mainwp-filesaver', MAINWP_PLUGIN_URL . 'assets/js/FileSaver.js', array(), $this->current_version, true );
1080 - }
1159 + /**
1160 + * Method deactivation()
1161 + *
1162 + * Deactivate MainWP.
1163 + */
1164 + public function deactivation() {
1165 + update_option( 'mainwp_extensions_all_activation_cached', '' );
1166 + }
1081 1167
1082 - /**
1083 - * Method admin_enqueue_scripts_fix_conflict()
1084 - *
1085 - * Enqueue Admin Scripts fix conflict.
1086 - */
1087 - public function admin_enqueue_scripts_fix_conflict() {
1088 - if ( static::is_mainwp_pages() ) {
1089 - // to fix conflict with the SVG Support plugin.
1090 - remove_action( 'admin_enqueue_scripts', 'bodhi_svgs_admin_multiselect' );
1091 - }
1092 - }
1168 + /**
1169 + * Method update_install()
1170 + *
1171 + * Update MainWP.
1172 + *
1173 + * @uses \MainWP\Dashboard\MainWP_Install::install()
1174 + */
1175 + public function update_install() {
1176 + MainWP_DB_Client::instance();
1177 + MainWP_DB_Site_Actions::instance();
1178 + MainWP_Install::instance()->install();
1179 + }
1093 1180
1094 - /**
1095 - * Method admin_enqueue_styles()
1096 - *
1097 - * Enqueue all Mainwp Admin Styles.
1098 - */
1099 - public function admin_enqueue_styles() { //phpcs:ignore -- NOSONAR - complex.
1181 + /**
1182 + * Method is_single_user()
1183 + *
1184 + * Check if single user environment.
1185 + *
1186 + * @return boolean true|false.
1187 + */
1188 + public function is_single_user() {
1189 + return true;
1190 + }
1100 1191
1101 - wp_enqueue_style( 'mainwp', MAINWP_PLUGIN_URL . 'assets/css/mainwp.css', array(), $this->current_version );
1102 - wp_enqueue_style( 'mainwp-responsive-layouts', MAINWP_PLUGIN_URL . 'assets/css/mainwp-responsive-layouts.css', array(), $this->current_version );
1192 + /**
1193 + * Method is_multi_user()
1194 + *
1195 + * Check if multi user environment.
1196 + *
1197 + * @return boolean true|false.
1198 + */
1199 + public function is_multi_user() {
1200 + return ! $this->is_single_user();
1201 + }
1103 1202
1104 - if ( isset( $_GET['hideall'] ) && 1 === (int) $_GET['hideall'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1105 - remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
1106 - }
1203 + /**
1204 + * Method get_plugin_slug()
1205 + *
1206 + * Get MainWP Plugin Slug.
1207 + */
1208 + public function get_plugin_slug() {
1209 + return $this->plugin_slug;
1210 + }
1107 1211
1108 - /**
1109 - * Current pagenow.
1110 - *
1111 - * @global string
1112 - */
1113 - global $pagenow;
1114 -
1115 - $load_cust_scripts = false;
1116 - if ( is_plugin_active( 'mainwp-custom-post-types/mainwp-custom-post-types.php' ) && ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) ) {
1117 - $load_cust_scripts = true;
1118 - }
1119 -
1120 - if ( static::is_mainwp_pages() ) {
1121 - wp_enqueue_style( 'mainwp-fonts', MAINWP_PLUGIN_URL . 'assets/css/mainwp-fonts.css', array(), $this->current_version );
1122 - wp_enqueue_style( 'fomantic-ui', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.css', array(), $this->current_version );
1123 - wp_enqueue_style( 'mainwp-fomantic', MAINWP_PLUGIN_URL . 'assets/css/mainwp-fomantic.css', array(), $this->current_version );
1124 -
1125 - wp_enqueue_style( 'datatables', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.dataTables.css', array(), $this->current_version );
1126 - wp_enqueue_style( 'datatables-semanticui', MAINWP_PLUGIN_URL . 'assets/js/datatables/dataTables.semanticui.css', array(), $this->current_version );
1127 - wp_enqueue_style( 'datatables-select', MAINWP_PLUGIN_URL . 'assets/js/datatables/select.semanticui.min.css', array(), $this->current_version );
1128 - wp_enqueue_style( 'datatables-add-ons', MAINWP_PLUGIN_URL . 'assets/js/datatables/datatables.min.css', array(), $this->current_version );
1129 -
1130 - wp_enqueue_style( 'hamburger', MAINWP_PLUGIN_URL . 'assets/js/hamburger/hamburger.css', array(), $this->current_version );
1131 - // to fix conflict layout.
1132 - wp_enqueue_style( 'jquery-ui-style', MAINWP_PLUGIN_URL . 'assets/css/1.11.1/jquery-ui.min.css', array(), '1.11.1' );
1133 -
1134 - // load custom MainWP theme.
1135 - $selected_theme = MainWP_Settings::get_instance()->get_selected_theme();
1136 - if ( ! empty( $selected_theme ) ) {
1137 - if ( 'dark' === $selected_theme ) {
1138 - wp_enqueue_style( 'mainwp-custom-dashboard-extension-dark-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-dark-theme.css', array(), $this->current_version );
1139 - } elseif ( 'wpadmin' === $selected_theme ) {
1140 - wp_enqueue_style( 'mainwp-custom-dashboard-extension-wp-admin-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-wpadmin-theme.css', array(), $this->current_version );
1141 - } elseif ( 'minimalistic' === $selected_theme ) {
1142 - wp_enqueue_style( 'mainwp-custom-dashboard-extension-minimalistic-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-minimalistic-theme.css', array(), $this->current_version );
1143 - } elseif ( 'default' === $selected_theme ) {
1144 - wp_enqueue_style( 'mainwp-custom-dashboard-extension-default-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-default-theme.css', array(), $this->current_version );
1145 - } else {
1146 - $dirs = MainWP_Settings::get_instance()->get_custom_theme_folder();
1147 - $custom_theme_url = $dirs[1];
1148 - wp_enqueue_style( 'mainwp-custom-dashboard-theme', $custom_theme_url . $selected_theme, array(), $this->current_version );
1149 - }
1150 - }
1151 - }
1152 -
1153 - if ( $load_cust_scripts ) {
1154 - wp_enqueue_style( 'mainwp-fonts', MAINWP_PLUGIN_URL . 'assets/css/mainwp-fonts.css', array(), $this->current_version );
1155 - wp_enqueue_style( 'fomantic-ui', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.css', array(), $this->current_version );
1156 - }
1157 - }
1158 -
1159 - /**
1160 - * Method admin_menu()
1161 - *
1162 - * Add Bulk Post/Pages menue.
1163 - */
1164 - public function admin_menu() {
1165 -
1166 - /**
1167 - * Admin menu array.
1168 - *
1169 - * @global object
1170 - */
1171 - global $menu;
1172 -
1173 - foreach ( $menu as $k => $item ) {
1174 - if ( 'edit.php?post_type=bulkpost' === $item[2] || 'edit.php?post_type=bulkpage' === $item[2] ) {
1175 - unset( $menu[ $k ] );
1176 - }
1177 - }
1178 - }
1179 -
1180 - /**
1181 - * Method enqueue_postbox_scripts()
1182 - *
1183 - * Enqueue postbox scripts.
1184 - */
1185 - public static function enqueue_postbox_scripts() {
1186 - wp_enqueue_script( 'common' );
1187 - wp_enqueue_script( 'wp-lists' );
1188 - wp_enqueue_script( 'postbox' );
1189 - }
1190 -
1191 - /**
1192 - * Method admin_footer()
1193 - *
1194 - * Create MainWP admin footer.
1195 - *
1196 - * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id()
1197 - * @uses \MainWP\Dashboard\MainWP_DB::query()
1198 - * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1199 - * @uses \MainWP\Dashboard\MainWP_DB::free_result()
1200 - * @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_menu()
1201 - * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
1202 - * @uses \MainWP\Dashboard\MainWP_System_View::render_footer_content()
1203 - * @uses \MainWP\Dashboard\MainWP_System_View::admin_footer()
1204 - */
1205 - public function admin_footer() { //phpcs:ignore -- NOSONAR - complex.
1206 - if ( ! static::is_mainwp_pages() ) {
1207 - $sites_count = MainWP_DB::instance()->get_websites_count();
1208 - if ( empty( $sites_count ) ) {
1209 - ?>
1210 - <script type="text/javascript">
1211 - jQuery( function($){
1212 - $( 'li#toplevel_page_mainwp_tab .wp-submenu-wrap .wp-submenu-head' ).after('<li style="background: #FFD300 !important;" class="wp-first-item"><a href="admin.php?page=mainwp-setup" style="color: #000 !important;" class="wp-first-item"><?php esc_html_e( 'Quick Setup', 'mainwp' ); ?></a></li>');
1213 - });
1214 - </script>
1215 - <?php
1216 - }
1217 - return;
1218 - }
1219 -
1220 - ?>
1221 - <div class="ui large modal" id="mainwp-response-data-modal">
1222 - <i class="close icon"></i>
1223 - <div class="header"><?php esc_html_e( 'Child Site Response', 'mainwp' ); ?></div>
1224 - <div class="content">
1225 - <div class="ui info message"><?php esc_html_e( 'To see the response in a more readable way, you can copy it and paste it into some HTML render tool, such as Codepen.io.', 'mainwp' ); ?>
1226 - </div>
1227 - </div>
1228 - <div class="scrolling content content-response" contenteditable="true"></div>
1229 - <div class="actions">
1230 - <button class="ui green button mainwp-response-copy-button"><?php esc_html_e( 'Copy Response', 'mainwp' ); ?></button>
1231 - </div>
1232 - </div>
1233 - <div id="mainwp-response-data-container" resp-data=""></div>
1234 - <?php
1235 -
1236 - if ( isset( $_GET['hideall'] ) && 1 === (int) $_GET['hideall'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1237 - return;
1238 - }
1239 - $current_wpid = MainWP_System_Utility::get_current_wpid();
1240 - if ( $current_wpid ) {
1241 - $website = MainWP_DB::instance()->get_website_by_id( $current_wpid );
1242 - $websites = array( $website );
1243 - } else {
1244 - $is_staging = 'no';
1245 - if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1246 - if ( ( 'managesites' === $_GET['page'] ) && ! isset( $_GET['id'] ) && ! isset( $_GET['do'] ) && ! isset( $_GET['dashboard'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1247 - $group_ids = get_user_option( 'mainwp_managesites_filter_group' );
1248 - if ( ! empty( $group_ids ) ) {
1249 - $group_ids = explode( ',', $group_ids ); // convert to array.
1250 - }
1251 - } elseif ( 'UpdatesManage' === $_GET['page'] || 'mainwp_tab' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1252 - $staging_enabled = is_plugin_active( 'mainwp-staging-extension/mainwp-staging-extension.php' ) ? true : false;
1253 - if ( $staging_enabled ) {
1254 - $staging_view = MainWP_System_Utility::get_staging_options_sites_view_for_current_users();
1255 - if ( 'staging' === $staging_view ) {
1256 - $is_staging = 'yes';
1257 - }
1258 - }
1259 - }
1260 - }
1261 - $websites = MainWP_DB::instance()->query( MainWP_DB::instance()->get_sql_websites_for_current_user( false, null, 'wp_sync.dtsSync DESC, wp.url ASC', false, false, null, false, array(), $is_staging ) );
1262 - }
1263 -
1264 - MainWP_System_View::render_footer_content( $websites, $current_wpid );
1265 - if ( empty( $current_wpid ) ) {
1266 - MainWP_DB::free_result( $websites );
1267 - }
1268 -
1269 - MainWP_System_View::admin_footer();
1270 - MainWP_System_View::render_plugins_install_check();
1271 -
1272 - MainWP_Menu::init_sub_pages();
1273 -
1274 - /**
1275 - * MainWP disabled menu items array.
1276 - *
1277 - * @global object
1278 - */
1279 - global $_mainwp_disable_menus_items;
1280 -
1281 - $_mainwp_disable_menus_items = apply_filters( 'mainwp_all_disablemenuitems', $_mainwp_disable_menus_items );
1282 - }
1283 -
1284 - /**
1285 - * Method activated_check()
1286 - *
1287 - * Activated check.
1288 - *
1289 - * @uses \MainWP\Dashboard\MainWP_Deprecated_Hooks::maybe_handle_deprecated_hook()
1290 - */
1291 - public function activated_check() {
1292 - MainWP_Deprecated_Hooks::maybe_handle_deprecated_hook();
1293 - return $this->get_version();
1294 - }
1295 -
1296 - /**
1297 - * Method activation()
1298 - *
1299 - * Activate MainWP.
1300 - *
1301 - * @uses \MainWP\Dashboard\MainWP_Install::install()
1302 - * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
1303 - */
1304 - public function activation() {
1305 - $this->update_install();
1306 - MainWP_Utility::update_option( 'mainwp_activated', 'yes' );
1307 - }
1308 -
1309 - /**
1310 - * Method deactivation()
1311 - *
1312 - * Deactivate MainWP.
1313 - */
1314 - public function deactivation() {
1315 - update_option( 'mainwp_extensions_all_activation_cached', '' );
1316 - }
1317 -
1318 - /**
1319 - * Method update_install()
1320 - *
1321 - * Update MainWP.
1322 - *
1323 - * @uses \MainWP\Dashboard\MainWP_Install::install()
1324 - */
1325 - public function update_install() {
1326 - MainWP_DB_Client::instance();
1327 - MainWP_DB_Site_Actions::instance();
1328 - MainWP_Install::instance()->install();
1329 - $this->check_to_updates();
1330 - }
1331 -
1332 -
1333 - /**
1334 - * Method check_to_updates()
1335 - *
1336 - * To check updates options.
1337 - */
1338 - public function check_to_updates() {
1339 - $update_ver = get_option( 'mainwp_update_check_version', false );
1340 - $current_ver = $this->check_ver_update;
1341 -
1342 - if ( false === $update_ver && version_compare( $current_ver, '0.0.1', '=' ) ) {
1343 - // to update new saving format.
1344 - MainWP_Api_Manager_Key::instance()->get_decrypt_master_api_key();
1345 - MainWP_Utility::update_option( 'mainwp_update_check_version', $current_ver );
1346 - }
1347 - }
1348 -
1349 - /**
1350 - * Method is_single_user()
1351 - *
1352 - * Check if single user environment.
1353 - *
1354 - * @return boolean true|false.
1355 - */
1356 - public function is_single_user() {
1357 - return true;
1358 - }
1359 -
1360 - /**
1361 - * Method is_multi_user()
1362 - *
1363 - * Check if multi user environment.
1364 - *
1365 - * @return boolean true|false.
1366 - */
1367 - public function is_multi_user() {
1368 - return ! $this->is_single_user();
1369 - }
1370 -
1371 - /**
1372 - * Method get_plugin_slug()
1373 - *
1374 - * Get MainWP Plugin Slug.
1375 - */
1376 - public function get_plugin_slug() {
1377 - return $this->plugin_slug;
1378 - }
1379 1212 }