PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.0
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.0
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 5.3.1 All 152 releases
mainwp / mainwp.php

mainwp.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.0, at mainwp.php

165 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: MainWP Dashboard
4 *
5 * Description: Manage all of your WP sites, even those on different servers, from one central dashboard that runs off of your own self-hosted WordPress install.
6 *
7 * Author: MainWP
8 * Author URI: https://mainwp.com
9 * Plugin URI: https://mainwp.com/
10 * Text Domain: mainwp
11 * Version: 6.0
12 *
13 * @package MainWP/Dashboard
14 *
15 * @uses \MainWP\Dashboard\MainWP_System
16 */
17
18 // Exit if accessed directly.
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit;
21 }
22
23 /**
24 * Ignore cron/bootstrap.php from Plugin Check direct file access protection.
25 * This file must execute before WordPress loads to locate wp-load.php,
26 * so the standard ABSPATH check would break functionality.
27 */
28 add_filter( 'wp_plugin_check_ignore_files', function( $ignored_files ) {
29 $ignored_files[] = 'cron/bootstrap.php';
30 return $ignored_files;
31 } );
32
33 if ( ! defined( 'MAINWP_PLUGIN_FILE' ) ) {
34
35 /**
36 * Define MainWP Dashboard Plugin absolute full path and filename of this file.
37 *
38 * @const ( string ) Defined MainWP dashboard file path.
39 * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php
40 */
41 define( 'MAINWP_PLUGIN_FILE', __FILE__ );
42 }
43
44 if ( ! defined( 'MAINWP_PLUGIN_DIR' ) ) {
45 /**
46 * Define MainWP Dashboard Plugin Directory.
47 *
48 * @const ( string ) Defined MainWP Dashboard Plugin Directory.
49 * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php
50 */
51 define( 'MAINWP_PLUGIN_DIR', plugin_dir_path( MAINWP_PLUGIN_FILE ) );
52 }
53
54 if ( ! defined( 'MAINWP_PLUGIN_URL' ) ) {
55 /**
56 * Define MainWP Child Dashboard URL.
57 *
58 * @const ( string ) Defined MainWP Dashboard Plugin URL.
59 * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php
60 */
61 define( 'MAINWP_PLUGIN_URL', plugin_dir_url( MAINWP_PLUGIN_FILE ) );
62 }
63
64
65 if ( ! defined( 'MAINWP_MODULES_DIR' ) ) {
66 define( 'MAINWP_MODULES_DIR', MAINWP_PLUGIN_DIR . 'modules' . DIRECTORY_SEPARATOR );
67 }
68
69 if ( ! defined( 'MAINWP_MODULES_URL' ) ) {
70 define( 'MAINWP_MODULES_URL', MAINWP_PLUGIN_URL . 'modules/' );
71 }
72
73
74 /**
75 * Define enable Log Module.
76 */
77 if ( ! defined( 'MAINWP_MODULE_LOG_ENABLED' ) ) {
78 define( 'MAINWP_MODULE_LOG_ENABLED', true );
79 }
80
81 if ( ! defined( 'MAINWP_MODULE_COST_TRACKER_ENABLED' ) ) {
82 define( 'MAINWP_MODULE_COST_TRACKER_ENABLED', true );
83 }
84
85 if ( ! defined( 'MAINWP_MODULE_API_BACKUPS_ENABLED' ) ) {
86 define( 'MAINWP_MODULE_API_BACKUPS_ENABLED', true );
87 }
88
89
90 // Version information from WordPress.
91 require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php'; // NOSONAR - WP compatible.
92
93 if ( ! function_exists( 'mainwp_autoload' ) ) {
94
95 /**
96 * Autoloader for all classes, pages & widgets
97 *
98 * @param string $class_name Folder name class|pages|widgets.
99 * @return require_once $autoload_path;
100 */
101 function mainwp_autoload( $class_name ) {
102
103 if ( 0 === strpos( $class_name, 'MainWP\Dashboard' ) ) {
104 // trip the namespace prefix: MainWP\Dashboard\ .
105 $class_name = substr( $class_name, 17 );
106 }
107
108 if ( 0 !== strpos( $class_name, 'MainWP_' ) ) {
109 return;
110 }
111
112 $autoload_types = array(
113 'class' => 'class',
114 'pages' => 'page',
115 'widgets' => 'widget',
116 );
117
118 foreach ( $autoload_types as $type => $prefix ) {
119 $autoload_dir = \trailingslashit( __DIR__ . DIRECTORY_SEPARATOR . $type );
120 $autoload_path = sprintf( '%s%s-%s.php', $autoload_dir, $prefix, strtolower( str_replace( '_', '-', $class_name ) ) );
121
122 if ( file_exists( $autoload_path ) ) {
123 require_once $autoload_path; // NOSONAR - WP compatible.
124 break;
125 }
126 }
127 }
128 }
129
130 spl_autoload_register( 'mainwp_autoload' );
131
132 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'functions.php'; // NOSONAR -- WP compatible.
133 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'core-functions.php'; // NOSONAR -- WP compatible.
134 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'compatible.php'; // NOSONAR -- WP compatible.
135 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'class-mainwp-includes.php'; // NOSONAR -- WP compatible.
136
137 // Load Abilities API integration (feature-gated).
138 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-util.php'; // NOSONAR -- WP compatible.
139 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-sites.php'; // NOSONAR -- WP compatible.
140 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-updates.php'; // NOSONAR -- WP compatible.
141 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-clients.php'; // NOSONAR -- WP compatible.
142 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-tags.php'; // NOSONAR -- WP compatible.
143 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-batch.php'; // NOSONAR -- WP compatible.
144 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities-cron.php'; // NOSONAR -- WP compatible.
145 require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'abilities' . DIRECTORY_SEPARATOR . 'class-mainwp-abilities.php'; // NOSONAR -- WP compatible.
146
147 // Initialize Abilities API integration (does nothing if Abilities API not available).
148 if ( class_exists( '\MainWP\Dashboard\MainWP_Abilities' ) ) {
149 \MainWP\Dashboard\MainWP_Abilities::init();
150 }
151
152 // Detect if secupress_scanner is running.
153 $mainwp_is_secupress_scanning = false;
154 if ( ! empty( $_GET ) && isset( $_GET['test'] ) && isset( $_GET['action'] ) && 'secupress_scanner' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized.Recommended
155 $mainwp_is_secupress_scanning = true;
156 }
157
158 // Fix a conflict with SecuPress plugin.
159 if ( ! $mainwp_is_secupress_scanning ) {
160 $mainWP = new MainWP\Dashboard\MainWP_System( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename( __FILE__ ) );
161 register_activation_hook( __FILE__, array( $mainWP, 'activation' ) );
162 register_deactivation_hook( __FILE__, array( $mainWP, 'deactivation' ) );
163 add_action( 'plugins_loaded', array( $mainWP, 'update_install' ) );
164 }
165