| @@ -12,63 +12,57 @@ | ||
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Logs class. |
| 15 | 15 | */ |
| 16 | -class MainWP_Module_Api_Backups { | |
| 17 | - /** | |
| 18 | - * Load required files and hooks to make the CLI work. | |
| 19 | - */ | |
| 20 | - public function __construct() { | |
| 21 | - $this->includes(); | |
| 22 | - add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) ); | |
| 23 | - add_filter( 'mainwp_init_load_all_options', array( $this, 'hook_load_options' ) ); | |
| 24 | - add_action( 'mainwp_system_init', array( $this, 'hook_mainwp_system_init' ) ); | |
| 25 | - } | |
| 16 | +class MainWP_Module_Api_Backups { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. | |
| 17 | + /** | |
| 18 | + * Load required files and hooks to make the CLI work. | |
| 19 | + */ | |
| 20 | + public function __construct() { | |
| 21 | + $this->includes(); | |
| 22 | + add_filter( 'mainwp_init_load_all_options', array( $this, 'hook_load_options' ) ); | |
| 23 | + add_action( 'mainwp_system_init', array( $this, 'hook_mainwp_system_init' ) ); | |
| 24 | + } | |
| 26 | 25 | |
| 27 | - /** | |
| 28 | - * Init method. | |
| 29 | - */ | |
| 30 | - public function plugins_loaded() { | |
| 31 | - } | |
| 26 | + /** | |
| 27 | + * Method get_instance(). | |
| 28 | + */ | |
| 29 | + public static function get_instance() { | |
| 30 | + return new self(); | |
| 31 | + } | |
| 32 | 32 | |
| 33 | - /** | |
| 34 | - * Load files. | |
| 35 | - */ | |
| 36 | - private function includes() { | |
| 37 | - $dir = MAINWP_MODULES_DIR; | |
| 38 | - if ( mainwp_modules_is_enabled( 'api-backups' ) ) { | |
| 39 | - if ( file_exists( $dir . 'api-backups/classes/class-api-backups-manager.php' ) ) { | |
| 40 | - require_once $dir . 'api-backups/classes/class-api-backups-manager.php'; | |
| 41 | - } | |
| 42 | - } | |
| 43 | - } | |
| 33 | + /** | |
| 34 | + * Load files. | |
| 35 | + */ | |
| 36 | + private function includes() { | |
| 37 | + $dir = MAINWP_MODULES_DIR; | |
| 38 | + if ( mainwp_modules_is_enabled( 'api-backups' ) && file_exists( $dir . 'api-backups/classes/class-api-backups-manager.php' ) ) { | |
| 39 | + require_once $dir . 'api-backups/classes/class-api-backups-manager.php'; // NOSONAR - WP compatible. | |
| 40 | + } | |
| 41 | + } | |
| 44 | 42 | |
| 45 | - /** | |
| 46 | - * Handle mainwp system init load options. | |
| 47 | - * | |
| 48 | - * @param array $all_opts All loading mainwp options. | |
| 49 | - * @return array $all_opts All loading mainwp options. | |
| 50 | - */ | |
| 51 | - public function hook_load_options( $all_opts ) { | |
| 52 | - return $all_opts; | |
| 53 | - } | |
| 43 | + /** | |
| 44 | + * Handle mainwp system init load options. | |
| 45 | + * | |
| 46 | + * @param array $all_opts All loading mainwp options. | |
| 47 | + * @return array $all_opts All loading mainwp options. | |
| 48 | + */ | |
| 49 | + public function hook_load_options( $all_opts ) { | |
| 50 | + return $all_opts; | |
| 51 | + } | |
| 54 | 52 | |
| 55 | - /** | |
| 56 | - * Handle mainwp system init. | |
| 57 | - */ | |
| 58 | - public function hook_mainwp_system_init() { | |
| 59 | - if ( mainwp_modules_is_enabled( 'api-backups' ) && class_exists( '\MainWP\Dashboard\Module\ApiBackups\Api_Backups_Manager' ) ) { | |
| 60 | - include_once ABSPATH . '/wp-admin/includes/plugin.php'; | |
| 61 | - if ( function_exists( '\is_plugin_active' ) ) { | |
| 62 | - // disable the api backups extension to prevent some conflicted UIs. | |
| 63 | - if ( is_plugin_active( 'mainwp-api-backups-extension/mainwp-api-backups-extension.php' ) ) { | |
| 64 | - if ( function_exists( '\deactivate_plugins' ) ) { | |
| 65 | - deactivate_plugins( 'mainwp-api-backups-extension/mainwp-api-backups-extension.php' ); | |
| 66 | - } | |
| 67 | - } | |
| 68 | - } | |
| 69 | - Api_Backups_Manager::get_instance(); | |
| 70 | - } | |
| 71 | - } | |
| 53 | + /** | |
| 54 | + * Handle mainwp system init. | |
| 55 | + */ | |
| 56 | + public function hook_mainwp_system_init() { | |
| 57 | + if ( mainwp_modules_is_enabled( 'api-backups' ) && class_exists( '\MainWP\Dashboard\Module\ApiBackups\Api_Backups_Manager' ) ) { | |
| 58 | + include_once ABSPATH . '/wp-admin/includes/plugin.php'; // NOSONAR - WP compatible. | |
| 59 | + // disable the api backups extension to prevent some conflicted UIs. | |
| 60 | + if ( function_exists( '\is_plugin_active' ) && is_plugin_active( 'mainwp-api-backups-extension/mainwp-api-backups-extension.php' ) && function_exists( '\deactivate_plugins' ) ) { | |
| 61 | + deactivate_plugins( 'mainwp-api-backups-extension/mainwp-api-backups-extension.php' ); | |
| 62 | + } | |
| 63 | + Api_Backups_Manager::get_instance(); | |
| 64 | + } | |
| 65 | + } | |
| 72 | 66 | } |
| 73 | 67 | |
| 74 | -new MainWP_Module_Api_Backups(); | |
| 68 | +MainWP_Module_Api_Backups::get_instance(); | |