PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / trunk
MainWP Dashboard: Self-hosted WordPress Management for Agencies vtrunk
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 | mainwp.php +117 -64 5.0trunk View file →
@@ -7,9 +7,11 @@
7 7 * Author: MainWP
8 8 * Author URI: https://mainwp.com
9 9 * Plugin URI: https://mainwp.com/
10 10 * Text Domain: mainwp
11 - * Version: 5.0
11 + * Version: 6.2
12 + * License: GPLv3 or later
13 + * License URI: https://www.gnu.org/licenses/gpl-3.0.html
12 14 *
13 15 * @package MainWP/Dashboard
14 16 *
15 17 * @uses \MainWP\Dashboard\MainWP_System
@@ -14,46 +16,64 @@
14 16 *
15 17 * @uses \MainWP\Dashboard\MainWP_System
16 18 */
17 19
20 +// Exit if accessed directly.
21 +if ( ! defined( 'ABSPATH' ) ) {
22 + exit;
23 +}
24 +
25 +/**
26 + * Ignore cron/bootstrap.php from Plugin Check direct file access protection.
27 + * This file must execute before WordPress loads to locate wp-load.php,
28 + * so the standard ABSPATH check would break functionality.
29 + */
30 +add_filter(
31 + 'wp_plugin_check_ignore_files',
32 + function ( $ignored_files ) {
33 + $ignored_files[] = 'cron/bootstrap.php';
34 + return $ignored_files;
35 + }
36 +);
37 +
18 38 if ( ! defined( 'MAINWP_PLUGIN_FILE' ) ) {
19 39
20 - /**
21 - * Define MainWP Dashboard Plugin absolute full path and filename of this file.
22 - *
23 - * @const ( string ) Defined MainWP dashboard file path.
24 - * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php
25 - */
26 - define( 'MAINWP_PLUGIN_FILE', __FILE__ );
40 + /**
41 + * Define MainWP Dashboard Plugin absolute full path and filename of this file.
42 + *
43 + * @const ( string ) Defined MainWP dashboard file path.
44 + * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php
45 + */
46 + define( 'MAINWP_PLUGIN_FILE', __FILE__ );
27 47 }
28 48
29 49 if ( ! defined( 'MAINWP_PLUGIN_DIR' ) ) {
30 - /**
31 - * Define MainWP Dashboard Plugin Directory.
32 - *
33 - * @const ( string ) Defined MainWP Dashboard Plugin Directory.
34 - * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php
35 - */
36 - define( 'MAINWP_PLUGIN_DIR', plugin_dir_path( MAINWP_PLUGIN_FILE ) );
50 + /**
51 + * Define MainWP Dashboard Plugin Directory.
52 + *
53 + * @const ( string ) Defined MainWP Dashboard Plugin Directory.
54 + * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php
55 + */
56 + define( 'MAINWP_PLUGIN_DIR', plugin_dir_path( MAINWP_PLUGIN_FILE ) );
37 57 }
38 58
39 59 if ( ! defined( 'MAINWP_PLUGIN_URL' ) ) {
40 - /**
41 - * Define MainWP Child Dashboard URL.
42 - *
43 - * @const ( string ) Defined MainWP Dashboard Plugin URL.
44 - * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php
45 - */
46 - define( 'MAINWP_PLUGIN_URL', plugin_dir_url( MAINWP_PLUGIN_FILE ) );
60 + /**
61 + * Define MainWP Child Dashboard URL.
62 + *
63 + * @const ( string ) Defined MainWP Dashboard Plugin URL.
64 + * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php
65 + */
66 + define( 'MAINWP_PLUGIN_URL', plugin_dir_url( MAINWP_PLUGIN_FILE ) );
47 67 }
48 68
49 69
50 70 if ( ! defined( 'MAINWP_MODULES_DIR' ) ) {
51 - define( 'MAINWP_MODULES_DIR', MAINWP_PLUGIN_DIR . 'modules' . DIRECTORY_SEPARATOR );
71 + define( 'MAINWP_MODULES_DIR', MAINWP_PLUGIN_DIR . 'modules' . DIRECTORY_SEPARATOR );
52 72 }
53 73
54 74 if ( ! defined( 'MAINWP_MODULES_URL' ) ) {
55 - define( 'MAINWP_MODULES_URL', MAINWP_PLUGIN_URL . 'modules/' );
75 + define( 'MAINWP_MODULES_URL', MAINWP_PLUGIN_URL . 'modules/' );
56 76 }
57 77
58 78
59 79 /**
@@ -59,75 +79,108 @@
59 79 /**
60 80 * Define enable Log Module.
61 81 */
62 82 if ( ! defined( 'MAINWP_MODULE_LOG_ENABLED' ) ) {
63 - define( 'MAINWP_MODULE_LOG_ENABLED', true );
83 + define( 'MAINWP_MODULE_LOG_ENABLED', true );
64 84 }
65 85
66 86 if ( ! defined( 'MAINWP_MODULE_COST_TRACKER_ENABLED' ) ) {
67 - define( 'MAINWP_MODULE_COST_TRACKER_ENABLED', true );
87 + define( 'MAINWP_MODULE_COST_TRACKER_ENABLED', true );
68 88 }
69 89
70 90 if ( ! defined( 'MAINWP_MODULE_API_BACKUPS_ENABLED' ) ) {
71 - define( 'MAINWP_MODULE_API_BACKUPS_ENABLED', true );
91 + define( 'MAINWP_MODULE_API_BACKUPS_ENABLED', true );
72 92 }
73 93
74 94
75 95 // Version information from WordPress.
76 -require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php';
96 +require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php'; // NOSONAR - WP compatible.
77 97
78 98 if ( ! function_exists( 'mainwp_autoload' ) ) {
79 99
80 - /**
81 - * Autoloader for all classes, pages & widgets
82 - *
83 - * @param string $class_name Folder name class|pages|widgets.
84 - * @return require_once $autoload_path;
85 - */
86 - function mainwp_autoload( $class_name ) {
100 + /**
101 + * Autoloader for all classes, pages & widgets
102 + *
103 + * @param string $class_name Folder name class|pages|widgets.
104 + * @return require_once $autoload_path;
105 + */
106 + function mainwp_autoload( $class_name ) {
87 107
88 - if ( 0 === strpos( $class_name, 'MainWP\Dashboard' ) ) {
89 - // trip the namespace prefix: MainWP\Dashboard\ .
90 - $class_name = substr( $class_name, 17 );
91 - }
108 + if ( 0 === strpos( $class_name, 'MainWP\Dashboard' ) ) {
109 + // trip the namespace prefix: MainWP\Dashboard\ .
110 + $class_name = substr( $class_name, 17 );
111 + }
92 112
93 - if ( 0 !== strpos( $class_name, 'MainWP_' ) ) {
94 - return;
95 - }
113 + if ( 0 !== strpos( $class_name, 'MainWP_' ) ) {
114 + return;
115 + }
96 116
97 - $autoload_types = array(
98 - 'class' => 'class',
99 - 'pages' => 'page',
100 - 'widgets' => 'widget',
101 - );
117 + $autoload_types = array(
118 + 'class' => 'class',
119 + 'pages' => 'page',
120 + 'widgets' => 'widget',
121 + );
102 122
103 - foreach ( $autoload_types as $type => $prefix ) {
104 - $autoload_dir = \trailingslashit( __DIR__ . DIRECTORY_SEPARATOR . $type );
105 - $autoload_path = sprintf( '%s%s-%s.php', $autoload_dir, $prefix, strtolower( str_replace( '_', '-', $class_name ) ) );
123 + foreach ( $autoload_types as $type => $prefix ) {
124 + $autoload_dir = \trailingslashit( __DIR__ . DIRECTORY_SEPARATOR . $type );
125 + $autoload_path = sprintf( '%s%s-%s.php', $autoload_dir, $prefix, strtolower( str_replace( '_', '-', $class_name ) ) );
106 126
107 - if ( file_exists( $autoload_path ) ) {
108 - require_once $autoload_path;
109 - break;
110 - }
111 - }
112 - }
127 + if ( file_exists( $autoload_path ) ) {
128 + require_once $autoload_path; // NOSONAR - WP compatible.
129 + break;
130 + }
131 + }
132 + }
113 133 }
114 134
115 135 spl_autoload_register( 'mainwp_autoload' );
116 136
117 -require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'functions.php';
118 -require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'compatible.php';
119 -require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'class-mainwp-includes.php';
137 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'functions.php'; // NOSONAR -- WP compatible.
138 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'core-functions.php'; // NOSONAR -- WP compatible.
139 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'compatible.php'; // NOSONAR -- WP compatible.
140 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'class-mainwp-includes.php'; // NOSONAR -- WP compatible.
120 141
142 +// Load Abilities API integration (feature-gated).
143 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-util.php'; // NOSONAR -- WP compatible.
144 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-sites.php'; // NOSONAR -- WP compatible.
145 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-updates.php'; // NOSONAR -- WP compatible.
146 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-clients.php'; // NOSONAR -- WP compatible.
147 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-tags.php'; // NOSONAR -- WP compatible.
148 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-batch.php'; // NOSONAR -- WP compatible.
149 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-cron.php'; // NOSONAR -- WP compatible.
150 +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities.php'; // NOSONAR -- WP compatible.
151 +
152 +// Initialize Abilities API integration (does nothing if Abilities API not available).
153 +if ( class_exists( '\MainWP\Dashboard\MainWP_Abilities' ) ) {
154 + \MainWP\Dashboard\MainWP_Abilities::init();
155 +}
156 +
157 +if ( file_exists( MAINWP_PLUGIN_DIR . 'modules/system-monitor/bootstrap.php' ) ) {
158 + define( 'MAINWP_SYSTEM_MONITOR_FILE', __FILE__ );
159 + require_once MAINWP_PLUGIN_DIR . 'modules/system-monitor/bootstrap.php'; // NOSONAR - WP compatible.
160 + register_activation_hook(
161 + MAINWP_SYSTEM_MONITOR_FILE,
162 + array( MainWP\Dashboard\SystemMonitor\MainWP_System_Monitor::class, 'activate' )
163 + );
164 + register_deactivation_hook(
165 + MAINWP_SYSTEM_MONITOR_FILE,
166 + array( MainWP\Dashboard\SystemMonitor\MainWP_System_Monitor::class, 'deactivate' )
167 + );
168 +}
169 +
121 170 // Detect if secupress_scanner is running.
122 171 $mainwp_is_secupress_scanning = false;
123 172 if ( ! empty( $_GET ) && isset( $_GET['test'] ) && isset( $_GET['action'] ) && 'secupress_scanner' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized.Recommended
124 - $mainwp_is_secupress_scanning = true;
173 + $mainwp_is_secupress_scanning = true;
125 174 }
126 175
127 176 // Fix a conflict with SecuPress plugin.
128 177 if ( ! $mainwp_is_secupress_scanning ) {
129 - $mainWP = new MainWP\Dashboard\MainWP_System( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename( __FILE__ ) );
130 - register_activation_hook( __FILE__, array( $mainWP, 'activation' ) );
131 - register_deactivation_hook( __FILE__, array( $mainWP, 'deactivation' ) );
132 - add_action( 'plugins_loaded', array( $mainWP, 'update_install' ) );
178 + $mainWP = new MainWP\Dashboard\MainWP_System( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename( __FILE__ ) );
179 + register_activation_hook( __FILE__, array( $mainWP, 'activation' ) );
180 + register_deactivation_hook( __FILE__, array( $mainWP, 'deactivation' ) );
181 + add_action( 'plugins_loaded', array( $mainWP, 'update_install' ) );
182 + // Register the post-upgrade hook for MWP-1557/1558 pk/ filename migration.
183 + // Must be registered before plugins_loaded fires so MainWP_Install::install()
184 + // sees a subscriber when it does_action('mainwp_db_after_update').
185 + add_action( 'plugins_loaded', array( 'MainWP\\Dashboard\\MainWP_Keys_Manager', 'register_migration_hooks' ), 5 );
133 186 }