| @@ -7,167 +7,98 @@ | ||
| 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: 6.1 | |
| 12 | - * License: GPLv3 or later | |
| 13 | - * License URI: https://www.gnu.org/licenses/gpl-3.0.html | |
| 11 | + * Version: 4.1 | |
| 14 | 12 | * |
| 15 | 13 | * @package MainWP/Dashboard |
| 16 | - * | |
| 17 | - * @uses \MainWP\Dashboard\MainWP_System | |
| 18 | 14 | */ |
| 19 | 15 | |
| 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 | - | |
| 38 | 16 | if ( ! defined( 'MAINWP_PLUGIN_FILE' ) ) { |
| 39 | 17 | |
| 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__ ); | |
| 18 | + /** | |
| 19 | + * Define MainWP Dashboard Plugin absolute full path and filename of this file. | |
| 20 | + * | |
| 21 | + * @const ( string ) Defined MainWP dashboard file path. | |
| 22 | + * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php | |
| 23 | + */ | |
| 24 | + define( 'MAINWP_PLUGIN_FILE', __FILE__ ); | |
| 47 | 25 | } |
| 48 | 26 | |
| 49 | 27 | if ( ! defined( 'MAINWP_PLUGIN_DIR' ) ) { |
| 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 ) ); | |
| 28 | + /** | |
| 29 | + * Define MainWP Dashboard Plugin Directory. | |
| 30 | + * | |
| 31 | + * @const ( string ) Defined MainWP Dashboard Plugin Directory. | |
| 32 | + * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php | |
| 33 | + */ | |
| 34 | + define( 'MAINWP_PLUGIN_DIR', plugin_dir_path( MAINWP_PLUGIN_FILE ) ); | |
| 57 | 35 | } |
| 58 | 36 | |
| 59 | 37 | if ( ! defined( 'MAINWP_PLUGIN_URL' ) ) { |
| 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 ) ); | |
| 38 | + /** | |
| 39 | + * Define MainWP Child Dashboard URL. | |
| 40 | + * | |
| 41 | + * @const ( string ) Defined MainWP Dashboard Plugin URL. | |
| 42 | + * @source https://github.com/mainwp/mainwp/blob/master/mainwp.php | |
| 43 | + */ | |
| 44 | + define( 'MAINWP_PLUGIN_URL', plugin_dir_url( MAINWP_PLUGIN_FILE ) ); | |
| 67 | 45 | } |
| 68 | 46 | |
| 69 | - | |
| 70 | -if ( ! defined( 'MAINWP_MODULES_DIR' ) ) { | |
| 71 | - define( 'MAINWP_MODULES_DIR', MAINWP_PLUGIN_DIR . 'modules' . DIRECTORY_SEPARATOR ); | |
| 72 | -} | |
| 73 | - | |
| 74 | -if ( ! defined( 'MAINWP_MODULES_URL' ) ) { | |
| 75 | - define( 'MAINWP_MODULES_URL', MAINWP_PLUGIN_URL . 'modules/' ); | |
| 76 | -} | |
| 77 | - | |
| 78 | - | |
| 79 | -/** | |
| 80 | - * Define enable Log Module. | |
| 81 | - */ | |
| 82 | -if ( ! defined( 'MAINWP_MODULE_LOG_ENABLED' ) ) { | |
| 83 | - define( 'MAINWP_MODULE_LOG_ENABLED', true ); | |
| 84 | -} | |
| 85 | - | |
| 86 | -if ( ! defined( 'MAINWP_MODULE_COST_TRACKER_ENABLED' ) ) { | |
| 87 | - define( 'MAINWP_MODULE_COST_TRACKER_ENABLED', true ); | |
| 88 | -} | |
| 89 | - | |
| 90 | -if ( ! defined( 'MAINWP_MODULE_API_BACKUPS_ENABLED' ) ) { | |
| 91 | - define( 'MAINWP_MODULE_API_BACKUPS_ENABLED', true ); | |
| 92 | -} | |
| 93 | - | |
| 94 | - | |
| 95 | 47 | // Version information from WordPress. |
| 96 | -require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php'; // NOSONAR - WP compatible. | |
| 48 | +require_once ABSPATH . 'wp-includes' . DIRECTORY_SEPARATOR . 'version.php'; | |
| 97 | 49 | |
| 98 | 50 | if ( ! function_exists( 'mainwp_autoload' ) ) { |
| 99 | 51 | |
| 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 ) { | |
| 52 | + /** | |
| 53 | + * Autoloader for all classes, pages & widgets | |
| 54 | + * | |
| 55 | + * @param string $class_name Folder name class|pages|widgets. | |
| 56 | + * @return require_once $autoload_path; | |
| 57 | + */ | |
| 58 | + function mainwp_autoload( $class_name ) { | |
| 107 | 59 | |
| 108 | - if ( 0 === strpos( $class_name, 'MainWP\Dashboard' ) ) { | |
| 109 | - // trip the namespace prefix: MainWP\Dashboard\ . | |
| 110 | - $class_name = substr( $class_name, 17 ); | |
| 111 | - } | |
| 60 | + if ( 0 === strpos( $class_name, 'MainWP\Dashboard' ) ) { | |
| 61 | + // trip the namespace prefix: MainWP\Dashboard\ . | |
| 62 | + $class_name = substr( $class_name, 17 ); | |
| 63 | + } | |
| 112 | 64 | |
| 113 | - if ( 0 !== strpos( $class_name, 'MainWP_' ) ) { | |
| 114 | - return; | |
| 115 | - } | |
| 65 | + if ( 0 !== strpos( $class_name, 'MainWP_' ) ) { | |
| 66 | + return; | |
| 67 | + } | |
| 116 | 68 | |
| 117 | - $autoload_types = array( | |
| 118 | - 'class' => 'class', | |
| 119 | - 'pages' => 'page', | |
| 120 | - 'widgets' => 'widget', | |
| 121 | - ); | |
| 69 | + $autoload_types = array( | |
| 70 | + 'class' => 'class', | |
| 71 | + 'pages' => 'page', | |
| 72 | + 'widgets' => 'widget', | |
| 73 | + ); | |
| 122 | 74 | |
| 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 ) ) ); | |
| 75 | + foreach ( $autoload_types as $type => $prefix ) { | |
| 76 | + $autoload_dir = \trailingslashit( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $type ); | |
| 77 | + $autoload_path = sprintf( '%s%s-%s.php', $autoload_dir, $prefix, strtolower( str_replace( '_', '-', $class_name ) ) ); | |
| 126 | 78 | |
| 127 | - if ( file_exists( $autoload_path ) ) { | |
| 128 | - require_once $autoload_path; // NOSONAR - WP compatible. | |
| 129 | - break; | |
| 130 | - } | |
| 131 | - } | |
| 132 | - } | |
| 79 | + if ( file_exists( $autoload_path ) ) { | |
| 80 | + require_once $autoload_path; | |
| 81 | + break; | |
| 82 | + } | |
| 83 | + } | |
| 84 | + } | |
| 133 | 85 | } |
| 134 | 86 | |
| 135 | 87 | spl_autoload_register( 'mainwp_autoload' ); |
| 136 | 88 | |
| 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. | |
| 89 | +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'functions.php'; | |
| 90 | +require_once MAINWP_PLUGIN_DIR . 'includes' . DIRECTORY_SEPARATOR . 'compatible.php'; | |
| 141 | 91 | |
| 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 | 92 | // Detect if secupress_scanner is running. |
| 158 | 93 | $mainwp_is_secupress_scanning = false; |
| 159 | -if ( ! empty( $_GET ) && isset( $_GET['test'] ) && isset( $_GET['action'] ) && 'secupress_scanner' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized.Recommended | |
| 160 | - $mainwp_is_secupress_scanning = true; | |
| 94 | +if ( ! empty( $_GET ) && isset( $_GET['test'] ) && isset( $_GET['action'] ) && 'secupress_scanner' === $_GET['action'] ) { | |
| 95 | + $mainwp_is_secupress_scanning = true; | |
| 161 | 96 | } |
| 162 | 97 | |
| 163 | 98 | // Fix a conflict with SecuPress plugin. |
| 164 | 99 | if ( ! $mainwp_is_secupress_scanning ) { |
| 165 | - $mainWP = new MainWP\Dashboard\MainWP_System( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename( __FILE__ ) ); | |
| 166 | - register_activation_hook( __FILE__, array( $mainWP, 'activation' ) ); | |
| 167 | - register_deactivation_hook( __FILE__, array( $mainWP, 'deactivation' ) ); | |
| 168 | - add_action( 'plugins_loaded', array( $mainWP, 'update_install' ) ); | |
| 169 | - // Register the post-upgrade hook for MWP-1557/1558 pk/ filename migration. | |
| 170 | - // Must be registered before plugins_loaded fires so MainWP_Install::install() | |
| 171 | - // sees a subscriber when it does_action('mainwp_db_after_update'). | |
| 172 | - add_action( 'plugins_loaded', array( 'MainWP\\Dashboard\\MainWP_Keys_Manager', 'register_migration_hooks' ), 5 ); | |
| 100 | + $mainWP = new MainWP\Dashboard\MainWP_System( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . plugin_basename( __FILE__ ) ); | |
| 101 | + register_activation_hook( __FILE__, array( $mainWP, 'activation' ) ); | |
| 102 | + register_deactivation_hook( __FILE__, array( $mainWP, 'deactivation' ) ); | |
| 103 | + add_action( 'plugins_loaded', array( $mainWP, 'update' ) ); | |
| 173 | 104 | } |